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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // ThemeProvider implementation. | 67 // ThemeProvider implementation. |
68 virtual SkBitmap* GetBitmapNamed(int id); | 68 virtual SkBitmap* GetBitmapNamed(int id); |
69 virtual SkColor GetColor(int id); | 69 virtual SkColor GetColor(int id); |
70 virtual bool GetDisplayProperty(int id, int* result); | 70 virtual bool GetDisplayProperty(int id, int* result); |
71 virtual bool ShouldUseNativeFrame(); | 71 virtual bool ShouldUseNativeFrame(); |
72 virtual bool HasCustomImage(int id); | 72 virtual bool HasCustomImage(int id); |
73 #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) | 73 #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) |
74 virtual GdkPixbuf* GetPixbufNamed(int id); | 74 virtual GdkPixbuf* GetPixbufNamed(int id); |
75 #elif defined(OS_MACOSX) | 75 #elif defined(OS_MACOSX) |
76 virtual NSImage* GetNSImageNamed(int id); | 76 virtual NSImage* GetNSImageNamed(int id); |
| 77 virtual NSColor* GetNSColorTint(int id); |
77 #endif | 78 #endif |
78 | 79 |
79 // Set the current theme to the theme defined in |extension|. | 80 // Set the current theme to the theme defined in |extension|. |
80 void SetTheme(Extension* extension); | 81 void SetTheme(Extension* extension); |
81 | 82 |
82 // Reset the theme to default. | 83 // Reset the theme to default. |
83 void UseDefaultTheme(); | 84 void UseDefaultTheme(); |
84 | 85 |
85 // Convert a bitfield alignment into a string like "top left". Public so that | 86 // Convert a bitfield alignment into a string like "top left". Public so that |
86 // it can be used to generate CSS values. Takes a bitfield of AlignmentMasks. | 87 // it can be used to generate CSS values. Takes a bitfield of AlignmentMasks. |
(...skipping 10 matching lines...) Expand all Loading... |
97 typedef std::map<const std::string, int> DisplayPropertyMap; | 98 typedef std::map<const std::string, int> DisplayPropertyMap; |
98 | 99 |
99 // Reads the image data from the theme file into the specified vector. Returns | 100 // Reads the image data from the theme file into the specified vector. Returns |
100 // true on success. | 101 // true on success. |
101 bool ReadThemeFileData(int id, std::vector<unsigned char>* raw_data); | 102 bool ReadThemeFileData(int id, std::vector<unsigned char>* raw_data); |
102 | 103 |
103 // Loads a bitmap from the theme, which may be tinted or | 104 // Loads a bitmap from the theme, which may be tinted or |
104 // otherwise modified, or an application default. | 105 // otherwise modified, or an application default. |
105 SkBitmap* LoadThemeBitmap(int id); | 106 SkBitmap* LoadThemeBitmap(int id); |
106 | 107 |
| 108 // Returns the string key for the given tint |id| TINT_* enum value. |
| 109 const std::string GetTintKey(int id); |
| 110 |
| 111 // Returns the default tint for the given tint |id| TINT_* enum value. |
| 112 skia::HSL GetDefaultTint(int id); |
| 113 |
107 // Get the specified tint - |id| is one of the TINT_* enum values. | 114 // Get the specified tint - |id| is one of the TINT_* enum values. |
108 skia::HSL GetTint(int id); | 115 skia::HSL GetTint(int id); |
109 | 116 |
110 // Tint |bitmap| with the tint specified by |hsl_id| | 117 // Tint |bitmap| with the tint specified by |hsl_id| |
111 SkBitmap TintBitmap(const SkBitmap& bitmap, int hsl_id); | 118 SkBitmap TintBitmap(const SkBitmap& bitmap, int hsl_id); |
112 | 119 |
113 // The following load data from specified dictionaries (either from | 120 // The following load data from specified dictionaries (either from |
114 // preferences or from an extension manifest) and update our theme | 121 // preferences or from an extension manifest) and update our theme |
115 // data appropriately. | 122 // data appropriately. |
116 // Allow any ResourceBundle image to be overridden. |images| should | 123 // Allow any ResourceBundle image to be overridden. |images| should |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 158 |
152 // Let all the browser views know that themes have changed. | 159 // Let all the browser views know that themes have changed. |
153 void NotifyThemeChanged(); | 160 void NotifyThemeChanged(); |
154 | 161 |
155 // Load theme data from preferences. | 162 // Load theme data from preferences. |
156 void LoadThemePrefs(); | 163 void LoadThemePrefs(); |
157 | 164 |
158 SkColor FindColor(const char* id, SkColor default_color); | 165 SkColor FindColor(const char* id, SkColor default_color); |
159 | 166 |
160 // Frees generated images and clears the image cache. | 167 // Frees generated images and clears the image cache. |
161 void FreeImages(); | 168 void ClearCaches(); |
162 | 169 |
163 // Clears the platform-specific image cache. Do not call directly; it's called | 170 // Clears the platform-specific caches. Do not call directly; it's called |
164 // from FreeImages(). | 171 // from ClearCaches(). |
165 void FreePlatformImages(); | 172 void FreePlatformCaches(); |
166 | 173 |
167 // Cached images. We cache all retrieved and generated bitmaps and keep | 174 // Cached images. We cache all retrieved and generated bitmaps and keep |
168 // track of the pointers. We own these and will delete them when we're done | 175 // track of the pointers. We own these and will delete them when we're done |
169 // using them. | 176 // using them. |
170 typedef std::map<int, SkBitmap*> ImageCache; | 177 typedef std::map<int, SkBitmap*> ImageCache; |
171 ImageCache image_cache_; | 178 ImageCache image_cache_; |
172 #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) | 179 #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) |
173 typedef std::map<int, GdkPixbuf*> GdkPixbufMap; | 180 typedef std::map<int, GdkPixbuf*> GdkPixbufMap; |
174 GdkPixbufMap gdk_pixbufs_; | 181 GdkPixbufMap gdk_pixbufs_; |
175 #elif defined(OS_MACOSX) | 182 #elif defined(OS_MACOSX) |
176 typedef std::map<int, NSImage*> NSImageMap; | 183 typedef std::map<int, NSImage*> NSImageMap; |
177 NSImageMap nsimage_cache_; | 184 NSImageMap nsimage_cache_; |
| 185 typedef std::map<int, NSColor*> NSColorMap; |
| 186 NSColorMap nscolor_cache_; |
178 #endif | 187 #endif |
179 | 188 |
180 ResourceBundle& rb_; | 189 ResourceBundle& rb_; |
181 Profile* profile_; | 190 Profile* profile_; |
182 | 191 |
183 ImageMap images_; | 192 ImageMap images_; |
184 ColorMap colors_; | 193 ColorMap colors_; |
185 TintMap tints_; | 194 TintMap tints_; |
186 DisplayPropertyMap display_properties_; | 195 DisplayPropertyMap display_properties_; |
187 | 196 |
188 DISALLOW_COPY_AND_ASSIGN(BrowserThemeProvider); | 197 DISALLOW_COPY_AND_ASSIGN(BrowserThemeProvider); |
189 }; | 198 }; |
190 | 199 |
191 #endif // CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_ | 200 #endif // CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_ |
OLD | NEW |