diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 22:33:08 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 22:33:08 +0000 |
commit | aee746fa720bec218bec090746df7e04f26d9f5b (patch) | |
tree | 96e679e635f5be8fbeb008bad5c11ac8e4ecf69d /chrome/browser/cocoa | |
parent | d26b4418ab4d417e87b1d3fd5367dea0cf978a7c (diff) | |
download | chromium_src-aee746fa720bec218bec090746df7e04f26d9f5b.zip chromium_src-aee746fa720bec218bec090746df7e04f26d9f5b.tar.gz chromium_src-aee746fa720bec218bec090746df7e04f26d9f5b.tar.bz2 |
[Mac] Re-enable pinned tabs; add support for mini-tabs and phantom tabs.
This CL rewires the old support for pinned tabs to support mini-tabs. This also
removes the kEnablePinnedTabs browser default now that all platforms support it.
Note that pinning is now only accessible through the context menu; drag-to-pin
has been removed.
BUG=36798, 32845
TEST=Right-click and pin two tabs. Test dragging on and off and around the tab strip.
TEST=Cmd+W a pinned tab and it should go phantom (renderer closes down) and the tab is made alpha.
Review URL: http://codereview.chromium.org/1119005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42548 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 20 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_controller.h | 10 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_controller.mm | 33 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.h | 9 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.mm | 144 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_model_observer_bridge.h | 14 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_model_observer_bridge.mm | 23 |
7 files changed, 146 insertions, 107 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 2be2960..62aba3d 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -365,7 +365,8 @@ // from this method. - (void)windowWillClose:(NSNotification*)notification { DCHECK_EQ([notification object], [self window]); - DCHECK(!browser_->tabstrip_model()->count()); + DCHECK(!browser_->tabstrip_model()->HasNonPhantomTabs() || + !browser_->tabstrip_model()->count()); [savedRegularWindow_ close]; // We delete statusBubble here because we need to kill off the dependency // that its window has on our window before our window goes away. @@ -1063,6 +1064,10 @@ tabOrigin = [[self tabStripView] convertPoint:tabOrigin fromView:nil]; destinationFrame.origin = tabOrigin; + // Before the tab is detached from its originating tab strip, store the + // pinned state so that it can be maintained between the windows. + bool isPinned = dragBWC->browser_->tabstrip_model()->IsTabPinned(index); + // Now that we have enough information about the tab, we can remove it from // the dragging window. We need to do this *before* we add it to the new // window as this will remove the TabContents' delegate. @@ -1071,7 +1076,9 @@ // Deposit it into our model at the appropriate location (it already knows // where it should go from tracking the drag). Doing this sets the tab's // delegate to be the Browser. - [tabStripController_ dropTabContents:contents withFrame:destinationFrame]; + [tabStripController_ dropTabContents:contents + withFrame:destinationFrame + asPinnedTab:isPinned]; } else { // Moving within a window. int index = [tabStripController_ modelIndexForTabView:view]; @@ -1114,7 +1121,7 @@ // Disable screen updates so that this appears as a single visual change. base::ScopedNSDisableScreenUpdates disabler; - // Fetch the tab contents for the tab being dragged + // Fetch the tab contents for the tab being dragged. int index = [tabStripController_ modelIndexForTabView:tabView]; TabContents* contents = browser_->tabstrip_model()->GetTabContentsAt(index); @@ -1132,6 +1139,9 @@ NSRect tabRect = [tabView frame]; + // Before detaching the tab, store the pinned state. + bool isPinned = browser_->tabstrip_model()->IsTabPinned(index); + // Detach it from the source window, which just updates the model without // deleting the tab contents. This needs to come before creating the new // Browser because it clears the TabContents' delegate, which gets hooked @@ -1146,6 +1156,10 @@ browserRect, dockInfo); + // Propagate the tab pinned state of the new tab (which is the only tab in + // this new window). + newBrowser->tabstrip_model()->SetTabPinned(0, isPinned); + // Get the new controller by asking the new window for its delegate. BrowserWindowController* controller = reinterpret_cast<BrowserWindowController*>( diff --git a/chrome/browser/cocoa/tab_controller.h b/chrome/browser/cocoa/tab_controller.h index 06d58c8..e5455ac 100644 --- a/chrome/browser/cocoa/tab_controller.h +++ b/chrome/browser/cocoa/tab_controller.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -44,7 +44,8 @@ class MenuDelegate; NSRect originalIconFrame_; // frame of iconView_ as loaded from nib BOOL isIconShowing_; // last state of iconView_ in updateVisibility BOOL selected_; - BOOL pinned_; + BOOL mini_; + BOOL phantom_; TabLoadingState loadingState_; CGFloat iconTitleXOffset_; // between left edges of icon and title CGFloat titleCloseWidthOffset_; // between right edges of icon and close btn. @@ -58,7 +59,8 @@ class MenuDelegate; @property(assign, nonatomic) TabLoadingState loadingState; @property(assign, nonatomic) BOOL selected; -@property(assign, nonatomic) BOOL pinned; +@property(assign, nonatomic) BOOL mini; +@property(assign, nonatomic) BOOL phantom; @property(assign, nonatomic) id target; @property(assign, nonatomic) SEL action; @@ -68,7 +70,7 @@ class MenuDelegate; + (CGFloat)minTabWidth; + (CGFloat)maxTabWidth; + (CGFloat)minSelectedTabWidth; -+ (CGFloat)pinnedTabWidth; ++ (CGFloat)miniTabWidth; // The view associated with this controller, pre-casted as a TabView - (TabView*)tabView; diff --git a/chrome/browser/cocoa/tab_controller.mm b/chrome/browser/cocoa/tab_controller.mm index ef0455e..8058935 100644 --- a/chrome/browser/cocoa/tab_controller.mm +++ b/chrome/browser/cocoa/tab_controller.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,10 +15,18 @@ @implementation TabController @synthesize loadingState = loadingState_; -@synthesize pinned = pinned_; +@synthesize mini = mini_; +@synthesize phantom = phantom_; @synthesize target = target_; @synthesize action = action_; +namespace { + +// If the tab is phantom, the opacity of the TabView is adjusted to this value. +const CGFloat kPhantomTabAlpha = 105.0 / 255.0; + +}; // anonymous namespace + namespace TabControllerInternal { // A C++ delegate that handles enabling/disabling menu items and handling when @@ -53,7 +61,7 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { // (this is not a checkmark menu item, per Apple's HIG). if (command_id == TabStripModel::CommandTogglePinned) { return l10n_util::GetStringUTF16( - [owner_ pinned] ? IDS_TAB_CXMENU_UNPIN_TAB_MAC + [owner_ mini] ? IDS_TAB_CXMENU_UNPIN_TAB_MAC : IDS_TAB_CXMENU_PIN_TAB_MAC); } return string16(); @@ -64,7 +72,7 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { TabController* owner_; // weak, owns me }; -} // namespace +} // TabControllerInternal namespace // The min widths match the windows values and are sums of left + right // padding, of which we have no comparable constants (we draw using paths, not @@ -72,7 +80,7 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { + (CGFloat)minTabWidth { return 31; } + (CGFloat)minSelectedTabWidth { return 47; } + (CGFloat)maxTabWidth { return 220; } -+ (CGFloat)pinnedTabWidth { return 53; } ++ (CGFloat)miniTabWidth { return 53; } - (TabView*)tabView { return static_cast<TabView*>([self view]); @@ -152,7 +160,7 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { - (void)setTitle:(NSString*)title { [[self view] setToolTip:title]; - if ([self pinned] && ![self selected]) { + if ([self mini] && ![self selected]) { TabView* tabView = static_cast<TabView*>([self view]); DCHECK([tabView isKindOfClass:[TabView class]]); [tabView startAlert]; @@ -208,7 +216,7 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { if (!iconView_) return NO; - if ([self pinned]) + if ([self mini]) return YES; int iconCapacity = [self iconCapacity]; @@ -220,7 +228,7 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { // Returns YES if we should be showing the close button. The selected tab // always shows the close button. - (BOOL)shouldShowCloseButton { - if ([self pinned]) + if ([self mini]) return NO; return ([self selected] || [self iconCapacity] >= 3); } @@ -235,8 +243,13 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { [iconView_ setHidden:newShowIcon ? NO : YES]; isIconShowing_ = newShowIcon; - // If the tab is pinned, hide the title. - [titleView_ setHidden:[self pinned]]; + // If the tab is a mini-tab, hide the title. + [titleView_ setHidden:[self mini]]; + + // If it's a phantom mini-tab, draw it alpha-style. Windows does this. + CGFloat alphaValue = [self phantom] ? kPhantomTabAlpha + : 1.0; + [[self view] setAlphaValue:alphaValue]; BOOL oldShowCloseButton = [closeButton_ isHidden] ? NO : YES; BOOL newShowCloseButton = [self shouldShowCloseButton] ? YES : NO; diff --git a/chrome/browser/cocoa/tab_strip_controller.h b/chrome/browser/cocoa/tab_strip_controller.h index b52f6c4..005b9c7 100644 --- a/chrome/browser/cocoa/tab_strip_controller.h +++ b/chrome/browser/cocoa/tab_strip_controller.h @@ -136,8 +136,13 @@ class ToolbarModel; // window when we don't have access to the TabContents as part of our strip. // |frame| is in the coordinate system of the tab strip view and represents // where the user dropped the new tab so it can be animated into its correct -// location when the tab is added to the model. -- (void)dropTabContents:(TabContents*)contents withFrame:(NSRect)frame; +// location when the tab is added to the model. If the tab was pinned in its +// previous window, setting |pinned| to YES will propagate that state to the +// new window. Mini-tabs are either app or pinned tabs; the app state is stored +// by the |contents|, but the |pinned| state is the caller's responsibility. +- (void)dropTabContents:(TabContents*)contents + withFrame:(NSRect)frame + asPinnedTab:(BOOL)pinned; // Returns the index of the subview |view|. Returns -1 if not present. Takes // closing tabs into account such that this index will correctly match the tab diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm index cf340bb..354a197 100644 --- a/chrome/browser/cocoa/tab_strip_controller.mm +++ b/chrome/browser/cocoa/tab_strip_controller.mm @@ -123,8 +123,8 @@ private: finished:(BOOL)finished; - (NSInteger)indexFromModelIndex:(NSInteger)index; - (NSInteger)numberOfOpenTabs; -- (NSInteger)numberOfOpenPinnedTabs; -- (NSInteger)numberOfOpenUnpinnedTabs; +- (NSInteger)numberOfOpenMiniTabs; +- (NSInteger)numberOfOpenNonMiniTabs; - (void)mouseMoved:(NSEvent*)event; - (void)setTabTrackingAreasEnabled:(BOOL)enabled; - (void)droppingURLsAt:(NSPoint)point @@ -462,18 +462,17 @@ private: return static_cast<NSInteger>(tabStripModel_->count()); } -// (Private) Returns the number of open, pinned tabs. -- (NSInteger)numberOfOpenPinnedTabs { - // Ask the model for the number of pinned tabs. Note that tabs which are in +// (Private) Returns the number of open, mini-tabs. +- (NSInteger)numberOfOpenMiniTabs { + // Ask the model for the number of mini tabs. Note that tabs which are in // the process of closing (i.e., whose controllers are in // |closingControllers_|) have already been removed from the model. - // TODO: convert to apps. - return 0; + return tabStripModel_->IndexOfFirstNonMiniTab(); } -// (Private) Returns the number of open, unpinned tabs. -- (NSInteger)numberOfOpenUnpinnedTabs { - NSInteger number = [self numberOfOpenTabs] - [self numberOfOpenPinnedTabs]; +// (Private) Returns the number of open, non-mini tabs. +- (NSInteger)numberOfOpenNonMiniTabs { + NSInteger number = [self numberOfOpenTabs] - [self numberOfOpenMiniTabs]; DCHECK_GE(number, 0); return number; } @@ -655,7 +654,7 @@ private: const CGFloat kMaxTabWidth = [TabController maxTabWidth]; const CGFloat kMinTabWidth = [TabController minTabWidth]; const CGFloat kMinSelectedTabWidth = [TabController minSelectedTabWidth]; - const CGFloat kPinnedTabWidth = [TabController pinnedTabWidth]; + const CGFloat kMiniTabWidth = [TabController miniTabWidth]; NSRect enclosingRect = NSZeroRect; ScopedNSAnimationContextGroup mainAnimationGroup(animate); @@ -666,7 +665,7 @@ private: [self regenerateSubviewList]; // Compute the base width of tabs given how much room we're allowed. Note that - // pinned tabs have a fixed width. We may not be able to use the entire width + // mini-tabs have a fixed width. We may not be able to use the entire width // if the user is quickly closing tabs. This may be negative, but that's okay // (taken care of by |MAX()| when calculating tab sizes). CGFloat availableWidth = 0; @@ -683,22 +682,22 @@ private: // This may be negative, but that's okay (taken care of by |MAX()| when // calculating tab sizes). - CGFloat availableWidthForUnpinned = availableWidth - - [self numberOfOpenPinnedTabs] * (kPinnedTabWidth - kTabOverlap); + CGFloat availableWidthForNonMini = availableWidth - + [self numberOfOpenMiniTabs] * (kMiniTabWidth - kTabOverlap); - // Initialize |unpinnedTabWidth| in case there aren't any unpinned tabs; this + // Initialize |nonMiniTabWidth| in case there aren't any non-mini-tabs; this // value shouldn't actually be used. - CGFloat unpinnedTabWidth = kMaxTabWidth; - const NSInteger numberOfOpenUnpinnedTabs = [self numberOfOpenUnpinnedTabs]; - if (numberOfOpenUnpinnedTabs) { // Find the width of an unpinned tab. + CGFloat nonMiniTabWidth = kMaxTabWidth; + const NSInteger numberOfOpenNonMiniTabs = [self numberOfOpenNonMiniTabs]; + if (numberOfOpenNonMiniTabs) { // Find the width of a non-mini-tab. // Add in the amount we "get back" from the tabs overlapping. - availableWidthForUnpinned += (numberOfOpenUnpinnedTabs - 1) * kTabOverlap; + availableWidthForNonMini += (numberOfOpenNonMiniTabs - 1) * kTabOverlap; - // Divide up the space between the unpinned tabs. - unpinnedTabWidth = availableWidthForUnpinned / numberOfOpenUnpinnedTabs; + // Divide up the space between the non-mini-tabs. + nonMiniTabWidth = availableWidthForNonMini / numberOfOpenNonMiniTabs; // Clamp the width between the max and min. - unpinnedTabWidth = MAX(MIN(unpinnedTabWidth, kMaxTabWidth), kMinTabWidth); + nonMiniTabWidth = MAX(MIN(nonMiniTabWidth, kMaxTabWidth), kMinTabWidth); } const CGFloat minX = NSMinX(placeholderFrame_); @@ -754,7 +753,7 @@ private: // Set the width. Selected tabs are slightly wider when things get really // small and thus we enforce a different minimum width. - tabFrame.size.width = [tab pinned] ? kPinnedTabWidth : unpinnedTabWidth; + tabFrame.size.width = [tab mini] ? kMiniTabWidth : nonMiniTabWidth; if ([tab selected]) tabFrame.size.width = MAX(tabFrame.size.width, kMinSelectedTabWidth); @@ -885,6 +884,7 @@ private: // Make a new tab and add it to the strip. Keep track of its controller. TabController* newController = [self newTab]; + [newController setMini:tabStripModel_->IsMiniTab(modelIndex)]; [tabArray_ insertObject:newController atIndex:index]; NSView* newView = [newController view]; @@ -929,6 +929,23 @@ private: // Take closing tabs into account. NSInteger index = [self indexFromModelIndex:modelIndex]; + if (oldContents) { + int oldModelIndex = + browser_->GetIndexOfController(&(oldContents->controller())); + if (oldModelIndex != -1) { // When closing a tab, the old tab may be gone. + NSInteger oldIndex = [self indexFromModelIndex:oldModelIndex]; + TabContentsController* oldController = + [tabContentsArray_ objectAtIndex:oldIndex]; + [oldController willBecomeUnselectedTab]; + oldContents->view()->StoreFocus(); + oldContents->WasHidden(); + // If the selection changed because the tab was made phantom, update the + // Cocoa side of the state. + TabController* tabController = [tabArray_ objectAtIndex:oldIndex]; + [tabController setPhantom:tabStripModel_->IsPhantomTab(oldModelIndex)]; + } + } + // De-select all other tabs and select the new tab. int i = 0; for (TabController* current in tabArray_.get()) { @@ -947,19 +964,6 @@ private: // selected tab to the top. [self layoutTabs]; - if (oldContents) { - int oldModelIndex = - browser_->GetIndexOfController(&(oldContents->controller())); - if (oldModelIndex != -1) { // When closing a tab, the old tab may be gone. - NSInteger oldIndex = [self indexFromModelIndex:oldModelIndex]; - TabContentsController* oldController = - [tabContentsArray_ objectAtIndex:oldIndex]; - [oldController willBecomeUnselectedTab]; - oldContents->view()->StoreFocus(); - oldContents->WasHidden(); - } - } - // Swap in the contents for the new tab. [self swapInTabAtIndex:modelIndex]; [self updateDevToolsForContents:newContents]; @@ -1125,9 +1129,15 @@ private: TabController* tabController = [tabArray_ objectAtIndex:index]; + // Since the tab is loading, it cannot be phantom any more. + if ([tabController phantom]) { + [tabController setPhantom:NO]; + [[tabController view] setNeedsDisplay:YES]; + } + bool oldHasIcon = [tabController iconView] != nil; bool newHasIcon = contents->ShouldDisplayFavIcon() || - tabStripModel_->IsTabPinned(modelIndex); // always show icon if pinned + tabStripModel_->IsMiniTab(modelIndex); // Always show icon if mini. TabLoadingState oldState = [tabController loadingState]; TabLoadingState newState = kTabDone; @@ -1188,8 +1198,15 @@ private: return; } + TabController* tabController = [tabArray_ objectAtIndex:index]; + if (change != TabStripModelObserver::LOADING_ONLY) - [self setTabTitle:[tabArray_ objectAtIndex:index] withContents:contents]; + [self setTabTitle:tabController withContents:contents]; + + // See if the change was to/from phantom. + bool isPhantom = tabStripModel_->IsPhantomTab(modelIndex); + if (isPhantom != [tabController phantom]) + [tabController setPhantom:isPhantom]; [self updateFavIconForContents:contents atIndex:modelIndex]; @@ -1203,8 +1220,7 @@ private: // simultaneously, so we need to take care of that. - (void)tabMovedWithContents:(TabContents*)contents fromIndex:(NSInteger)modelFrom - toIndex:(NSInteger)modelTo - pinnedStateChanged:(BOOL)pinnedChanged { + toIndex:(NSInteger)modelTo { // Take closing tabs into account. NSInteger from = [self indexFromModelIndex:modelFrom]; NSInteger to = [self indexFromModelIndex:modelTo]; @@ -1220,32 +1236,22 @@ private: [tabArray_ removeObjectAtIndex:from]; [tabArray_ insertObject:movedTabController.get() atIndex:to]; - if (pinnedChanged) { - [movedTabController - setPinned:(tabStripModel_->IsTabPinned(modelTo) ? YES : NO)]; - [self updateFavIconForContents:contents atIndex:modelTo]; - } - - // TODO(viettrungluu): I don't think this is needed. Investigate. See also - // |-tabPinnedStateChangedWithContents:...|. - [self layoutTabs]; + // The tab moved, which means that the mini-tab state may have changed. + if (tabStripModel_->IsMiniTab(modelTo) != [movedTabController mini]) + [self tabMiniStateChangedWithContents:contents atIndex:modelTo]; } // Called when a tab is pinned or unpinned without moving. -- (void)tabPinnedStateChangedWithContents:(TabContents*)contents - atIndex:(NSInteger)modelIndex { +- (void)tabMiniStateChangedWithContents:(TabContents*)contents + atIndex:(NSInteger)modelIndex { // Take closing tabs into account. NSInteger index = [self indexFromModelIndex:modelIndex]; TabController* tabController = [tabArray_ objectAtIndex:index]; DCHECK([tabController isKindOfClass:[TabController class]]); - [tabController setPinned: - (tabStripModel_->IsTabPinned(modelIndex) ? YES : NO)]; + [tabController setMini: + (tabStripModel_->IsMiniTab(modelIndex) ? YES : NO)]; [self updateFavIconForContents:contents atIndex:modelIndex]; - - // TODO(viettrungluu): I don't think this is needed. Investigate. See also - // |-tabMovedWithContents:...|. - [self layoutTabs]; } - (void)setFrameOfSelectedTab:(NSRect)frame { @@ -1311,8 +1317,13 @@ private: // window when we don't have access to the TabContents as part of our strip. // |frame| is in the coordinate system of the tab strip view and represents // where the user dropped the new tab so it can be animated into its correct -// location when the tab is added to the model. -- (void)dropTabContents:(TabContents*)contents withFrame:(NSRect)frame { +// location when the tab is added to the model. If the tab was pinned in its +// previous window, setting |pinned| to YES will propagate that state to the +// new window. Mini-tabs are either app or pinned tabs; the app state is stored +// by the |contents|, but the |pinned| state is the caller's responsibility. +- (void)dropTabContents:(TabContents*)contents + withFrame:(NSRect)frame + asPinnedTab:(BOOL)pinned { int modelIndex = [self indexOfPlaceholder]; // Mark that the new tab being created should start at |frame|. It will be @@ -1321,19 +1332,8 @@ private: // Insert it into this tab strip. We want it in the foreground and to not // inherit the current tab's group. - tabStripModel_->InsertTabContentsAt(modelIndex, contents, true, false); - - // Take closing tabs into account. - NSInteger index = [self indexFromModelIndex:modelIndex]; - - // The tab's pinned status may have changed. - // TODO(viettrungluu): Improve the behaviour for drops at the dividing point - // between pinned and unpinned tabs. - TabController* tabController = [tabArray_ objectAtIndex:index]; - DCHECK([tabController isKindOfClass:[TabController class]]); - [tabController setPinned: - (tabStripModel_->IsTabPinned(modelIndex) ? YES : NO)]; - [self updateFavIconForContents:contents atIndex:modelIndex]; + tabStripModel_->InsertTabContentsAt(modelIndex, contents, true, false, + pinned); } // Called when the tab strip view changes size. As we only registered for diff --git a/chrome/browser/cocoa/tab_strip_model_observer_bridge.h b/chrome/browser/cocoa/tab_strip_model_observer_bridge.h index fc608fc..689cd3e 100644 --- a/chrome/browser/cocoa/tab_strip_model_observer_bridge.h +++ b/chrome/browser/cocoa/tab_strip_model_observer_bridge.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -36,7 +36,10 @@ class TabStripModelObserverBridge : public TabStripModelObserver { int to_index); virtual void TabChangedAt(TabContents* contents, int index, TabChangeType change_type); - virtual void TabPinnedStateChanged(TabContents* contents, int index); + virtual void TabReplacedAt(TabContents* old_contents, + TabContents* new_contents, + int index); + virtual void TabMiniStateChanged(TabContents* contents, int index); virtual void TabStripEmpty(); private: @@ -61,13 +64,12 @@ class TabStripModelObserverBridge : public TabStripModelObserver { userGesture:(bool)wasUserGesture; - (void)tabMovedWithContents:(TabContents*)contents fromIndex:(NSInteger)from - toIndex:(NSInteger)to - pinnedStateChanged:(BOOL)pinnedChanged; + toIndex:(NSInteger)to; - (void)tabChangedWithContents:(TabContents*)contents atIndex:(NSInteger)index changeType:(TabStripModelObserver::TabChangeType)change; -- (void)tabPinnedStateChangedWithContents:(TabContents*)contents - atIndex:(NSInteger)index; +- (void)tabMiniStateChangedWithContents:(TabContents*)contents + atIndex:(NSInteger)index; - (void)tabStripEmpty; @end diff --git a/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm b/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm index 87051c0..e5280dc 100644 --- a/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm +++ b/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -63,12 +63,10 @@ void TabStripModelObserverBridge::TabMoved(TabContents* contents, int from_index, int to_index) { if ([controller_ respondsToSelector: - @selector(tabMovedWithContents:fromIndex:toIndex:pinnedStateChanged:)]) { - // TODO: clean this up, need to remove pinnedStateChanged param. + @selector(tabMovedWithContents:fromIndex:toIndex:)]) { [controller_ tabMovedWithContents:contents fromIndex:from_index - toIndex:to_index - pinnedStateChanged:NO]; + toIndex:to_index]; } } @@ -83,12 +81,17 @@ void TabStripModelObserverBridge::TabChangedAt(TabContents* contents, } } -void TabStripModelObserverBridge::TabPinnedStateChanged(TabContents* contents, - int index) { +void TabStripModelObserverBridge::TabReplacedAt(TabContents* old_contents, + TabContents* new_contents, + int index) { + TabChangedAt(new_contents, index, ALL); +} + +void TabStripModelObserverBridge::TabMiniStateChanged(TabContents* contents, + int index) { if ([controller_ respondsToSelector: - @selector(tabPinnedStateChangedWithContents:atIndex:)]) { - [controller_ tabPinnedStateChangedWithContents:contents - atIndex:index]; + @selector(tabMiniStateChangedWithContents:atIndex:)]) { + [controller_ tabMiniStateChangedWithContents:contents atIndex:index]; } } |