Fix bug 295429: when seeing a failure code on the nsIRequest on OnLocationChange, set the site icon to a little warning triangle, rather than the site icon.

This commit is contained in:
smfr%smfr.org 2005-05-26 04:32:26 +00:00
Родитель 0e3be21354
Коммит 839a0d2559
5 изменённых файлов: 26 добавлений и 17 удалений

Просмотреть файл

@ -196,7 +196,7 @@ class nsISupportsArray;
- (void)onLoadingCompleted:(BOOL)succeeded;
- (void)onProgressChange64:(long long)currentBytes outOf:(long long)maxBytes;
- (void)onProgressChange:(long)currentBytes outOf:(long)maxBytes;
- (void)onLocationChange:(NSString*)urlSpec;
- (void)onLocationChange:(NSString*)urlSpec requestOK:(BOOL)isOK;
- (void)onStatusChange:(NSString*)aMessage;
- (void)onSecurityStateChange:(unsigned long)newState;
- (void)onShowTooltip:(NSPoint)where withText:(NSString*)text;

Просмотреть файл

@ -80,7 +80,7 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
- (void)setSiteIconImage:(NSImage*)inSiteIcon;
- (void)setSiteIconURI:(NSString*)inSiteIconURI;
- (void)updateSiteIconImage:(NSImage*)inSiteIcon withURI:(NSString *)inSiteIconURI;
- (void)updateSiteIconImage:(NSImage*)inSiteIcon withURI:(NSString *)inSiteIconURI loadError:(BOOL)inLoadError;
- (void)setTabTitle:(NSString*)tabTitle windowTitle:(NSString*)windowTitle;
- (NSString*)displayTitleForPageURL:(NSString*)inURL title:(NSString*)inTitle;
@ -478,16 +478,15 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
}
}
- (void)onLocationChange:(NSString*)urlSpec
- (void)onLocationChange:(NSString*)urlSpec requestOK:(BOOL)isOK
{
BOOL useSiteIcons = [[PreferenceManager sharedInstance] getBooleanPref:"browser.chrome.favicons" withSuccess:NULL];
BOOL siteIconLoadInitiated = NO;
SiteIconProvider* faviconProvider = [SiteIconProvider sharedFavoriteIconProvider];
NSString* faviconURI = [SiteIconProvider faviconLocationStringFromURI:urlSpec];
if (useSiteIcons && [faviconURI length] > 0)
if (isOK && useSiteIcons && [faviconURI length] > 0)
{
SiteIconProvider* faviconProvider = [SiteIconProvider sharedFavoriteIconProvider];
// if the favicon uri has changed, fire off favicon load. When it completes, our
// imageLoadedNotification selector gets called.
if (![faviconURI isEqualToString:mSiteIconURI])
@ -501,7 +500,7 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
cachedImageURI = faviconURI;
// immediately update the site icon (to the cached one, or the default)
[self updateSiteIconImage:cachedImage withURI:cachedImageURI];
[self updateSiteIconImage:cachedImage withURI:cachedImageURI loadError:!isOK];
// note that this is the only time we hit the network for site icons.
// note also that we may get a site icon from a link element later,
@ -519,7 +518,7 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
else
faviconURI = @"";
[self updateSiteIconImage:nil withURI:faviconURI];
[self updateSiteIconImage:nil withURI:faviconURI loadError:!isOK];
}
[mDelegate updateLocationFields:urlSpec ignoreTyping:NO];
@ -861,7 +860,7 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
// A nil inSiteIcon image indicates that we should use the default icon
// If inSiteIconURI is "about:blank", we don't show any icon
- (void)updateSiteIconImage:(NSImage*)inSiteIcon withURI:(NSString *)inSiteIconURI
- (void)updateSiteIconImage:(NSImage*)inSiteIcon withURI:(NSString *)inSiteIconURI loadError:(BOOL)inLoadError
{
BOOL resetTabIcon = NO;
BOOL tabIconDraggable = YES;
@ -871,10 +870,16 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
{
if (!siteIcon)
{
if ([inSiteIconURI isEqualToString:@"about:blank"]) {
if ([inSiteIconURI isEqualToString:@"about:blank"])
{
siteIcon = [NSImage imageNamed:@"smallDocument"];
tabIconDraggable = NO;
} else
}
else if (inLoadError)
{
siteIcon = [NSImage imageNamed:@"brokenbookmark_icon"]; // it should have its own image
}
else
siteIcon = [NSImage imageNamed:@"globe_ico"];
}
@ -918,7 +923,7 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
if (iconImage == nil)
siteIconURI = @""; // go back to default image
[self updateSiteIconImage:iconImage withURI:siteIconURI];
[self updateSiteIconImage:iconImage withURI:siteIconURI loadError:NO];
}
}

Просмотреть файл

@ -1048,7 +1048,7 @@ KeychainFormSubmitObserver::CheckChangeDataYN(nsIDOMWindowInternal* window)
{
}
- (void)onLocationChange:(NSString*)urlSpec
- (void)onLocationChange:(NSString*)urlSpec requestOK:(BOOL)isOK
{
}

Просмотреть файл

@ -600,7 +600,7 @@ NS_IMETHODIMP
CHBrowserListener::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest,
nsIURI *aLocation)
{
if (!aLocation || !aWebProgress)
if (!aLocation || !aWebProgress || !aRequest)
return NS_ERROR_FAILURE;
// only pay attention to location change for our nsIDOMWindow
@ -610,6 +610,10 @@ CHBrowserListener::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aR
if (windowForProgress != ourWindow)
return NS_OK;
nsresult requestStatus = NS_OK;
aRequest->GetStatus(&requestStatus);
BOOL requestOK = NS_SUCCEEDED(requestStatus);
nsCAutoString spec;
aLocation->GetSpec(spec);
NSString* str = [NSString stringWithUTF8String:spec.get()];
@ -617,7 +621,7 @@ CHBrowserListener::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aR
NSEnumerator* enumerator = [mListeners objectEnumerator];
id<CHBrowserListener> obj;
while ((obj = [enumerator nextObject]))
[obj onLocationChange:str];
[obj onLocationChange:str requestOK:requestOK];
return NS_OK;
}

Просмотреть файл

@ -70,7 +70,7 @@ class nsISupports;
// in. If the total number of bytes expected is unknown,
// maxBytes is -1.
- (void)onProgressChange:(int)currentBytes outOf:(int)maxBytes;
- (void)onLocationChange:(NSString*)urlSpec;
- (void)onLocationChange:(NSString*)urlSpec requestOK:(BOOL)isOK;
- (void)onStatusChange:(NSString*)aMessage;
- (void)onSecurityStateChange:(unsigned long)newState;
// Called when a context menu should be shown.