| 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_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 10 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class ExtensionRegistry; | 26 class ExtensionRegistry; |
| 27 class ExtensionSet; | 27 class ExtensionSet; |
| 28 | 28 |
| 29 // Model for the browser actions toolbar. | 29 // Model for the browser actions toolbar. |
| 30 class ExtensionToolbarModel : public content::NotificationObserver, | 30 class ExtensionToolbarModel : public content::NotificationObserver, |
| 31 public ExtensionActionAPI::Observer, | 31 public ExtensionActionAPI::Observer, |
| 32 public ExtensionRegistryObserver, | 32 public ExtensionRegistryObserver, |
| 33 public KeyedService { | 33 public KeyedService { |
| 34 public: | 34 public: |
| 35 ExtensionToolbarModel(Profile* profile, ExtensionPrefs* extension_prefs); | 35 ExtensionToolbarModel(Profile* profile, ExtensionPrefs* extension_prefs); |
| 36 virtual ~ExtensionToolbarModel(); | 36 ~ExtensionToolbarModel() override; |
| 37 | 37 |
| 38 // A class which is informed of changes to the model; represents the view of | 38 // A class which is informed of changes to the model; represents the view of |
| 39 // MVC. Also used for signaling view changes such as showing extension popups. | 39 // MVC. Also used for signaling view changes such as showing extension popups. |
| 40 // TODO(devlin): Should this really be an observer? It acts more like a | 40 // TODO(devlin): Should this really be an observer? It acts more like a |
| 41 // delegate. | 41 // delegate. |
| 42 class Observer { | 42 class Observer { |
| 43 public: | 43 public: |
| 44 // An extension has been added to the toolbar and should go at |index|. | 44 // An extension has been added to the toolbar and should go at |index|. |
| 45 virtual void ToolbarExtensionAdded(const Extension* extension, | 45 virtual void ToolbarExtensionAdded(const Extension* extension, |
| 46 int index) = 0; | 46 int index) = 0; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // be shown. | 132 // be shown. |
| 133 // Returns true if highlighting mode is entered, false otherwise. | 133 // Returns true if highlighting mode is entered, false otherwise. |
| 134 bool HighlightExtensions(const ExtensionIdList& extension_ids); | 134 bool HighlightExtensions(const ExtensionIdList& extension_ids); |
| 135 | 135 |
| 136 // Stop highlighting extensions. All extensions can be shown again, and the | 136 // Stop highlighting extensions. All extensions can be shown again, and the |
| 137 // number of visible icons will be reset to what it was before highlighting. | 137 // number of visible icons will be reset to what it was before highlighting. |
| 138 void StopHighlighting(); | 138 void StopHighlighting(); |
| 139 | 139 |
| 140 private: | 140 private: |
| 141 // content::NotificationObserver: | 141 // content::NotificationObserver: |
| 142 virtual void Observe(int type, | 142 void Observe(int type, |
| 143 const content::NotificationSource& source, | 143 const content::NotificationSource& source, |
| 144 const content::NotificationDetails& details) override; | 144 const content::NotificationDetails& details) override; |
| 145 | 145 |
| 146 // Callback when extensions are ready. | 146 // Callback when extensions are ready. |
| 147 void OnReady(); | 147 void OnReady(); |
| 148 | 148 |
| 149 // ExtensionRegistryObserver: | 149 // ExtensionRegistryObserver: |
| 150 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | 150 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 151 const Extension* extension) override; | 151 const Extension* extension) override; |
| 152 virtual void OnExtensionUnloaded( | 152 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 153 content::BrowserContext* browser_context, | 153 const Extension* extension, |
| 154 const Extension* extension, | 154 UnloadedExtensionInfo::Reason reason) override; |
| 155 UnloadedExtensionInfo::Reason reason) override; | 155 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
| 156 virtual void OnExtensionUninstalled( | 156 const Extension* extension, |
| 157 content::BrowserContext* browser_context, | 157 extensions::UninstallReason reason) override; |
| 158 const Extension* extension, | |
| 159 extensions::UninstallReason reason) override; | |
| 160 | 158 |
| 161 // ExtensionActionAPI::Observer: | 159 // ExtensionActionAPI::Observer: |
| 162 virtual void OnExtensionActionUpdated( | 160 void OnExtensionActionUpdated( |
| 163 ExtensionAction* extension_action, | 161 ExtensionAction* extension_action, |
| 164 content::WebContents* web_contents, | 162 content::WebContents* web_contents, |
| 165 content::BrowserContext* browser_context) override; | 163 content::BrowserContext* browser_context) override; |
| 166 | 164 |
| 167 // To be called after the extension service is ready; gets loaded extensions | 165 // To be called after the extension service is ready; gets loaded extensions |
| 168 // from the ExtensionRegistry and their saved order from the pref service | 166 // from the ExtensionRegistry and their saved order from the pref service |
| 169 // and constructs |toolbar_items_| from these data. IncognitoPopulate() | 167 // and constructs |toolbar_items_| from these data. IncognitoPopulate() |
| 170 // takes the shortcut - looking at the regular model's content and modifying | 168 // takes the shortcut - looking at the regular model's content and modifying |
| 171 // it. | 169 // it. |
| 172 void InitializeExtensionList(); | 170 void InitializeExtensionList(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 base::Closure pref_change_callback_; | 246 base::Closure pref_change_callback_; |
| 249 | 247 |
| 250 base::WeakPtrFactory<ExtensionToolbarModel> weak_ptr_factory_; | 248 base::WeakPtrFactory<ExtensionToolbarModel> weak_ptr_factory_; |
| 251 | 249 |
| 252 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarModel); | 250 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarModel); |
| 253 }; | 251 }; |
| 254 | 252 |
| 255 } // namespace extensions | 253 } // namespace extensions |
| 256 | 254 |
| 257 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ | 255 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ |
| OLD | NEW |