1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_
8 #include "base/strings/string16.h"
9 #include "chrome/browser/ui/views/tabs/tab_strip_types.h"
10 #include "ui/base/ui_base_types.h"
21 class ListSelectionModel
;
24 // Model/Controller for the TabStrip.
25 // NOTE: All indices used by this class are in model coordinates.
26 class TabStripController
{
28 virtual ~TabStripController() {}
30 // Returns the selection model of the tabstrip.
31 virtual const ui::ListSelectionModel
& GetSelectionModel() = 0;
33 // Returns the number of tabs in the model.
34 virtual int GetCount() const = 0;
36 // Returns true if |index| is a valid model index.
37 virtual bool IsValidIndex(int index
) const = 0;
39 // Returns true if the tab at |index| is the active tab. The active tab is the
40 // one whose content is shown.
41 virtual bool IsActiveTab(int index
) const = 0;
43 // Returns the index of the active tab.
44 virtual int GetActiveIndex() const = 0;
46 // Returns true if the selected index is selected.
47 virtual bool IsTabSelected(int index
) const = 0;
49 // Returns true if the selected index is pinned.
50 virtual bool IsTabPinned(int index
) const = 0;
52 // Returns true if the selected index is the new tab page.
53 virtual bool IsNewTabPage(int index
) const = 0;
55 // Select the tab at the specified index in the model.
56 virtual void SelectTab(int index
) = 0;
58 // Extends the selection from the anchor to the specified index in the model.
59 virtual void ExtendSelectionTo(int index
) = 0;
61 // Toggles the selection of the specified index in the model.
62 virtual void ToggleSelected(int index
) = 0;
64 // Adds the selection the anchor to |index|.
65 virtual void AddSelectionFromAnchorTo(int index
) = 0;
67 // Closes the tab at the specified index in the model.
68 virtual void CloseTab(int index
, CloseTabSource source
) = 0;
70 // Toggles audio muting for the tab at the specified index in the model.
71 virtual void ToggleTabAudioMute(int index
) = 0;
73 // Shows a context menu for the tab at the specified point in screen coords.
74 virtual void ShowContextMenuForTab(Tab
* tab
,
76 ui::MenuSourceType source_type
) = 0;
78 // Updates the loading animations of all the tabs.
79 virtual void UpdateLoadingAnimations() = 0;
81 // Returns true if the associated TabStrip's delegate supports tab moving or
82 // detaching. Used by the Frame to determine if dragging on the Tab
83 // itself should move the window in cases where there's only one
85 virtual int HasAvailableDragActions() const = 0;
87 // Notifies controller of a drop index update.
88 virtual void OnDropIndexUpdate(int index
, bool drop_before
) = 0;
90 // Performs a drop at the specified location.
91 virtual void PerformDrop(bool drop_before
, int index
, const GURL
& url
) = 0;
93 // Return true if this tab strip is compatible with the provided tab strip.
94 // Compatible tab strips can transfer tabs during drag and drop.
95 virtual bool IsCompatibleWith(TabStrip
* other
) const = 0;
97 // Creates the new tab.
98 virtual void CreateNewTab() = 0;
100 // Creates a new tab, and loads |location| in the tab. If |location| is a
101 // valid URL, then simply loads the URL, otherwise this can open a
102 // search-result page for |location|.
103 virtual void CreateNewTabWithLocation(const base::string16
& location
) = 0;
105 // Returns true if the tab strip is in an incognito window.
106 virtual bool IsIncognito() = 0;
108 // Invoked if the stacked layout (on or off) might have changed.
109 virtual void StackedLayoutMaybeChanged() = 0;
111 // Notifies controller that the user started dragging this tabstrip's tabs.
112 virtual void OnStartedDraggingTabs() = 0;
114 // Notifies controller that the user stopped dragging this tabstrip's tabs.
115 // This is also called when the tabs that the user is dragging were detached
116 // from this tabstrip but the user is still dragging the tabs.
117 virtual void OnStoppedDraggingTabs() = 0;
119 // Determines if the file type of the URL is supported. Should invoke
120 // TabStrip::FileSupported to report the result.
121 virtual void CheckFileSupported(const GURL
& url
) = 0;
124 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_