Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_BROWSER_THEME_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_ | 6 #define CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "app/theme_provider.h" | 12 #include "app/theme_provider.h" |
| 13 #include "base/non_thread_safe.h" | 13 #include "base/non_thread_safe.h" |
| 14 #include "base/ref_counted.h" | 14 #include "base/ref_counted.h" |
| 15 | 15 |
| 16 namespace color_utils { | 16 namespace color_utils { |
| 17 struct HSL; | 17 struct HSL; |
| 18 } | 18 } |
| 19 | 19 |
| 20 class BrowserThemePack; | 20 class BrowserThemePack; |
| 21 class BrowserThemeProviderTest; | 21 class BrowserThemeProviderTest; |
| 22 class DictionaryValue; | 22 class DictionaryValue; |
| 23 class Extension; | 23 class Extension; |
| 24 class FilePath; | 24 class FilePath; |
| 25 class PrefService; | 25 class PrefService; |
| 26 class Profile; | 26 class Profile; |
| 27 class ResourceBundle; | 27 class ResourceBundle; |
| 28 | 28 |
| 29 #ifdef __OBJC__ | |
| 30 @class NSString; | |
| 31 // Sent whenever the browser theme changes. Object => NSValue wrapping the | |
| 32 // BrowserThemeProvider that changed. | |
| 33 extern "C" NSString* const kBrowserThemeDidChangeNotification; | |
| 34 #endif // __OBJC__ | |
| 35 | |
| 29 class BrowserThemeProvider : public NonThreadSafe, | 36 class BrowserThemeProvider : public NonThreadSafe, |
| 30 public ThemeProvider { | 37 public ThemeProvider { |
| 31 public: | 38 public: |
| 32 // Public constants used in BrowserThemeProvider and its subclasses: | 39 // Public constants used in BrowserThemeProvider and its subclasses: |
| 33 | 40 |
| 34 // Strings used in alignment properties. | 41 // Strings used in alignment properties. |
| 35 static const char* kAlignmentTop; | 42 static const char* kAlignmentTop; |
| 36 static const char* kAlignmentBottom; | 43 static const char* kAlignmentBottom; |
| 37 static const char* kAlignmentLeft; | 44 static const char* kAlignmentLeft; |
| 38 static const char* kAlignmentRight; | 45 static const char* kAlignmentRight; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 virtual SkBitmap* GetBitmapNamed(int id) const; | 111 virtual SkBitmap* GetBitmapNamed(int id) const; |
| 105 virtual SkColor GetColor(int id) const; | 112 virtual SkColor GetColor(int id) const; |
| 106 virtual bool GetDisplayProperty(int id, int* result) const; | 113 virtual bool GetDisplayProperty(int id, int* result) const; |
| 107 virtual bool ShouldUseNativeFrame() const; | 114 virtual bool ShouldUseNativeFrame() const; |
| 108 virtual bool HasCustomImage(int id) const; | 115 virtual bool HasCustomImage(int id) const; |
| 109 virtual RefCountedMemory* GetRawData(int id) const; | 116 virtual RefCountedMemory* GetRawData(int id) const; |
| 110 #if defined(OS_LINUX) | 117 #if defined(OS_LINUX) |
| 111 virtual GdkPixbuf* GetPixbufNamed(int id) const; | 118 virtual GdkPixbuf* GetPixbufNamed(int id) const; |
| 112 virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) const; | 119 virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) const; |
| 113 #elif defined(OS_MACOSX) | 120 #elif defined(OS_MACOSX) |
| 114 virtual NSImage* GetNSImageNamed(int id) const; | 121 virtual NSImage* GetNSImageNamed(int id, bool allow_default) const; |
|
Nico
2010/02/17 22:22:40
How about using an enum instead of a bool? Makes t
| |
| 115 virtual NSColor* GetNSColor(int id) const; | 122 virtual NSColor* GetNSColor(int id, bool allow_default) const; |
| 116 virtual NSColor* GetNSColorTint(int id) const; | 123 virtual NSColor* GetNSColorTint(int id, bool allow_default) const; |
| 117 #endif | 124 #endif |
| 118 | 125 |
| 119 // Set the current theme to the theme defined in |extension|. | 126 // Set the current theme to the theme defined in |extension|. |
| 120 virtual void SetTheme(Extension* extension); | 127 virtual void SetTheme(Extension* extension); |
| 121 | 128 |
| 122 // Reset the theme to default. | 129 // Reset the theme to default. |
| 123 virtual void UseDefaultTheme(); | 130 virtual void UseDefaultTheme(); |
| 124 | 131 |
| 125 // Set the current theme to the native theme. On some platforms, the native | 132 // Set the current theme to the native theme. On some platforms, the native |
| 126 // theme is the default theme. | 133 // theme is the default theme. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 | 182 |
| 176 // Clears all the override fields and saves the dictionary. | 183 // Clears all the override fields and saves the dictionary. |
| 177 virtual void ClearAllThemeData(); | 184 virtual void ClearAllThemeData(); |
| 178 | 185 |
| 179 // Load theme data from preferences. | 186 // Load theme data from preferences. |
| 180 virtual void LoadThemePrefs(); | 187 virtual void LoadThemePrefs(); |
| 181 | 188 |
| 182 // Let all the browser views know that themes have changed. | 189 // Let all the browser views know that themes have changed. |
| 183 virtual void NotifyThemeChanged(); | 190 virtual void NotifyThemeChanged(); |
| 184 | 191 |
| 192 #if defined(OS_MACOSX) | |
| 193 // Let all the browser views know that themes have changed in a platform way. | |
| 194 virtual void NotifyPlatformThemeChanged(); | |
| 195 #endif // OS_MACOSX | |
| 196 | |
| 185 // Clears the platform-specific caches. Do not call directly; it's called | 197 // Clears the platform-specific caches. Do not call directly; it's called |
| 186 // from ClearCaches(). | 198 // from ClearCaches(). |
| 187 virtual void FreePlatformCaches(); | 199 virtual void FreePlatformCaches(); |
| 188 | 200 |
| 189 Profile* profile() { return profile_; } | 201 Profile* profile() { return profile_; } |
| 190 | 202 |
| 191 private: | 203 private: |
| 192 friend class BrowserThemeProviderTest; | 204 friend class BrowserThemeProviderTest; |
| 193 | 205 |
| 194 // Saves the filename of the cached theme pack. | 206 // Saves the filename of the cached theme pack. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 208 // Loads an image and flips it horizontally if |rtl_enabled| is true. | 220 // Loads an image and flips it horizontally if |rtl_enabled| is true. |
| 209 GdkPixbuf* GetPixbufImpl(int id, bool rtl_enabled) const; | 221 GdkPixbuf* GetPixbufImpl(int id, bool rtl_enabled) const; |
| 210 #endif | 222 #endif |
| 211 | 223 |
| 212 #if defined(OS_LINUX) | 224 #if defined(OS_LINUX) |
| 213 typedef std::map<int, GdkPixbuf*> GdkPixbufMap; | 225 typedef std::map<int, GdkPixbuf*> GdkPixbufMap; |
| 214 mutable GdkPixbufMap gdk_pixbufs_; | 226 mutable GdkPixbufMap gdk_pixbufs_; |
| 215 #elif defined(OS_MACOSX) | 227 #elif defined(OS_MACOSX) |
| 216 typedef std::map<int, NSImage*> NSImageMap; | 228 typedef std::map<int, NSImage*> NSImageMap; |
| 217 mutable NSImageMap nsimage_cache_; | 229 mutable NSImageMap nsimage_cache_; |
| 218 typedef std::map<int, NSColor*> NSColorMap; | 230 // The bool member of the pair is whether the color is a default color. |
| 231 typedef std::map<int, std::pair<NSColor*, bool> > NSColorMap; | |
| 219 mutable NSColorMap nscolor_cache_; | 232 mutable NSColorMap nscolor_cache_; |
| 220 #endif | 233 #endif |
| 221 | 234 |
| 222 ResourceBundle& rb_; | 235 ResourceBundle& rb_; |
| 223 Profile* profile_; | 236 Profile* profile_; |
| 224 | 237 |
| 225 scoped_refptr<BrowserThemePack> theme_pack_; | 238 scoped_refptr<BrowserThemePack> theme_pack_; |
| 226 | 239 |
| 227 // The number of infobars currently displayed. | 240 // The number of infobars currently displayed. |
| 228 int number_of_infobars_; | 241 int number_of_infobars_; |
| 229 | 242 |
| 230 DISALLOW_COPY_AND_ASSIGN(BrowserThemeProvider); | 243 DISALLOW_COPY_AND_ASSIGN(BrowserThemeProvider); |
| 231 }; | 244 }; |
| 232 | 245 |
| 233 #endif // CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_ | 246 #endif // CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_ |
| OLD | NEW |