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 // Toggles whether tab-wide audio muting is active. 48 virtual void ToggleTabAudioMute(Tab* tab) = 0; 49 50 // Shows a context menu for the tab at the specified point in screen coords. 51 virtual void ShowContextMenuForTab(Tab* tab, 52 const gfx::Point& p, 53 ui::MenuSourceType source_type) = 0; 54 55 // Returns true if |tab| is the active tab. The active tab is the one whose 56 // content is shown in the browser. 57 virtual bool IsActiveTab(const Tab* tab) const = 0; 58 59 // Returns true if the specified Tab is selected. 60 virtual bool IsTabSelected(const Tab* tab) const = 0; 61 62 // Returns true if the specified Tab is pinned. 63 virtual bool IsTabPinned(const Tab* tab) const = 0; 64 65 // Potentially starts a drag for the specified Tab. 66 virtual void MaybeStartDrag( 67 Tab* tab, 68 const ui::LocatedEvent& event, 69 const ui::ListSelectionModel& original_selection) = 0; 70 71 // Continues dragging a Tab. 72 virtual void ContinueDrag(views::View* view, 73 const ui::LocatedEvent& event) = 0; 74 75 // Ends dragging a Tab. Returns whether the tab has been destroyed. 76 virtual bool EndDrag(EndDragReason reason) = 0; 77 78 // Returns the tab that contains the specified coordinates, in terms of |tab|, 79 // or NULL if there is no tab that contains the specified point. 80 virtual Tab* GetTabAt(Tab* tab, 81 const gfx::Point& tab_in_tab_coordinates) = 0; 82 83 // Invoked when a mouse event occurs on |source|. 84 virtual void OnMouseEventInTab(views::View* source, 85 const ui::MouseEvent& event) = 0; 86 87 // Returns true if |tab| needs to be painted. If false is returned the tab is 88 // not painted. If true is returned the tab should be painted and |clip| is 89 // set to the clip (if |clip| is empty means no clip). 90 virtual bool ShouldPaintTab(const Tab* tab, gfx::Rect* clip) = 0; 91 92 // Returns true if tabs painted in the rectangular light-bar style. 93 virtual bool IsImmersiveStyle() const = 0; 94 95 // Adds private information to the tab's accessibility state. 96 virtual void UpdateTabAccessibilityState(const Tab* tab, 97 ui::AXViewState* state) = 0; 98 99 protected: 100 virtual ~TabController() {} 101}; 102 103#endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_CONTROLLER_H_ 104