diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-16 21:57:45 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-16 21:57:45 +0000 |
commit | c848d3d965724a00356d0bb92ae98505f2853a6c (patch) | |
tree | 5d0c5340cb7e51b5fc3b04d59cb1da5ac31a78f2 /chrome/browser/tabs | |
parent | 2f9791735a0c7066a261702d85eea393ac1c84cb (diff) | |
download | chromium_src-c848d3d965724a00356d0bb92ae98505f2853a6c.zip chromium_src-c848d3d965724a00356d0bb92ae98505f2853a6c.tar.gz chromium_src-c848d3d965724a00356d0bb92ae98505f2853a6c.tar.bz2 |
Moves TabStripModelObserver/Delegate into their own headers.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3425009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59733 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tabs')
-rw-r--r-- | chrome/browser/tabs/pinned_tab_codec_unittest.cc | 1 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model.cc | 61 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model.h | 255 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model_delegate.h | 135 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model_observer.cc | 62 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model_observer.h | 142 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model_unittest.cc | 2 |
7 files changed, 345 insertions, 313 deletions
diff --git a/chrome/browser/tabs/pinned_tab_codec_unittest.cc b/chrome/browser/tabs/pinned_tab_codec_unittest.cc index a94934c..6737c01 100644 --- a/chrome/browser/tabs/pinned_tab_codec_unittest.cc +++ b/chrome/browser/tabs/pinned_tab_codec_unittest.cc @@ -6,6 +6,7 @@ #include <vector> #include "chrome/browser/tabs/pinned_tab_codec.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/test/browser_with_test_window_test.h" #include "chrome/test/testing_profile.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index 4f6cfde..14df8d1 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -18,6 +18,7 @@ #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/sessions/tab_restore_service.h" +#include "chrome/browser/tabs/tab_strip_model_delegate.h" #include "chrome/browser/tabs/tab_strip_model_order_controller.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/tab_contents.h" @@ -46,66 +47,6 @@ bool ShouldForgetOpenersForTransition(PageTransition::Type transition) { } // namespace /////////////////////////////////////////////////////////////////////////////// -// TabStripModelObserver, public: - -void TabStripModelObserver::TabInsertedAt(TabContents* contents, - int index, - bool foreground) { -} - -void TabStripModelObserver::TabClosingAt(TabContents* contents, int index) { -} - -void TabStripModelObserver::TabDetachedAt(TabContents* contents, int index) { -} - -void TabStripModelObserver::TabDeselectedAt(TabContents* contents, int index) { -} - -void TabStripModelObserver::TabSelectedAt(TabContents* old_contents, - TabContents* new_contents, - int index, - bool user_gesture) { -} - -void TabStripModelObserver::TabMoved(TabContents* contents, - int from_index, - int to_index) { -} - -void TabStripModelObserver::TabChangedAt(TabContents* contents, int index, - TabChangeType change_type) { -} - -void TabStripModelObserver::TabReplacedAt(TabContents* old_contents, - TabContents* new_contents, - int index) { -} - -void TabStripModelObserver::TabReplacedAt(TabContents* old_contents, - TabContents* new_contents, - int index, - TabReplaceType type) { - TabReplacedAt(old_contents, new_contents, index); -} - -void TabStripModelObserver::TabPinnedStateChanged(TabContents* contents, - int index) { -} - -void TabStripModelObserver::TabMiniStateChanged(TabContents* contents, - int index) { -} - -void TabStripModelObserver::TabBlockedStateChanged(TabContents* contents, - int index) { -} - -void TabStripModelObserver::TabStripEmpty() {} - -void TabStripModelObserver::TabStripModelDeleted() {} - -/////////////////////////////////////////////////////////////////////////////// // TabStripModelDelegate, public: bool TabStripModelDelegate::CanCloseTab() const { diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h index 5143207..003f3d6 100644 --- a/chrome/browser/tabs/tab_strip_model.h +++ b/chrome/browser/tabs/tab_strip_model.h @@ -9,267 +9,16 @@ #include <vector> #include "base/observer_list.h" +#include "chrome/browser/tabs/tab_strip_model_observer.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/page_transition_types.h" -namespace gfx { -class Rect; -} -class Browser; -class DockInfo; -class GURL; class NavigationController; class Profile; -class SiteInstance; class TabContents; +class TabStripModelDelegate; class TabStripModelOrderController; -class TabStripModel; - -//////////////////////////////////////////////////////////////////////////////// -// -// TabStripModelObserver -// -// Objects implement this interface when they wish to be notified of changes -// to the TabStripModel. -// -// Two major implementers are the TabStrip, which uses notifications sent -// via this interface to update the presentation of the strip, and the Browser -// object, which updates bookkeeping and shows/hides individual TabContentses. -// -// Register your TabStripModelObserver with the TabStripModel using its -// Add/RemoveObserver methods. -// -//////////////////////////////////////////////////////////////////////////////// -class TabStripModelObserver { - public: - // Enumeration of the possible values supplied to TabChangedAt. - enum TabChangeType { - // Only the loading state changed. - LOADING_ONLY, - - // Only the title changed and page isn't loading. - TITLE_NOT_LOADING, - - // Change not characterized by LOADING_ONLY or TITLE_NOT_LOADING. - ALL - }; - - // Enum used by ReplaceTabContentsAt. - // TODO(sky): TabReplaceType should be declared outside the scope of - // the observer. I need to put all the enums in a namespace and cleanup this - // file. - enum TabReplaceType { - // The replace is the result of the tab being made phantom. - REPLACE_MADE_PHANTOM, - - // The replace is the result of the match preview being committed. - REPLACE_MATCH_PREVIEW - }; - - // A new TabContents was inserted into the TabStripModel at the specified - // index. |foreground| is whether or not it was opened in the foreground - // (selected). - virtual void TabInsertedAt(TabContents* contents, - int index, - bool foreground); - - // The specified TabContents at |index| is being closed (and eventually - // destroyed). - virtual void TabClosingAt(TabContents* contents, int index); - - // The specified TabContents at |index| is being detached, perhaps to be - // inserted in another TabStripModel. The implementer should take whatever - // action is necessary to deal with the TabContents no longer being present. - virtual void TabDetachedAt(TabContents* contents, int index); - - // The selected TabContents is about to change from |old_contents| at |index|. - // This gives observers a chance to prepare for an impending switch before it - // happens. - virtual void TabDeselectedAt(TabContents* contents, int index); - - // The selected TabContents changed from |old_contents| to |new_contents| at - // |index|. |user_gesture| specifies whether or not this was done by a user - // input event (e.g. clicking on a tab, keystroke) or as a side-effect of - // some other function. - virtual void TabSelectedAt(TabContents* old_contents, - TabContents* new_contents, - int index, - bool user_gesture); - - // The specified TabContents at |from_index| was moved to |to_index|. - virtual void TabMoved(TabContents* contents, - int from_index, - int to_index); - - // The specified TabContents at |index| changed in some way. |contents| may - // be an entirely different object and the old value is no longer available - // by the time this message is delivered. - // - // See TabChangeType for a description of |change_type|. - virtual void TabChangedAt(TabContents* contents, int index, - TabChangeType change_type); - - // The tab contents was replaced at the specified index. This is invoked when - // a tab becomes phantom. See description of phantom tabs in class description - // of TabStripModel for details. - // TODO(sky): nuke this in favor of the 4 arg variant. - virtual void TabReplacedAt(TabContents* old_contents, - TabContents* new_contents, - int index); - - // The tab contents was replaced at the specified index. |type| describes - // the type of replace. - // This invokes TabReplacedAt with three args. - virtual void TabReplacedAt(TabContents* old_contents, - TabContents* new_contents, - int index, - TabReplaceType type); - - // Invoked when the pinned state of a tab changes. This is not invoked if the - // tab ends up moving as a result of the mini state changing. - // See note in TabMiniStateChanged as to how this relates to - // TabMiniStateChanged. - virtual void TabPinnedStateChanged(TabContents* contents, int index); - - // Invoked if the mini state of a tab changes. This is not invoked if the - // tab ends up moving as a result of the mini state changing. - // NOTE: this is sent when the pinned state of a non-app tab changes and is - // sent in addition to TabPinnedStateChanged. UI code typically need not care - // about TabPinnedStateChanged, but instead this. - virtual void TabMiniStateChanged(TabContents* contents, int index); - - // Invoked when the blocked state of a tab changes. - // NOTE: This is invoked when a tab becomes blocked/unblocked by a tab modal - // window. - virtual void TabBlockedStateChanged(TabContents* contents, int index); - - // The TabStripModel now no longer has any phantom tabs. The implementer may - // use this as a trigger to try and close the window containing the - // TabStripModel, for example... - virtual void TabStripEmpty(); - - // Sent when the tabstrip model is about to be deleted and any reference held - // must be dropped. - virtual void TabStripModelDeleted(); - - protected: - virtual ~TabStripModelObserver() {} -}; - -/////////////////////////////////////////////////////////////////////////////// -// -// TabStripModelDelegate -// -// A delegate interface that the TabStripModel uses to perform work that it -// can't do itself, such as obtain a container HWND for creating new -// TabContents, creating new TabStripModels for detached tabs, etc. -// -// This interface is typically implemented by the controller that instantiates -// the TabStripModel (in our case the Browser object). -// -/////////////////////////////////////////////////////////////////////////////// -class TabStripModelDelegate { - public: - // Adds what the delegate considers to be a blank tab to the model. - virtual TabContents* AddBlankTab(bool foreground) = 0; - virtual TabContents* AddBlankTabAt(int index, bool foreground) = 0; - - // Asks for a new TabStripModel to be created and the given tab contents to - // be added to it. Its size and position are reflected in |window_bounds|. - // If |dock_info|'s type is other than NONE, the newly created window should - // be docked as identified by |dock_info|. Returns the Browser object - // representing the newly created window and tab strip. This does not - // show the window, it's up to the caller to do so. - virtual Browser* CreateNewStripWithContents(TabContents* contents, - const gfx::Rect& window_bounds, - const DockInfo& dock_info, - bool maximize) = 0; - - // Creates a new Browser object and window containing the specified - // |contents|, and continues a drag operation that began within the source - // window's tab strip. |window_bounds| are the bounds of the source window in - // screen coordinates, used to place the new window, and |tab_bounds| are the - // bounds of the dragged Tab view in the source window, in screen coordinates, - // used to place the new Tab in the new window. - virtual void ContinueDraggingDetachedTab(TabContents* contents, - const gfx::Rect& window_bounds, - const gfx::Rect& tab_bounds) = 0; - - enum { - TAB_MOVE_ACTION = 1, - TAB_TEAROFF_ACTION = 2 - }; - - // Determines what drag actions are possible for the specified strip. - virtual int GetDragActions() const = 0; - - // Creates an appropriate TabContents for the given URL. This is handled by - // the delegate since the TabContents may require special circumstances to - // exist for it to be constructed (e.g. a parent HWND). - // If |defer_load| is true, the navigation controller doesn't load the url. - // If |instance| is not null, its process is used to render the tab. - virtual TabContents* CreateTabContentsForURL( - const GURL& url, - const GURL& referrer, - Profile* profile, - PageTransition::Type transition, - bool defer_load, - SiteInstance* instance) const = 0; - - // Returns whether some contents can be duplicated. - virtual bool CanDuplicateContentsAt(int index) = 0; - - // Duplicates the contents at the provided index and places it into its own - // window. - virtual void DuplicateContentsAt(int index) = 0; - - // Called when a drag session has completed and the frame that initiated the - // the session should be closed. - virtual void CloseFrameAfterDragSession() = 0; - - // Creates an entry in the historical tab database for the specified - // TabContents. - virtual void CreateHistoricalTab(TabContents* contents) = 0; - - // Runs any unload listeners associated with the specified TabContents before - // it is closed. If there are unload listeners that need to be run, this - // function returns true and the TabStripModel will wait before closing the - // TabContents. If it returns false, there are no unload listeners and the - // TabStripModel can close the TabContents immediately. - virtual bool RunUnloadListenerBeforeClosing(TabContents* contents) = 0; - - // Returns true if a tab can be restored. - virtual bool CanRestoreTab() = 0; - - // Restores the last closed tab if CanRestoreTab would return true. - virtual void RestoreTab() = 0; - - // Returns whether some contents can be closed. - virtual bool CanCloseContentsAt(int index) = 0; - - // Returns true if we should allow "bookmark all tabs" in this window; this is - // true when there is more than one bookmarkable tab open. - virtual bool CanBookmarkAllTabs() const = 0; - - // Creates a bookmark folder containing a bookmark for all open tabs. - virtual void BookmarkAllTabs() = 0; - - // Returns true if any of the tabs can be closed. - virtual bool CanCloseTab() const; - - // Returns true if the vertical tabstrip presentation should be used. - virtual bool UseVerticalTabs() const = 0; - - // Toggles the use of the vertical tabstrip. - virtual void ToggleUseVerticalTabs() = 0; - - // Returns true if the tab strip can use large icons. - virtual bool LargeIconsPermitted() const = 0; - - protected: - virtual ~TabStripModelDelegate() {} -}; //////////////////////////////////////////////////////////////////////////////// // diff --git a/chrome/browser/tabs/tab_strip_model_delegate.h b/chrome/browser/tabs/tab_strip_model_delegate.h new file mode 100644 index 0000000..4901bbe --- /dev/null +++ b/chrome/browser/tabs/tab_strip_model_delegate.h @@ -0,0 +1,135 @@ +// 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. + +#ifndef CHROME_BROWSER_TABS_TAB_STRIP_MODEL_DELEGATE_H_ +#define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_DELEGATE_H_ +#pragma once + +#include "chrome/common/page_transition_types.h" + +class Browser; +class DockInfo; +class GURL; +class Profile; +class SiteInstance; +class TabContents; +namespace gfx { +class Rect; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// TabStripModelDelegate +// +// A delegate interface that the TabStripModel uses to perform work that it +// can't do itself, such as obtain a container HWND for creating new +// TabContents, creating new TabStripModels for detached tabs, etc. +// +// This interface is typically implemented by the controller that instantiates +// the TabStripModel (in our case the Browser object). +// +/////////////////////////////////////////////////////////////////////////////// +class TabStripModelDelegate { + public: + enum { + TAB_MOVE_ACTION = 1, + TAB_TEAROFF_ACTION = 2 + }; + + // Adds what the delegate considers to be a blank tab to the model. + virtual TabContents* AddBlankTab(bool foreground) = 0; + virtual TabContents* AddBlankTabAt(int index, bool foreground) = 0; + + // Asks for a new TabStripModel to be created and the given tab contents to + // be added to it. Its size and position are reflected in |window_bounds|. + // If |dock_info|'s type is other than NONE, the newly created window should + // be docked as identified by |dock_info|. Returns the Browser object + // representing the newly created window and tab strip. This does not + // show the window, it's up to the caller to do so. + virtual Browser* CreateNewStripWithContents(TabContents* contents, + const gfx::Rect& window_bounds, + const DockInfo& dock_info, + bool maximize) = 0; + + // Creates a new Browser object and window containing the specified + // |contents|, and continues a drag operation that began within the source + // window's tab strip. |window_bounds| are the bounds of the source window in + // screen coordinates, used to place the new window, and |tab_bounds| are the + // bounds of the dragged Tab view in the source window, in screen coordinates, + // used to place the new Tab in the new window. + virtual void ContinueDraggingDetachedTab(TabContents* contents, + const gfx::Rect& window_bounds, + const gfx::Rect& tab_bounds) = 0; + + // Determines what drag actions are possible for the specified strip. + virtual int GetDragActions() const = 0; + + // Creates an appropriate TabContents for the given URL. This is handled by + // the delegate since the TabContents may require special circumstances to + // exist for it to be constructed (e.g. a parent HWND). + // If |defer_load| is true, the navigation controller doesn't load the url. + // If |instance| is not null, its process is used to render the tab. + virtual TabContents* CreateTabContentsForURL( + const GURL& url, + const GURL& referrer, + Profile* profile, + PageTransition::Type transition, + bool defer_load, + SiteInstance* instance) const = 0; + + // Returns whether some contents can be duplicated. + virtual bool CanDuplicateContentsAt(int index) = 0; + + // Duplicates the contents at the provided index and places it into its own + // window. + virtual void DuplicateContentsAt(int index) = 0; + + // Called when a drag session has completed and the frame that initiated the + // the session should be closed. + virtual void CloseFrameAfterDragSession() = 0; + + // Creates an entry in the historical tab database for the specified + // TabContents. + virtual void CreateHistoricalTab(TabContents* contents) = 0; + + // Runs any unload listeners associated with the specified TabContents before + // it is closed. If there are unload listeners that need to be run, this + // function returns true and the TabStripModel will wait before closing the + // TabContents. If it returns false, there are no unload listeners and the + // TabStripModel can close the TabContents immediately. + virtual bool RunUnloadListenerBeforeClosing(TabContents* contents) = 0; + + // Returns true if a tab can be restored. + virtual bool CanRestoreTab() = 0; + + // Restores the last closed tab if CanRestoreTab would return true. + virtual void RestoreTab() = 0; + + // Returns whether some contents can be closed. + virtual bool CanCloseContentsAt(int index) = 0; + + // Returns true if we should allow "bookmark all tabs" in this window; this is + // true when there is more than one bookmarkable tab open. + virtual bool CanBookmarkAllTabs() const = 0; + + // Creates a bookmark folder containing a bookmark for all open tabs. + virtual void BookmarkAllTabs() = 0; + + // Returns true if any of the tabs can be closed. + virtual bool CanCloseTab() const = 0; + + // Returns true if the vertical tabstrip presentation should be used. + virtual bool UseVerticalTabs() const = 0; + + // Toggles the use of the vertical tabstrip. + virtual void ToggleUseVerticalTabs() = 0; + + // Returns true if the tab strip can use large icons. + virtual bool LargeIconsPermitted() const = 0; + + protected: + virtual ~TabStripModelDelegate() {} +}; + +#endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_DELEGATE_H_ diff --git a/chrome/browser/tabs/tab_strip_model_observer.cc b/chrome/browser/tabs/tab_strip_model_observer.cc new file mode 100644 index 0000000..c3bfb9b --- /dev/null +++ b/chrome/browser/tabs/tab_strip_model_observer.cc @@ -0,0 +1,62 @@ +// 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. + +#include "chrome/browser/tabs/tab_strip_model_observer.h" + +void TabStripModelObserver::TabInsertedAt(TabContents* contents, + int index, + bool foreground) { +} + +void TabStripModelObserver::TabClosingAt(TabContents* contents, int index) { +} + +void TabStripModelObserver::TabDetachedAt(TabContents* contents, int index) { +} + +void TabStripModelObserver::TabDeselectedAt(TabContents* contents, int index) { +} + +void TabStripModelObserver::TabSelectedAt(TabContents* old_contents, + TabContents* new_contents, + int index, + bool user_gesture) { +} + +void TabStripModelObserver::TabMoved(TabContents* contents, + int from_index, + int to_index) { +} + +void TabStripModelObserver::TabChangedAt(TabContents* contents, int index, + TabChangeType change_type) { +} + +void TabStripModelObserver::TabReplacedAt(TabContents* old_contents, + TabContents* new_contents, + int index) { +} + +void TabStripModelObserver::TabReplacedAt(TabContents* old_contents, + TabContents* new_contents, + int index, + TabReplaceType type) { + TabReplacedAt(old_contents, new_contents, index); +} + +void TabStripModelObserver::TabPinnedStateChanged(TabContents* contents, + int index) { +} + +void TabStripModelObserver::TabMiniStateChanged(TabContents* contents, + int index) { +} + +void TabStripModelObserver::TabBlockedStateChanged(TabContents* contents, + int index) { +} + +void TabStripModelObserver::TabStripEmpty() {} + +void TabStripModelObserver::TabStripModelDeleted() {} diff --git a/chrome/browser/tabs/tab_strip_model_observer.h b/chrome/browser/tabs/tab_strip_model_observer.h new file mode 100644 index 0000000..cfbf9e8 --- /dev/null +++ b/chrome/browser/tabs/tab_strip_model_observer.h @@ -0,0 +1,142 @@ +// 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. + +#ifndef CHROME_BROWSER_TABS_TAB_STRIP_MODEL_OBSERVER_H_ +#define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_OBSERVER_H_ +#pragma once + +class TabContents; + +//////////////////////////////////////////////////////////////////////////////// +// +// TabStripModelObserver +// +// Objects implement this interface when they wish to be notified of changes +// to the TabStripModel. +// +// Two major implementers are the TabStrip, which uses notifications sent +// via this interface to update the presentation of the strip, and the Browser +// object, which updates bookkeeping and shows/hides individual TabContentses. +// +// Register your TabStripModelObserver with the TabStripModel using its +// Add/RemoveObserver methods. +// +//////////////////////////////////////////////////////////////////////////////// +class TabStripModelObserver { + public: + // Enumeration of the possible values supplied to TabChangedAt. + enum TabChangeType { + // Only the loading state changed. + LOADING_ONLY, + + // Only the title changed and page isn't loading. + TITLE_NOT_LOADING, + + // Change not characterized by LOADING_ONLY or TITLE_NOT_LOADING. + ALL + }; + + // Enum used by ReplaceTabContentsAt. + // TODO(sky): nuke this, pinned is being removed so there is no point in the + // enum. + enum TabReplaceType { + // The replace is the result of the tab being made phantom. + REPLACE_MADE_PHANTOM, + + // The replace is the result of the match preview being committed. + REPLACE_MATCH_PREVIEW + }; + + // A new TabContents was inserted into the TabStripModel at the specified + // index. |foreground| is whether or not it was opened in the foreground + // (selected). + virtual void TabInsertedAt(TabContents* contents, + int index, + bool foreground); + + // The specified TabContents at |index| is being closed (and eventually + // destroyed). + virtual void TabClosingAt(TabContents* contents, int index); + + // The specified TabContents at |index| is being detached, perhaps to be + // inserted in another TabStripModel. The implementer should take whatever + // action is necessary to deal with the TabContents no longer being present. + virtual void TabDetachedAt(TabContents* contents, int index); + + // The selected TabContents is about to change from |old_contents| at |index|. + // This gives observers a chance to prepare for an impending switch before it + // happens. + virtual void TabDeselectedAt(TabContents* contents, int index); + + // The selected TabContents changed from |old_contents| to |new_contents| at + // |index|. |user_gesture| specifies whether or not this was done by a user + // input event (e.g. clicking on a tab, keystroke) or as a side-effect of + // some other function. + virtual void TabSelectedAt(TabContents* old_contents, + TabContents* new_contents, + int index, + bool user_gesture); + + // The specified TabContents at |from_index| was moved to |to_index|. + virtual void TabMoved(TabContents* contents, + int from_index, + int to_index); + + // The specified TabContents at |index| changed in some way. |contents| may + // be an entirely different object and the old value is no longer available + // by the time this message is delivered. + // + // See TabChangeType for a description of |change_type|. + virtual void TabChangedAt(TabContents* contents, + int index, + TabChangeType change_type); + + // The tab contents was replaced at the specified index. This is invoked when + // a tab becomes phantom. See description of phantom tabs in class description + // of TabStripModel for details. + // TODO(sky): nuke this in favor of the 4 arg variant. + virtual void TabReplacedAt(TabContents* old_contents, + TabContents* new_contents, + int index); + + // The tab contents was replaced at the specified index. |type| describes + // the type of replace. + // This invokes TabReplacedAt with three args. + virtual void TabReplacedAt(TabContents* old_contents, + TabContents* new_contents, + int index, + TabReplaceType type); + + // Invoked when the pinned state of a tab changes. This is not invoked if the + // tab ends up moving as a result of the mini state changing. + // See note in TabMiniStateChanged as to how this relates to + // TabMiniStateChanged. + virtual void TabPinnedStateChanged(TabContents* contents, int index); + + // Invoked if the mini state of a tab changes. This is not invoked if the + // tab ends up moving as a result of the mini state changing. + // NOTE: this is sent when the pinned state of a non-app tab changes and is + // sent in addition to TabPinnedStateChanged. UI code typically need not care + // about TabPinnedStateChanged, but instead this. + virtual void TabMiniStateChanged(TabContents* contents, int index); + + // Invoked when the blocked state of a tab changes. + // NOTE: This is invoked when a tab becomes blocked/unblocked by a tab modal + // window. + virtual void TabBlockedStateChanged(TabContents* contents, int index); + + // The TabStripModel now no longer has any phantom tabs. The implementer may + // use this as a trigger to try and close the window containing the + // TabStripModel, for example... + virtual void TabStripEmpty(); + + // Sent when the tabstrip model is about to be deleted and any reference held + // must be dropped. + virtual void TabStripModelDeleted(); + + protected: + virtual ~TabStripModelObserver() {} +}; + +#endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_OBSERVER_H_ diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index 51924cf..9fabf5b 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -22,6 +22,7 @@ #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/tabs/tab_strip_model_delegate.h" #include "chrome/browser/tabs/tab_strip_model_order_controller.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/notification_observer_mock.h" @@ -83,6 +84,7 @@ class TabStripDummyDelegate : public TabStripModelDelegate { virtual bool CanCloseContentsAt(int index) { return can_close_ ; } virtual bool CanBookmarkAllTabs() const { return false; } virtual void BookmarkAllTabs() {} + virtual bool CanCloseTab() const { return true; } virtual bool UseVerticalTabs() const { return false; } virtual void ToggleUseVerticalTabs() {} virtual bool LargeIconsPermitted() const { return true; } |