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

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_actions_model.h

Issue 2678083005: Remove extension-to-component migration mechanism (Closed)
Patch Set: Address Derek's comments Created 3 years, 10 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_TOOLBAR_TOOLBAR_ACTIONS_MODEL_H_ 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_MODEL_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_MODEL_H_ 6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_MODEL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
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 "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "base/scoped_observer.h" 13 #include "base/scoped_observer.h"
14 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 14 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
15 #include "chrome/browser/extensions/component_migration_helper.h"
16 #include "chrome/browser/extensions/extension_action.h" 15 #include "chrome/browser/extensions/extension_action.h"
16 #include "chrome/browser/ui/toolbar/component_action_delegate.h"
17 #include "components/keyed_service/core/keyed_service.h" 17 #include "components/keyed_service/core/keyed_service.h"
18 #include "components/prefs/pref_change_registrar.h" 18 #include "components/prefs/pref_change_registrar.h"
19 #include "extensions/browser/extension_prefs.h" 19 #include "extensions/browser/extension_prefs.h"
20 #include "extensions/browser/extension_registry_observer.h" 20 #include "extensions/browser/extension_registry_observer.h"
21 #include "extensions/common/extension.h" 21 #include "extensions/common/extension.h"
22 22
23 class Browser; 23 class Browser;
24 class PrefService; 24 class PrefService;
25 class Profile; 25 class Profile;
26 class ToolbarActionsBar; 26 class ToolbarActionsBar;
27 class ToolbarActionViewController; 27 class ToolbarActionViewController;
28 28
29 namespace extensions { 29 namespace extensions {
30 class ExtensionActionManager; 30 class ExtensionActionManager;
31 class ExtensionMessageBubbleController; 31 class ExtensionMessageBubbleController;
32 class ExtensionRegistry; 32 class ExtensionRegistry;
33 } 33 }
34 34
35 // Model for the browser actions toolbar. This is a per-profile instance, and 35 // Model for the browser actions toolbar. This is a per-profile instance, and
36 // manages the user's global preferences. 36 // manages the user's global preferences.
37 // Each browser window will attempt to show browser actions as specified by this 37 // Each browser window will attempt to show browser actions as specified by this
38 // model, but if the window is too narrow, actions may end up pushed into the 38 // model, but if the window is too narrow, actions may end up pushed into the
39 // overflow menu on a per-window basis. Callers interested in the arrangement of 39 // overflow menu on a per-window basis. Callers interested in the arrangement of
40 // actions in a particular window should check that window's instance of 40 // actions in a particular window should check that window's instance of
41 // ToolbarActionsBar, which is responsible for the per-window layout. 41 // ToolbarActionsBar, which is responsible for the per-window layout.
42 class ToolbarActionsModel 42 class ToolbarActionsModel : public extensions::ExtensionActionAPI::Observer,
43 : public extensions::ExtensionActionAPI::Observer, 43 public extensions::ExtensionRegistryObserver,
44 public extensions::ExtensionRegistryObserver, 44 public KeyedService,
45 public KeyedService, 45 public ComponentActionDelegate {
46 public extensions::ComponentMigrationHelper::ComponentActionDelegate {
47 public: 46 public:
48 // The different options for highlighting. 47 // The different options for highlighting.
49 enum HighlightType { 48 enum HighlightType {
50 HIGHLIGHT_NONE, 49 HIGHLIGHT_NONE,
51 HIGHLIGHT_WARNING, 50 HIGHLIGHT_WARNING,
52 }; 51 };
53 52
54 // The different types of actions. 53 // The different types of actions.
55 enum ActionType { 54 enum ActionType {
56 UNKNOWN_ACTION, 55 UNKNOWN_ACTION,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 ToolbarActionsBar* bar); 155 ToolbarActionsBar* bar);
157 std::unique_ptr<ToolbarActionViewController> CreateActionForItem( 156 std::unique_ptr<ToolbarActionViewController> CreateActionForItem(
158 Browser* browser, 157 Browser* browser,
159 ToolbarActionsBar* bar, 158 ToolbarActionsBar* bar,
160 const ToolbarItem& item); 159 const ToolbarItem& item);
161 160
162 const std::vector<ToolbarItem>& toolbar_items() const { 161 const std::vector<ToolbarItem>& toolbar_items() const {
163 return is_highlighting() ? highlighted_items_ : toolbar_items_; 162 return is_highlighting() ? highlighted_items_ : toolbar_items_;
164 } 163 }
165 164
166 extensions::ComponentMigrationHelper* component_migration_helper() {
167 return component_migration_helper_.get();
168 }
169
170 bool is_highlighting() const { return highlight_type_ != HIGHLIGHT_NONE; } 165 bool is_highlighting() const { return highlight_type_ != HIGHLIGHT_NONE; }
171 HighlightType highlight_type() const { return highlight_type_; } 166 HighlightType highlight_type() const { return highlight_type_; }
172 167
173 bool has_active_bubble() const { return has_active_bubble_; } 168 bool has_active_bubble() const { return has_active_bubble_; }
174 void set_has_active_bubble(bool has_active_bubble) { 169 void set_has_active_bubble(bool has_active_bubble) {
175 has_active_bubble_ = has_active_bubble; 170 has_active_bubble_ = has_active_bubble;
176 } 171 }
177 172
178 void SetActionVisibility(const std::string& action_id, bool visible); 173 void SetActionVisibility(const std::string& action_id, bool visible);
179 174
180 // ComponentMigrationHelper::ComponentActionDelegate: 175 // ComponentActionDelegate:
181 // AddComponentAction() is a no-op if |actions_initialized_| is false. 176 // AddComponentAction() is a no-op if |actions_initialized_| is false.
182 void AddComponentAction(const std::string& action_id) override; 177 void AddComponentAction(const std::string& action_id) override;
183 void RemoveComponentAction(const std::string& action_id) override; 178 void RemoveComponentAction(const std::string& action_id) override;
184 bool HasComponentAction(const std::string& action_id) const override; 179 bool HasComponentAction(const std::string& action_id) const override;
185 180
186 void OnActionToolbarPrefChange(); 181 void OnActionToolbarPrefChange();
187 182
188 // Highlights the actions specified by |action_ids|. This will cause 183 // Highlights the actions specified by |action_ids|. This will cause
189 // the ToolbarModel to only display those actions. 184 // the ToolbarModel to only display those actions.
190 // Highlighting mode is only entered if there is at least one action to be 185 // Highlighting mode is only entered if there is at least one action to be
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 279
285 // The ExtensionActionAPI object, cached for convenience. 280 // The ExtensionActionAPI object, cached for convenience.
286 extensions::ExtensionActionAPI* extension_action_api_; 281 extensions::ExtensionActionAPI* extension_action_api_;
287 282
288 // The ExtensionRegistry object, cached for convenience. 283 // The ExtensionRegistry object, cached for convenience.
289 extensions::ExtensionRegistry* extension_registry_; 284 extensions::ExtensionRegistry* extension_registry_;
290 285
291 // The ExtensionActionManager, cached for convenience. 286 // The ExtensionActionManager, cached for convenience.
292 extensions::ExtensionActionManager* extension_action_manager_; 287 extensions::ExtensionActionManager* extension_action_manager_;
293 288
294 // The ComponentMigrationHelper.
295 std::unique_ptr<extensions::ComponentMigrationHelper>
296 component_migration_helper_;
297
298 // True if we've handled the initial EXTENSIONS_READY notification. 289 // True if we've handled the initial EXTENSIONS_READY notification.
299 bool actions_initialized_; 290 bool actions_initialized_;
300 291
301 // If true, we include all actions in the toolbar model. 292 // If true, we include all actions in the toolbar model.
302 bool use_redesign_; 293 bool use_redesign_;
303 294
304 // Ordered list of browser actions. 295 // Ordered list of browser actions.
305 std::vector<ToolbarItem> toolbar_items_; 296 std::vector<ToolbarItem> toolbar_items_;
306 297
307 // List of browser actions which should be highlighted. 298 // List of browser actions which should be highlighted.
(...skipping 30 matching lines...) Expand all
338 // For observing change of toolbar order preference by external entity (sync). 329 // For observing change of toolbar order preference by external entity (sync).
339 PrefChangeRegistrar pref_change_registrar_; 330 PrefChangeRegistrar pref_change_registrar_;
340 base::Closure pref_change_callback_; 331 base::Closure pref_change_callback_;
341 332
342 base::WeakPtrFactory<ToolbarActionsModel> weak_ptr_factory_; 333 base::WeakPtrFactory<ToolbarActionsModel> weak_ptr_factory_;
343 334
344 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsModel); 335 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsModel);
345 }; 336 };
346 337
347 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_MODEL_H_ 338 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/mock_media_router_action_controller.cc ('k') | chrome/browser/ui/toolbar/toolbar_actions_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698