OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_UI_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 | 26 |
27 namespace ui { | 27 namespace ui { |
28 class ListSelectionModel; | 28 class ListSelectionModel; |
29 } | 29 } |
30 | 30 |
31 // An implementation of TabStripController that sources data from the | 31 // An implementation of TabStripController that sources data from the |
32 // WebContentses in a TabStripModel. | 32 // WebContentses in a TabStripModel. |
33 class BrowserTabStripController : public TabStripController, | 33 class BrowserTabStripController : public TabStripController, |
34 public TabStripModelObserver { | 34 public TabStripModelObserver { |
35 public: | 35 public: |
36 BrowserTabStripController(Browser* browser, TabStripModel* model); | 36 BrowserTabStripController(Browser* browser, |
37 TabStripModel* model, | |
38 BrowserView* browser_view); | |
sky
2017/01/03 23:11:41
BrowserView has a browser() function, so that now
edwardjung
2017/01/05 16:59:45
Done.
| |
37 ~BrowserTabStripController() override; | 39 ~BrowserTabStripController() override; |
38 | 40 |
39 void InitFromModel(TabStrip* tabstrip); | 41 void InitFromModel(TabStrip* tabstrip); |
40 | 42 |
41 TabStripModel* model() const { return model_; } | 43 TabStripModel* model() const { return model_; } |
42 | 44 |
43 bool IsCommandEnabledForTab(TabStripModel::ContextMenuCommand command_id, | 45 bool IsCommandEnabledForTab(TabStripModel::ContextMenuCommand command_id, |
44 Tab* tab) const; | 46 Tab* tab) const; |
45 void ExecuteCommandForTab(TabStripModel::ContextMenuCommand command_id, | 47 void ExecuteCommandForTab(TabStripModel::ContextMenuCommand command_id, |
46 Tab* tab); | 48 Tab* tab); |
(...skipping 22 matching lines...) Expand all Loading... | |
69 void PerformDrop(bool drop_before, int index, const GURL& url) override; | 71 void PerformDrop(bool drop_before, int index, const GURL& url) override; |
70 bool IsCompatibleWith(TabStrip* other) const override; | 72 bool IsCompatibleWith(TabStrip* other) const override; |
71 void CreateNewTab() override; | 73 void CreateNewTab() override; |
72 void CreateNewTabWithLocation(const base::string16& loc) override; | 74 void CreateNewTabWithLocation(const base::string16& loc) override; |
73 bool IsIncognito() override; | 75 bool IsIncognito() override; |
74 void StackedLayoutMaybeChanged() override; | 76 void StackedLayoutMaybeChanged() override; |
75 void OnStartedDraggingTabs() override; | 77 void OnStartedDraggingTabs() override; |
76 void OnStoppedDraggingTabs() override; | 78 void OnStoppedDraggingTabs() override; |
77 void CheckFileSupported(const GURL& url) override; | 79 void CheckFileSupported(const GURL& url) override; |
78 SkColor GetToolbarTopSeparatorColor() const override; | 80 SkColor GetToolbarTopSeparatorColor() const override; |
81 base::string16 GetAccessibleTabName(const Tab* tab) const override; | |
79 | 82 |
80 // TabStripModelObserver implementation: | 83 // TabStripModelObserver implementation: |
81 void TabInsertedAt(TabStripModel* tab_strip_model, | 84 void TabInsertedAt(TabStripModel* tab_strip_model, |
82 content::WebContents* contents, | 85 content::WebContents* contents, |
83 int model_index, | 86 int model_index, |
84 bool is_active) override; | 87 bool is_active) override; |
85 void TabDetachedAt(content::WebContents* contents, int model_index) override; | 88 void TabDetachedAt(content::WebContents* contents, int model_index) override; |
86 void TabSelectionChanged(TabStripModel* tab_strip_model, | 89 void TabSelectionChanged(TabStripModel* tab_strip_model, |
87 const ui::ListSelectionModel& old_model) override; | 90 const ui::ListSelectionModel& old_model) override; |
88 void TabMoved(content::WebContents* contents, | 91 void TabMoved(content::WebContents* contents, |
89 int from_model_index, | 92 int from_model_index, |
90 int to_model_index) override; | 93 int to_model_index) override; |
91 void TabChangedAt(content::WebContents* contents, | 94 void TabChangedAt(content::WebContents* contents, |
92 int model_index, | 95 int model_index, |
93 TabChangeType change_type) override; | 96 TabChangeType change_type) override; |
94 void TabReplacedAt(TabStripModel* tab_strip_model, | 97 void TabReplacedAt(TabStripModel* tab_strip_model, |
95 content::WebContents* old_contents, | 98 content::WebContents* old_contents, |
96 content::WebContents* new_contents, | 99 content::WebContents* new_contents, |
97 int model_index) override; | 100 int model_index) override; |
98 void TabPinnedStateChanged(TabStripModel* tab_strip_model, | 101 void TabPinnedStateChanged(TabStripModel* tab_strip_model, |
99 content::WebContents* contents, | 102 content::WebContents* contents, |
100 int model_index) override; | 103 int model_index) override; |
101 void TabBlockedStateChanged(content::WebContents* contents, | 104 void TabBlockedStateChanged(content::WebContents* contents, |
102 int model_index) override; | 105 int model_index) override; |
103 | 106 |
107 const Browser* browser() const { return browser_; } | |
108 | |
104 protected: | 109 protected: |
105 // The context in which SetTabRendererDataFromModel is being called. | 110 // The context in which SetTabRendererDataFromModel is being called. |
106 enum TabStatus { | 111 enum TabStatus { |
107 NEW_TAB, | 112 NEW_TAB, |
108 EXISTING_TAB | 113 EXISTING_TAB |
109 }; | 114 }; |
110 | 115 |
111 // Sets the TabRendererData from the TabStripModel. | 116 // Sets the TabRendererData from the TabStripModel. |
112 virtual void SetTabRendererDataFromModel(content::WebContents* contents, | 117 virtual void SetTabRendererDataFromModel(content::WebContents* contents, |
113 int model_index, | 118 int model_index, |
114 TabRendererData* data, | 119 TabRendererData* data, |
115 TabStatus tab_status); | 120 TabStatus tab_status); |
116 | 121 |
117 Profile* profile() const { return model_->profile(); } | 122 Profile* profile() const { return model_->profile(); } |
118 | 123 |
119 const TabStrip* tabstrip() const { return tabstrip_; } | 124 const TabStrip* tabstrip() const { return tabstrip_; } |
120 | 125 |
121 const Browser* browser() const { return browser_; } | |
122 | |
123 private: | 126 private: |
124 class TabContextMenuContents; | 127 class TabContextMenuContents; |
125 | 128 |
126 // Invokes tabstrip_->SetTabData. | 129 // Invokes tabstrip_->SetTabData. |
127 void SetTabDataAt(content::WebContents* web_contents, int model_index); | 130 void SetTabDataAt(content::WebContents* web_contents, int model_index); |
128 | 131 |
129 void StartHighlightTabsForCommand( | 132 void StartHighlightTabsForCommand( |
130 TabStripModel::ContextMenuCommand command_id, | 133 TabStripModel::ContextMenuCommand command_id, |
131 Tab* tab); | 134 Tab* tab); |
132 void StopHighlightTabsForCommand( | 135 void StopHighlightTabsForCommand( |
(...skipping 11 matching lines...) Expand all Loading... | |
144 void OnFindURLMimeTypeCompleted(const GURL& url, | 147 void OnFindURLMimeTypeCompleted(const GURL& url, |
145 const std::string& mime_type); | 148 const std::string& mime_type); |
146 | 149 |
147 TabStripModel* model_; | 150 TabStripModel* model_; |
148 | 151 |
149 TabStrip* tabstrip_; | 152 TabStrip* tabstrip_; |
150 | 153 |
151 // Non-owning pointer to the browser which is using this controller. | 154 // Non-owning pointer to the browser which is using this controller. |
152 Browser* browser_; | 155 Browser* browser_; |
153 | 156 |
157 BrowserView* browser_view_; | |
158 | |
154 // If non-NULL it means we're showing a menu for the tab. | 159 // If non-NULL it means we're showing a menu for the tab. |
155 std::unique_ptr<TabContextMenuContents> context_menu_contents_; | 160 std::unique_ptr<TabContextMenuContents> context_menu_contents_; |
156 | 161 |
157 // Helper for performing tab selection as a result of dragging over a tab. | 162 // Helper for performing tab selection as a result of dragging over a tab. |
158 HoverTabSelector hover_tab_selector_; | 163 HoverTabSelector hover_tab_selector_; |
159 | 164 |
160 // Forces the tabs to use the regular (non-immersive) style and the | 165 // Forces the tabs to use the regular (non-immersive) style and the |
161 // top-of-window views to be revealed when the user is dragging |tabstrip|'s | 166 // top-of-window views to be revealed when the user is dragging |tabstrip|'s |
162 // tabs. | 167 // tabs. |
163 std::unique_ptr<ImmersiveRevealedLock> immersive_reveal_lock_; | 168 std::unique_ptr<ImmersiveRevealedLock> immersive_reveal_lock_; |
164 | 169 |
165 PrefChangeRegistrar local_pref_registrar_; | 170 PrefChangeRegistrar local_pref_registrar_; |
166 | 171 |
167 base::WeakPtrFactory<BrowserTabStripController> weak_ptr_factory_; | 172 base::WeakPtrFactory<BrowserTabStripController> weak_ptr_factory_; |
168 | 173 |
169 DISALLOW_COPY_AND_ASSIGN(BrowserTabStripController); | 174 DISALLOW_COPY_AND_ASSIGN(BrowserTabStripController); |
170 }; | 175 }; |
171 | 176 |
172 #endif // CHROME_BROWSER_UI_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_ | 177 #endif // CHROME_BROWSER_UI_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_ |
OLD | NEW |