Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5673)

Unified Diff: chrome/browser/cocoa/tab_strip_controller.mm

Issue 184003: Don't show favicons or throbbers for the New Tab page on the Mac.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/tab_controller_unittest.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/tab_strip_controller.mm
===================================================================
--- chrome/browser/cocoa/tab_strip_controller.mm (revision 25138)
+++ chrome/browser/cocoa/tab_strip_controller.mm (working copy)
@@ -648,20 +648,15 @@
// Either we don't have a valid favicon or there was some issue converting it
// from an SkBitmap. Either way, just show the default.
if (!image) {
- NSBundle* bundle = mac_util::MainAppBundle();
- image = [[NSImage alloc] initByReferencingFile:
- [bundle pathForResource:@"nav" ofType:@"pdf"]];
- [image autorelease];
+ image = nsimage_cache::ImageNamed(@"nav.pdf");
}
[view setImage:image];
return view;
}
-// Update the current loading state, replacing the favicon with a throbber, or
-// vice versa. This will get called repeatedly with the same state during a
-// load, so we need to make sure we're not creating the throbber view over and
-// over. However, when the page is done, every state change is important.
+// Updates the current loading state, replacing the icon view with a favicon,
+// a throbber, the default icon, or nothing at all.
- (void)updateFavIconForContents:(TabContents*)contents
atIndex:(NSInteger)index {
if (!contents)
@@ -675,36 +670,50 @@
[nsimage_cache::ImageNamed(@"sadfavicon.png") retain];
TabController* tabController = [tabArray_ objectAtIndex:index];
+
+ bool oldHasIcon = [tabController iconView] != nil;
+ bool newHasIcon = contents->ShouldDisplayFavIcon();
+
TabLoadingState oldState = [tabController loadingState];
TabLoadingState newState = kTabDone;
NSImage* throbberImage = nil;
- if (contents->waiting_for_response()) {
+ if (contents->is_crashed()) {
+ newState = kTabCrashed;
+ newHasIcon = true;
+ } else if (contents->waiting_for_response()) {
newState = kTabWaiting;
throbberImage = throbberWaitingImage;
} else if (contents->is_loading()) {
newState = kTabLoading;
throbberImage = throbberLoadingImage;
- } else if (contents->is_crashed()) {
- newState = kTabCrashed;
}
- if (oldState != newState || newState == kTabDone) {
+ if (oldState != newState)
+ [tabController setLoadingState:newState];
+
+ // While loading, this function is called repeatedly with the same state.
+ // To avoid expensive unnecessary view manipulation, only make changes when
+ // the state is actually changing. When loading is complete (kTabDone),
+ // every call to this function is significant.
+ if (newState == kTabDone || oldState != newState ||
+ oldHasIcon != newHasIcon) {
NSView* iconView = nil;
- if (newState == kTabDone) {
- iconView = [self favIconImageViewForContents:contents];
- } else if (newState == kTabCrashed) {
- NSImage* oldImage = [[self favIconImageViewForContents:contents] image];
- NSRect frame = NSMakeRect(0, 0, 16, 16);
- iconView = [ThrobberView toastThrobberViewWithFrame:frame
- beforeImage:oldImage
- afterImage:sadFaviconImage];
- } else {
- NSRect frame = NSMakeRect(0, 0, 16, 16);
- iconView = [ThrobberView filmstripThrobberViewWithFrame:frame
- image:throbberImage];
+ if (newHasIcon) {
+ if (newState == kTabDone) {
+ iconView = [self favIconImageViewForContents:contents];
+ } else if (newState == kTabCrashed) {
+ NSImage* oldImage = [[self favIconImageViewForContents:contents] image];
+ NSRect frame = NSMakeRect(0, 0, 16, 16);
+ iconView = [ThrobberView toastThrobberViewWithFrame:frame
+ beforeImage:oldImage
+ afterImage:sadFaviconImage];
+ } else {
+ NSRect frame = NSMakeRect(0, 0, 16, 16);
+ iconView = [ThrobberView filmstripThrobberViewWithFrame:frame
+ image:throbberImage];
+ }
}
- [tabController setLoadingState:newState];
[tabController setIconView:iconView];
}
}
« no previous file with comments | « chrome/browser/cocoa/tab_controller_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698