Chromium Code Reviews| 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_THEMES_THEME_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_THEMES_THEME_SERVICE_H_ |
| 6 #define CHROME_BROWSER_THEMES_THEME_SERVICE_H_ | 6 #define CHROME_BROWSER_THEMES_THEME_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 // Sent whenever the browser theme changes. Object => NSValue wrapping the | 54 // Sent whenever the browser theme changes. Object => NSValue wrapping the |
| 55 // ThemeService that changed. | 55 // ThemeService that changed. |
| 56 extern "C" NSString* const kBrowserThemeDidChangeNotification; | 56 extern "C" NSString* const kBrowserThemeDidChangeNotification; |
| 57 #endif // __OBJC__ | 57 #endif // __OBJC__ |
| 58 | 58 |
| 59 class ThemeService : public base::NonThreadSafe, | 59 class ThemeService : public base::NonThreadSafe, |
| 60 public content::NotificationObserver, | 60 public content::NotificationObserver, |
| 61 public KeyedService, | 61 public KeyedService, |
| 62 public ui::ThemeProvider { | 62 public ui::ThemeProvider { |
| 63 public: | 63 public: |
| 64 // Receive notification when extension will be installed, loaded, unloaded. | |
| 65 class ExtensionObserver { | |
|
Lei Zhang
2015/03/10 19:25:52
This class needs to:
- inherit from extensions::E
| |
| 66 public: | |
| 67 explicit ExtensionObserver(ThemeService& service); | |
| 68 ~ExtensionObserver(); | |
| 69 void OnExtensionWillBeInstalled(const extensions::Extension* extension); | |
| 70 void OnExtensionLoaded(const extensions::Extension* extension); | |
| 71 // Not be called when reason is REASON_LOCK_ALL or REASON_UPDATED. | |
| 72 void OnExtensionUnloaded(const extensions::Extension* extension); | |
| 73 | |
| 74 private: | |
| 75 ThemeService& theme_service_; | |
| 76 }; | |
| 77 | |
| 64 // Public constants used in ThemeService and its subclasses: | 78 // Public constants used in ThemeService and its subclasses: |
| 65 static const char* kDefaultThemeID; | 79 static const char* kDefaultThemeID; |
| 66 | 80 |
| 67 ThemeService(); | 81 ThemeService(); |
| 68 ~ThemeService() override; | 82 ~ThemeService() override; |
| 69 | 83 |
| 70 virtual void Init(Profile* profile); | 84 virtual void Init(Profile* profile); |
| 71 | 85 |
| 72 // Returns a cross platform image for an id. | 86 // Returns a cross platform image for an id. |
| 73 // | 87 // |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 | 145 |
| 132 // Uninstall theme extensions which are no longer in use. |ignore_infobars| is | 146 // Uninstall theme extensions which are no longer in use. |ignore_infobars| is |
| 133 // whether unused themes should be removed despite a theme infobar being | 147 // whether unused themes should be removed despite a theme infobar being |
| 134 // visible. | 148 // visible. |
| 135 void RemoveUnusedThemes(bool ignore_infobars); | 149 void RemoveUnusedThemes(bool ignore_infobars); |
| 136 | 150 |
| 137 // Returns the syncable service for syncing theme. The returned service is | 151 // Returns the syncable service for syncing theme. The returned service is |
| 138 // owned by |this| object. | 152 // owned by |this| object. |
| 139 virtual ThemeSyncableService* GetThemeSyncableService() const; | 153 virtual ThemeSyncableService* GetThemeSyncableService() const; |
| 140 | 154 |
| 155 ExtensionObserver extension_observer() const; | |
| 156 | |
| 141 // Save the images to be written to disk, mapping file path to id. | 157 // Save the images to be written to disk, mapping file path to id. |
| 142 typedef std::map<base::FilePath, int> ImagesDiskCache; | 158 typedef std::map<base::FilePath, int> ImagesDiskCache; |
| 143 | 159 |
| 144 protected: | 160 protected: |
| 145 // Set a custom default theme instead of the normal default theme. | 161 // Set a custom default theme instead of the normal default theme. |
| 146 virtual void SetCustomDefaultTheme( | 162 virtual void SetCustomDefaultTheme( |
| 147 scoped_refptr<CustomThemeSupplier> theme_supplier); | 163 scoped_refptr<CustomThemeSupplier> theme_supplier); |
| 148 | 164 |
| 149 // Returns true if the ThemeService should use the system theme on startup. | 165 // Returns true if the ThemeService should use the system theme on startup. |
| 150 virtual bool ShouldInitWithSystemTheme() const; | 166 virtual bool ShouldInitWithSystemTheme() const; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 // recently installed theme extensions | 257 // recently installed theme extensions |
| 242 std::string installed_pending_load_id_; | 258 std::string installed_pending_load_id_; |
| 243 | 259 |
| 244 // The number of infobars currently displayed. | 260 // The number of infobars currently displayed. |
| 245 int number_of_infobars_; | 261 int number_of_infobars_; |
| 246 | 262 |
| 247 content::NotificationRegistrar registrar_; | 263 content::NotificationRegistrar registrar_; |
| 248 | 264 |
| 249 scoped_ptr<ThemeSyncableService> theme_syncable_service_; | 265 scoped_ptr<ThemeSyncableService> theme_syncable_service_; |
| 250 | 266 |
| 267 ExtensionObserver extension_observer_; | |
| 268 | |
| 251 base::WeakPtrFactory<ThemeService> weak_ptr_factory_; | 269 base::WeakPtrFactory<ThemeService> weak_ptr_factory_; |
| 252 | 270 |
| 253 DISALLOW_COPY_AND_ASSIGN(ThemeService); | 271 DISALLOW_COPY_AND_ASSIGN(ThemeService); |
| 254 }; | 272 }; |
| 255 | 273 |
| 256 #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_ | 274 #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_ |
| OLD | NEW |