| 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_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/extension_action.h" | 15 #include "chrome/browser/extensions/extension_action.h" |
| 16 #include "chrome/browser/ui/toolbar/component_action_delegate.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 ComponentToolbarActionsFactory; |
| 24 class PrefService; | 25 class PrefService; |
| 25 class Profile; | 26 class Profile; |
| 26 class ToolbarActionsBar; | 27 class ToolbarActionsBar; |
| 27 class ToolbarActionViewController; | 28 class ToolbarActionViewController; |
| 28 | 29 |
| 29 namespace extensions { | 30 namespace extensions { |
| 30 class ExtensionActionManager; | 31 class ExtensionActionManager; |
| 31 class ExtensionMessageBubbleController; | 32 class ExtensionMessageBubbleController; |
| 32 class ExtensionRegistry; | 33 class ExtensionRegistry; |
| 33 } | 34 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 164 } |
| 164 | 165 |
| 165 bool is_highlighting() const { return highlight_type_ != HIGHLIGHT_NONE; } | 166 bool is_highlighting() const { return highlight_type_ != HIGHLIGHT_NONE; } |
| 166 HighlightType highlight_type() const { return highlight_type_; } | 167 HighlightType highlight_type() const { return highlight_type_; } |
| 167 | 168 |
| 168 bool has_active_bubble() const { return has_active_bubble_; } | 169 bool has_active_bubble() const { return has_active_bubble_; } |
| 169 void set_has_active_bubble(bool has_active_bubble) { | 170 void set_has_active_bubble(bool has_active_bubble) { |
| 170 has_active_bubble_ = has_active_bubble; | 171 has_active_bubble_ = has_active_bubble; |
| 171 } | 172 } |
| 172 | 173 |
| 174 ComponentToolbarActionsFactory* component_actions_factory() { |
| 175 return component_actions_factory_.get(); |
| 176 } |
| 177 |
| 173 void SetActionVisibility(const std::string& action_id, bool visible); | 178 void SetActionVisibility(const std::string& action_id, bool visible); |
| 174 | 179 |
| 175 // ComponentActionDelegate: | 180 // ComponentActionDelegate: |
| 176 // AddComponentAction() is a no-op if |actions_initialized_| is false. | 181 // AddComponentAction() is a no-op if |actions_initialized_| is false. |
| 177 void AddComponentAction(const std::string& action_id) override; | 182 void AddComponentAction(const std::string& action_id) override; |
| 178 void RemoveComponentAction(const std::string& action_id) override; | 183 void RemoveComponentAction(const std::string& action_id) override; |
| 179 bool HasComponentAction(const std::string& action_id) const override; | 184 bool HasComponentAction(const std::string& action_id) const override; |
| 180 | 185 |
| 181 void OnActionToolbarPrefChange(); | 186 void OnActionToolbarPrefChange(); |
| 182 | 187 |
| 183 // Highlights the actions specified by |action_ids|. This will cause | 188 // Highlights the actions specified by |action_ids|. This will cause |
| 184 // the ToolbarModel to only display those actions. | 189 // the ToolbarModel to only display those actions. |
| 185 // Highlighting mode is only entered if there is at least one action to be | 190 // Highlighting mode is only entered if there is at least one action to be |
| 186 // shown. | 191 // shown. |
| 187 // Returns true if highlighting mode is entered, false otherwise. | 192 // Returns true if highlighting mode is entered, false otherwise. |
| 188 bool HighlightActions(const std::vector<std::string>& action_ids, | 193 bool HighlightActions(const std::vector<std::string>& action_ids, |
| 189 HighlightType type); | 194 HighlightType type); |
| 190 | 195 |
| 191 // Stop highlighting actions. All actions can be shown again, and the | 196 // Stop highlighting actions. All actions can be shown again, and the |
| 192 // number of visible icons will be reset to what it was before highlighting. | 197 // number of visible icons will be reset to what it was before highlighting. |
| 193 void StopHighlighting(); | 198 void StopHighlighting(); |
| 194 | 199 |
| 195 // Gets the ExtensionMessageBubbleController that should be shown for this | 200 // Gets the ExtensionMessageBubbleController that should be shown for this |
| 196 // profile, if any. | 201 // profile, if any. |
| 197 std::unique_ptr<extensions::ExtensionMessageBubbleController> | 202 std::unique_ptr<extensions::ExtensionMessageBubbleController> |
| 198 GetExtensionMessageBubbleController(Browser* browser); | 203 GetExtensionMessageBubbleController(Browser* browser); |
| 199 | 204 |
| 205 // Sets the component action factory for this object. Used in tests. |
| 206 void SetMockActionsFactoryForTest( |
| 207 std::unique_ptr<ComponentToolbarActionsFactory> mock_factory); |
| 208 |
| 200 private: | 209 private: |
| 201 // Callback when actions are ready. | 210 // Callback when actions are ready. |
| 202 void OnReady(); | 211 void OnReady(); |
| 203 | 212 |
| 204 // ExtensionRegistryObserver: | 213 // ExtensionRegistryObserver: |
| 205 void OnExtensionLoaded(content::BrowserContext* browser_context, | 214 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 206 const extensions::Extension* extension) override; | 215 const extensions::Extension* extension) override; |
| 207 void OnExtensionUnloaded( | 216 void OnExtensionUnloaded( |
| 208 content::BrowserContext* browser_context, | 217 content::BrowserContext* browser_context, |
| 209 const extensions::Extension* extension, | 218 const extensions::Extension* extension, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 288 |
| 280 // The ExtensionActionAPI object, cached for convenience. | 289 // The ExtensionActionAPI object, cached for convenience. |
| 281 extensions::ExtensionActionAPI* extension_action_api_; | 290 extensions::ExtensionActionAPI* extension_action_api_; |
| 282 | 291 |
| 283 // The ExtensionRegistry object, cached for convenience. | 292 // The ExtensionRegistry object, cached for convenience. |
| 284 extensions::ExtensionRegistry* extension_registry_; | 293 extensions::ExtensionRegistry* extension_registry_; |
| 285 | 294 |
| 286 // The ExtensionActionManager, cached for convenience. | 295 // The ExtensionActionManager, cached for convenience. |
| 287 extensions::ExtensionActionManager* extension_action_manager_; | 296 extensions::ExtensionActionManager* extension_action_manager_; |
| 288 | 297 |
| 298 std::unique_ptr<ComponentToolbarActionsFactory> component_actions_factory_; |
| 299 |
| 289 // True if we've handled the initial EXTENSIONS_READY notification. | 300 // True if we've handled the initial EXTENSIONS_READY notification. |
| 290 bool actions_initialized_; | 301 bool actions_initialized_; |
| 291 | 302 |
| 292 // If true, we include all actions in the toolbar model. | 303 // If true, we include all actions in the toolbar model. |
| 293 bool use_redesign_; | 304 bool use_redesign_; |
| 294 | 305 |
| 295 // Ordered list of browser actions. | 306 // Ordered list of browser actions. |
| 296 std::vector<ToolbarItem> toolbar_items_; | 307 std::vector<ToolbarItem> toolbar_items_; |
| 297 | 308 |
| 298 // List of browser actions which should be highlighted. | 309 // List of browser actions which should be highlighted. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 329 // For observing change of toolbar order preference by external entity (sync). | 340 // For observing change of toolbar order preference by external entity (sync). |
| 330 PrefChangeRegistrar pref_change_registrar_; | 341 PrefChangeRegistrar pref_change_registrar_; |
| 331 base::Closure pref_change_callback_; | 342 base::Closure pref_change_callback_; |
| 332 | 343 |
| 333 base::WeakPtrFactory<ToolbarActionsModel> weak_ptr_factory_; | 344 base::WeakPtrFactory<ToolbarActionsModel> weak_ptr_factory_; |
| 334 | 345 |
| 335 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsModel); | 346 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsModel); |
| 336 }; | 347 }; |
| 337 | 348 |
| 338 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_MODEL_H_ | 349 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_MODEL_H_ |
| OLD | NEW |