tab_controller.h revision 5f1c94371a64b3196d4be9466099bb892df9b88e
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_CONTROLLER_H_
6#define CHROME_BROWSER_UI_VIEWS_TABS_TAB_CONTROLLER_H_
7
8#include "chrome/browser/ui/views/tabs/tab_strip_types.h"
9
10class Tab;
11
12namespace gfx {
13class Point;
14}
15namespace ui {
16class ListSelectionModel;
17class LocatedEvent;
18class MouseEvent;
19}
20namespace views {
21class View;
22}
23
24// Controller for tabs.
25class TabController {
26 public:
27  virtual const ui::ListSelectionModel& GetSelectionModel() = 0;
28
29  // Returns true if multiple selection is supported.
30  virtual bool SupportsMultipleSelection() = 0;
31
32  // Selects the tab.
33  virtual void SelectTab(Tab* tab) = 0;
34
35  // Extends the selection from the anchor to |tab|.
36  virtual void ExtendSelectionTo(Tab* tab) = 0;
37
38  // Toggles whether |tab| is selected.
39  virtual void ToggleSelected(Tab* tab) = 0;
40
41  // Adds the selection from the anchor to |tab|.
42  virtual void AddSelectionFromAnchorTo(Tab* tab) = 0;
43
44  // Closes the tab.
45  virtual void CloseTab(Tab* tab, CloseTabSource source) = 0;
46
47  // Shows a context menu for the tab at the specified point in screen coords.
48  virtual void ShowContextMenuForTab(Tab* tab,
49                                     const gfx::Point& p,
50                                     ui::MenuSourceType source_type) = 0;
51
52  // Returns true if |tab| is the active tab. The active tab is the one whose
53  // content is shown in the browser.
54  virtual bool IsActiveTab(const Tab* tab) const = 0;
55
56  // Returns true if the specified Tab is selected.
57  virtual bool IsTabSelected(const Tab* tab) const = 0;
58
59  // Returns true if the specified Tab is pinned.
60  virtual bool IsTabPinned(const Tab* tab) const = 0;
61
62  // Potentially starts a drag for the specified Tab.
63  virtual void MaybeStartDrag(
64      Tab* tab,
65      const ui::LocatedEvent& event,
66      const ui::ListSelectionModel& original_selection) = 0;
67
68  // Continues dragging a Tab.
69  virtual void ContinueDrag(views::View* view,
70                            const ui::LocatedEvent& event) = 0;
71
72  // Ends dragging a Tab. Returns whether the tab has been destroyed.
73  virtual bool EndDrag(EndDragReason reason) = 0;
74
75  // Returns the tab that contains the specified coordinates, in terms of |tab|,
76  // or NULL if there is no tab that contains the specified point.
77  virtual Tab* GetTabAt(Tab* tab,
78                        const gfx::Point& tab_in_tab_coordinates) = 0;
79
80  // Invoked when a mouse event occurs on |source|.
81  virtual void OnMouseEventInTab(views::View* source,
82                                 const ui::MouseEvent& event) = 0;
83
84  // Returns true if |tab| needs to be painted. If false is returned the tab is
85  // not painted. If true is returned the tab should be painted and |clip| is
86  // set to the clip (if |clip| is empty means no clip).
87  virtual bool ShouldPaintTab(const Tab* tab, gfx::Rect* clip) = 0;
88
89  // Returns true if tabs painted in the rectangular light-bar style.
90  virtual bool IsImmersiveStyle() const = 0;
91
92  // Adds private information to the tab's accessibility state.
93  virtual void UpdateTabAccessibilityState(const Tab* tab,
94                                        ui::AXViewState* state) = 0;
95
96 protected:
97  virtual ~TabController() {}
98};
99
100#endif  // CHROME_BROWSER_UI_VIEWS_TABS_TAB_CONTROLLER_H_
101