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/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.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 = 34; | 46 const int kThemePackVersion = 33; |
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; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 { 39, IDR_MENU_DROPARROW, NULL }, | 155 { 39, IDR_MENU_DROPARROW, NULL }, |
156 { 40, IDR_THROBBER, NULL }, | 156 { 40, IDR_THROBBER, NULL }, |
157 { 41, IDR_THROBBER_WAITING, NULL }, | 157 { 41, IDR_THROBBER_WAITING, NULL }, |
158 { 42, IDR_THROBBER_LIGHT, NULL }, | 158 { 42, IDR_THROBBER_LIGHT, NULL }, |
159 { 43, IDR_TOOLBAR_BEZEL_HOVER, NULL }, | 159 { 43, IDR_TOOLBAR_BEZEL_HOVER, NULL }, |
160 { 44, IDR_TOOLBAR_BEZEL_PRESSED, NULL }, | 160 { 44, IDR_TOOLBAR_BEZEL_PRESSED, NULL }, |
161 { 45, IDR_TOOLS_BAR, NULL }, | 161 { 45, IDR_TOOLS_BAR, NULL }, |
162 }; | 162 }; |
163 const size_t kPersistingImagesLength = arraysize(kPersistingImages); | 163 const size_t kPersistingImagesLength = arraysize(kPersistingImages); |
164 | 164 |
165 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | 165 #if defined(OS_WIN) |
166 // Persistent theme ids for Windows. | 166 // Persistent theme ids for Windows. |
167 const int PRS_THEME_FRAME_DESKTOP = 100; | 167 const int PRS_THEME_FRAME_WIN = 100; |
168 const int PRS_THEME_FRAME_INACTIVE_DESKTOP = 101; | 168 const int PRS_THEME_FRAME_INACTIVE_WIN = 101; |
169 const int PRS_THEME_FRAME_INCOGNITO_DESKTOP = 102; | 169 const int PRS_THEME_FRAME_INCOGNITO_WIN = 102; |
170 const int PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP = 103; | 170 const int PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN = 103; |
171 const int PRS_THEME_TOOLBAR_DESKTOP = 104; | 171 const int PRS_THEME_TOOLBAR_WIN = 104; |
172 const int PRS_THEME_TAB_BACKGROUND_DESKTOP = 105; | 172 const int PRS_THEME_TAB_BACKGROUND_WIN = 105; |
173 const int PRS_THEME_TAB_BACKGROUND_INCOGNITO_DESKTOP = 106; | 173 const int PRS_THEME_TAB_BACKGROUND_INCOGNITO_WIN = 106; |
174 | 174 |
175 // Persistent theme to resource id mapping for Windows AURA. | 175 // Persistent theme to resource id mapping for Windows AURA. |
176 PersistingImagesTable kPersistingImagesDesktopAura[] = { | 176 PersistingImagesTable kPersistingImagesWinDesktopAura[] = { |
177 { PRS_THEME_FRAME_DESKTOP, IDR_THEME_FRAME_DESKTOP, | 177 { PRS_THEME_FRAME_WIN, IDR_THEME_FRAME_WIN, |
178 "theme_frame" }, | 178 "theme_frame" }, |
179 { PRS_THEME_FRAME_INACTIVE_DESKTOP, IDR_THEME_FRAME_INACTIVE_DESKTOP, | 179 { PRS_THEME_FRAME_INACTIVE_WIN, IDR_THEME_FRAME_INACTIVE_WIN, |
180 "theme_frame_inactive" }, | 180 "theme_frame_inactive" }, |
181 { PRS_THEME_FRAME_INCOGNITO_DESKTOP, IDR_THEME_FRAME_INCOGNITO_DESKTOP, | 181 { PRS_THEME_FRAME_INCOGNITO_WIN, IDR_THEME_FRAME_INCOGNITO_WIN, |
182 "theme_frame_incognito" }, | 182 "theme_frame_incognito" }, |
183 { PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP, | 183 { PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN, |
184 IDR_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP, | 184 IDR_THEME_FRAME_INCOGNITO_INACTIVE_WIN, |
185 "theme_frame_incognito_inactive" }, | 185 "theme_frame_incognito_inactive" }, |
186 { PRS_THEME_TOOLBAR_DESKTOP, IDR_THEME_TOOLBAR_DESKTOP, | 186 { PRS_THEME_TOOLBAR_WIN, IDR_THEME_TOOLBAR_WIN, |
187 "theme_toolbar" }, | 187 "theme_toolbar" }, |
188 { PRS_THEME_TAB_BACKGROUND_DESKTOP, IDR_THEME_TAB_BACKGROUND_DESKTOP, | 188 { PRS_THEME_TAB_BACKGROUND_WIN, IDR_THEME_TAB_BACKGROUND_WIN, |
189 "theme_tab_background" }, | 189 "theme_tab_background" }, |
190 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_DESKTOP, | 190 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_WIN, |
191 IDR_THEME_TAB_BACKGROUND_INCOGNITO_DESKTOP, | 191 IDR_THEME_TAB_BACKGROUND_INCOGNITO_WIN, |
192 "theme_tab_background_incognito" }, | 192 "theme_tab_background_incognito" }, |
193 }; | 193 }; |
194 const size_t kPersistingImagesDesktopAuraLength = | 194 const size_t kPersistingImagesWinDesktopAuraLength = |
195 arraysize(kPersistingImagesDesktopAura); | 195 arraysize(kPersistingImagesWinDesktopAura); |
196 #endif | 196 #endif |
197 | 197 |
198 int GetPersistentIDByNameHelper(const std::string& key, | 198 int GetPersistentIDByNameHelper(const std::string& key, |
199 const PersistingImagesTable* image_table, | 199 const PersistingImagesTable* image_table, |
200 size_t image_table_size) { | 200 size_t image_table_size) { |
201 for (size_t i = 0; i < image_table_size; ++i) { | 201 for (size_t i = 0; i < image_table_size; ++i) { |
202 if (image_table[i].key != NULL && | 202 if (image_table[i].key != NULL && |
203 base::strcasecmp(key.c_str(), image_table[i].key) == 0) { | 203 base::strcasecmp(key.c_str(), image_table[i].key) == 0) { |
204 return image_table[i].persistent_id; | 204 return image_table[i].persistent_id; |
205 } | 205 } |
206 } | 206 } |
207 return -1; | 207 return -1; |
208 } | 208 } |
209 | 209 |
210 int GetPersistentIDByName(const std::string& key) { | 210 int GetPersistentIDByName(const std::string& key) { |
211 return GetPersistentIDByNameHelper(key, | 211 return GetPersistentIDByNameHelper(key, |
212 kPersistingImages, | 212 kPersistingImages, |
213 kPersistingImagesLength); | 213 kPersistingImagesLength); |
214 } | 214 } |
215 | 215 |
216 int GetPersistentIDByIDR(int idr) { | 216 int GetPersistentIDByIDR(int idr) { |
217 static std::map<int,int>* lookup_table = new std::map<int,int>(); | 217 static std::map<int,int>* lookup_table = new std::map<int,int>(); |
218 if (lookup_table->empty()) { | 218 if (lookup_table->empty()) { |
219 for (size_t i = 0; i < kPersistingImagesLength; ++i) { | 219 for (size_t i = 0; i < kPersistingImagesLength; ++i) { |
220 int idr = kPersistingImages[i].idr_id; | 220 int idr = kPersistingImages[i].idr_id; |
221 int prs_id = kPersistingImages[i].persistent_id; | 221 int prs_id = kPersistingImages[i].persistent_id; |
222 (*lookup_table)[idr] = prs_id; | 222 (*lookup_table)[idr] = prs_id; |
223 } | 223 } |
224 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | 224 #if defined(OS_WIN) |
225 for (size_t i = 0; i < kPersistingImagesDesktopAuraLength; ++i) { | 225 for (size_t i = 0; i < kPersistingImagesWinDesktopAuraLength; ++i) { |
226 int idr = kPersistingImagesDesktopAura[i].idr_id; | 226 int idr = kPersistingImagesWinDesktopAura[i].idr_id; |
227 int prs_id = kPersistingImagesDesktopAura[i].persistent_id; | 227 int prs_id = kPersistingImagesWinDesktopAura[i].persistent_id; |
228 (*lookup_table)[idr] = prs_id; | 228 (*lookup_table)[idr] = prs_id; |
229 } | 229 } |
230 #endif | 230 #endif |
231 } | 231 } |
232 std::map<int,int>::iterator it = lookup_table->find(idr); | 232 std::map<int,int>::iterator it = lookup_table->find(idr); |
233 return (it == lookup_table->end()) ? -1 : it->second; | 233 return (it == lookup_table->end()) ? -1 : it->second; |
234 } | 234 } |
235 | 235 |
236 // Returns true if the scales in |input| match those in |expected|. | 236 // Returns true if the scales in |input| match those in |expected|. |
237 // The order must match as the index is used in determining the raw id. | 237 // The order must match as the index is used in determining the raw id. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 // tint ID that should maybe be applied to it. | 334 // tint ID that should maybe be applied to it. |
335 IntToIntTable kFrameTintMap[] = { | 335 IntToIntTable kFrameTintMap[] = { |
336 { PRS_THEME_FRAME, ThemeProperties::TINT_FRAME }, | 336 { PRS_THEME_FRAME, ThemeProperties::TINT_FRAME }, |
337 { PRS_THEME_FRAME_INACTIVE, ThemeProperties::TINT_FRAME_INACTIVE }, | 337 { PRS_THEME_FRAME_INACTIVE, ThemeProperties::TINT_FRAME_INACTIVE }, |
338 { PRS_THEME_FRAME_OVERLAY, ThemeProperties::TINT_FRAME }, | 338 { PRS_THEME_FRAME_OVERLAY, ThemeProperties::TINT_FRAME }, |
339 { PRS_THEME_FRAME_OVERLAY_INACTIVE, | 339 { PRS_THEME_FRAME_OVERLAY_INACTIVE, |
340 ThemeProperties::TINT_FRAME_INACTIVE }, | 340 ThemeProperties::TINT_FRAME_INACTIVE }, |
341 { PRS_THEME_FRAME_INCOGNITO, ThemeProperties::TINT_FRAME_INCOGNITO }, | 341 { PRS_THEME_FRAME_INCOGNITO, ThemeProperties::TINT_FRAME_INCOGNITO }, |
342 { PRS_THEME_FRAME_INCOGNITO_INACTIVE, | 342 { PRS_THEME_FRAME_INCOGNITO_INACTIVE, |
343 ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE }, | 343 ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE }, |
344 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | 344 #if defined(OS_WIN) |
345 { PRS_THEME_FRAME_DESKTOP, ThemeProperties::TINT_FRAME }, | 345 { PRS_THEME_FRAME_WIN, ThemeProperties::TINT_FRAME }, |
346 { PRS_THEME_FRAME_INACTIVE_DESKTOP, ThemeProperties::TINT_FRAME_INACTIVE }, | 346 { PRS_THEME_FRAME_INACTIVE_WIN, ThemeProperties::TINT_FRAME_INACTIVE }, |
347 { PRS_THEME_FRAME_INCOGNITO_DESKTOP, ThemeProperties::TINT_FRAME_INCOGNITO }, | 347 { PRS_THEME_FRAME_INCOGNITO_WIN, ThemeProperties::TINT_FRAME_INCOGNITO }, |
348 { PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP, | 348 { PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN, |
349 ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE }, | 349 ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE }, |
350 #endif | 350 #endif |
351 }; | 351 }; |
352 | 352 |
353 // Mapping used in GenerateTabBackgroundImages() to associate what frame image | 353 // Mapping used in GenerateTabBackgroundImages() to associate what frame image |
354 // goes with which tab background. | 354 // goes with which tab background. |
355 IntToIntTable kTabBackgroundMap[] = { | 355 IntToIntTable kTabBackgroundMap[] = { |
356 { PRS_THEME_TAB_BACKGROUND, PRS_THEME_FRAME }, | 356 { PRS_THEME_TAB_BACKGROUND, PRS_THEME_FRAME }, |
357 { PRS_THEME_TAB_BACKGROUND_INCOGNITO, PRS_THEME_FRAME_INCOGNITO }, | 357 { PRS_THEME_TAB_BACKGROUND_INCOGNITO, PRS_THEME_FRAME_INCOGNITO }, |
358 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | 358 #if defined(OS_WIN) |
359 { PRS_THEME_TAB_BACKGROUND_DESKTOP, PRS_THEME_FRAME_DESKTOP }, | 359 { PRS_THEME_TAB_BACKGROUND_WIN, PRS_THEME_FRAME_WIN }, |
360 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_DESKTOP, | 360 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_WIN, PRS_THEME_FRAME_INCOGNITO_WIN }, |
361 PRS_THEME_FRAME_INCOGNITO_DESKTOP }, | |
362 #endif | 361 #endif |
363 }; | 362 }; |
364 | 363 |
365 struct CropEntry { | 364 struct CropEntry { |
366 int prs_id; | 365 int prs_id; |
367 | 366 |
368 // The maximum useful height of the image at |prs_id|. | 367 // The maximum useful height of the image at |prs_id|. |
369 int max_height; | 368 int max_height; |
370 | 369 |
371 // Whether cropping the image at |prs_id| should be skipped on OSes which | 370 // Whether cropping the image at |prs_id| should be skipped on OSes which |
(...skipping 11 matching lines...) Expand all Loading... |
383 struct CropEntry kImagesToCrop[] = { | 382 struct CropEntry kImagesToCrop[] = { |
384 { PRS_THEME_FRAME, 120, true }, | 383 { PRS_THEME_FRAME, 120, true }, |
385 { PRS_THEME_FRAME_INACTIVE, 120, true }, | 384 { PRS_THEME_FRAME_INACTIVE, 120, true }, |
386 { PRS_THEME_FRAME_INCOGNITO, 120, true }, | 385 { PRS_THEME_FRAME_INCOGNITO, 120, true }, |
387 { PRS_THEME_FRAME_INCOGNITO_INACTIVE, 120, true }, | 386 { PRS_THEME_FRAME_INCOGNITO_INACTIVE, 120, true }, |
388 { PRS_THEME_FRAME_OVERLAY, 120, true }, | 387 { PRS_THEME_FRAME_OVERLAY, 120, true }, |
389 { PRS_THEME_FRAME_OVERLAY_INACTIVE, 120, true }, | 388 { PRS_THEME_FRAME_OVERLAY_INACTIVE, 120, true }, |
390 { PRS_THEME_TOOLBAR, 200, false }, | 389 { PRS_THEME_TOOLBAR, 200, false }, |
391 { PRS_THEME_BUTTON_BACKGROUND, 60, false }, | 390 { PRS_THEME_BUTTON_BACKGROUND, 60, false }, |
392 { PRS_THEME_WINDOW_CONTROL_BACKGROUND, 50, false }, | 391 { PRS_THEME_WINDOW_CONTROL_BACKGROUND, 50, false }, |
393 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | 392 #if defined(OS_WIN) |
394 { PRS_THEME_TOOLBAR_DESKTOP, 200, false } | 393 { PRS_THEME_TOOLBAR_WIN, 200, false } |
395 #endif | 394 #endif |
396 }; | 395 }; |
397 | 396 |
398 | 397 |
399 // A list of images that don't need tinting or any other modification and can | 398 // 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 | 399 // 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, | 400 // persistent IDs for all themeable image IDs that aren't in kFrameTintMap, |
402 // kTabBackgroundMap or kImagesToCrop. | 401 // kTabBackgroundMap or kImagesToCrop. |
403 const int kPreloadIDs[] = { | 402 const int kPreloadIDs[] = { |
404 PRS_THEME_NTP_BACKGROUND, | 403 PRS_THEME_NTP_BACKGROUND, |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 | 761 |
763 // static | 762 // static |
764 void BrowserThemePack::GetThemeableImageIDRs(std::set<int>* result) { | 763 void BrowserThemePack::GetThemeableImageIDRs(std::set<int>* result) { |
765 if (!result) | 764 if (!result) |
766 return; | 765 return; |
767 | 766 |
768 result->clear(); | 767 result->clear(); |
769 for (size_t i = 0; i < kPersistingImagesLength; ++i) | 768 for (size_t i = 0; i < kPersistingImagesLength; ++i) |
770 result->insert(kPersistingImages[i].idr_id); | 769 result->insert(kPersistingImages[i].idr_id); |
771 | 770 |
772 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | 771 #if defined(OS_WIN) |
773 for (size_t i = 0; i < kPersistingImagesDesktopAuraLength; ++i) | 772 for (size_t i = 0; i < kPersistingImagesWinDesktopAuraLength; ++i) |
774 result->insert(kPersistingImagesDesktopAura[i].idr_id); | 773 result->insert(kPersistingImagesWinDesktopAura[i].idr_id); |
775 #endif | 774 #endif |
776 } | 775 } |
777 | 776 |
778 bool BrowserThemePack::WriteToDisk(const base::FilePath& path) const { | 777 bool BrowserThemePack::WriteToDisk(const base::FilePath& path) const { |
779 // Add resources for each of the property arrays. | 778 // Add resources for each of the property arrays. |
780 RawDataForWriting resources; | 779 RawDataForWriting resources; |
781 resources[kHeaderID] = base::StringPiece( | 780 resources[kHeaderID] = base::StringPiece( |
782 reinterpret_cast<const char*>(header_), sizeof(BrowserThemePackHeader)); | 781 reinterpret_cast<const char*>(header_), sizeof(BrowserThemePackHeader)); |
783 resources[kTintsID] = base::StringPiece( | 782 resources[kTintsID] = base::StringPiece( |
784 reinterpret_cast<const char*>(tints_), | 783 reinterpret_cast<const char*>(tints_), |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 } | 1201 } |
1203 } | 1202 } |
1204 | 1203 |
1205 void BrowserThemePack::AddFileAtScaleToMap(const std::string& image_name, | 1204 void BrowserThemePack::AddFileAtScaleToMap(const std::string& image_name, |
1206 ui::ScaleFactor scale_factor, | 1205 ui::ScaleFactor scale_factor, |
1207 const base::FilePath& image_path, | 1206 const base::FilePath& image_path, |
1208 FilePathMap* file_paths) const { | 1207 FilePathMap* file_paths) const { |
1209 int id = GetPersistentIDByName(image_name); | 1208 int id = GetPersistentIDByName(image_name); |
1210 if (id != -1) | 1209 if (id != -1) |
1211 (*file_paths)[id][scale_factor] = image_path; | 1210 (*file_paths)[id][scale_factor] = image_path; |
1212 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | 1211 #if defined(OS_WIN) |
1213 id = GetPersistentIDByNameHelper(image_name, | 1212 id = GetPersistentIDByNameHelper(image_name, |
1214 kPersistingImagesDesktopAura, | 1213 kPersistingImagesWinDesktopAura, |
1215 kPersistingImagesDesktopAuraLength); | 1214 kPersistingImagesWinDesktopAuraLength); |
1216 if (id != -1) | 1215 if (id != -1) |
1217 (*file_paths)[id][scale_factor] = image_path; | 1216 (*file_paths)[id][scale_factor] = image_path; |
1218 #endif | 1217 #endif |
1219 } | 1218 } |
1220 | 1219 |
1221 void BrowserThemePack::BuildSourceImagesArray(const FilePathMap& file_paths) { | 1220 void BrowserThemePack::BuildSourceImagesArray(const FilePathMap& file_paths) { |
1222 std::vector<int> ids; | 1221 std::vector<int> ids; |
1223 for (FilePathMap::const_iterator it = file_paths.begin(); | 1222 for (FilePathMap::const_iterator it = file_paths.begin(); |
1224 it != file_paths.end(); ++it) { | 1223 it != file_paths.end(); ++it) { |
1225 ids.push_back(it->first); | 1224 ids.push_back(it->first); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 ImageCache temp_output; | 1329 ImageCache temp_output; |
1331 | 1330 |
1332 for (size_t i = 0; i < arraysize(kFrameTintMap); ++i) { | 1331 for (size_t i = 0; i < arraysize(kFrameTintMap); ++i) { |
1333 int prs_id = kFrameTintMap[i].key; | 1332 int prs_id = kFrameTintMap[i].key; |
1334 gfx::Image frame; | 1333 gfx::Image frame; |
1335 // If there's no frame image provided for the specified id, then load | 1334 // If there's no frame image provided for the specified id, then load |
1336 // the default provided frame. If that's not provided, skip this whole | 1335 // the default provided frame. If that's not provided, skip this whole |
1337 // thing and just use the default images. | 1336 // thing and just use the default images. |
1338 int prs_base_id = 0; | 1337 int prs_base_id = 0; |
1339 | 1338 |
1340 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | 1339 #if defined(OS_WIN) |
1341 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP) { | 1340 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN) { |
1342 prs_base_id = images->count(PRS_THEME_FRAME_INCOGNITO_DESKTOP) ? | 1341 prs_base_id = images->count(PRS_THEME_FRAME_INCOGNITO_WIN) ? |
1343 PRS_THEME_FRAME_INCOGNITO_DESKTOP : PRS_THEME_FRAME_DESKTOP; | 1342 PRS_THEME_FRAME_INCOGNITO_WIN : PRS_THEME_FRAME_WIN; |
1344 } else if (prs_id == PRS_THEME_FRAME_INACTIVE_DESKTOP) { | 1343 } else if (prs_id == PRS_THEME_FRAME_INACTIVE_WIN) { |
1345 prs_base_id = PRS_THEME_FRAME_DESKTOP; | 1344 prs_base_id = PRS_THEME_FRAME_WIN; |
1346 } else if (prs_id == PRS_THEME_FRAME_INCOGNITO_DESKTOP && | 1345 } else if (prs_id == PRS_THEME_FRAME_INCOGNITO_WIN && |
1347 !images->count(PRS_THEME_FRAME_INCOGNITO_DESKTOP)) { | 1346 !images->count(PRS_THEME_FRAME_INCOGNITO_WIN)) { |
1348 prs_base_id = PRS_THEME_FRAME_DESKTOP; | 1347 prs_base_id = PRS_THEME_FRAME_WIN; |
1349 } | 1348 } |
1350 #endif | 1349 #endif |
1351 if (!prs_base_id) { | 1350 if (!prs_base_id) { |
1352 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE) { | 1351 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE) { |
1353 prs_base_id = images->count(PRS_THEME_FRAME_INCOGNITO) ? | 1352 prs_base_id = images->count(PRS_THEME_FRAME_INCOGNITO) ? |
1354 PRS_THEME_FRAME_INCOGNITO : PRS_THEME_FRAME; | 1353 PRS_THEME_FRAME_INCOGNITO : PRS_THEME_FRAME; |
1355 } else if (prs_id == PRS_THEME_FRAME_OVERLAY_INACTIVE) { | 1354 } else if (prs_id == PRS_THEME_FRAME_OVERLAY_INACTIVE) { |
1356 prs_base_id = PRS_THEME_FRAME_OVERLAY; | 1355 prs_base_id = PRS_THEME_FRAME_OVERLAY; |
1357 } else if (prs_id == PRS_THEME_FRAME_INACTIVE) { | 1356 } else if (prs_id == PRS_THEME_FRAME_INACTIVE) { |
1358 prs_base_id = PRS_THEME_FRAME; | 1357 prs_base_id = PRS_THEME_FRAME; |
1359 } else if (prs_id == PRS_THEME_FRAME_INCOGNITO && | 1358 } else if (prs_id == PRS_THEME_FRAME_INCOGNITO && |
1360 !images->count(PRS_THEME_FRAME_INCOGNITO)) { | 1359 !images->count(PRS_THEME_FRAME_INCOGNITO)) { |
1361 prs_base_id = PRS_THEME_FRAME; | 1360 prs_base_id = PRS_THEME_FRAME; |
1362 } else { | 1361 } else { |
1363 prs_base_id = prs_id; | 1362 prs_base_id = prs_id; |
1364 } | 1363 } |
1365 } | 1364 } |
1366 if (images->count(prs_id)) { | 1365 if (images->count(prs_id)) { |
1367 frame = (*images)[prs_id]; | 1366 frame = (*images)[prs_id]; |
1368 } else if (prs_base_id != prs_id && images->count(prs_base_id)) { | 1367 } else if (prs_base_id != prs_id && images->count(prs_base_id)) { |
1369 frame = (*images)[prs_base_id]; | 1368 frame = (*images)[prs_base_id]; |
1370 } else if (prs_base_id == PRS_THEME_FRAME_OVERLAY) { | 1369 } else if (prs_base_id == PRS_THEME_FRAME_OVERLAY) { |
1371 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | 1370 #if defined(OS_WIN) |
1372 if (images->count(PRS_THEME_FRAME_DESKTOP)) { | 1371 if (images->count(PRS_THEME_FRAME_WIN)) { |
1373 #else | 1372 #else |
1374 if (images->count(PRS_THEME_FRAME)) { | 1373 if (images->count(PRS_THEME_FRAME)) { |
1375 #endif | 1374 #endif |
1376 // If there is no theme overlay, don't tint the default frame, | 1375 // If there is no theme overlay, don't tint the default frame, |
1377 // because it will overwrite the custom frame image when we cache and | 1376 // because it will overwrite the custom frame image when we cache and |
1378 // reload from disk. | 1377 // reload from disk. |
1379 frame = gfx::Image(); | 1378 frame = gfx::Image(); |
1380 } | 1379 } |
1381 } else { | 1380 } else { |
1382 // If the theme doesn't specify an image, then apply the tint to | 1381 // If the theme doesn't specify an image, then apply the tint to |
1383 // the default frame. | 1382 // the default frame. |
1384 frame = rb.GetImageNamed(IDR_THEME_FRAME); | 1383 frame = rb.GetImageNamed(IDR_THEME_FRAME); |
1385 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | 1384 #if defined(OS_WIN) && defined(USE_AURA) |
1386 if (prs_id >= PRS_THEME_FRAME_DESKTOP && | 1385 if (prs_id >= PRS_THEME_FRAME_WIN && |
1387 prs_id <= PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP) { | 1386 prs_id <= PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN) { |
1388 frame = rb.GetImageNamed(IDR_THEME_FRAME_DESKTOP); | 1387 frame = rb.GetImageNamed(IDR_THEME_FRAME_WIN); |
1389 } | 1388 } |
1390 #endif | 1389 #endif |
1391 } | 1390 } |
1392 if (!frame.IsEmpty()) { | 1391 if (!frame.IsEmpty()) { |
1393 temp_output[prs_id] = CreateHSLShiftedImage( | 1392 temp_output[prs_id] = CreateHSLShiftedImage( |
1394 frame, GetTintInternal(kFrameTintMap[i].value)); | 1393 frame, GetTintInternal(kFrameTintMap[i].value)); |
1395 } | 1394 } |
1396 } | 1395 } |
1397 MergeImageCaches(temp_output, images); | 1396 MergeImageCaches(temp_output, images); |
1398 } | 1397 } |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 false, | 1603 false, |
1605 &bitmap_data)) { | 1604 &bitmap_data)) { |
1606 NOTREACHED() << "Unable to encode theme image for prs_id=" | 1605 NOTREACHED() << "Unable to encode theme image for prs_id=" |
1607 << prs_id << " for scale_factor=" << scale_factors_[i]; | 1606 << prs_id << " for scale_factor=" << scale_factors_[i]; |
1608 break; | 1607 break; |
1609 } | 1608 } |
1610 image_memory_[scaled_raw_id] = | 1609 image_memory_[scaled_raw_id] = |
1611 base::RefCountedBytes::TakeVector(&bitmap_data); | 1610 base::RefCountedBytes::TakeVector(&bitmap_data); |
1612 } | 1611 } |
1613 } | 1612 } |
OLD | NEW |