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 "extensions/browser/extension_registry_observer.h" |
21 #include "ui/base/theme_provider.h" | 22 #include "ui/base/theme_provider.h" |
22 | 23 |
23 class CustomThemeSupplier; | 24 class CustomThemeSupplier; |
24 class BrowserThemePack; | 25 class BrowserThemePack; |
25 class ThemeSyncableService; | 26 class ThemeSyncableService; |
26 class Profile; | 27 class Profile; |
27 | 28 |
28 namespace base { | 29 namespace base { |
29 class FilePath; | 30 class FilePath; |
30 } | 31 } |
31 | 32 |
32 namespace color_utils { | 33 namespace color_utils { |
33 struct HSL; | 34 struct HSL; |
34 } | 35 } |
35 | 36 |
36 namespace extensions { | 37 namespace extensions { |
37 class Extension; | 38 class Extension; |
| 39 class ExtensionRegistry; |
38 } | 40 } |
39 | 41 |
40 namespace gfx { | 42 namespace gfx { |
41 class Image; | 43 class Image; |
42 } | 44 } |
43 | 45 |
44 namespace theme_service_internal { | 46 namespace theme_service_internal { |
45 class ThemeServiceTest; | 47 class ThemeServiceTest; |
46 } | 48 } |
47 | 49 |
48 namespace ui { | 50 namespace ui { |
49 class ResourceBundle; | 51 class ResourceBundle; |
50 } | 52 } |
51 | 53 |
52 #ifdef __OBJC__ | 54 #ifdef __OBJC__ |
53 @class NSString; | 55 @class NSString; |
54 // Sent whenever the browser theme changes. Object => NSValue wrapping the | 56 // Sent whenever the browser theme changes. Object => NSValue wrapping the |
55 // ThemeService that changed. | 57 // ThemeService that changed. |
56 extern "C" NSString* const kBrowserThemeDidChangeNotification; | 58 extern "C" NSString* const kBrowserThemeDidChangeNotification; |
57 #endif // __OBJC__ | 59 #endif // __OBJC__ |
58 | 60 |
59 class ThemeService : public base::NonThreadSafe, | 61 class ThemeService : public base::NonThreadSafe, |
60 public content::NotificationObserver, | 62 public content::NotificationObserver, |
| 63 public extensions::ExtensionRegistryObserver, |
61 public KeyedService, | 64 public KeyedService, |
62 public ui::ThemeProvider { | 65 public ui::ThemeProvider { |
63 public: | 66 public: |
64 // Public constants used in ThemeService and its subclasses: | 67 // Public constants used in ThemeService and its subclasses: |
65 static const char* kDefaultThemeID; | 68 static const char* kDefaultThemeID; |
66 | 69 |
67 ThemeService(); | 70 ThemeService(); |
68 ~ThemeService() override; | 71 ~ThemeService() override; |
69 | 72 |
70 virtual void Init(Profile* profile); | 73 virtual void Init(Profile* profile); |
(...skipping 19 matching lines...) Expand all Loading... |
90 NSColor* GetNSColor(int id) const override; | 93 NSColor* GetNSColor(int id) const override; |
91 NSColor* GetNSColorTint(int id) const override; | 94 NSColor* GetNSColorTint(int id) const override; |
92 NSGradient* GetNSGradient(int id) const override; | 95 NSGradient* GetNSGradient(int id) const override; |
93 #endif | 96 #endif |
94 | 97 |
95 // Overridden from content::NotificationObserver: | 98 // Overridden from content::NotificationObserver: |
96 void Observe(int type, | 99 void Observe(int type, |
97 const content::NotificationSource& source, | 100 const content::NotificationSource& source, |
98 const content::NotificationDetails& details) override; | 101 const content::NotificationDetails& details) override; |
99 | 102 |
| 103 // extensions::ExtensionRegistryObserver: |
| 104 void OnExtensionLoaded( |
| 105 content::BrowserContext* browser_context, |
| 106 const extensions::Extension* extension) override; |
| 107 void OnExtensionUnloaded( |
| 108 content::BrowserContext* browser_context, |
| 109 const extensions::Extension* extension, |
| 110 extensions::UnloadedExtensionInfo::Reason reason) override; |
| 111 void OnExtensionWillBeInstalled( |
| 112 content::BrowserContext* browser_context, |
| 113 const extensions::Extension* extension, |
| 114 bool is_update, |
| 115 bool from_ephemeral, |
| 116 const std::string& old_name) override; |
| 117 |
| 118 // KeyedService: |
| 119 void Shutdown() override; |
| 120 |
100 // Set the current theme to the theme defined in |extension|. | 121 // Set the current theme to the theme defined in |extension|. |
101 // |extension| must already be added to this profile's | 122 // |extension| must already be added to this profile's |
102 // ExtensionService. | 123 // ExtensionService. |
103 virtual void SetTheme(const extensions::Extension* extension); | 124 virtual void SetTheme(const extensions::Extension* extension); |
104 | 125 |
105 // Reset the theme to default. | 126 // Reset the theme to default. |
106 virtual void UseDefaultTheme(); | 127 virtual void UseDefaultTheme(); |
107 | 128 |
108 // Set the current theme to the system theme. On some platforms, the system | 129 // Set the current theme to the system theme. On some platforms, the system |
109 // theme is the default theme. | 130 // theme is the default theme. |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // never be loaded if the install is due to updating a disabled theme. | 260 // never be loaded if the install is due to updating a disabled theme. |
240 // |pending_install_id_| should be set to |kDefaultThemeID| if there are no | 261 // |pending_install_id_| should be set to |kDefaultThemeID| if there are no |
241 // recently installed theme extensions | 262 // recently installed theme extensions |
242 std::string installed_pending_load_id_; | 263 std::string installed_pending_load_id_; |
243 | 264 |
244 // The number of infobars currently displayed. | 265 // The number of infobars currently displayed. |
245 int number_of_infobars_; | 266 int number_of_infobars_; |
246 | 267 |
247 content::NotificationRegistrar registrar_; | 268 content::NotificationRegistrar registrar_; |
248 | 269 |
| 270 extensions::ExtensionRegistry* extension_registry_; |
| 271 |
249 scoped_ptr<ThemeSyncableService> theme_syncable_service_; | 272 scoped_ptr<ThemeSyncableService> theme_syncable_service_; |
250 | 273 |
251 base::WeakPtrFactory<ThemeService> weak_ptr_factory_; | 274 base::WeakPtrFactory<ThemeService> weak_ptr_factory_; |
252 | 275 |
253 DISALLOW_COPY_AND_ASSIGN(ThemeService); | 276 DISALLOW_COPY_AND_ASSIGN(ThemeService); |
254 }; | 277 }; |
255 | 278 |
256 #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_ | 279 #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_ |
OLD | NEW |