diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-01 17:57:12 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-01 17:57:12 +0000 |
commit | 2036263adeb836b2943ef6e68b2c53df603cc9cd (patch) | |
tree | a7314bc7ad7b2c824cca1af8c9c212ce70542d36 /chrome/browser/cocoa | |
parent | 741e1971f600c76a8ac47a548352578da981cbe0 (diff) | |
download | chromium_src-2036263adeb836b2943ef6e68b2c53df603cc9cd.zip chromium_src-2036263adeb836b2943ef6e68b2c53df603cc9cd.tar.gz chromium_src-2036263adeb836b2943ef6e68b2c53df603cc9cd.tar.bz2 |
Mac: change tab change notifications to pass full TabChangeType.
This makes the Mac code better parallel that on other platforms. It will also be needed to make the "glow" animation for (unselected, title-changing) pinned tabs work. (I have a mostly-working patch which does the glow, but it's horribly hacky and to get it to completely work would either involve much more hackiness or significant refactoring. That's why the glow is not part of this CL.)
Also: prevent changes in background tabs (e.g., loading finished) from killing any current bookmark bar animation. Still to do on this front (part of issue 27693): be smarter about bookmark bar updates in the selected tab.
BUG=28154, 27693
TEST=Load lots of (slow-loading) pages in background tabs while pressing Shift-Cmd-B repeatedly; make sure changes in background (unselected) tabs don't cancel the animation.
Review URL: http://codereview.chromium.org/449056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33455 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
4 files changed, 24 insertions, 27 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index ab139df..d22e5e5 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -1103,35 +1103,31 @@ willPositionSheet:(NSWindow*)sheet // Update various elements that are interested in knowing the current // TabContents. -#if 0 -// TODO(pinkerton):Update as more things become window-specific - contents_container_->SetTabContents(newContents); -#endif // Update all the UI bits. windowShim_->UpdateTitleBar(); -#if 0 -// TODO(pinkerton):Update as more things become window-specific - toolbar_->SetProfile(newContents->profile()); - UpdateToolbar(newContents, true); - UpdateUIForContents(newContents); -#endif - // Update the bookmark bar. [self updateBookmarkBarVisibilityWithAnimation:NO]; } - (void)tabChangedWithContents:(TabContents*)contents atIndex:(NSInteger)index - loadingOnly:(BOOL)loading { + changeType:(TabStripModelObserver::TabChangeType)change { if (index == browser_->tabstrip_model()->selected_index()) { - // Update titles if this is the currently selected tab. - windowShim_->UpdateTitleBar(); + // Update titles if this is the currently selected tab and if it isn't just + // the loading state which changed. + if (change != TabStripModelObserver::LOADING_ONLY) + windowShim_->UpdateTitleBar(); + + // Update the bookmark bar if this is the currently selected tab and if it + // isn't just the title which changed. This for transitions between the NTP + // (showing its floating bookmark bar) and normal web pages (showing no + // bookmark bar). + // TODO(viettrungluu): perhaps update to not terminate running animations? + if (change != TabStripModelObserver::TITLE_NOT_LOADING) + [self updateBookmarkBarVisibilityWithAnimation:NO]; } - - // Update the bookmark bar. - [self updateBookmarkBarVisibilityWithAnimation:NO]; } - (void)userChangedTheme { diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm index 08dd8d7..b6f2573 100644 --- a/chrome/browser/cocoa/tab_strip_controller.mm +++ b/chrome/browser/cocoa/tab_strip_controller.mm @@ -1112,11 +1112,17 @@ private: // throbber state, not anything else about the (partially) loading tab. - (void)tabChangedWithContents:(TabContents*)contents atIndex:(NSInteger)modelIndex - loadingOnly:(BOOL)loading { + changeType:(TabStripModelObserver::TabChangeType)change { // Take closing tabs into account. NSInteger index = [self indexFromModelIndex:modelIndex]; - if (!loading) + if (change == TabStripModelObserver::TITLE_NOT_LOADING) { + // TODO(sky): make this work. + // We'll receive another notification of the change asynchronously. + return; + } + + if (change != TabStripModelObserver::LOADING_ONLY) [self setTabTitle:[tabArray_ objectAtIndex:index] withContents:contents]; [self updateFavIconForContents:contents atIndex:index]; diff --git a/chrome/browser/cocoa/tab_strip_model_observer_bridge.h b/chrome/browser/cocoa/tab_strip_model_observer_bridge.h index 61a3dd7..a052344 100644 --- a/chrome/browser/cocoa/tab_strip_model_observer_bridge.h +++ b/chrome/browser/cocoa/tab_strip_model_observer_bridge.h @@ -66,7 +66,7 @@ class TabStripModelObserverBridge : public TabStripModelObserver { pinnedStateChanged:(BOOL)pinnedChanged; - (void)tabChangedWithContents:(TabContents*)contents atIndex:(NSInteger)index - loadingOnly:(BOOL)loading; + changeType:(TabStripModelObserver::TabChangeType)change; - (void)tabPinnedStateChangedWithContents:(TabContents*)contents atIndex:(NSInteger)index; - (void)tabStripEmpty; diff --git a/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm b/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm index cb89acc..e3f2c02 100644 --- a/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm +++ b/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm @@ -75,16 +75,11 @@ void TabStripModelObserverBridge::TabMoved(TabContents* contents, void TabStripModelObserverBridge::TabChangedAt(TabContents* contents, int index, TabChangeType change_type) { - if (change_type == TITLE_NOT_LOADING) { - // TODO(sky): make this work. - // We'll receive another notification of the change asynchronously. - return; - } if ([controller_ respondsToSelector: - @selector(tabChangedWithContents:atIndex:loadingOnly:)]) { + @selector(tabChangedWithContents:atIndex:changeType:)]) { [controller_ tabChangedWithContents:contents atIndex:index - loadingOnly:change_type == LOADING_ONLY ? YES : NO]; + changeType:change_type]; } } |