1 // Copyright (c) 2011 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 #pragma once 8 9 class BaseTab; 10 11 namespace gfx { 12 class Point; 13 } 14 namespace views { 15 class MouseEvent; 16 } 17 18 // Controller for tabs. 19 class TabController { 20 public: 21 // Selects the tab. 22 virtual void SelectTab(BaseTab* tab) = 0; 23 24 // Extends the selection from the anchor to |tab|. 25 virtual void ExtendSelectionTo(BaseTab* tab) = 0; 26 27 // Toggles whether |tab| is selected. 28 virtual void ToggleSelected(BaseTab* tab) = 0; 29 30 // Adds the selection the anchor to |tab|. 31 virtual void AddSelectionFromAnchorTo(BaseTab* tab) = 0; 32 33 // Closes the tab. 34 virtual void CloseTab(BaseTab* tab) = 0; 35 36 // Shows a context menu for the tab at the specified point in screen coords. 37 virtual void ShowContextMenuForTab(BaseTab* tab, const gfx::Point& p) = 0; 38 39 // Returns true if |tab| is the active tab. The active tab is the one whose 40 // content is shown in the browser. 41 virtual bool IsActiveTab(const BaseTab* tab) const = 0; 42 43 // Returns true if the specified Tab is selected. 44 virtual bool IsTabSelected(const BaseTab* tab) const = 0; 45 46 // Returns true if the specified Tab is pinned. 47 virtual bool IsTabPinned(const BaseTab* tab) const = 0; 48 49 // Returns true if the specified Tab is closeable. 50 virtual bool IsTabCloseable(const BaseTab* tab) const = 0; 51 52 // Potentially starts a drag for the specified Tab. 53 virtual void MaybeStartDrag(BaseTab* tab, const views::MouseEvent& event) = 0; 54 55 // Continues dragging a Tab. 56 virtual void ContinueDrag(const views::MouseEvent& event) = 0; 57 58 // Ends dragging a Tab. |canceled| is true if the drag was aborted in a way 59 // other than the user releasing the mouse. Returns whether the tab has been 60 // destroyed. 61 virtual bool EndDrag(bool canceled) = 0; 62 63 // Returns the tab that contains the specified coordinates, in terms of |tab|, 64 // or NULL if there is no tab that contains the specified point. 65 virtual BaseTab* GetTabAt(BaseTab* tab, 66 const gfx::Point& tab_in_tab_coordinates) = 0; 67 68 protected: ~TabController()69 virtual ~TabController() {} 70 }; 71 72 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_CONTROLLER_H_ 73