Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: chrome/browser/ui/views/tabs/browser_tab_strip_controller.h

Issue 2581023002: Add tab status to accessibility labels (Closed)
Patch Set: Return early if invalid tab index Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "chrome/browser/ui/tabs/hover_tab_selector.h" 12 #include "chrome/browser/ui/tabs/hover_tab_selector.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/browser/ui/views/frame/browser_view.h"
14 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 15 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
15 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" 16 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h"
16 #include "components/prefs/pref_change_registrar.h" 17 #include "components/prefs/pref_change_registrar.h"
17 18
18 class Browser; 19 class Browser;
19 class Tab; 20 class Tab;
20 class TabStrip; 21 class TabStrip;
21 struct TabRendererData; 22 struct TabRendererData;
22 23
23 namespace content { 24 namespace content {
24 class WebContents; 25 class WebContents;
25 } 26 }
26 27
27 namespace ui { 28 namespace ui {
28 class ListSelectionModel; 29 class ListSelectionModel;
29 } 30 }
30 31
31 // An implementation of TabStripController that sources data from the 32 // An implementation of TabStripController that sources data from the
32 // WebContentses in a TabStripModel. 33 // WebContentses in a TabStripModel.
33 class BrowserTabStripController : public TabStripController, 34 class BrowserTabStripController : public TabStripController,
34 public TabStripModelObserver { 35 public TabStripModelObserver {
35 public: 36 public:
36 BrowserTabStripController(Browser* browser, TabStripModel* model); 37 BrowserTabStripController(TabStripModel* model, BrowserView* browser_view);
37 ~BrowserTabStripController() override; 38 ~BrowserTabStripController() override;
38 39
39 void InitFromModel(TabStrip* tabstrip); 40 void InitFromModel(TabStrip* tabstrip);
40 41
41 TabStripModel* model() const { return model_; } 42 TabStripModel* model() const { return model_; }
42 43
43 bool IsCommandEnabledForTab(TabStripModel::ContextMenuCommand command_id, 44 bool IsCommandEnabledForTab(TabStripModel::ContextMenuCommand command_id,
44 Tab* tab) const; 45 Tab* tab) const;
45 void ExecuteCommandForTab(TabStripModel::ContextMenuCommand command_id, 46 void ExecuteCommandForTab(TabStripModel::ContextMenuCommand command_id,
46 Tab* tab); 47 Tab* tab);
(...skipping 22 matching lines...) Expand all
69 void PerformDrop(bool drop_before, int index, const GURL& url) override; 70 void PerformDrop(bool drop_before, int index, const GURL& url) override;
70 bool IsCompatibleWith(TabStrip* other) const override; 71 bool IsCompatibleWith(TabStrip* other) const override;
71 void CreateNewTab() override; 72 void CreateNewTab() override;
72 void CreateNewTabWithLocation(const base::string16& loc) override; 73 void CreateNewTabWithLocation(const base::string16& loc) override;
73 bool IsIncognito() override; 74 bool IsIncognito() override;
74 void StackedLayoutMaybeChanged() override; 75 void StackedLayoutMaybeChanged() override;
75 void OnStartedDraggingTabs() override; 76 void OnStartedDraggingTabs() override;
76 void OnStoppedDraggingTabs() override; 77 void OnStoppedDraggingTabs() override;
77 void CheckFileSupported(const GURL& url) override; 78 void CheckFileSupported(const GURL& url) override;
78 SkColor GetToolbarTopSeparatorColor() const override; 79 SkColor GetToolbarTopSeparatorColor() const override;
80 base::string16 GetAccessibleTabName(const Tab* tab) const override;
79 81
80 // TabStripModelObserver implementation: 82 // TabStripModelObserver implementation:
81 void TabInsertedAt(TabStripModel* tab_strip_model, 83 void TabInsertedAt(TabStripModel* tab_strip_model,
82 content::WebContents* contents, 84 content::WebContents* contents,
83 int model_index, 85 int model_index,
84 bool is_active) override; 86 bool is_active) override;
85 void TabDetachedAt(content::WebContents* contents, int model_index) override; 87 void TabDetachedAt(content::WebContents* contents, int model_index) override;
86 void TabSelectionChanged(TabStripModel* tab_strip_model, 88 void TabSelectionChanged(TabStripModel* tab_strip_model,
87 const ui::ListSelectionModel& old_model) override; 89 const ui::ListSelectionModel& old_model) override;
88 void TabMoved(content::WebContents* contents, 90 void TabMoved(content::WebContents* contents,
89 int from_model_index, 91 int from_model_index,
90 int to_model_index) override; 92 int to_model_index) override;
91 void TabChangedAt(content::WebContents* contents, 93 void TabChangedAt(content::WebContents* contents,
92 int model_index, 94 int model_index,
93 TabChangeType change_type) override; 95 TabChangeType change_type) override;
94 void TabReplacedAt(TabStripModel* tab_strip_model, 96 void TabReplacedAt(TabStripModel* tab_strip_model,
95 content::WebContents* old_contents, 97 content::WebContents* old_contents,
96 content::WebContents* new_contents, 98 content::WebContents* new_contents,
97 int model_index) override; 99 int model_index) override;
98 void TabPinnedStateChanged(TabStripModel* tab_strip_model, 100 void TabPinnedStateChanged(TabStripModel* tab_strip_model,
99 content::WebContents* contents, 101 content::WebContents* contents,
100 int model_index) override; 102 int model_index) override;
101 void TabBlockedStateChanged(content::WebContents* contents, 103 void TabBlockedStateChanged(content::WebContents* contents,
102 int model_index) override; 104 int model_index) override;
103 105
106 const Browser* browser() const { return browser_view_->browser(); }
107
104 protected: 108 protected:
105 // The context in which SetTabRendererDataFromModel is being called. 109 // The context in which SetTabRendererDataFromModel is being called.
106 enum TabStatus { 110 enum TabStatus {
107 NEW_TAB, 111 NEW_TAB,
108 EXISTING_TAB 112 EXISTING_TAB
109 }; 113 };
110 114
111 // Sets the TabRendererData from the TabStripModel. 115 // Sets the TabRendererData from the TabStripModel.
112 virtual void SetTabRendererDataFromModel(content::WebContents* contents, 116 virtual void SetTabRendererDataFromModel(content::WebContents* contents,
113 int model_index, 117 int model_index,
114 TabRendererData* data, 118 TabRendererData* data,
115 TabStatus tab_status); 119 TabStatus tab_status);
116 120
117 Profile* profile() const { return model_->profile(); } 121 Profile* profile() const { return model_->profile(); }
118 122
119 const TabStrip* tabstrip() const { return tabstrip_; } 123 const TabStrip* tabstrip() const { return tabstrip_; }
120 124
121 const Browser* browser() const { return browser_; }
122
123 private: 125 private:
124 class TabContextMenuContents; 126 class TabContextMenuContents;
125 127
126 // Invokes tabstrip_->SetTabData. 128 // Invokes tabstrip_->SetTabData.
127 void SetTabDataAt(content::WebContents* web_contents, int model_index); 129 void SetTabDataAt(content::WebContents* web_contents, int model_index);
128 130
129 void StartHighlightTabsForCommand( 131 void StartHighlightTabsForCommand(
130 TabStripModel::ContextMenuCommand command_id, 132 TabStripModel::ContextMenuCommand command_id,
131 Tab* tab); 133 Tab* tab);
132 void StopHighlightTabsForCommand( 134 void StopHighlightTabsForCommand(
133 TabStripModel::ContextMenuCommand command_id, 135 TabStripModel::ContextMenuCommand command_id,
134 Tab* tab); 136 Tab* tab);
135 137
136 // Adds a tab. 138 // Adds a tab.
137 void AddTab(content::WebContents* contents, int index, bool is_active); 139 void AddTab(content::WebContents* contents, int index, bool is_active);
138 140
139 // Resets the tabstrips stacked layout (true or false) from prefs. 141 // Resets the tabstrips stacked layout (true or false) from prefs.
140 void UpdateStackedLayout(); 142 void UpdateStackedLayout();
141 143
142 // Notifies the tabstrip whether |url| is supported once a MIME type request 144 // Notifies the tabstrip whether |url| is supported once a MIME type request
143 // has completed. 145 // has completed.
144 void OnFindURLMimeTypeCompleted(const GURL& url, 146 void OnFindURLMimeTypeCompleted(const GURL& url,
145 const std::string& mime_type); 147 const std::string& mime_type);
146 148
147 TabStripModel* model_; 149 TabStripModel* model_;
148 150
149 TabStrip* tabstrip_; 151 TabStrip* tabstrip_;
150 152
151 // Non-owning pointer to the browser which is using this controller. 153 BrowserView* browser_view_;
152 Browser* browser_;
153 154
154 // If non-NULL it means we're showing a menu for the tab. 155 // If non-NULL it means we're showing a menu for the tab.
155 std::unique_ptr<TabContextMenuContents> context_menu_contents_; 156 std::unique_ptr<TabContextMenuContents> context_menu_contents_;
156 157
157 // Helper for performing tab selection as a result of dragging over a tab. 158 // Helper for performing tab selection as a result of dragging over a tab.
158 HoverTabSelector hover_tab_selector_; 159 HoverTabSelector hover_tab_selector_;
159 160
160 // Forces the tabs to use the regular (non-immersive) style and the 161 // 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 162 // top-of-window views to be revealed when the user is dragging |tabstrip|'s
162 // tabs. 163 // tabs.
163 std::unique_ptr<ImmersiveRevealedLock> immersive_reveal_lock_; 164 std::unique_ptr<ImmersiveRevealedLock> immersive_reveal_lock_;
164 165
165 PrefChangeRegistrar local_pref_registrar_; 166 PrefChangeRegistrar local_pref_registrar_;
166 167
167 base::WeakPtrFactory<BrowserTabStripController> weak_ptr_factory_; 168 base::WeakPtrFactory<BrowserTabStripController> weak_ptr_factory_;
168 169
169 DISALLOW_COPY_AND_ASSIGN(BrowserTabStripController); 170 DISALLOW_COPY_AND_ASSIGN(BrowserTabStripController);
170 }; 171 };
171 172
172 #endif // CHROME_BROWSER_UI_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_ 173 #endif // CHROME_BROWSER_UI_VIEWS_TABS_BROWSER_TAB_STRIP_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698