tab_strip_controller.h revision f2477e01787aa58f445919b809d89e252beef54f
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.
4
5#ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_
6#define CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_
7
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"
11
12class GURL;
13class Tab;
14class TabStrip;
15
16namespace gfx {
17class Point;
18}
19
20namespace ui {
21class ListSelectionModel;
22}
23
24// Model/Controller for the TabStrip.
25// NOTE: All indices used by this class are in model coordinates.
26class TabStripController {
27 public:
28  virtual ~TabStripController() {}
29
30  // Returns the selection model of the tabstrip.
31  virtual const ui::ListSelectionModel& GetSelectionModel() = 0;
32
33  // Returns the number of tabs in the model.
34  virtual int GetCount() const = 0;
35
36  // Returns true if |index| is a valid model index.
37  virtual bool IsValidIndex(int index) const = 0;
38
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;
42
43  // Returns the index of the active tab.
44  virtual int GetActiveIndex() const = 0;
45
46  // Returns true if the selected index is selected.
47  virtual bool IsTabSelected(int index) const = 0;
48
49  // Returns true if the selected index is pinned.
50  virtual bool IsTabPinned(int index) const = 0;
51
52  // Returns true if the selected index is the new tab page.
53  virtual bool IsNewTabPage(int index) const = 0;
54
55  // Select the tab at the specified index in the model.
56  virtual void SelectTab(int index) = 0;
57
58  // Extends the selection from the anchor to the specified index in the model.
59  virtual void ExtendSelectionTo(int index) = 0;
60
61  // Toggles the selection of the specified index in the model.
62  virtual void ToggleSelected(int index) = 0;
63
64  // Adds the selection the anchor to |index|.
65  virtual void AddSelectionFromAnchorTo(int index) = 0;
66
67  // Closes the tab at the specified index in the model.
68  virtual void CloseTab(int index, CloseTabSource source) = 0;
69
70  // Shows a context menu for the tab at the specified point in screen coords.
71  virtual void ShowContextMenuForTab(Tab* tab,
72                                     const gfx::Point& p,
73                                     ui::MenuSourceType source_type) = 0;
74
75  // Updates the loading animations of all the tabs.
76  virtual void UpdateLoadingAnimations() = 0;
77
78  // Returns true if the associated TabStrip's delegate supports tab moving or
79  // detaching. Used by the Frame to determine if dragging on the Tab
80  // itself should move the window in cases where there's only one
81  // non drag-able Tab.
82  virtual int HasAvailableDragActions() const = 0;
83
84  // Notifies controller of a drop index update.
85  virtual void OnDropIndexUpdate(int index, bool drop_before) = 0;
86
87  // Performs a drop at the specified location.
88  virtual void PerformDrop(bool drop_before, int index, const GURL& url) = 0;
89
90  // Return true if this tab strip is compatible with the provided tab strip.
91  // Compatible tab strips can transfer tabs during drag and drop.
92  virtual bool IsCompatibleWith(TabStrip* other) const = 0;
93
94  // Creates the new tab.
95  virtual void CreateNewTab() = 0;
96
97  // Creates a new tab, and loads |location| in the tab. If |location| is a
98  // valid URL, then simply loads the URL, otherwise this can open a
99  // search-result page for |location|.
100  virtual void CreateNewTabWithLocation(const base::string16& location) = 0;
101
102  // Returns true if the tab strip is in an incognito window.
103  virtual bool IsIncognito() = 0;
104
105  // Invoked if the layout type might have changed.
106  virtual void LayoutTypeMaybeChanged() = 0;
107
108  // Notifies controller that the user started dragging this tabstrip's tabs.
109  virtual void OnStartedDraggingTabs() = 0;
110
111  // Notifies controller that the user stopped dragging this tabstrip's tabs.
112  // This is also called when the tabs that the user is dragging were detached
113  // from this tabstrip but the user is still dragging the tabs.
114  virtual void OnStoppedDraggingTabs() = 0;
115};
116
117#endif  // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_
118