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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 REPEAT = 3 | 155 REPEAT = 3 |
156 } Tiling; | 156 } Tiling; |
157 | 157 |
158 // ThemeProvider implementation. | 158 // ThemeProvider implementation. |
159 virtual void Init(Profile* profile); | 159 virtual void Init(Profile* profile); |
160 virtual SkBitmap* GetBitmapNamed(int id) const; | 160 virtual SkBitmap* GetBitmapNamed(int id) const; |
161 virtual SkColor GetColor(int id) const; | 161 virtual SkColor GetColor(int id) const; |
162 virtual bool GetDisplayProperty(int id, int* result) const; | 162 virtual bool GetDisplayProperty(int id, int* result) const; |
163 virtual bool ShouldUseNativeFrame() const; | 163 virtual bool ShouldUseNativeFrame() const; |
164 virtual bool HasCustomImage(int id) const; | 164 virtual bool HasCustomImage(int id) const; |
165 virtual bool GetRawData(int id, std::vector<unsigned char>* raw_data) const; | 165 virtual RefCountedMemory* GetRawData(int id) const; |
166 #if defined(OS_LINUX) | 166 #if defined(OS_LINUX) |
167 virtual GdkPixbuf* GetPixbufNamed(int id) const; | 167 virtual GdkPixbuf* GetPixbufNamed(int id) const; |
168 virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) const; | 168 virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) const; |
169 #elif defined(OS_MACOSX) | 169 #elif defined(OS_MACOSX) |
170 virtual NSImage* GetNSImageNamed(int id) const; | 170 virtual NSImage* GetNSImageNamed(int id) const; |
171 virtual NSColor* GetNSColor(int id) const; | 171 virtual NSColor* GetNSColor(int id) const; |
172 virtual NSColor* GetNSColorTint(int id) const; | 172 virtual NSColor* GetNSColorTint(int id) const; |
173 #endif | 173 #endif |
174 | 174 |
175 // Set the current theme to the theme defined in |extension|. | 175 // Set the current theme to the theme defined in |extension|. |
176 virtual void SetTheme(Extension* extension); | 176 virtual void SetTheme(Extension* extension); |
177 | 177 |
178 // Reset the theme to default. | 178 // Reset the theme to default. |
179 virtual void UseDefaultTheme(); | 179 virtual void UseDefaultTheme(); |
180 | 180 |
181 // Set the current theme to the native theme. On some platforms, the native | 181 // Set the current theme to the native theme. On some platforms, the native |
182 // theme is the default theme. | 182 // theme is the default theme. |
183 virtual void SetNativeTheme() { UseDefaultTheme(); } | 183 virtual void SetNativeTheme() { UseDefaultTheme(); } |
184 | 184 |
185 // Gets the id of the last installed theme. (The theme may have been further | 185 // Gets the id of the last installed theme. (The theme may have been further |
186 // locally customized.) | 186 // locally customized.) |
187 std::string GetThemeID() const; | 187 std::string GetThemeID() const; |
188 | 188 |
189 // Reads the image data from the theme file into the specified vector. Returns | 189 // Reads the image data from the theme file into the specified vector. Returns |
190 // true on success. | 190 // true on success. |
191 bool ReadThemeFileData(int id, std::vector<unsigned char>* raw_data) const; | 191 RefCountedMemory* ReadThemeFileData(int id) const; |
192 | 192 |
193 // Convert a bitfield alignment into a string like "top left". Public so that | 193 // Convert a bitfield alignment into a string like "top left". Public so that |
194 // it can be used to generate CSS values. Takes a bitfield of AlignmentMasks. | 194 // it can be used to generate CSS values. Takes a bitfield of AlignmentMasks. |
195 static std::string AlignmentToString(int alignment); | 195 static std::string AlignmentToString(int alignment); |
196 | 196 |
197 // Parse alignments from something like "top left" into a bitfield of | 197 // Parse alignments from something like "top left" into a bitfield of |
198 // AlignmentMasks | 198 // AlignmentMasks |
199 static int StringToAlignment(const std::string& alignment); | 199 static int StringToAlignment(const std::string& alignment); |
200 | 200 |
201 // Convert a tiling value into a string like "no-repeat". Public | 201 // Convert a tiling value into a string like "no-repeat". Public |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 270 |
271 // Subclasses may need us to not use the on-disk image cache. The GTK | 271 // Subclasses may need us to not use the on-disk image cache. The GTK |
272 // interface needs to generate some images itself. | 272 // interface needs to generate some images itself. |
273 void force_process_images() { process_images_ = true; } | 273 void force_process_images() { process_images_ = true; } |
274 | 274 |
275 private: | 275 private: |
276 typedef std::map<const int, std::string> ImageMap; | 276 typedef std::map<const int, std::string> ImageMap; |
277 typedef std::map<const std::string, SkColor> ColorMap; | 277 typedef std::map<const std::string, SkColor> ColorMap; |
278 typedef std::map<const std::string, color_utils::HSL> TintMap; | 278 typedef std::map<const std::string, color_utils::HSL> TintMap; |
279 typedef std::map<const std::string, int> DisplayPropertyMap; | 279 typedef std::map<const std::string, int> DisplayPropertyMap; |
280 typedef std::map<const int, std::vector<unsigned char> > RawDataMap; | 280 typedef std::map<const int, scoped_refptr<RefCountedMemory> > RawDataMap; |
281 typedef std::map<const int, std::string> ResourceNameMap; | 281 typedef std::map<const int, std::string> ResourceNameMap; |
282 | 282 |
283 // Returns the string key for the given tint |id| TINT_* enum value. | 283 // Returns the string key for the given tint |id| TINT_* enum value. |
284 const std::string GetTintKey(int id) const; | 284 const std::string GetTintKey(int id) const; |
285 | 285 |
286 // Returns the default tint for the given tint |id| TINT_* enum value. | 286 // Returns the default tint for the given tint |id| TINT_* enum value. |
287 color_utils::HSL GetDefaultTint(int id) const; | 287 color_utils::HSL GetDefaultTint(int id) const; |
288 | 288 |
289 // Returns the string key for the given color |id| COLOR_* enum value. | 289 // Returns the string key for the given color |id| COLOR_* enum value. |
290 const std::string GetColorKey(int id) const; | 290 const std::string GetColorKey(int id) const; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 // If true, process all images; if false, just load from disk. | 382 // If true, process all images; if false, just load from disk. |
383 bool process_images_; | 383 bool process_images_; |
384 | 384 |
385 // Where we will store our generated images. | 385 // Where we will store our generated images. |
386 FilePath image_dir_; | 386 FilePath image_dir_; |
387 | 387 |
388 DISALLOW_COPY_AND_ASSIGN(BrowserThemeProvider); | 388 DISALLOW_COPY_AND_ASSIGN(BrowserThemeProvider); |
389 }; | 389 }; |
390 | 390 |
391 #endif // CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_ | 391 #endif // CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_ |
OLD | NEW |