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