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