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_BROWSER_THEME_PACK_H_ | 5 #ifndef CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ |
6 #define CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ | 6 #define CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
16 #include "content/browser/browser_thread.h" | 16 #include "content/browser/browser_thread.h" |
17 #include "ui/gfx/color_utils.h" | 17 #include "ui/gfx/color_utils.h" |
18 | 18 |
19 class DictionaryValue; | |
20 class FilePath; | 19 class FilePath; |
21 class RefCountedMemory; | 20 class RefCountedMemory; |
22 namespace ui { | 21 namespace ui { |
23 class DataPack; | 22 class DataPack; |
24 } | 23 } |
25 namespace gfx { | 24 namespace gfx { |
26 class Image; | 25 class Image; |
27 } | 26 } |
| 27 namespace base { |
| 28 class DictionaryValue; |
| 29 } |
28 | 30 |
29 // An optimized representation of a theme, backed by a mmapped DataPack. | 31 // An optimized representation of a theme, backed by a mmapped DataPack. |
30 // | 32 // |
31 // The idea is to pre-process all images (tinting, compositing, etc) at theme | 33 // The idea is to pre-process all images (tinting, compositing, etc) at theme |
32 // install time, save all the PNG-ified data into an mmappable file so we don't | 34 // install time, save all the PNG-ified data into an mmappable file so we don't |
33 // suffer multiple file system access times, therefore solving two of the | 35 // suffer multiple file system access times, therefore solving two of the |
34 // problems with the previous implementation. | 36 // problems with the previous implementation. |
35 // | 37 // |
36 // A note on const-ness. All public, non-static methods are const. We do this | 38 // A note on const-ness. All public, non-static methods are const. We do this |
37 // because once we've constructed a BrowserThemePack through the | 39 // because once we've constructed a BrowserThemePack through the |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // Default. Everything is empty. | 112 // Default. Everything is empty. |
111 BrowserThemePack(); | 113 BrowserThemePack(); |
112 | 114 |
113 virtual ~BrowserThemePack(); | 115 virtual ~BrowserThemePack(); |
114 | 116 |
115 // Builds a header ready to write to disk. | 117 // Builds a header ready to write to disk. |
116 void BuildHeader(const Extension* extension); | 118 void BuildHeader(const Extension* extension); |
117 | 119 |
118 // Transforms the JSON tint values into their final versions in the |tints_| | 120 // Transforms the JSON tint values into their final versions in the |tints_| |
119 // array. | 121 // array. |
120 void BuildTintsFromJSON(DictionaryValue* tints_value); | 122 void BuildTintsFromJSON(base::DictionaryValue* tints_value); |
121 | 123 |
122 // Transforms the JSON color values into their final versions in the | 124 // Transforms the JSON color values into their final versions in the |
123 // |colors_| array and also fills in unspecified colors based on tint values. | 125 // |colors_| array and also fills in unspecified colors based on tint values. |
124 void BuildColorsFromJSON(DictionaryValue* color_value); | 126 void BuildColorsFromJSON(base::DictionaryValue* color_value); |
125 | 127 |
126 // Implementation details of BuildColorsFromJSON(). | 128 // Implementation details of BuildColorsFromJSON(). |
127 void ReadColorsFromJSON(DictionaryValue* colors_value, | 129 void ReadColorsFromJSON(base::DictionaryValue* colors_value, |
128 std::map<int, SkColor>* temp_colors); | 130 std::map<int, SkColor>* temp_colors); |
129 void GenerateMissingColors(std::map<int, SkColor>* temp_colors); | 131 void GenerateMissingColors(std::map<int, SkColor>* temp_colors); |
130 | 132 |
131 // Transforms the JSON display properties into |display_properties_|. | 133 // Transforms the JSON display properties into |display_properties_|. |
132 void BuildDisplayPropertiesFromJSON(DictionaryValue* display_value); | 134 void BuildDisplayPropertiesFromJSON(base::DictionaryValue* display_value); |
133 | 135 |
134 // Parses the image names out of an extension. | 136 // Parses the image names out of an extension. |
135 void ParseImageNamesFromJSON(DictionaryValue* images_value, | 137 void ParseImageNamesFromJSON(base::DictionaryValue* images_value, |
136 const FilePath& images_path, | 138 const FilePath& images_path, |
137 FilePathMap* file_paths) const; | 139 FilePathMap* file_paths) const; |
138 | 140 |
139 // Creates the data for |source_images_| from |file_paths|. | 141 // Creates the data for |source_images_| from |file_paths|. |
140 void BuildSourceImagesArray(const FilePathMap& file_paths); | 142 void BuildSourceImagesArray(const FilePathMap& file_paths); |
141 | 143 |
142 // Loads the unmodified bitmaps packed in the extension to SkBitmaps. Returns | 144 // Loads the unmodified bitmaps packed in the extension to SkBitmaps. Returns |
143 // true if all images loaded. | 145 // true if all images loaded. |
144 bool LoadRawBitmapsTo(const FilePathMap& file_paths, | 146 bool LoadRawBitmapsTo(const FilePathMap& file_paths, |
145 ImageCache* raw_bitmaps); | 147 ImageCache* raw_bitmaps); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // in |image_memory_| that are in |prepared_images_| or vice versa. | 233 // in |image_memory_| that are in |prepared_images_| or vice versa. |
232 ImageCache prepared_images_; | 234 ImageCache prepared_images_; |
233 | 235 |
234 // Loaded images. These are loaded from |image_memory_| or the |data_pack_|. | 236 // Loaded images. These are loaded from |image_memory_| or the |data_pack_|. |
235 mutable ImageCache loaded_images_; | 237 mutable ImageCache loaded_images_; |
236 | 238 |
237 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack); | 239 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack); |
238 }; | 240 }; |
239 | 241 |
240 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ | 242 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ |
OLD | NEW |