| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "extensions/common/extension.h" | 22 #include "extensions/common/extension.h" |
| 23 | 23 |
| 24 class Browser; | 24 class Browser; |
| 25 class PrefService; | 25 class PrefService; |
| 26 class Profile; | 26 class Profile; |
| 27 class ToolbarActionsBar; | 27 class ToolbarActionsBar; |
| 28 class ToolbarActionViewController; | 28 class ToolbarActionViewController; |
| 29 | 29 |
| 30 namespace extensions { | 30 namespace extensions { |
| 31 class ExtensionActionManager; | 31 class ExtensionActionManager; |
| 32 class ExtensionMessageBubbleController; |
| 32 class ExtensionRegistry; | 33 class ExtensionRegistry; |
| 33 class ExtensionSet; | 34 class ExtensionSet; |
| 34 } | 35 } |
| 35 | 36 |
| 36 // Model for the browser actions toolbar. This is a per-profile instance, and | 37 // Model for the browser actions toolbar. This is a per-profile instance, and |
| 37 // manages the user's global preferences. | 38 // manages the user's global preferences. |
| 38 // Each browser window will attempt to show browser actions as specified by this | 39 // Each browser window will attempt to show browser actions as specified by this |
| 39 // model, but if the window is too narrow, actions may end up pushed into the | 40 // model, but if the window is too narrow, actions may end up pushed into the |
| 40 // overflow menu on a per-window basis. Callers interested in the arrangement of | 41 // overflow menu on a per-window basis. Callers interested in the arrangement of |
| 41 // actions in a particular window should check that window's instance of | 42 // actions in a particular window should check that window's instance of |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 return is_highlighting() ? highlighted_items_ : toolbar_items_; | 166 return is_highlighting() ? highlighted_items_ : toolbar_items_; |
| 166 } | 167 } |
| 167 | 168 |
| 168 extensions::ComponentMigrationHelper* component_migration_helper() { | 169 extensions::ComponentMigrationHelper* component_migration_helper() { |
| 169 return component_migration_helper_.get(); | 170 return component_migration_helper_.get(); |
| 170 } | 171 } |
| 171 | 172 |
| 172 bool is_highlighting() const { return highlight_type_ != HIGHLIGHT_NONE; } | 173 bool is_highlighting() const { return highlight_type_ != HIGHLIGHT_NONE; } |
| 173 HighlightType highlight_type() const { return highlight_type_; } | 174 HighlightType highlight_type() const { return highlight_type_; } |
| 174 | 175 |
| 176 bool has_active_bubble() const { return has_active_bubble_; } |
| 177 void set_has_active_bubble(bool has_active_bubble) { |
| 178 has_active_bubble_ = has_active_bubble; |
| 179 } |
| 180 |
| 175 void SetActionVisibility(const std::string& action_id, bool visible); | 181 void SetActionVisibility(const std::string& action_id, bool visible); |
| 176 | 182 |
| 177 // ComponentMigrationHelper::ComponentActionDelegate: | 183 // ComponentMigrationHelper::ComponentActionDelegate: |
| 178 void AddComponentAction(const std::string& action_id) override; | 184 void AddComponentAction(const std::string& action_id) override; |
| 179 void RemoveComponentAction(const std::string& action_id) override; | 185 void RemoveComponentAction(const std::string& action_id) override; |
| 180 bool HasComponentAction(const std::string& action_id) const override; | 186 bool HasComponentAction(const std::string& action_id) const override; |
| 181 | 187 |
| 182 void OnActionToolbarPrefChange(); | 188 void OnActionToolbarPrefChange(); |
| 183 | 189 |
| 184 // Highlights the actions specified by |action_ids|. This will cause | 190 // Highlights the actions specified by |action_ids|. This will cause |
| 185 // the ToolbarModel to only display those actions. | 191 // the ToolbarModel to only display those actions. |
| 186 // Highlighting mode is only entered if there is at least one action to be | 192 // Highlighting mode is only entered if there is at least one action to be |
| 187 // shown. | 193 // shown. |
| 188 // Returns true if highlighting mode is entered, false otherwise. | 194 // Returns true if highlighting mode is entered, false otherwise. |
| 189 bool HighlightActions(const std::vector<std::string>& action_ids, | 195 bool HighlightActions(const std::vector<std::string>& action_ids, |
| 190 HighlightType type); | 196 HighlightType type); |
| 191 | 197 |
| 192 // Stop highlighting actions. All actions can be shown again, and the | 198 // Stop highlighting actions. All actions can be shown again, and the |
| 193 // number of visible icons will be reset to what it was before highlighting. | 199 // number of visible icons will be reset to what it was before highlighting. |
| 194 void StopHighlighting(); | 200 void StopHighlighting(); |
| 195 | 201 |
| 202 // Gets the ExtensionMessageBubbleController that should be shown for this |
| 203 // profile, if any. |
| 204 std::unique_ptr<extensions::ExtensionMessageBubbleController> |
| 205 GetExtensionMessageBubbleController(Browser* browser); |
| 206 |
| 196 private: | 207 private: |
| 197 // Callback when actions are ready. | 208 // Callback when actions are ready. |
| 198 void OnReady(); | 209 void OnReady(); |
| 199 | 210 |
| 200 // ExtensionRegistryObserver: | 211 // ExtensionRegistryObserver: |
| 201 void OnExtensionLoaded(content::BrowserContext* browser_context, | 212 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 202 const extensions::Extension* extension) override; | 213 const extensions::Extension* extension) override; |
| 203 void OnExtensionUnloaded( | 214 void OnExtensionUnloaded( |
| 204 content::BrowserContext* browser_context, | 215 content::BrowserContext* browser_context, |
| 205 const extensions::Extension* extension, | 216 const extensions::Extension* extension, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 std::vector<std::string> last_known_positions_; | 316 std::vector<std::string> last_known_positions_; |
| 306 | 317 |
| 307 // The number of icons visible (the rest should be hidden in the overflow | 318 // The number of icons visible (the rest should be hidden in the overflow |
| 308 // chevron). A value of -1 indicates that all icons should be visible. | 319 // chevron). A value of -1 indicates that all icons should be visible. |
| 309 // Instead of using this variable directly, use visible_icon_count() if | 320 // Instead of using this variable directly, use visible_icon_count() if |
| 310 // possible. | 321 // possible. |
| 311 // TODO(devlin): Make a new variable to indicate that all icons should be | 322 // TODO(devlin): Make a new variable to indicate that all icons should be |
| 312 // visible, instead of overloading this one. | 323 // visible, instead of overloading this one. |
| 313 int visible_icon_count_; | 324 int visible_icon_count_; |
| 314 | 325 |
| 326 // Whether or not there is an active ExtensionMessageBubbleController |
| 327 // associated with the profile. There should only be one at a time. |
| 328 bool has_active_bubble_; |
| 329 |
| 315 ScopedObserver<extensions::ExtensionActionAPI, | 330 ScopedObserver<extensions::ExtensionActionAPI, |
| 316 extensions::ExtensionActionAPI::Observer> | 331 extensions::ExtensionActionAPI::Observer> |
| 317 extension_action_observer_; | 332 extension_action_observer_; |
| 318 | 333 |
| 319 // Listen to extension load, unloaded notifications. | 334 // Listen to extension load, unloaded notifications. |
| 320 ScopedObserver<extensions::ExtensionRegistry, ExtensionRegistryObserver> | 335 ScopedObserver<extensions::ExtensionRegistry, ExtensionRegistryObserver> |
| 321 extension_registry_observer_; | 336 extension_registry_observer_; |
| 322 | 337 |
| 323 // For observing change of toolbar order preference by external entity (sync). | 338 // For observing change of toolbar order preference by external entity (sync). |
| 324 PrefChangeRegistrar pref_change_registrar_; | 339 PrefChangeRegistrar pref_change_registrar_; |
| 325 base::Closure pref_change_callback_; | 340 base::Closure pref_change_callback_; |
| 326 | 341 |
| 327 base::WeakPtrFactory<ToolbarActionsModel> weak_ptr_factory_; | 342 base::WeakPtrFactory<ToolbarActionsModel> weak_ptr_factory_; |
| 328 | 343 |
| 329 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsModel); | 344 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsModel); |
| 330 }; | 345 }; |
| 331 | 346 |
| 332 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_MODEL_H_ | 347 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_MODEL_H_ |
| OLD | NEW |