| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_ | 6 #define CHROME_BROWSER_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/scoped_ptr.h" | |
| 9 | |
| 10 #include "chrome/browser/tabs/tab_strip_model.h" | 8 #include "chrome/browser/tabs/tab_strip_model.h" |
| 11 #include "chrome/browser/views/tabs/side_tab_strip_model.h" | 9 #include "chrome/browser/views/tabs/side_tab_strip_model.h" |
| 12 | 10 |
| 13 class SideTabStrip; | 11 class SideTabStrip; |
| 14 | 12 |
| 15 // An implementation of SideTabStripModel that sources data from | 13 // An implementation of SideTabStripModel that sources data from |
| 16 // the TabContentses in a TabStripModel. | 14 // the TabContentses in a TabStripModel. |
| 17 class BrowserTabStripController : public SideTabStripModel, | 15 class BrowserTabStripController : public SideTabStripModel, |
| 18 public TabStripModelObserver { | 16 public TabStripModelObserver { |
| 19 public: | 17 public: |
| 20 BrowserTabStripController(TabStripModel* model, SideTabStrip* tabstrip); | 18 BrowserTabStripController(TabStripModel* model, SideTabStrip* tabstrip); |
| 21 virtual ~BrowserTabStripController(); | 19 virtual ~BrowserTabStripController(); |
| 22 | 20 |
| 23 void InitFromModel(); | |
| 24 | |
| 25 bool IsCommandEnabledForTab(TabStripModel::ContextMenuCommand command_id, | |
| 26 int tab_index) const; | |
| 27 bool IsCommandCheckedForTab(TabStripModel::ContextMenuCommand command_id, | |
| 28 int tab_index) const; | |
| 29 void ExecuteCommandForTab(TabStripModel::ContextMenuCommand command_id, | |
| 30 int tab_index); | |
| 31 | |
| 32 // SideTabStripModel implementation: | 21 // SideTabStripModel implementation: |
| 33 virtual SkBitmap GetIcon(int index) const; | 22 virtual SkBitmap GetIcon(int index) const; |
| 34 virtual string16 GetTitle(int index) const; | 23 virtual string16 GetTitle(int index) const; |
| 35 virtual bool IsSelected(int index) const; | 24 virtual bool IsSelected(int index) const; |
| 36 virtual NetworkState GetNetworkState(int index) const; | 25 virtual NetworkState GetNetworkState(int index) const; |
| 37 virtual void SelectTab(int index); | 26 virtual void SelectTab(int index); |
| 38 virtual void CloseTab(int index); | 27 virtual void CloseTab(int index); |
| 39 virtual void ShowContextMenu(int index, const gfx::Point& p); | |
| 40 | 28 |
| 41 // TabStripModelObserver implementation: | 29 // TabStripModelObserver implementation: |
| 42 virtual void TabInsertedAt(TabContents* contents, int index, | 30 virtual void TabInsertedAt(TabContents* contents, int index, |
| 43 bool foreground); | 31 bool foreground); |
| 44 virtual void TabDetachedAt(TabContents* contents, int index); | 32 virtual void TabDetachedAt(TabContents* contents, int index); |
| 45 virtual void TabSelectedAt(TabContents* old_contents, | 33 virtual void TabSelectedAt(TabContents* old_contents, |
| 46 TabContents* contents, int index, | 34 TabContents* contents, int index, |
| 47 bool user_gesture); | 35 bool user_gesture); |
| 48 virtual void TabMoved(TabContents* contents, int from_index, | 36 virtual void TabMoved(TabContents* contents, int from_index, |
| 49 int to_index); | 37 int to_index); |
| 50 virtual void TabChangedAt(TabContents* contents, int index, | 38 virtual void TabChangedAt(TabContents* contents, int index, |
| 51 TabChangeType change_type); | 39 TabChangeType change_type); |
| 52 virtual void TabReplacedAt(TabContents* old_contents, | 40 virtual void TabReplacedAt(TabContents* old_contents, |
| 53 TabContents* new_contents, int index); | 41 TabContents* new_contents, int index); |
| 54 virtual void TabPinnedStateChanged(TabContents* contents, int index); | 42 virtual void TabPinnedStateChanged(TabContents* contents, int index); |
| 55 virtual void TabBlockedStateChanged(TabContents* contents, int index); | 43 virtual void TabBlockedStateChanged(TabContents* contents, int index); |
| 56 | 44 |
| 57 private: | 45 private: |
| 58 class TabContextMenuContents; | |
| 59 | |
| 60 TabStripModel* model_; | 46 TabStripModel* model_; |
| 61 SideTabStrip* tabstrip_; | 47 SideTabStrip* tabstrip_; |
| 62 | 48 |
| 63 // If non-NULL it means we're showing a menu for the tab. | |
| 64 scoped_ptr<TabContextMenuContents> context_menu_contents_; | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(BrowserTabStripController); | 49 DISALLOW_COPY_AND_ASSIGN(BrowserTabStripController); |
| 67 }; | 50 }; |
| 68 | 51 |
| 69 #endif // CHROME_BROWSER_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_ | 52 #endif // CHROME_BROWSER_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_ |
| 70 | 53 |
| OLD | NEW |