| 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/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
| 17 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 17 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "ui/base/theme_provider.h" | 20 #include "ui/base/theme_provider.h" |
| 21 | 21 |
| 22 class CustomThemeProvider; |
| 22 class BrowserThemePack; | 23 class BrowserThemePack; |
| 23 class ThemeServiceTest; | 24 class ThemeServiceTest; |
| 24 class ThemeSyncableService; | 25 class ThemeSyncableService; |
| 25 class Profile; | 26 class Profile; |
| 26 | 27 |
| 27 namespace base { | 28 namespace base { |
| 28 class FilePath; | 29 class FilePath; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace color_utils { | 32 namespace color_utils { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // Overridden from content::NotificationObserver: | 98 // Overridden from content::NotificationObserver: |
| 98 virtual void Observe(int type, | 99 virtual void Observe(int type, |
| 99 const content::NotificationSource& source, | 100 const content::NotificationSource& source, |
| 100 const content::NotificationDetails& details) OVERRIDE; | 101 const content::NotificationDetails& details) OVERRIDE; |
| 101 | 102 |
| 102 // Set the current theme to the theme defined in |extension|. | 103 // Set the current theme to the theme defined in |extension|. |
| 103 // |extension| must already be added to this profile's | 104 // |extension| must already be added to this profile's |
| 104 // ExtensionService. | 105 // ExtensionService. |
| 105 virtual void SetTheme(const extensions::Extension* extension); | 106 virtual void SetTheme(const extensions::Extension* extension); |
| 106 | 107 |
| 108 // Set a custom default theme instead of the normal default theme. |
| 109 virtual void SetCustomDefaultTheme( |
| 110 scoped_refptr<CustomThemeProvider> theme_provider); |
| 111 |
| 107 // Reset the theme to default. | 112 // Reset the theme to default. |
| 108 virtual void UseDefaultTheme(); | 113 virtual void UseDefaultTheme(); |
| 109 | 114 |
| 110 // Set the current theme to the native theme. On some platforms, the native | 115 // Set the current theme to the native theme. On some platforms, the native |
| 111 // theme is the default theme. | 116 // theme is the default theme. |
| 112 virtual void SetNativeTheme(); | 117 virtual void SetNativeTheme(); |
| 113 | 118 |
| 114 // Whether we're using the chrome default theme. Virtual so linux can check | 119 // Whether we're using the chrome default theme. Virtual so linux can check |
| 115 // if we're using the GTK theme. | 120 // if we're using the GTK theme. |
| 116 virtual bool UsingDefaultTheme() const; | 121 virtual bool UsingDefaultTheme() const; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 #endif // OS_MACOSX | 165 #endif // OS_MACOSX |
| 161 | 166 |
| 162 // Clears the platform-specific caches. Do not call directly; it's called | 167 // Clears the platform-specific caches. Do not call directly; it's called |
| 163 // from ClearCaches(). | 168 // from ClearCaches(). |
| 164 virtual void FreePlatformCaches(); | 169 virtual void FreePlatformCaches(); |
| 165 | 170 |
| 166 Profile* profile() const { return profile_; } | 171 Profile* profile() const { return profile_; } |
| 167 | 172 |
| 168 void set_ready() { ready_ = true; } | 173 void set_ready() { ready_ = true; } |
| 169 | 174 |
| 175 const CustomThemeProvider* GetThemeProvider() const { |
| 176 return theme_provider_.get(); |
| 177 } |
| 178 |
| 170 private: | 179 private: |
| 171 friend class ThemeServiceTest; | 180 friend class ThemeServiceTest; |
| 172 | 181 |
| 173 // Migrate the theme to the new theme pack schema by recreating the data pack | 182 // Migrate the theme to the new theme pack schema by recreating the data pack |
| 174 // from the extension. | 183 // from the extension. |
| 175 void MigrateTheme(); | 184 void MigrateTheme(); |
| 176 | 185 |
| 177 // Saves the filename of the cached theme pack. | 186 // Saves the filename of the cached theme pack. |
| 178 void SavePackName(const base::FilePath& pack_path); | 187 void SavePackName(const base::FilePath& pack_path); |
| 179 | 188 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 208 #endif | 217 #endif |
| 209 | 218 |
| 210 ui::ResourceBundle& rb_; | 219 ui::ResourceBundle& rb_; |
| 211 Profile* profile_; | 220 Profile* profile_; |
| 212 | 221 |
| 213 // True if the theme service is ready to be used. | 222 // True if the theme service is ready to be used. |
| 214 // TODO(pkotwicz): Add DCHECKS to the theme service's getters once | 223 // TODO(pkotwicz): Add DCHECKS to the theme service's getters once |
| 215 // ThemeSource no longer uses the ThemeService when it is not ready. | 224 // ThemeSource no longer uses the ThemeService when it is not ready. |
| 216 bool ready_; | 225 bool ready_; |
| 217 | 226 |
| 218 scoped_refptr<BrowserThemePack> theme_pack_; | 227 scoped_refptr<CustomThemeProvider> theme_provider_; |
| 219 | 228 |
| 220 // The number of infobars currently displayed. | 229 // The number of infobars currently displayed. |
| 221 int number_of_infobars_; | 230 int number_of_infobars_; |
| 222 | 231 |
| 223 content::NotificationRegistrar registrar_; | 232 content::NotificationRegistrar registrar_; |
| 224 | 233 |
| 225 scoped_ptr<ThemeSyncableService> theme_syncable_service_; | 234 scoped_ptr<ThemeSyncableService> theme_syncable_service_; |
| 226 | 235 |
| 227 DISALLOW_COPY_AND_ASSIGN(ThemeService); | 236 DISALLOW_COPY_AND_ASSIGN(ThemeService); |
| 228 }; | 237 }; |
| 229 | 238 |
| 230 #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_ | 239 #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_ |
| OLD | NEW |