OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <string> | 11 #include <string> |
10 #include <vector> | 12 #include <vector> |
11 | 13 |
12 #include "base/basictypes.h" | 14 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
14 #include "base/sequenced_task_runner_helpers.h" | 16 #include "base/sequenced_task_runner_helpers.h" |
15 #include "chrome/browser/themes/custom_theme_supplier.h" | 17 #include "chrome/browser/themes/custom_theme_supplier.h" |
16 #include "extensions/common/extension.h" | 18 #include "extensions/common/extension.h" |
17 #include "third_party/skia/include/core/SkColor.h" | 19 #include "third_party/skia/include/core/SkColor.h" |
18 #include "ui/base/layout.h" | 20 #include "ui/base/layout.h" |
19 #include "ui/gfx/color_utils.h" | 21 #include "ui/gfx/color_utils.h" |
20 | 22 |
21 namespace base { | 23 namespace base { |
22 class DictionaryValue; | 24 class DictionaryValue; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 private: | 92 private: |
91 friend class BrowserThemePackTest; | 93 friend class BrowserThemePackTest; |
92 | 94 |
93 // Cached images. | 95 // Cached images. |
94 typedef std::map<int, gfx::Image> ImageCache; | 96 typedef std::map<int, gfx::Image> ImageCache; |
95 | 97 |
96 // The raw PNG memory associated with a certain id. | 98 // The raw PNG memory associated with a certain id. |
97 typedef std::map<int, scoped_refptr<base::RefCountedMemory> > RawImages; | 99 typedef std::map<int, scoped_refptr<base::RefCountedMemory> > RawImages; |
98 | 100 |
99 // The type passed to ui::DataPack::WritePack. | 101 // The type passed to ui::DataPack::WritePack. |
100 typedef std::map<uint16, base::StringPiece> RawDataForWriting; | 102 typedef std::map<uint16_t, base::StringPiece> RawDataForWriting; |
101 | 103 |
102 // Maps scale factors (enum values) to file paths. | 104 // Maps scale factors (enum values) to file paths. |
103 typedef std::map<ui::ScaleFactor, base::FilePath> ScaleFactorToFileMap; | 105 typedef std::map<ui::ScaleFactor, base::FilePath> ScaleFactorToFileMap; |
104 | 106 |
105 // Maps image ids to maps of scale factors to file paths. | 107 // Maps image ids to maps of scale factors to file paths. |
106 typedef std::map<int, ScaleFactorToFileMap> FilePathMap; | 108 typedef std::map<int, ScaleFactorToFileMap> FilePathMap; |
107 | 109 |
108 // Default. Everything is empty. | 110 // Default. Everything is empty. |
109 BrowserThemePack(); | 111 BrowserThemePack(); |
110 | 112 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 212 |
211 // Data pack, if we have one. | 213 // Data pack, if we have one. |
212 scoped_ptr<ui::DataPack> data_pack_; | 214 scoped_ptr<ui::DataPack> data_pack_; |
213 | 215 |
214 // All structs written to disk need to be packed; no alignment tricks here, | 216 // All structs written to disk need to be packed; no alignment tricks here, |
215 // please. | 217 // please. |
216 #pragma pack(push,1) | 218 #pragma pack(push,1) |
217 // Header that is written to disk. | 219 // Header that is written to disk. |
218 struct BrowserThemePackHeader { | 220 struct BrowserThemePackHeader { |
219 // Numeric version to make sure we're compatible in the future. | 221 // Numeric version to make sure we're compatible in the future. |
220 int32 version; | 222 int32_t version; |
221 | 223 |
222 // 1 if little_endian. 0 if big_endian. On mismatch, abort load. | 224 // 1 if little_endian. 0 if big_endian. On mismatch, abort load. |
223 int32 little_endian; | 225 int32_t little_endian; |
224 | 226 |
225 // theme_id without NULL terminator. | 227 // theme_id without NULL terminator. |
226 uint8 theme_id[16]; | 228 uint8_t theme_id[16]; |
227 } *header_; | 229 } *header_; |
228 | 230 |
229 // The remaining structs represent individual entries in an array. For the | 231 // The remaining structs represent individual entries in an array. For the |
230 // following three structs, BrowserThemePack will either allocate an array or | 232 // following three structs, BrowserThemePack will either allocate an array or |
231 // will point directly to mmapped data. | 233 // will point directly to mmapped data. |
232 struct TintEntry { | 234 struct TintEntry { |
233 int32 id; | 235 int32_t id; |
234 double h; | 236 double h; |
235 double s; | 237 double s; |
236 double l; | 238 double l; |
237 } *tints_; | 239 } *tints_; |
238 | 240 |
239 struct ColorPair { | 241 struct ColorPair { |
240 int32 id; | 242 int32_t id; |
241 SkColor color; | 243 SkColor color; |
242 } *colors_; | 244 } *colors_; |
243 | 245 |
244 struct DisplayPropertyPair { | 246 struct DisplayPropertyPair { |
245 int32 id; | 247 int32_t id; |
246 int32 property; | 248 int32_t property; |
247 } *display_properties_; | 249 } *display_properties_; |
248 | 250 |
249 // A list of included source images. A pointer to a -1 terminated array of | 251 // A list of included source images. A pointer to a -1 terminated array of |
250 // our persistent IDs. | 252 // our persistent IDs. |
251 int* source_images_; | 253 int* source_images_; |
252 #pragma pack(pop) | 254 #pragma pack(pop) |
253 | 255 |
254 // The scale factors represented by the images in the theme pack. | 256 // The scale factors represented by the images in the theme pack. |
255 std::vector<ui::ScaleFactor> scale_factors_; | 257 std::vector<ui::ScaleFactor> scale_factors_; |
256 | 258 |
(...skipping 11 matching lines...) Expand all Loading... |
268 // Cache of images created in BuildFromExtension(). Once the theme pack is | 270 // Cache of images created in BuildFromExtension(). Once the theme pack is |
269 // created, this cache should only be accessed on the file thread. There | 271 // created, this cache should only be accessed on the file thread. There |
270 // should be no IDs in |image_memory_| that are in |images_on_file_thread_| | 272 // should be no IDs in |image_memory_| that are in |images_on_file_thread_| |
271 // or vice versa. | 273 // or vice versa. |
272 ImageCache images_on_file_thread_; | 274 ImageCache images_on_file_thread_; |
273 | 275 |
274 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack); | 276 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack); |
275 }; | 277 }; |
276 | 278 |
277 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ | 279 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ |
OLD | NEW |