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 #include "chrome/browser/themes/browser_theme_pack.h" | 5 #include "chrome/browser/themes/browser_theme_pack.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "ui/gfx/skia_util.h" | 36 #include "ui/gfx/skia_util.h" |
37 | 37 |
38 using content::BrowserThread; | 38 using content::BrowserThread; |
39 using extensions::Extension; | 39 using extensions::Extension; |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 // Version number of the current theme pack. We just throw out and rebuild | 43 // Version number of the current theme pack. We just throw out and rebuild |
44 // theme packs that aren't int-equal to this. Increment this number if you | 44 // theme packs that aren't int-equal to this. Increment this number if you |
45 // change default theme assets. | 45 // change default theme assets. |
46 const int kThemePackVersion = 31; | 46 const int kThemePackVersion = 32; |
47 | 47 |
48 // IDs that are in the DataPack won't clash with the positive integer | 48 // IDs that are in the DataPack won't clash with the positive integer |
49 // uint16. kHeaderID should always have the maximum value because we want the | 49 // uint16. kHeaderID should always have the maximum value because we want the |
50 // "header" to be written last. That way we can detect whether the pack was | 50 // "header" to be written last. That way we can detect whether the pack was |
51 // successfully written and ignore and regenerate if it was only partially | 51 // successfully written and ignore and regenerate if it was only partially |
52 // written (i.e. chrome crashed on a different thread while writing the pack). | 52 // written (i.e. chrome crashed on a different thread while writing the pack). |
53 const int kMaxID = 0x0000FFFF; // Max unsigned 16-bit int. | 53 const int kMaxID = 0x0000FFFF; // Max unsigned 16-bit int. |
54 const int kHeaderID = kMaxID - 1; | 54 const int kHeaderID = kMaxID - 1; |
55 const int kTintsID = kMaxID - 2; | 55 const int kTintsID = kMaxID - 2; |
56 const int kColorsID = kMaxID - 3; | 56 const int kColorsID = kMaxID - 3; |
57 const int kDisplayPropertiesID = kMaxID - 4; | 57 const int kDisplayPropertiesID = kMaxID - 4; |
58 const int kSourceImagesID = kMaxID - 5; | 58 const int kSourceImagesID = kMaxID - 5; |
59 const int kScaleFactorsID = kMaxID - 6; | 59 const int kScaleFactorsID = kMaxID - 6; |
60 | 60 |
61 // The sum of kFrameBorderThickness and kNonClientRestoredExtraThickness from | |
62 // OpaqueBrowserFrameView. | |
63 const int kRestoredTabVerticalOffset = 15; | |
64 | |
65 // Persistent constants for the main images that we need. These have the same | 61 // Persistent constants for the main images that we need. These have the same |
66 // names as their IDR_* counterparts but these values will always stay the | 62 // names as their IDR_* counterparts but these values will always stay the |
67 // same. | 63 // same. |
68 const int PRS_THEME_FRAME = 1; | 64 const int PRS_THEME_FRAME = 1; |
69 const int PRS_THEME_FRAME_INACTIVE = 2; | 65 const int PRS_THEME_FRAME_INACTIVE = 2; |
70 const int PRS_THEME_FRAME_INCOGNITO = 3; | 66 const int PRS_THEME_FRAME_INCOGNITO = 3; |
71 const int PRS_THEME_FRAME_INCOGNITO_INACTIVE = 4; | 67 const int PRS_THEME_FRAME_INCOGNITO_INACTIVE = 4; |
72 const int PRS_THEME_TOOLBAR = 5; | 68 const int PRS_THEME_TOOLBAR = 5; |
73 const int PRS_THEME_TAB_BACKGROUND = 6; | 69 const int PRS_THEME_TAB_BACKGROUND_OVERLAY = 6; |
74 const int PRS_THEME_TAB_BACKGROUND_INCOGNITO = 7; | 70 const int PRS_THEME_TAB_BACKGROUND_INCOGNITO_OVERLAY = 7; |
75 const int PRS_THEME_TAB_BACKGROUND_V = 8; | 71 const int PRS_THEME_TAB_BACKGROUND_V_OVERLAY = 8; |
76 const int PRS_THEME_NTP_BACKGROUND = 9; | 72 const int PRS_THEME_NTP_BACKGROUND = 9; |
77 const int PRS_THEME_FRAME_OVERLAY = 10; | 73 const int PRS_THEME_FRAME_OVERLAY = 10; |
78 const int PRS_THEME_FRAME_OVERLAY_INACTIVE = 11; | 74 const int PRS_THEME_FRAME_OVERLAY_INACTIVE = 11; |
79 const int PRS_THEME_BUTTON_BACKGROUND = 12; | 75 const int PRS_THEME_BUTTON_BACKGROUND = 12; |
80 const int PRS_THEME_NTP_ATTRIBUTION = 13; | 76 const int PRS_THEME_NTP_ATTRIBUTION = 13; |
81 const int PRS_THEME_WINDOW_CONTROL_BACKGROUND = 14; | 77 const int PRS_THEME_WINDOW_CONTROL_BACKGROUND = 14; |
| 78 const int PRS_THEME_TAB_BACKGROUND = 15; |
| 79 const int PRS_THEME_TAB_BACKGROUND_INCOGNITO = 16; |
82 | 80 |
83 struct PersistingImagesTable { | 81 struct PersistingImagesTable { |
84 // A non-changing integer ID meant to be saved in theme packs. This ID must | 82 // A non-changing integer ID meant to be saved in theme packs. This ID must |
85 // not change between versions of chrome. | 83 // not change between versions of chrome. |
86 int persistent_id; | 84 int persistent_id; |
87 | 85 |
88 // The IDR that depends on the whims of GRIT and therefore changes whenever | 86 // The IDR that depends on the whims of GRIT and therefore changes whenever |
89 // someone adds a new resource. | 87 // someone adds a new resource. |
90 int idr_id; | 88 int idr_id; |
91 | 89 |
92 // String to check for when parsing theme manifests or NULL if this isn't | 90 // String to check for when parsing theme manifests or NULL if this isn't |
93 // supposed to be changeable by the user. | 91 // supposed to be changeable by the user. |
94 const char* key; | 92 const char* key; |
95 }; | 93 }; |
96 | 94 |
97 // IDR_* resource names change whenever new resources are added; use persistent | 95 // IDR_* resource names change whenever new resources are added; use persistent |
98 // IDs when storing to a cached pack. | 96 // IDs when storing to a cached pack. |
99 PersistingImagesTable kPersistingImages[] = { | 97 PersistingImagesTable kPersistingImages[] = { |
100 { PRS_THEME_FRAME, IDR_THEME_FRAME, | 98 { PRS_THEME_FRAME, IDR_THEME_FRAME, |
101 "theme_frame" }, | 99 "theme_frame" }, |
102 { PRS_THEME_FRAME_INACTIVE, IDR_THEME_FRAME_INACTIVE, | 100 { PRS_THEME_FRAME_INACTIVE, IDR_THEME_FRAME_INACTIVE, |
103 "theme_frame_inactive" }, | 101 "theme_frame_inactive" }, |
104 { PRS_THEME_FRAME_INCOGNITO, IDR_THEME_FRAME_INCOGNITO, | 102 { PRS_THEME_FRAME_INCOGNITO, IDR_THEME_FRAME_INCOGNITO, |
105 "theme_frame_incognito" }, | 103 "theme_frame_incognito" }, |
106 { PRS_THEME_FRAME_INCOGNITO_INACTIVE, IDR_THEME_FRAME_INCOGNITO_INACTIVE, | 104 { PRS_THEME_FRAME_INCOGNITO_INACTIVE, IDR_THEME_FRAME_INCOGNITO_INACTIVE, |
107 "theme_frame_incognito_inactive" }, | 105 "theme_frame_incognito_inactive" }, |
108 { PRS_THEME_TOOLBAR, IDR_THEME_TOOLBAR, | 106 { PRS_THEME_TOOLBAR, IDR_THEME_TOOLBAR, |
109 "theme_toolbar" }, | 107 "theme_toolbar" }, |
110 { PRS_THEME_TAB_BACKGROUND, IDR_THEME_TAB_BACKGROUND, | 108 { PRS_THEME_TAB_BACKGROUND_OVERLAY, IDR_THEME_TAB_BACKGROUND_OVERLAY, |
111 "theme_tab_background" }, | 109 "theme_tab_background" }, |
112 { PRS_THEME_TAB_BACKGROUND_INCOGNITO, IDR_THEME_TAB_BACKGROUND_INCOGNITO, | 110 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_OVERLAY, |
| 111 IDR_THEME_TAB_BACKGROUND_INCOGNITO_OVERLAY, |
113 "theme_tab_background_incognito" }, | 112 "theme_tab_background_incognito" }, |
114 { PRS_THEME_TAB_BACKGROUND_V, IDR_THEME_TAB_BACKGROUND_V, | 113 { PRS_THEME_TAB_BACKGROUND_V_OVERLAY, IDR_THEME_TAB_BACKGROUND_V_OVERLAY, |
115 "theme_tab_background_v"}, | 114 "theme_tab_background_v"}, |
116 { PRS_THEME_NTP_BACKGROUND, IDR_THEME_NTP_BACKGROUND, | 115 { PRS_THEME_NTP_BACKGROUND, IDR_THEME_NTP_BACKGROUND, |
117 "theme_ntp_background" }, | 116 "theme_ntp_background" }, |
118 { PRS_THEME_FRAME_OVERLAY, IDR_THEME_FRAME_OVERLAY, | 117 { PRS_THEME_FRAME_OVERLAY, IDR_THEME_FRAME_OVERLAY, |
119 "theme_frame_overlay" }, | 118 "theme_frame_overlay" }, |
120 { PRS_THEME_FRAME_OVERLAY_INACTIVE, IDR_THEME_FRAME_OVERLAY_INACTIVE, | 119 { PRS_THEME_FRAME_OVERLAY_INACTIVE, IDR_THEME_FRAME_OVERLAY_INACTIVE, |
121 "theme_frame_overlay_inactive" }, | 120 "theme_frame_overlay_inactive" }, |
122 { PRS_THEME_BUTTON_BACKGROUND, IDR_THEME_BUTTON_BACKGROUND, | 121 { PRS_THEME_BUTTON_BACKGROUND, IDR_THEME_BUTTON_BACKGROUND, |
123 "theme_button_background" }, | 122 "theme_button_background" }, |
124 { PRS_THEME_NTP_ATTRIBUTION, IDR_THEME_NTP_ATTRIBUTION, | 123 { PRS_THEME_NTP_ATTRIBUTION, IDR_THEME_NTP_ATTRIBUTION, |
125 "theme_ntp_attribution" }, | 124 "theme_ntp_attribution" }, |
126 { PRS_THEME_WINDOW_CONTROL_BACKGROUND, IDR_THEME_WINDOW_CONTROL_BACKGROUND, | 125 { PRS_THEME_WINDOW_CONTROL_BACKGROUND, IDR_THEME_WINDOW_CONTROL_BACKGROUND, |
127 "theme_window_control_background"}, | 126 "theme_window_control_background"}, |
128 | 127 |
129 // The rest of these entries have no key because they can't be overridden | 128 // The rest of these entries have no key because they can't be overridden |
130 // from the json manifest. | 129 // from the json manifest. |
131 { 15, IDR_BACK, NULL }, | 130 { PRS_THEME_TAB_BACKGROUND, IDR_THEME_TAB_BACKGROUND, NULL }, |
132 { 16, IDR_BACK_D, NULL }, | 131 { PRS_THEME_TAB_BACKGROUND_INCOGNITO, |
133 { 17, IDR_BACK_H, NULL }, | 132 IDR_THEME_TAB_BACKGROUND_INCOGNITO, NULL }, |
134 { 18, IDR_BACK_P, NULL }, | 133 { 17, IDR_BACK, NULL }, |
135 { 19, IDR_FORWARD, NULL }, | 134 { 18, IDR_BACK_D, NULL }, |
136 { 20, IDR_FORWARD_D, NULL }, | 135 { 19, IDR_BACK_H, NULL }, |
137 { 21, IDR_FORWARD_H, NULL }, | 136 { 20, IDR_BACK_P, NULL }, |
138 { 22, IDR_FORWARD_P, NULL }, | 137 { 21, IDR_FORWARD, NULL }, |
139 { 23, IDR_HOME, NULL }, | 138 { 22, IDR_FORWARD_D, NULL }, |
140 { 24, IDR_HOME_H, NULL }, | 139 { 23, IDR_FORWARD_H, NULL }, |
141 { 25, IDR_HOME_P, NULL }, | 140 { 24, IDR_FORWARD_P, NULL }, |
142 { 26, IDR_RELOAD, NULL }, | 141 { 25, IDR_HOME, NULL }, |
143 { 27, IDR_RELOAD_H, NULL }, | 142 { 26, IDR_HOME_H, NULL }, |
144 { 28, IDR_RELOAD_P, NULL }, | 143 { 27, IDR_HOME_P, NULL }, |
145 { 29, IDR_STOP, NULL }, | 144 { 28, IDR_RELOAD, NULL }, |
146 { 30, IDR_STOP_D, NULL }, | 145 { 29, IDR_RELOAD_H, NULL }, |
147 { 31, IDR_STOP_H, NULL }, | 146 { 30, IDR_RELOAD_P, NULL }, |
148 { 32, IDR_STOP_P, NULL }, | 147 { 31, IDR_STOP, NULL }, |
149 { 33, IDR_BROWSER_ACTIONS_OVERFLOW, NULL }, | 148 { 32, IDR_STOP_D, NULL }, |
150 { 34, IDR_BROWSER_ACTIONS_OVERFLOW_H, NULL }, | 149 { 33, IDR_STOP_H, NULL }, |
151 { 35, IDR_BROWSER_ACTIONS_OVERFLOW_P, NULL }, | 150 { 34, IDR_STOP_P, NULL }, |
152 { 36, IDR_TOOLS, NULL }, | 151 { 35, IDR_BROWSER_ACTIONS_OVERFLOW, NULL }, |
153 { 37, IDR_TOOLS_H, NULL }, | 152 { 36, IDR_BROWSER_ACTIONS_OVERFLOW_H, NULL }, |
154 { 38, IDR_TOOLS_P, NULL }, | 153 { 37, IDR_BROWSER_ACTIONS_OVERFLOW_P, NULL }, |
155 { 39, IDR_MENU_DROPARROW, NULL }, | 154 { 38, IDR_TOOLS, NULL }, |
156 { 40, IDR_THROBBER, NULL }, | 155 { 39, IDR_TOOLS_H, NULL }, |
157 { 41, IDR_THROBBER_WAITING, NULL }, | 156 { 40, IDR_TOOLS_P, NULL }, |
158 { 42, IDR_THROBBER_LIGHT, NULL }, | 157 { 41, IDR_MENU_DROPARROW, NULL }, |
159 { 43, IDR_TOOLBAR_BEZEL_HOVER, NULL }, | 158 { 42, IDR_THROBBER, NULL }, |
160 { 44, IDR_TOOLBAR_BEZEL_PRESSED, NULL }, | 159 { 43, IDR_THROBBER_WAITING, NULL }, |
161 { 45, IDR_TOOLS_BAR, NULL }, | 160 { 44, IDR_THROBBER_LIGHT, NULL }, |
| 161 { 45, IDR_TOOLBAR_BEZEL_HOVER, NULL }, |
| 162 { 46, IDR_TOOLBAR_BEZEL_PRESSED, NULL }, |
| 163 { 47, IDR_TOOLS_BAR, NULL }, |
162 }; | 164 }; |
163 const size_t kPersistingImagesLength = arraysize(kPersistingImages); | 165 const size_t kPersistingImagesLength = arraysize(kPersistingImages); |
164 | 166 |
165 #if defined(OS_WIN) && defined(USE_AURA) | 167 #if defined(OS_WIN) && defined(USE_AURA) |
166 // Persistent theme ids for Windows AURA. | 168 // Persistent theme ids for Windows AURA. |
167 const int PRS_THEME_FRAME_WIN = 100; | 169 const int PRS_THEME_FRAME_WIN = 100; |
168 const int PRS_THEME_FRAME_INACTIVE_WIN = 101; | 170 const int PRS_THEME_FRAME_INACTIVE_WIN = 101; |
169 const int PRS_THEME_FRAME_INCOGNITO_WIN = 102; | 171 const int PRS_THEME_FRAME_INCOGNITO_WIN = 102; |
170 const int PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN = 103; | 172 const int PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN = 103; |
171 const int PRS_THEME_TOOLBAR_WIN = 104; | 173 const int PRS_THEME_TOOLBAR_WIN = 104; |
172 const int PRS_THEME_TAB_BACKGROUND_WIN = 105; | 174 const int PRS_THEME_TAB_BACKGROUND_OVERLAY_WIN = 105; |
173 const int PRS_THEME_TAB_BACKGROUND_INCOGNITO_WIN = 106; | 175 const int PRS_THEME_TAB_BACKGROUND_INCOGNITO_OVERLAY_WIN = 106; |
| 176 const int PRS_THEME_TAB_BACKGROUND_WIN = 107; |
| 177 const int PRS_THEME_TAB_BACKGROUND_INCOGNITO_WIN = 108; |
174 | 178 |
175 // Persistent theme to resource id mapping for Windows AURA. | 179 // Persistent theme to resource id mapping for Windows AURA. |
176 PersistingImagesTable kPersistingImagesWinDesktopAura[] = { | 180 PersistingImagesTable kPersistingImagesWinDesktopAura[] = { |
177 { PRS_THEME_FRAME_WIN, IDR_THEME_FRAME_WIN, | 181 { PRS_THEME_FRAME_WIN, IDR_THEME_FRAME_WIN, |
178 "theme_frame" }, | 182 "theme_frame" }, |
179 { PRS_THEME_FRAME_INACTIVE_WIN, IDR_THEME_FRAME_INACTIVE_WIN, | 183 { PRS_THEME_FRAME_INACTIVE_WIN, IDR_THEME_FRAME_INACTIVE_WIN, |
180 "theme_frame_inactive" }, | 184 "theme_frame_inactive" }, |
181 { PRS_THEME_FRAME_INCOGNITO_WIN, IDR_THEME_FRAME_INCOGNITO_WIN, | 185 { PRS_THEME_FRAME_INCOGNITO_WIN, IDR_THEME_FRAME_INCOGNITO_WIN, |
182 "theme_frame_incognito" }, | 186 "theme_frame_incognito" }, |
183 { PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN, | 187 { PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN, |
184 IDR_THEME_FRAME_INCOGNITO_INACTIVE_WIN, | 188 IDR_THEME_FRAME_INCOGNITO_INACTIVE_WIN, |
185 "theme_frame_incognito_inactive" }, | 189 "theme_frame_incognito_inactive" }, |
186 { PRS_THEME_TOOLBAR_WIN, IDR_THEME_TOOLBAR_WIN, | 190 { PRS_THEME_TOOLBAR_WIN, IDR_THEME_TOOLBAR_WIN, |
187 "theme_toolbar" }, | 191 "theme_toolbar" }, |
188 { PRS_THEME_TAB_BACKGROUND_WIN, IDR_THEME_TAB_BACKGROUND_WIN, | 192 { PRS_THEME_TAB_BACKGROUND_OVERLAY_WIN, IDR_THEME_TAB_BACKGROUND_OVERLAY_WIN, |
189 "theme_tab_background" }, | 193 "theme_tab_background" }, |
190 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_WIN, | 194 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_OVERLAY_WIN, |
191 IDR_THEME_TAB_BACKGROUND_INCOGNITO_WIN, | 195 IDR_THEME_TAB_BACKGROUND_INCOGNITO_OVERLAY_WIN, |
192 "theme_tab_background_incognito" }, | 196 "theme_tab_background_incognito" }, |
193 }; | 197 }; |
194 const size_t kPersistingImagesWinDesktopAuraLength = | 198 const size_t kPersistingImagesWinDesktopAuraLength = |
195 arraysize(kPersistingImagesWinDesktopAura); | 199 arraysize(kPersistingImagesWinDesktopAura); |
196 #endif | 200 #endif |
197 | 201 |
198 int GetPersistentIDByNameHelper(const std::string& key, | 202 int GetPersistentIDByNameHelper(const std::string& key, |
199 const PersistingImagesTable* image_table, | 203 const PersistingImagesTable* image_table, |
200 size_t image_table_size) { | 204 size_t image_table_size) { |
201 for (size_t i = 0; i < image_table_size; ++i) { | 205 for (size_t i = 0; i < image_table_size; ++i) { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE }, | 347 ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE }, |
344 #if defined(OS_WIN) && defined(USE_AURA) | 348 #if defined(OS_WIN) && defined(USE_AURA) |
345 { PRS_THEME_FRAME_WIN, ThemeProperties::TINT_FRAME }, | 349 { PRS_THEME_FRAME_WIN, ThemeProperties::TINT_FRAME }, |
346 { PRS_THEME_FRAME_INACTIVE_WIN, ThemeProperties::TINT_FRAME_INACTIVE }, | 350 { PRS_THEME_FRAME_INACTIVE_WIN, ThemeProperties::TINT_FRAME_INACTIVE }, |
347 { PRS_THEME_FRAME_INCOGNITO_WIN, ThemeProperties::TINT_FRAME_INCOGNITO }, | 351 { PRS_THEME_FRAME_INCOGNITO_WIN, ThemeProperties::TINT_FRAME_INCOGNITO }, |
348 { PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN, | 352 { PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN, |
349 ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE }, | 353 ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE }, |
350 #endif | 354 #endif |
351 }; | 355 }; |
352 | 356 |
353 // Mapping used in GenerateTabBackgroundImages() to associate what frame image | 357 // Mapping used in CreateTabBackgroundImages() to associate what frame image |
354 // goes with which tab background. | 358 // goes with which tab background. |
355 IntToIntTable kTabBackgroundMap[] = { | 359 IntToIntTable kTabBackgroundMap[] = { |
356 { PRS_THEME_TAB_BACKGROUND, PRS_THEME_FRAME }, | 360 { PRS_THEME_TAB_BACKGROUND, PRS_THEME_FRAME }, |
357 { PRS_THEME_TAB_BACKGROUND_INCOGNITO, PRS_THEME_FRAME_INCOGNITO }, | 361 { PRS_THEME_TAB_BACKGROUND_INCOGNITO, PRS_THEME_FRAME_INCOGNITO }, |
358 #if defined(OS_WIN) && defined(USE_AURA) | 362 #if defined(OS_WIN) && defined(USE_AURA) |
359 { PRS_THEME_TAB_BACKGROUND_WIN, PRS_THEME_FRAME_WIN }, | 363 { PRS_THEME_TAB_BACKGROUND_WIN, PRS_THEME_FRAME_WIN }, |
360 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_WIN, PRS_THEME_FRAME_INCOGNITO_WIN }, | 364 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_WIN, PRS_THEME_FRAME_INCOGNITO_WIN }, |
361 #endif | 365 #endif |
362 }; | 366 }; |
363 | 367 |
| 368 // The tab background overlay images. For the sake of simplicity, these images |
| 369 // are resized to have the exact height listed in |kImagesToCrop|. |
| 370 int kTabBackgroundOverlayImages[] = { |
| 371 PRS_THEME_TAB_BACKGROUND_OVERLAY, |
| 372 PRS_THEME_TAB_BACKGROUND_INCOGNITO_OVERLAY, |
| 373 #if defined(OS_WIN) && defined(USE_AURA) |
| 374 PRS_THEME_TAB_BACKGROUND_OVERLAY_WIN, |
| 375 PRS_THEME_TAB_BACKGROUND_INCOGNITO_OVERLAY_WIN |
| 376 #endif |
| 377 }; |
| 378 |
364 struct CropEntry { | 379 struct CropEntry { |
365 int prs_id; | 380 int prs_id; |
366 | 381 |
367 // The maximum useful height of the image at |prs_id|. | 382 // The maximum useful height of the image at |prs_id|. |
368 int max_height; | 383 int max_height; |
369 | 384 |
370 // Whether cropping the image at |prs_id| should be skipped on OSes which | 385 // Whether cropping the image at |prs_id| should be skipped on OSes which |
371 // have a frame border to the left and right of the web contents. | 386 // have a frame border to the left and right of the web contents. |
372 // This should be true for images which can be used to decorate the border to | 387 // This should be true for images which can be used to decorate the border to |
373 // the left and the right of the web contents. | 388 // the left and the right of the web contents. |
374 bool skip_if_frame_border; | 389 bool skip_if_frame_border; |
375 }; | 390 }; |
376 | 391 |
377 // The images which should be cropped before being saved to the data pack. The | 392 // The images which should be cropped before being saved to the data pack. The |
378 // maximum heights are meant to be conservative as to give room for the UI to | 393 // maximum heights are meant to be conservative as to give room for the UI to |
379 // change without the maximum heights having to be modified. | 394 // change without the maximum heights having to be modified. |
380 // |kThemePackVersion| must be incremented if any of the maximum heights below | 395 // |kThemePackVersion| must be incremented if any of the maximum heights below |
381 // are modified. | 396 // are modified. |
382 struct CropEntry kImagesToCrop[] = { | 397 CropEntry kImagesToCrop[] = { |
383 { PRS_THEME_FRAME, 120, true }, | 398 { PRS_THEME_FRAME, 120, true }, |
384 { PRS_THEME_FRAME_INACTIVE, 120, true }, | 399 { PRS_THEME_FRAME_INACTIVE, 120, true }, |
385 { PRS_THEME_FRAME_INCOGNITO, 120, true }, | 400 { PRS_THEME_FRAME_INCOGNITO, 120, true }, |
386 { PRS_THEME_FRAME_INCOGNITO_INACTIVE, 120, true }, | 401 { PRS_THEME_FRAME_INCOGNITO_INACTIVE, 120, true }, |
387 { PRS_THEME_FRAME_OVERLAY, 120, true }, | 402 { PRS_THEME_FRAME_OVERLAY, 120, true }, |
388 { PRS_THEME_FRAME_OVERLAY_INACTIVE, 120, true }, | 403 { PRS_THEME_FRAME_OVERLAY_INACTIVE, 120, true }, |
389 { PRS_THEME_TOOLBAR, 200, false }, | 404 { PRS_THEME_TOOLBAR, 200, false }, |
| 405 { PRS_THEME_TAB_BACKGROUND_OVERLAY, 120, false }, |
| 406 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_OVERLAY, 120, false }, |
| 407 { PRS_THEME_TAB_BACKGROUND_V_OVERLAY, 120, false }, |
| 408 { PRS_THEME_TAB_BACKGROUND, 120, false }, |
| 409 { PRS_THEME_TAB_BACKGROUND_INCOGNITO, 120, false }, |
390 { PRS_THEME_BUTTON_BACKGROUND, 60, false }, | 410 { PRS_THEME_BUTTON_BACKGROUND, 60, false }, |
391 { PRS_THEME_WINDOW_CONTROL_BACKGROUND, 50, false }, | 411 { PRS_THEME_WINDOW_CONTROL_BACKGROUND, 50, false }, |
392 #if defined(OS_WIN) && defined(USE_AURA) | 412 #if defined(OS_WIN) && defined(USE_AURA) |
393 { PRS_THEME_TOOLBAR_WIN, 200, false } | 413 { PRS_THEME_TOOLBAR_WIN, 200, false }, |
| 414 { PRS_THEME_TAB_BACKGROUND_OVERLAY_WIN, 120, false }, |
| 415 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_OVERLAY_WIN, 120, false }, |
| 416 { PRS_THEME_TAB_BACKGROUND_WIN, 120, false }, |
| 417 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_WIN, 120, false } |
394 #endif | 418 #endif |
395 }; | 419 }; |
396 | 420 |
397 | |
398 // A list of images that don't need tinting or any other modification and can | 421 // A list of images that don't need tinting or any other modification and can |
399 // be byte-copied directly into the finished DataPack. This should contain the | 422 // be byte-copied directly into the finished DataPack. This should contain the |
400 // persistent IDs for all themeable image IDs that aren't in kFrameTintMap, | 423 // persistent IDs for all themeable image IDs that aren't in kFrameTintMap, |
401 // kTabBackgroundMap or kImagesToCrop. | 424 // kTabBackgroundMap or kImagesToCrop. |
402 const int kPreloadIDs[] = { | 425 const int kPreloadIDs[] = { |
403 PRS_THEME_NTP_BACKGROUND, | 426 PRS_THEME_NTP_BACKGROUND, |
404 PRS_THEME_NTP_ATTRIBUTION, | 427 PRS_THEME_NTP_ATTRIBUTION, |
405 }; | 428 }; |
406 | 429 |
407 // Returns true if this OS uses a browser frame which has a non zero width to | 430 // Returns true if this OS uses a browser frame which has a non zero width to |
(...skipping 20 matching lines...) Expand all Loading... |
428 char* data = reinterpret_cast<char*>(&(raw_data.front())); | 451 char* data = reinterpret_cast<char*>(&(raw_data.front())); |
429 if (file.ReadUntilComplete(data, size) == avail) | 452 if (file.ReadUntilComplete(data, size) == avail) |
430 return base::RefCountedBytes::TakeVector(&raw_data); | 453 return base::RefCountedBytes::TakeVector(&raw_data); |
431 } | 454 } |
432 } | 455 } |
433 } | 456 } |
434 | 457 |
435 return NULL; | 458 return NULL; |
436 } | 459 } |
437 | 460 |
438 // Shifts an image's HSL values. The caller is responsible for deleting | 461 // Returns the maximum height for |prs_id|. Returns -1 if there is no maximum |
439 // the returned image. | 462 // height. |
440 gfx::Image CreateHSLShiftedImage(const gfx::Image& image, | 463 int GetMaxHeight(int prs_id) { |
441 const color_utils::HSL& hsl_shift) { | 464 for (size_t i = 0; i < arraysize(kImagesToCrop); ++i) { |
442 const gfx::ImageSkia* src_image = image.ToImageSkia(); | 465 if (kImagesToCrop[i].prs_id != prs_id) |
| 466 continue; |
| 467 |
| 468 if (HasFrameBorder() && kImagesToCrop[i].skip_if_frame_border) |
| 469 return -1; |
| 470 return kImagesToCrop[i].max_height; |
| 471 } |
| 472 return -1; |
| 473 } |
| 474 |
| 475 // Returns an image which is cropped based on the maximum height for |
| 476 // |destination_prs_id|. This method is a no-op if no cropping is necessary. |
| 477 gfx::Image CreateCroppedImage(const gfx::Image& source_image, |
| 478 int destination_prs_id) { |
| 479 int crop_height = GetMaxHeight(destination_prs_id); |
| 480 if (crop_height < 0) |
| 481 return source_image; |
| 482 |
| 483 gfx::ImageSkia image_skia = source_image.AsImageSkia(); |
| 484 return gfx::Image(gfx::ImageSkiaOperations::ExtractSubset( |
| 485 image_skia, gfx::Rect(0, 0, image_skia.width(), crop_height))); |
| 486 } |
| 487 |
| 488 // Retuns an image which is cropped based on the maximum height for |
| 489 // |destination_prs_id| and which is shifted by |hsl_shift|. |
| 490 gfx::Image CreateHSLShiftedAndCroppedImage(const gfx::Image& image, |
| 491 const color_utils::HSL& hsl_shift, |
| 492 int destination_prs_id) { |
| 493 gfx::Image cropped = CreateCroppedImage(image, destination_prs_id); |
443 return gfx::Image(gfx::ImageSkiaOperations::CreateHSLShiftedImage( | 494 return gfx::Image(gfx::ImageSkiaOperations::CreateHSLShiftedImage( |
444 *src_image, hsl_shift)); | 495 cropped.AsImageSkia(), hsl_shift)); |
445 } | 496 } |
446 | 497 |
447 // Computes a bitmap at one scale from a bitmap at a different scale. | 498 // Computes a bitmap at one scale from a bitmap at a different scale. |
448 SkBitmap CreateLowQualityResizedBitmap(const SkBitmap& source_bitmap, | 499 SkBitmap CreateLowQualityResizedBitmap(const SkBitmap& source_bitmap, |
449 ui::ScaleFactor source_scale_factor, | 500 ui::ScaleFactor source_scale_factor, |
450 ui::ScaleFactor desired_scale_factor) { | 501 ui::ScaleFactor desired_scale_factor) { |
451 gfx::Size scaled_size = gfx::ToCeiledSize( | 502 gfx::Size scaled_size = gfx::ToCeiledSize( |
452 gfx::ScaleSize(gfx::Size(source_bitmap.width(), | 503 gfx::ScaleSize(gfx::Size(source_bitmap.width(), |
453 source_bitmap.height()), | 504 source_bitmap.height()), |
454 ui::GetScaleFactorScale(desired_scale_factor) / | 505 ui::GetScaleFactorScale(desired_scale_factor) / |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 } | 625 } |
575 | 626 |
576 PngMap png_map_; | 627 PngMap png_map_; |
577 | 628 |
578 typedef std::map<ui::ScaleFactor, SkBitmap> BitmapMap; | 629 typedef std::map<ui::ScaleFactor, SkBitmap> BitmapMap; |
579 BitmapMap bitmap_map_; | 630 BitmapMap bitmap_map_; |
580 | 631 |
581 DISALLOW_COPY_AND_ASSIGN(ThemeImagePngSource); | 632 DISALLOW_COPY_AND_ASSIGN(ThemeImagePngSource); |
582 }; | 633 }; |
583 | 634 |
584 class TabBackgroundImageSource: public gfx::CanvasImageSource { | 635 // ImageSkiaSource which resizes |image| to |size| by padding |image| with |
| 636 // transparent pixels. |
| 637 class PadWithTransparentImageSource : public gfx::CanvasImageSource { |
585 public: | 638 public: |
586 TabBackgroundImageSource(const gfx::ImageSkia& image_to_tint, | 639 PadWithTransparentImageSource(const gfx::ImageSkia& image, |
587 const gfx::ImageSkia& overlay, | 640 const gfx::Size& size) |
588 const color_utils::HSL& hsl_shift, | 641 : gfx::CanvasImageSource(size, false), |
589 int vertical_offset) | 642 image_(image) { |
590 : gfx::CanvasImageSource(image_to_tint.size(), false), | |
591 image_to_tint_(image_to_tint), | |
592 overlay_(overlay), | |
593 hsl_shift_(hsl_shift), | |
594 vertical_offset_(vertical_offset) { | |
595 } | 643 } |
596 | 644 virtual ~PadWithTransparentImageSource() { |
597 virtual ~TabBackgroundImageSource() { | |
598 } | |
599 | |
600 // Overridden from CanvasImageSource: | |
601 virtual void Draw(gfx::Canvas* canvas) OVERRIDE { | |
602 gfx::ImageSkia bg_tint = | |
603 gfx::ImageSkiaOperations::CreateHSLShiftedImage(image_to_tint_, | |
604 hsl_shift_); | |
605 canvas->TileImageInt(bg_tint, 0, vertical_offset_, 0, 0, | |
606 size().width(), size().height()); | |
607 | |
608 // If they've provided a custom image, overlay it. | |
609 if (!overlay_.isNull()) { | |
610 canvas->TileImageInt(overlay_, 0, 0, size().width(), | |
611 overlay_.height()); | |
612 } | |
613 } | 645 } |
614 | 646 |
615 private: | 647 private: |
616 const gfx::ImageSkia image_to_tint_; | 648 // Overridden from CanvasImageSource: |
617 const gfx::ImageSkia overlay_; | 649 virtual void Draw(gfx::Canvas* canvas) OVERRIDE { |
618 const color_utils::HSL hsl_shift_; | 650 canvas->DrawImageInt(image_, 0, 0); |
619 const int vertical_offset_; | 651 } |
620 | 652 |
621 DISALLOW_COPY_AND_ASSIGN(TabBackgroundImageSource); | 653 const gfx::ImageSkia image_; |
| 654 |
| 655 DISALLOW_COPY_AND_ASSIGN(PadWithTransparentImageSource); |
622 }; | 656 }; |
623 | 657 |
624 } // namespace | 658 } // namespace |
625 | 659 |
626 BrowserThemePack::~BrowserThemePack() { | 660 BrowserThemePack::~BrowserThemePack() { |
627 if (!data_pack_.get()) { | 661 if (!data_pack_.get()) { |
628 delete header_; | 662 delete header_; |
629 delete [] tints_; | 663 delete [] tints_; |
630 delete [] colors_; | 664 delete [] colors_; |
631 delete [] display_properties_; | 665 delete [] display_properties_; |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 } | 1333 } |
1300 | 1334 |
1301 void BrowserThemePack::CreateImages(ImageCache* images) const { | 1335 void BrowserThemePack::CreateImages(ImageCache* images) const { |
1302 CropImages(images); | 1336 CropImages(images); |
1303 CreateFrameImages(images); | 1337 CreateFrameImages(images); |
1304 CreateTintedButtons(GetTintInternal(ThemeProperties::TINT_BUTTONS), images); | 1338 CreateTintedButtons(GetTintInternal(ThemeProperties::TINT_BUTTONS), images); |
1305 CreateTabBackgroundImages(images); | 1339 CreateTabBackgroundImages(images); |
1306 } | 1340 } |
1307 | 1341 |
1308 void BrowserThemePack::CropImages(ImageCache* images) const { | 1342 void BrowserThemePack::CropImages(ImageCache* images) const { |
1309 bool has_frame_border = HasFrameBorder(); | 1343 ImageCache temp_output; |
1310 for (size_t i = 0; i < arraysize(kImagesToCrop); ++i) { | 1344 for (ImageCache::const_iterator it = images->begin(); |
1311 if (has_frame_border && kImagesToCrop[i].skip_if_frame_border) | 1345 it != images->end(); ++it) { |
1312 continue; | 1346 temp_output[it->first] = CreateCroppedImage(it->second, it->first); |
1313 | |
1314 int prs_id = kImagesToCrop[i].prs_id; | |
1315 ImageCache::iterator it = images->find(prs_id); | |
1316 if (it == images->end()) | |
1317 continue; | |
1318 | |
1319 int crop_height = kImagesToCrop[i].max_height; | |
1320 gfx::ImageSkia image_skia = it->second.AsImageSkia(); | |
1321 (*images)[prs_id] = gfx::Image(gfx::ImageSkiaOperations::ExtractSubset( | |
1322 image_skia, gfx::Rect(0, 0, image_skia.width(), crop_height))); | |
1323 } | 1347 } |
| 1348 MergeImageCaches(temp_output, images); |
1324 } | 1349 } |
1325 | 1350 |
1326 void BrowserThemePack::CreateFrameImages(ImageCache* images) const { | 1351 void BrowserThemePack::CreateFrameImages(ImageCache* images) const { |
1327 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1352 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
1328 | 1353 |
1329 // Create all the output images in a separate cache and move them back into | 1354 // Create all the output images in a separate cache and move them back into |
1330 // the input images because there can be name collisions. | 1355 // the input images because there can be name collisions. |
1331 ImageCache temp_output; | 1356 ImageCache temp_output; |
1332 | 1357 |
1333 for (size_t i = 0; i < arraysize(kFrameTintMap); ++i) { | 1358 for (size_t i = 0; i < arraysize(kFrameTintMap); ++i) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 // the default frame. | 1409 // the default frame. |
1385 frame = rb.GetImageNamed(IDR_THEME_FRAME); | 1410 frame = rb.GetImageNamed(IDR_THEME_FRAME); |
1386 #if defined(OS_WIN) && defined(USE_AURA) | 1411 #if defined(OS_WIN) && defined(USE_AURA) |
1387 if (prs_id >= PRS_THEME_FRAME_WIN && | 1412 if (prs_id >= PRS_THEME_FRAME_WIN && |
1388 prs_id <= PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN) { | 1413 prs_id <= PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN) { |
1389 frame = rb.GetImageNamed(IDR_THEME_FRAME_WIN); | 1414 frame = rb.GetImageNamed(IDR_THEME_FRAME_WIN); |
1390 } | 1415 } |
1391 #endif | 1416 #endif |
1392 } | 1417 } |
1393 if (!frame.IsEmpty()) { | 1418 if (!frame.IsEmpty()) { |
1394 temp_output[prs_id] = CreateHSLShiftedImage( | 1419 temp_output[prs_id] = CreateHSLShiftedAndCroppedImage( |
1395 frame, GetTintInternal(kFrameTintMap[i].value)); | 1420 frame, GetTintInternal(kFrameTintMap[i].value), prs_id); |
1396 } | 1421 } |
1397 } | 1422 } |
1398 MergeImageCaches(temp_output, images); | 1423 MergeImageCaches(temp_output, images); |
1399 } | 1424 } |
1400 | 1425 |
1401 void BrowserThemePack::CreateTintedButtons( | 1426 void BrowserThemePack::CreateTintedButtons( |
1402 const color_utils::HSL& button_tint, | 1427 const color_utils::HSL& button_tint, |
1403 ImageCache* processed_images) const { | 1428 ImageCache* processed_images) const { |
1404 if (button_tint.h != -1 || button_tint.s != -1 || button_tint.l != -1) { | 1429 if (button_tint.h != -1 || button_tint.s != -1 || button_tint.l != -1) { |
1405 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1430 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
1406 const std::set<int>& idr_ids = | 1431 const std::set<int>& idr_ids = |
1407 ThemeProperties::GetTintableToolbarButtons(); | 1432 ThemeProperties::GetTintableToolbarButtons(); |
1408 for (std::set<int>::const_iterator it = idr_ids.begin(); | 1433 for (std::set<int>::const_iterator it = idr_ids.begin(); |
1409 it != idr_ids.end(); ++it) { | 1434 it != idr_ids.end(); ++it) { |
1410 int prs_id = GetPersistentIDByIDR(*it); | 1435 int prs_id = GetPersistentIDByIDR(*it); |
1411 DCHECK(prs_id > 0); | 1436 DCHECK(prs_id > 0); |
1412 | 1437 |
1413 // Fetch the image by IDR... | 1438 // Fetch the image by IDR... |
1414 gfx::Image& button = rb.GetImageNamed(*it); | 1439 gfx::Image& button = rb.GetImageNamed(*it); |
1415 | 1440 |
1416 // but save a version with the persistent ID. | 1441 // but save a version with the persistent ID. |
1417 (*processed_images)[prs_id] = | 1442 (*processed_images)[prs_id] = |
1418 CreateHSLShiftedImage(button, button_tint); | 1443 CreateHSLShiftedAndCroppedImage(button, button_tint, prs_id); |
1419 } | 1444 } |
1420 } | 1445 } |
1421 } | 1446 } |
1422 | 1447 |
1423 void BrowserThemePack::CreateTabBackgroundImages(ImageCache* images) const { | 1448 void BrowserThemePack::CreateTabBackgroundImages(ImageCache* images) const { |
1424 ImageCache temp_output; | 1449 ImageCache temp_output; |
1425 for (size_t i = 0; i < arraysize(kTabBackgroundMap); ++i) { | 1450 for (size_t i = 0; i < arraysize(kTabBackgroundMap); ++i) { |
1426 int prs_id = kTabBackgroundMap[i].key; | 1451 int prs_frame_id = kTabBackgroundMap[i].value; |
1427 int prs_base_id = kTabBackgroundMap[i].value; | 1452 ImageCache::const_iterator frame_it = images->find(prs_frame_id); |
| 1453 if (frame_it == images->end()) { |
| 1454 // There is no image to tint. |
| 1455 continue; |
| 1456 } |
1428 | 1457 |
1429 // We only need to generate the background tab images if we were provided | 1458 int prs_dest_id = kTabBackgroundMap[i].key; |
1430 // with a PRS_THEME_FRAME. | 1459 color_utils::HSL tint = GetTintInternal( |
1431 ImageCache::const_iterator it = images->find(prs_base_id); | 1460 ThemeProperties::TINT_BACKGROUND_TAB); |
1432 if (it != images->end()) { | 1461 temp_output[prs_dest_id] = CreateHSLShiftedAndCroppedImage( |
1433 gfx::ImageSkia image_to_tint = (it->second).AsImageSkia(); | 1462 frame_it->second, tint, prs_dest_id); |
1434 color_utils::HSL hsl_shift = GetTintInternal( | 1463 } |
1435 ThemeProperties::TINT_BACKGROUND_TAB); | |
1436 int vertical_offset = images->count(prs_id) | |
1437 ? kRestoredTabVerticalOffset : 0; | |
1438 | 1464 |
1439 gfx::ImageSkia overlay; | 1465 // The tab background overlay images are tiled horizontally but not |
1440 ImageCache::const_iterator overlay_it = images->find(prs_id); | 1466 // vertically. We have always done it this way. Pad the overlay images |
1441 if (overlay_it != images->end()) | 1467 // with enough transparent pixels so that they do not get tiled vertically |
1442 overlay = overlay_it->second.AsImageSkia(); | 1468 // to simplify the code which deals with the tab background overlay images. |
| 1469 // TODO: Investigate if any themes rely on the vertical tiling behavior. |
| 1470 for (size_t i = 0; i < arraysize(kTabBackgroundOverlayImages); ++i) { |
| 1471 int prs_overlay_id = kTabBackgroundOverlayImages[i]; |
| 1472 ImageCache::const_iterator overlay_it = images->find(prs_overlay_id); |
| 1473 if (overlay_it == images->end()) |
| 1474 continue; |
1443 | 1475 |
1444 gfx::ImageSkiaSource* source = new TabBackgroundImageSource( | 1476 int desired_height = GetMaxHeight(prs_overlay_id); |
1445 image_to_tint, overlay, hsl_shift, vertical_offset); | 1477 gfx::ImageSkia overlay = overlay_it->second.AsImageSkia(); |
1446 // ImageSkia takes ownership of |source|. | 1478 if (overlay.height() == desired_height) |
1447 temp_output[prs_id] = gfx::Image(gfx::ImageSkia(source, | 1479 continue; |
1448 image_to_tint.size())); | 1480 |
1449 } | 1481 // The ImageSkia takes ownership of |source|. |
| 1482 PadWithTransparentImageSource* source = new PadWithTransparentImageSource( |
| 1483 overlay, gfx::Size(overlay.width(), desired_height)); |
| 1484 temp_output[prs_overlay_id] = gfx::Image(gfx::ImageSkia( |
| 1485 source, source->size())); |
1450 } | 1486 } |
1451 MergeImageCaches(temp_output, images); | 1487 MergeImageCaches(temp_output, images); |
1452 } | 1488 } |
1453 | 1489 |
1454 void BrowserThemePack::RepackImages(const ImageCache& images, | 1490 void BrowserThemePack::RepackImages(const ImageCache& images, |
1455 RawImages* reencoded_images) const { | 1491 RawImages* reencoded_images) const { |
1456 typedef std::vector<ui::ScaleFactor> ScaleFactors; | 1492 typedef std::vector<ui::ScaleFactor> ScaleFactors; |
1457 for (ImageCache::const_iterator it = images.begin(); | 1493 for (ImageCache::const_iterator it = images.begin(); |
1458 it != images.end(); ++it) { | 1494 it != images.end(); ++it) { |
1459 gfx::ImageSkia image_skia = *it->second.ToImageSkia(); | 1495 gfx::ImageSkia image_skia = *it->second.ToImageSkia(); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 false, | 1640 false, |
1605 &bitmap_data)) { | 1641 &bitmap_data)) { |
1606 NOTREACHED() << "Unable to encode theme image for prs_id=" | 1642 NOTREACHED() << "Unable to encode theme image for prs_id=" |
1607 << prs_id << " for scale_factor=" << scale_factors_[i]; | 1643 << prs_id << " for scale_factor=" << scale_factors_[i]; |
1608 break; | 1644 break; |
1609 } | 1645 } |
1610 image_memory_[scaled_raw_id] = | 1646 image_memory_[scaled_raw_id] = |
1611 base::RefCountedBytes::TakeVector(&bitmap_data); | 1647 base::RefCountedBytes::TakeVector(&bitmap_data); |
1612 } | 1648 } |
1613 } | 1649 } |
OLD | NEW |