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 "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 virtual ~ThemeService(); | 71 virtual ~ThemeService(); |
| 69 | 72 |
| 70 virtual void Init(Profile* profile); | 73 virtual void Init(Profile* profile); |
| 71 | 74 |
| 72 // Returns a cross platform image for an id. | 75 // Returns a cross platform image for an id. |
| 73 // | 76 // |
| 74 // TODO(erg): Make this part of the ui::ThemeProvider and the main way to get | 77 // TODO(erg): Make this part of the ui::ThemeProvider and the main way to get |
| 75 // theme properties out of the theme provider since it's cross platform. | 78 // theme properties out of the theme provider since it's cross platform. |
| 76 virtual gfx::Image GetImageNamed(int id) const; | 79 virtual gfx::Image GetImageNamed(int id) const; |
| 77 | 80 |
| 78 // Overridden from ui::ThemeProvider: | 81 // Overridden from ui::ThemeProvider: |
|
pkotwicz
2014/09/16 15:18:25
Nit: Can you change the comment to "ui::ThemeProvi
Jitu( very slow this week)
2014/09/24 11:48:15
Done.
| |
| 79 virtual bool UsingSystemTheme() const OVERRIDE; | 82 virtual bool UsingSystemTheme() const OVERRIDE; |
| 80 virtual gfx::ImageSkia* GetImageSkiaNamed(int id) const OVERRIDE; | 83 virtual gfx::ImageSkia* GetImageSkiaNamed(int id) const OVERRIDE; |
| 81 virtual SkColor GetColor(int id) const OVERRIDE; | 84 virtual SkColor GetColor(int id) const OVERRIDE; |
| 82 virtual int GetDisplayProperty(int id) const OVERRIDE; | 85 virtual int GetDisplayProperty(int id) const OVERRIDE; |
| 83 virtual bool ShouldUseNativeFrame() const OVERRIDE; | 86 virtual bool ShouldUseNativeFrame() const OVERRIDE; |
| 84 virtual bool HasCustomImage(int id) const OVERRIDE; | 87 virtual bool HasCustomImage(int id) const OVERRIDE; |
| 85 virtual base::RefCountedMemory* GetRawData( | 88 virtual base::RefCountedMemory* GetRawData( |
| 86 int id, | 89 int id, |
| 87 ui::ScaleFactor scale_factor) const OVERRIDE; | 90 ui::ScaleFactor scale_factor) const OVERRIDE; |
| 88 #if defined(OS_MACOSX) | 91 #if defined(OS_MACOSX) |
| 89 virtual NSImage* GetNSImageNamed(int id) const OVERRIDE; | 92 virtual NSImage* GetNSImageNamed(int id) const OVERRIDE; |
| 90 virtual NSColor* GetNSImageColorNamed(int id) const OVERRIDE; | 93 virtual NSColor* GetNSImageColorNamed(int id) const OVERRIDE; |
| 91 virtual NSColor* GetNSColor(int id) const OVERRIDE; | 94 virtual NSColor* GetNSColor(int id) const OVERRIDE; |
| 92 virtual NSColor* GetNSColorTint(int id) const OVERRIDE; | 95 virtual NSColor* GetNSColorTint(int id) const OVERRIDE; |
| 93 virtual NSGradient* GetNSGradient(int id) const OVERRIDE; | 96 virtual NSGradient* GetNSGradient(int id) const OVERRIDE; |
| 94 #endif | 97 #endif |
| 95 | 98 |
| 96 // Overridden from content::NotificationObserver: | 99 // Overridden from content::NotificationObserver: |
|
pkotwicz
2014/09/16 15:18:25
Nit: Can you change the comment to "content::Notif
| |
| 97 virtual void Observe(int type, | 100 virtual void Observe(int type, |
| 98 const content::NotificationSource& source, | 101 const content::NotificationSource& source, |
| 99 const content::NotificationDetails& details) OVERRIDE; | 102 const content::NotificationDetails& details) OVERRIDE; |
| 100 | 103 |
| 104 // Overridden from extensions::ExtensionRegistryObserver: | |
|
pkotwicz
2014/09/16 15:18:25
I think the new style for these comments is "exten
Jitu( very slow this week)
2014/09/24 11:48:15
Done.
| |
| 105 virtual void OnExtensionWillBeInstalled( | |
| 106 content::BrowserContext* browser_context, | |
| 107 const extensions::Extension* extension, | |
| 108 bool is_update, | |
| 109 bool from_ephemeral, | |
| 110 const std::string& old_name) OVERRIDE; | |
|
pkotwicz
2014/09/16 15:18:25
Nit: Remove the new line
Jitu( very slow this week)
2014/09/24 11:48:16
Done.
| |
| 111 | |
| 112 virtual void OnExtensionLoaded( | |
| 113 content::BrowserContext* browser_context, | |
| 114 const extensions::Extension* extension) OVERRIDE; | |
|
pkotwicz
2014/09/16 15:18:25
Nit: Remove the new line
Jitu( very slow this week)
2014/09/24 11:48:15
Done.
| |
| 115 | |
| 116 virtual void OnExtensionUnloaded( | |
| 117 content::BrowserContext* browser_context, | |
| 118 const extensions::Extension* extension, | |
| 119 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; | |
| 120 | |
| 101 // Set the current theme to the theme defined in |extension|. | 121 // Set the current theme to the theme defined in |extension|. |
| 102 // |extension| must already be added to this profile's | 122 // |extension| must already be added to this profile's |
| 103 // ExtensionService. | 123 // ExtensionService. |
| 104 virtual void SetTheme(const extensions::Extension* extension); | 124 virtual void SetTheme(const extensions::Extension* extension); |
| 105 | 125 |
| 106 // Reset the theme to default. | 126 // Reset the theme to default. |
| 107 virtual void UseDefaultTheme(); | 127 virtual void UseDefaultTheme(); |
| 108 | 128 |
| 109 // 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 |
| 110 // theme is the default theme. | 130 // theme is the default theme. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 // never be loaded if the install is due to updating a disabled theme. | 258 // never be loaded if the install is due to updating a disabled theme. |
| 239 // |pending_install_id_| should be set to |kDefaultThemeID| if there are no | 259 // |pending_install_id_| should be set to |kDefaultThemeID| if there are no |
| 240 // recently installed theme extensions | 260 // recently installed theme extensions |
| 241 std::string installed_pending_load_id_; | 261 std::string installed_pending_load_id_; |
| 242 | 262 |
| 243 // The number of infobars currently displayed. | 263 // The number of infobars currently displayed. |
| 244 int number_of_infobars_; | 264 int number_of_infobars_; |
| 245 | 265 |
| 246 content::NotificationRegistrar registrar_; | 266 content::NotificationRegistrar registrar_; |
| 247 | 267 |
| 268 extensions::ExtensionRegistry* extension_registry_; | |
| 269 | |
| 248 scoped_ptr<ThemeSyncableService> theme_syncable_service_; | 270 scoped_ptr<ThemeSyncableService> theme_syncable_service_; |
| 249 | 271 |
| 250 base::WeakPtrFactory<ThemeService> weak_ptr_factory_; | 272 base::WeakPtrFactory<ThemeService> weak_ptr_factory_; |
| 251 | 273 |
| 252 DISALLOW_COPY_AND_ASSIGN(ThemeService); | 274 DISALLOW_COPY_AND_ASSIGN(ThemeService); |
| 253 }; | 275 }; |
| 254 | 276 |
| 255 #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_ | 277 #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_ |
| OLD | NEW |