Home | History | Annotate | Download | only in tabs
      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_STRIP_CONTROLLER_H_
      6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_
      7 #pragma once
      8 
      9 class BaseTab;
     10 class BaseTabStrip;
     11 class GURL;
     12 
     13 namespace gfx {
     14 class Point;
     15 }
     16 
     17 // Model/Controller for the TabStrip.
     18 // NOTE: All indices used by this class are in model coordinates.
     19 class TabStripController {
     20  public:
     21   virtual ~TabStripController() {}
     22 
     23   // Returns the number of tabs in the model.
     24   virtual int GetCount() const = 0;
     25 
     26   // Returns true if |index| is a valid model index.
     27   virtual bool IsValidIndex(int index) const = 0;
     28 
     29   // Returns true if the tab at |index| is the active tab. The active tab is the
     30   // one whose content is shown.
     31   virtual bool IsActiveTab(int index) const = 0;
     32 
     33   // Returns true if the selected index is selected.
     34   virtual bool IsTabSelected(int index) const = 0;
     35 
     36   // Returns true if the selected index is pinned.
     37   virtual bool IsTabPinned(int index) const = 0;
     38 
     39   // Returns true if the selected index is closeable.
     40   virtual bool IsTabCloseable(int index) const = 0;
     41 
     42   // Returns true if the selected index is the new tab page.
     43   virtual bool IsNewTabPage(int index) const = 0;
     44 
     45   // Select the tab at the specified index in the model.
     46   virtual void SelectTab(int index) = 0;
     47 
     48   // Extends the selection from the anchor to the specified index in the model.
     49   virtual void ExtendSelectionTo(int index) = 0;
     50 
     51   // Toggles the selection of the specified index in the model.
     52   virtual void ToggleSelected(int index) = 0;
     53 
     54   // Adds the selection the anchor to |index|.
     55   virtual void AddSelectionFromAnchorTo(int index) = 0;
     56 
     57   // Closes the tab at the specified index in the model.
     58   virtual void CloseTab(int index) = 0;
     59 
     60   // Shows a context menu for the tab at the specified point in screen coords.
     61   virtual void ShowContextMenuForTab(BaseTab* tab, const gfx::Point& p) = 0;
     62 
     63   // Updates the loading animations of all the tabs.
     64   virtual void UpdateLoadingAnimations() = 0;
     65 
     66   // Returns true if the associated TabStrip's delegate supports tab moving or
     67   // detaching. Used by the Frame to determine if dragging on the Tab
     68   // itself should move the window in cases where there's only one
     69   // non drag-able Tab.
     70   virtual int HasAvailableDragActions() const = 0;
     71 
     72   // Performans a drop at the specified location.
     73   virtual void PerformDrop(bool drop_before, int index, const GURL& url) = 0;
     74 
     75   // Return true if this tab strip is compatible with the provided tab strip.
     76   // Compatible tab strips can transfer tabs during drag and drop.
     77   virtual bool IsCompatibleWith(BaseTabStrip* other) const = 0;
     78 
     79   // Creates the new tab.
     80   virtual void CreateNewTab() = 0;
     81 };
     82 
     83 #endif  // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_CONTROLLER_H_
     84