| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
| 15 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 16 #include "content/common/notification_observer.h" |
| 17 #include "content/common/notification_registrar.h" |
| 15 #include "ui/base/theme_provider.h" | 18 #include "ui/base/theme_provider.h" |
| 16 | 19 |
| 17 class BrowserThemePack; | 20 class BrowserThemePack; |
| 18 class ThemeServiceTest; | 21 class ThemeServiceTest; |
| 19 class Extension; | 22 class Extension; |
| 20 class FilePath; | 23 class FilePath; |
| 21 class Profile; | 24 class Profile; |
| 22 | 25 |
| 23 namespace color_utils { | 26 namespace color_utils { |
| 24 struct HSL; | 27 struct HSL; |
| 25 } | 28 } |
| 26 | 29 |
| 27 namespace ui { | 30 namespace ui { |
| 28 class ResourceBundle; | 31 class ResourceBundle; |
| 29 } | 32 } |
| 30 using ui::ResourceBundle; | 33 using ui::ResourceBundle; |
| 31 | 34 |
| 32 #ifdef __OBJC__ | 35 #ifdef __OBJC__ |
| 33 @class NSString; | 36 @class NSString; |
| 34 // Sent whenever the browser theme changes. Object => NSValue wrapping the | 37 // Sent whenever the browser theme changes. Object => NSValue wrapping the |
| 35 // ThemeService that changed. | 38 // ThemeService that changed. |
| 36 extern "C" NSString* const kBrowserThemeDidChangeNotification; | 39 extern "C" NSString* const kBrowserThemeDidChangeNotification; |
| 37 #endif // __OBJC__ | 40 #endif // __OBJC__ |
| 38 | 41 |
| 39 class ThemeService : public base::NonThreadSafe, | 42 class ThemeService : public base::NonThreadSafe, |
| 43 public NotificationObserver, |
| 44 public ProfileKeyedService, |
| 40 public ui::ThemeProvider { | 45 public ui::ThemeProvider { |
| 41 public: | 46 public: |
| 42 // Public constants used in ThemeService and its subclasses: | 47 // Public constants used in ThemeService and its subclasses: |
| 43 | 48 |
| 44 // Strings used in alignment properties. | 49 // Strings used in alignment properties. |
| 45 static const char* kAlignmentTop; | 50 static const char* kAlignmentTop; |
| 46 static const char* kAlignmentBottom; | 51 static const char* kAlignmentBottom; |
| 47 static const char* kAlignmentLeft; | 52 static const char* kAlignmentLeft; |
| 48 static const char* kAlignmentRight; | 53 static const char* kAlignmentRight; |
| 49 | 54 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // Let all the browser views know that themes have changed in a platform way. | 239 // Let all the browser views know that themes have changed in a platform way. |
| 235 virtual void NotifyPlatformThemeChanged(); | 240 virtual void NotifyPlatformThemeChanged(); |
| 236 #endif // OS_MACOSX | 241 #endif // OS_MACOSX |
| 237 | 242 |
| 238 // Clears the platform-specific caches. Do not call directly; it's called | 243 // Clears the platform-specific caches. Do not call directly; it's called |
| 239 // from ClearCaches(). | 244 // from ClearCaches(). |
| 240 virtual void FreePlatformCaches(); | 245 virtual void FreePlatformCaches(); |
| 241 | 246 |
| 242 Profile* profile() { return profile_; } | 247 Profile* profile() { return profile_; } |
| 243 | 248 |
| 249 // NotificationObserver: |
| 250 virtual void Observe(NotificationType type, |
| 251 const NotificationSource& source, |
| 252 const NotificationDetails& details); |
| 253 |
| 244 private: | 254 private: |
| 245 friend class ThemeServiceTest; | 255 friend class ThemeServiceTest; |
| 246 | 256 |
| 247 // Saves the filename of the cached theme pack. | 257 // Saves the filename of the cached theme pack. |
| 248 void SavePackName(const FilePath& pack_path); | 258 void SavePackName(const FilePath& pack_path); |
| 249 | 259 |
| 250 // Save the id of the last theme installed. | 260 // Save the id of the last theme installed. |
| 251 void SaveThemeID(const std::string& id); | 261 void SaveThemeID(const std::string& id); |
| 252 | 262 |
| 253 // Implementation of SetTheme() (and the fallback from LoadThemePrefs() in | 263 // Implementation of SetTheme() (and the fallback from LoadThemePrefs() in |
| (...skipping 21 matching lines...) Expand all Loading... |
| 275 #endif | 285 #endif |
| 276 | 286 |
| 277 ResourceBundle& rb_; | 287 ResourceBundle& rb_; |
| 278 Profile* profile_; | 288 Profile* profile_; |
| 279 | 289 |
| 280 scoped_refptr<BrowserThemePack> theme_pack_; | 290 scoped_refptr<BrowserThemePack> theme_pack_; |
| 281 | 291 |
| 282 // The number of infobars currently displayed. | 292 // The number of infobars currently displayed. |
| 283 int number_of_infobars_; | 293 int number_of_infobars_; |
| 284 | 294 |
| 295 NotificationRegistrar registrar_; |
| 296 |
| 285 DISALLOW_COPY_AND_ASSIGN(ThemeService); | 297 DISALLOW_COPY_AND_ASSIGN(ThemeService); |
| 286 }; | 298 }; |
| 287 | 299 |
| 288 #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_ | 300 #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_ |
| OLD | NEW |