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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 // Returns the theme pack image for |id|. Returns an empty image if an image | 84 // Returns the theme pack image for |id|. Returns an empty image if an image |
85 // is not found. | 85 // is not found. |
86 gfx::Image GetImageNamed(int id); | 86 gfx::Image GetImageNamed(int id); |
87 | 87 |
88 // Returns the raw PNG encoded data for IDR_THEME_NTP_*. This method is only | 88 // Returns the raw PNG encoded data for IDR_THEME_NTP_*. This method is only |
89 // supposed to work for the NTP attribution and background resources. | 89 // supposed to work for the NTP attribution and background resources. |
90 base::RefCountedMemory* GetRawData(int id, | 90 base::RefCountedMemory* GetRawData(int id, |
91 ui::ScaleFactor scale_factor) const; | 91 ui::ScaleFactor scale_factor) const; |
92 | 92 |
| 93 // Returns the raw PNG encoded data for IDR_THEME_NTP_* for the available |
| 94 // scale factor with the highest scale if available, otherwise NULL. |
| 95 // The corresponding scale factor is returned in |scale_factor|. |
| 96 base::RefCountedMemory* GetRawDataWithHighestScale( |
| 97 int id, |
| 98 ui::ScaleFactor* scale_factor) const; |
| 99 |
93 // Returns the set of image idrs which can be overwritten by a user provided | 100 // Returns the set of image idrs which can be overwritten by a user provided |
94 // theme. | 101 // theme. |
95 static void GetThemeableImageIDRs(std::set<int>* result); | 102 static void GetThemeableImageIDRs(std::set<int>* result); |
96 | 103 |
97 // Whether this theme provides an image for |id|. | 104 // Whether this theme provides an image for |id|. |
98 bool HasCustomImage(int id) const; | 105 bool HasCustomImage(int id) const; |
99 | 106 |
100 private: | 107 private: |
101 friend struct content::BrowserThread::DeleteOnThread< | 108 friend struct content::BrowserThread::DeleteOnThread< |
102 content::BrowserThread::FILE>; | 109 content::BrowserThread::FILE>; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } *display_properties_; | 267 } *display_properties_; |
261 | 268 |
262 // A list of included source images. A pointer to a -1 terminated array of | 269 // A list of included source images. A pointer to a -1 terminated array of |
263 // our persistent IDs. | 270 // our persistent IDs. |
264 int* source_images_; | 271 int* source_images_; |
265 #pragma pack(pop) | 272 #pragma pack(pop) |
266 | 273 |
267 // The scale factors represented by the images in the theme pack. | 274 // The scale factors represented by the images in the theme pack. |
268 std::vector<ui::ScaleFactor> scale_factors_; | 275 std::vector<ui::ScaleFactor> scale_factors_; |
269 | 276 |
| 277 // The scale factors ordered by scale from lowest to highest. |
| 278 std::vector<ui::ScaleFactor> scale_factors_ordered_by_scale_; |
| 279 |
270 // References to raw PNG data. This map isn't touched when |data_pack_| is | 280 // References to raw PNG data. This map isn't touched when |data_pack_| is |
271 // non-NULL; |image_memory_| is only filled during BuildFromExtension(). Any | 281 // non-NULL; |image_memory_| is only filled during BuildFromExtension(). Any |
272 // image data that needs to be written to the DataPack during WriteToDisk() | 282 // image data that needs to be written to the DataPack during WriteToDisk() |
273 // needs to be in |image_memory_|. | 283 // needs to be in |image_memory_|. |
274 RawImages image_memory_; | 284 RawImages image_memory_; |
275 | 285 |
276 // Loaded images. These are loaded from |image_memory_|, from |data_pack_|, | 286 // Loaded images. These are loaded from |image_memory_|, from |data_pack_|, |
277 // and by BuildFromExtension(). These images should only be accessed on the UI | 287 // and by BuildFromExtension(). These images should only be accessed on the UI |
278 // thread. | 288 // thread. |
279 ImageCache images_on_ui_thread_; | 289 ImageCache images_on_ui_thread_; |
280 | 290 |
281 // Cache of images created in BuildFromExtension(). Once the theme pack is | 291 // Cache of images created in BuildFromExtension(). Once the theme pack is |
282 // created, this cache should only be accessed on the file thread. There | 292 // created, this cache should only be accessed on the file thread. There |
283 // should be no IDs in |image_memory_| that are in |images_on_file_thread_| | 293 // should be no IDs in |image_memory_| that are in |images_on_file_thread_| |
284 // or vice versa. | 294 // or vice versa. |
285 ImageCache images_on_file_thread_; | 295 ImageCache images_on_file_thread_; |
286 | 296 |
| 297 base::WeakPtrFactory<BrowserThemePack> weak_ptr_factory_; |
| 298 |
287 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack); | 299 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack); |
288 }; | 300 }; |
289 | 301 |
290 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ | 302 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ |
OLD | NEW |