| 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" |
| 11 #include "base/scoped_observer.h" |
| 11 #include "components/keyed_service/core/keyed_service.h" | 12 #include "components/keyed_service/core/keyed_service.h" |
| 12 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 14 #include "extensions/browser/extension_prefs.h" | 15 #include "extensions/browser/extension_prefs.h" |
| 16 #include "extensions/browser/extension_registry_observer.h" |
| 15 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
| 16 | 18 |
| 17 class Browser; | 19 class Browser; |
| 18 class ExtensionService; | 20 class ExtensionService; |
| 19 class PrefService; | 21 class PrefService; |
| 20 class Profile; | 22 class Profile; |
| 21 | 23 |
| 22 namespace extensions { | 24 namespace extensions { |
| 25 class ExtensionRegistry; |
| 23 | 26 |
| 24 // Model for the browser actions toolbar. | 27 // Model for the browser actions toolbar. |
| 25 class ExtensionToolbarModel : public content::NotificationObserver, | 28 class ExtensionToolbarModel : public content::NotificationObserver, |
| 29 public ExtensionRegistryObserver, |
| 26 public KeyedService { | 30 public KeyedService { |
| 27 public: | 31 public: |
| 28 ExtensionToolbarModel(Profile* profile, ExtensionPrefs* extension_prefs); | 32 ExtensionToolbarModel(Profile* profile, ExtensionPrefs* extension_prefs); |
| 29 virtual ~ExtensionToolbarModel(); | 33 virtual ~ExtensionToolbarModel(); |
| 30 | 34 |
| 31 // The action that should be taken as a result of clicking a browser action. | 35 // The action that should be taken as a result of clicking a browser action. |
| 32 enum Action { | 36 enum Action { |
| 33 ACTION_NONE, | 37 ACTION_NONE, |
| 34 ACTION_SHOW_POPUP, | 38 ACTION_SHOW_POPUP, |
| 35 // Unlike LocationBarController there is no ACTION_SHOW_CONTEXT_MENU, | 39 // Unlike LocationBarController there is no ACTION_SHOW_CONTEXT_MENU, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // Stop highlighting extensions. All extensions can be shown again, and the | 134 // Stop highlighting extensions. All extensions can be shown again, and the |
| 131 // number of visible icons will be reset to what it was before highlighting. | 135 // number of visible icons will be reset to what it was before highlighting. |
| 132 void StopHighlighting(); | 136 void StopHighlighting(); |
| 133 | 137 |
| 134 private: | 138 private: |
| 135 // content::NotificationObserver implementation. | 139 // content::NotificationObserver implementation. |
| 136 virtual void Observe(int type, | 140 virtual void Observe(int type, |
| 137 const content::NotificationSource& source, | 141 const content::NotificationSource& source, |
| 138 const content::NotificationDetails& details) OVERRIDE; | 142 const content::NotificationDetails& details) OVERRIDE; |
| 139 | 143 |
| 144 // ExtensionRegistryObserver implementation. |
| 145 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 146 const Extension* extension) OVERRIDE; |
| 147 virtual void OnExtensionUnloaded( |
| 148 content::BrowserContext* browser_context, |
| 149 const Extension* extension, |
| 150 UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| 151 |
| 140 // To be called after the extension service is ready; gets loaded extensions | 152 // To be called after the extension service is ready; gets loaded extensions |
| 141 // from the extension service and their saved order from the pref service | 153 // from the extension service and their saved order from the pref service |
| 142 // and constructs |toolbar_items_| from these data. | 154 // and constructs |toolbar_items_| from these data. |
| 143 void InitializeExtensionList(ExtensionService* service); | 155 void InitializeExtensionList(ExtensionService* service); |
| 144 void Populate(const ExtensionIdList& positions, ExtensionService* service); | 156 void Populate(const ExtensionIdList& positions, ExtensionService* service); |
| 145 | 157 |
| 146 // Fills |list| with extensions based on provided |order|. | 158 // Fills |list| with extensions based on provided |order|. |
| 147 void FillExtensionList(const ExtensionIdList& order, | 159 void FillExtensionList(const ExtensionIdList& order, |
| 148 ExtensionService* service); | 160 ExtensionService* service); |
| 149 | 161 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 int old_visible_icon_count_; | 198 int old_visible_icon_count_; |
| 187 | 199 |
| 188 ExtensionIdList last_known_positions_; | 200 ExtensionIdList last_known_positions_; |
| 189 | 201 |
| 190 // The number of icons visible (the rest should be hidden in the overflow | 202 // The number of icons visible (the rest should be hidden in the overflow |
| 191 // chevron). | 203 // chevron). |
| 192 int visible_icon_count_; | 204 int visible_icon_count_; |
| 193 | 205 |
| 194 content::NotificationRegistrar registrar_; | 206 content::NotificationRegistrar registrar_; |
| 195 | 207 |
| 208 // Listen to extension load, unloaded notifications. |
| 209 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 210 extension_registry_observer_; |
| 211 |
| 196 // For observing change of toolbar order preference by external entity (sync). | 212 // For observing change of toolbar order preference by external entity (sync). |
| 197 PrefChangeRegistrar pref_change_registrar_; | 213 PrefChangeRegistrar pref_change_registrar_; |
| 198 base::Closure pref_change_callback_; | 214 base::Closure pref_change_callback_; |
| 199 | 215 |
| 200 base::WeakPtrFactory<ExtensionToolbarModel> weak_ptr_factory_; | 216 base::WeakPtrFactory<ExtensionToolbarModel> weak_ptr_factory_; |
| 201 | 217 |
| 202 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarModel); | 218 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarModel); |
| 203 }; | 219 }; |
| 204 | 220 |
| 205 } // namespace extensions | 221 } // namespace extensions |
| 206 | 222 |
| 207 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ | 223 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ |
| OLD | NEW |