tab_strip_controller.h revision 1320f92c476a1ad9d19dba2a48c72b75566198e9
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 // Toggles audio muting for the tab at the specified index in the model. 71 virtual void ToggleTabAudioMute(int index) = 0; 72 73 // Shows a context menu for the tab at the specified point in screen coords. 74 virtual void ShowContextMenuForTab(Tab* tab, 75 const gfx::Point& p, 76 ui::MenuSourceType source_type) = 0; 77 78 // Updates the loading animations of all the tabs. 79 virtual void UpdateLoadingAnimations() = 0; 80 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 84 // non drag-able Tab. 85 virtual int HasAvailableDragActions() const = 0; 86 87 // Notifies controller of a drop index update. 88 virtual void OnDropIndexUpdate(int index, bool drop_before) = 0; 89 90 // Performs a drop at the specified location. 91 virtual void PerformDrop(bool drop_before, int index, const GURL& url) = 0; 92 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; 96 97 // Creates the new tab. 98 virtual void CreateNewTab() = 0; 99 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; 104 105 // Returns true if the tab strip is in an incognito window. 106 virtual bool IsIncognito() = 0; 107 108 // Invoked if the stacked layout (on or off) might have changed. 109 virtual void StackedLayoutMaybeChanged() = 0; 110 111 // Notifies controller that the user started dragging this tabstrip's tabs. 112 virtual void OnStartedDraggingTabs() = 0; 113 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; 118 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; 122}; 123 124#endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_ 125