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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
| 18 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
| 19 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
| 20 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 21 #include "ui/base/theme_provider.h" | 21 #include "ui/base/theme_provider.h" |
| 22 | 22 |
| 23 #if defined(ENABLE_EXTENSIONS) | |
| 24 #include "extensions/browser/extension_registry_observer.h" | |
| 25 #endif | |
| 26 | |
| 23 class CustomThemeSupplier; | 27 class CustomThemeSupplier; |
| 24 class BrowserThemePack; | 28 class BrowserThemePack; |
| 25 class ThemeSyncableService; | 29 class ThemeSyncableService; |
| 26 class Profile; | 30 class Profile; |
| 27 | 31 |
| 28 namespace base { | 32 namespace base { |
| 29 class FilePath; | 33 class FilePath; |
| 30 } | 34 } |
| 31 | 35 |
| 32 namespace color_utils { | 36 namespace color_utils { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 base::RefCountedMemory* GetRawData(int id, ui::ScaleFactor scale_factor) | 89 base::RefCountedMemory* GetRawData(int id, ui::ScaleFactor scale_factor) |
| 86 const override; | 90 const override; |
| 87 #if defined(OS_MACOSX) | 91 #if defined(OS_MACOSX) |
| 88 NSImage* GetNSImageNamed(int id) const override; | 92 NSImage* GetNSImageNamed(int id) const override; |
| 89 NSColor* GetNSImageColorNamed(int id) const override; | 93 NSColor* GetNSImageColorNamed(int id) const override; |
| 90 NSColor* GetNSColor(int id) const override; | 94 NSColor* GetNSColor(int id) const override; |
| 91 NSColor* GetNSColorTint(int id) const override; | 95 NSColor* GetNSColorTint(int id) const override; |
| 92 NSGradient* GetNSGradient(int id) const override; | 96 NSGradient* GetNSGradient(int id) const override; |
| 93 #endif | 97 #endif |
| 94 | 98 |
| 99 // KeyedService: | |
| 100 void Shutdown() override; | |
| 101 | |
| 95 // Overridden from content::NotificationObserver: | 102 // Overridden from content::NotificationObserver: |
| 96 void Observe(int type, | 103 void Observe(int type, |
| 97 const content::NotificationSource& source, | 104 const content::NotificationSource& source, |
| 98 const content::NotificationDetails& details) override; | 105 const content::NotificationDetails& details) override; |
| 99 | 106 |
| 100 // Set the current theme to the theme defined in |extension|. | 107 // Set the current theme to the theme defined in |extension|. |
| 101 // |extension| must already be added to this profile's | 108 // |extension| must already be added to this profile's |
| 102 // ExtensionService. | 109 // ExtensionService. |
| 103 virtual void SetTheme(const extensions::Extension* extension); | 110 virtual void SetTheme(const extensions::Extension* extension); |
| 104 | 111 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 return theme_supplier_.get(); | 185 return theme_supplier_.get(); |
| 179 } | 186 } |
| 180 | 187 |
| 181 // True if the theme service is ready to be used. | 188 // True if the theme service is ready to be used. |
| 182 // TODO(pkotwicz): Add DCHECKS to the theme service's getters once | 189 // TODO(pkotwicz): Add DCHECKS to the theme service's getters once |
| 183 // ThemeSource no longer uses the ThemeService when it is not ready. | 190 // ThemeSource no longer uses the ThemeService when it is not ready. |
| 184 bool ready_; | 191 bool ready_; |
| 185 | 192 |
| 186 private: | 193 private: |
| 187 friend class theme_service_internal::ThemeServiceTest; | 194 friend class theme_service_internal::ThemeServiceTest; |
| 195 #if defined(ENABLE_EXTENSIONS) | |
|
not at google - send to devlin
2015/03/12 17:08:33
to minimise the number of #if defined(..) calls, y
limasdf
2015/03/13 03:01:54
Done.
| |
| 196 class ExtensionObserver; | |
|
not at google - send to devlin
2015/03/12 17:10:55
Also, I think ExtensionObserver could be better na
limasdf
2015/03/13 03:01:54
Done.
| |
| 197 #endif | |
| 188 | 198 |
| 189 // Called when the extension service is ready. | 199 // Called when the extension service is ready. |
| 190 void OnExtensionServiceReady(); | 200 void OnExtensionServiceReady(); |
| 191 | 201 |
| 192 // Migrate the theme to the new theme pack schema by recreating the data pack | 202 // Migrate the theme to the new theme pack schema by recreating the data pack |
| 193 // from the extension. | 203 // from the extension. |
| 194 void MigrateTheme(); | 204 void MigrateTheme(); |
| 195 | 205 |
| 196 // Replaces the current theme supplier with a new one and calls | 206 // Replaces the current theme supplier with a new one and calls |
| 197 // StopUsingTheme() or StartUsingTheme() as appropriate. | 207 // StopUsingTheme() or StartUsingTheme() as appropriate. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 // recently installed theme extensions | 251 // recently installed theme extensions |
| 242 std::string installed_pending_load_id_; | 252 std::string installed_pending_load_id_; |
| 243 | 253 |
| 244 // The number of infobars currently displayed. | 254 // The number of infobars currently displayed. |
| 245 int number_of_infobars_; | 255 int number_of_infobars_; |
| 246 | 256 |
| 247 content::NotificationRegistrar registrar_; | 257 content::NotificationRegistrar registrar_; |
| 248 | 258 |
| 249 scoped_ptr<ThemeSyncableService> theme_syncable_service_; | 259 scoped_ptr<ThemeSyncableService> theme_syncable_service_; |
| 250 | 260 |
| 261 #if defined(ENABLE_EXTENSIONS) | |
| 262 scoped_ptr<ExtensionObserver> extension_observer_; | |
| 263 extensions::ExtensionRegistry* extension_registry_; | |
|
Lei Zhang
2015/03/12 21:07:23
Maybe encapsulate this within ExtensionObserver?
limasdf
2015/03/13 03:01:54
Done.
| |
| 264 #endif | |
| 265 | |
| 251 base::WeakPtrFactory<ThemeService> weak_ptr_factory_; | 266 base::WeakPtrFactory<ThemeService> weak_ptr_factory_; |
| 252 | 267 |
| 253 DISALLOW_COPY_AND_ASSIGN(ThemeService); | 268 DISALLOW_COPY_AND_ASSIGN(ThemeService); |
| 254 }; | 269 }; |
| 255 | 270 |
| 256 #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_ | 271 #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_ |
| OLD | NEW |