Camino only - Bug 346228:Use files' actual icons for favicons of local files. r=murph sr=pink

git-svn-id: svn://10.0.0.236/trunk@217135 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
stridey%gmail.com
2006-12-18 18:28:57 +00:00
parent 191ed00378
commit be988612ec
2 changed files with 19 additions and 22 deletions

View File

@@ -229,7 +229,6 @@ const int kReuseWindowOnAE = 2;
// register some special favicon images
[[SiteIconProvider sharedFavoriteIconProvider] registerFaviconImage:[NSImage imageNamed:@"smallDocument"] forPageURI:@"about:blank"];
[[SiteIconProvider sharedFavoriteIconProvider] registerFaviconImage:[NSImage imageNamed:@"smallDocument"] forPageURI:@"about:local_file"];
[[SiteIconProvider sharedFavoriteIconProvider] registerFaviconImage:[NSImage imageNamed:@"bm_favicon"] forPageURI:@"about:bookmarks"];
[[SiteIconProvider sharedFavoriteIconProvider] registerFaviconImage:[NSImage imageNamed:@"historyicon"] forPageURI:@"about:history"];

View File

@@ -366,26 +366,29 @@ NeckoCacheHelper::ClearCache()
// So we just go ahead and try to make the image; it will return nil on
// failure.
NSImage* faviconImage = nil;
NS_DURING
faviconImage = [[[NSImage alloc] initWithData:data] autorelease];
NS_HANDLER
NSLog(@"Exception \"%@\" making favicon image for %@", localException, inURI);
faviconImage = nil;
NS_ENDHANDLER
NSURL* inURIAsNSURL = [NSURL URLWithString:inURI];
if ([inURIAsNSURL isFileURL]) {
faviconImage = [[NSWorkspace sharedWorkspace] iconForFile:[inURIAsNSURL path]];
}
else {
NS_DURING
faviconImage = [[[NSImage alloc] initWithData:data] autorelease];
NS_HANDLER
NSLog(@"Exception \"%@\" making favicon image for %@", localException, inURI);
faviconImage = nil;
NS_ENDHANDLER
}
BOOL gotImageData = loadOK && (faviconImage != nil);
if (NS_SUCCEEDED(status) && !gotImageData) // error status indicates that load was attempted from cache
{
if (NS_SUCCEEDED(status) && !gotImageData) // error status indicates that load was attempted from cache
[self addToMissedIconsCache:inURI withExpirationSeconds:SITE_ICON_EXPIRATION_SECONDS];
}
if (gotImageData)
{
if (gotImageData) {
[faviconImage setDataRetained:YES];
[faviconImage setScalesWhenResized:YES];
[faviconImage setSize:NSMakeSize(16, 16)];
// add the image to the cache
[[SiteIconCache sharedSiteIconCache] setSiteIcon:faviconImage
forURL:inURI
@@ -543,15 +546,10 @@ NeckoCacheHelper::ClearCache()
+ (NSString*)defaultFaviconLocationStringFromURI:(NSString*)inURI
{
// about: urls are special
if ([inURI hasPrefix:@"about:"])
// about: urls and local files are special
if ([inURI hasPrefix:@"about:"] || [inURI hasPrefix:@"file:"])
return inURI;
// show small file icon for local files (this assumes that someone has
// registered the blank document icon for "about:blank")
if ([inURI compare:@"file://" options:NSCaseInsensitiveSearch range:NSMakeRange(0, 7)] == NSOrderedSame)
return @"about:local_file";
// we use nsIURI here, rather than NSURL, because the former does
// a better job with suspect urls (e.g. those containing |), and
// allows us go keep the port