Chromium Code Reviews| 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.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 const int PRS_THEME_TAB_BACKGROUND_V = 8; | 80 const int PRS_THEME_TAB_BACKGROUND_V = 8; |
| 81 const int PRS_THEME_NTP_BACKGROUND = 9; | 81 const int PRS_THEME_NTP_BACKGROUND = 9; |
| 82 const int PRS_THEME_FRAME_OVERLAY = 10; | 82 const int PRS_THEME_FRAME_OVERLAY = 10; |
| 83 const int PRS_THEME_FRAME_OVERLAY_INACTIVE = 11; | 83 const int PRS_THEME_FRAME_OVERLAY_INACTIVE = 11; |
| 84 const int PRS_THEME_BUTTON_BACKGROUND = 12; | 84 const int PRS_THEME_BUTTON_BACKGROUND = 12; |
| 85 const int PRS_THEME_NTP_ATTRIBUTION = 13; | 85 const int PRS_THEME_NTP_ATTRIBUTION = 13; |
| 86 const int PRS_THEME_WINDOW_CONTROL_BACKGROUND = 14; | 86 const int PRS_THEME_WINDOW_CONTROL_BACKGROUND = 14; |
| 87 | 87 |
| 88 struct PersistingImagesTable { | 88 struct PersistingImagesTable { |
| 89 // A non-changing integer ID meant to be saved in theme packs. This ID must | 89 // A non-changing integer ID meant to be saved in theme packs. This ID must |
| 90 // not change between versions of chrome. | 90 // not change between versions of chrome. |
|
Evan Stade
2016/02/09 00:11:02
does this comment mean it's not OK to just delete
pkotwicz
2016/02/09 00:23:54
This comment indicates that you must change kTheme
Evan Stade
2016/02/09 00:31:46
Done.
| |
| 91 int persistent_id; | 91 int persistent_id; |
| 92 | 92 |
| 93 // The IDR that depends on the whims of GRIT and therefore changes whenever | 93 // The IDR that depends on the whims of GRIT and therefore changes whenever |
| 94 // someone adds a new resource. | 94 // someone adds a new resource. |
| 95 int idr_id; | 95 int idr_id; |
| 96 | 96 |
| 97 // String to check for when parsing theme manifests or NULL if this isn't | 97 // String to check for when parsing theme manifests or NULL if this isn't |
| 98 // supposed to be changeable by the user. | 98 // supposed to be changeable by the user. |
| 99 const char* const key; | 99 const char* const key; |
| 100 }; | 100 }; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 {36, IDR_TOOLS, NULL}, | 170 {36, IDR_TOOLS, NULL}, |
| 171 {37, IDR_TOOLS_H, NULL}, | 171 {37, IDR_TOOLS_H, NULL}, |
| 172 {38, IDR_TOOLS_P, NULL}, | 172 {38, IDR_TOOLS_P, NULL}, |
| 173 {39, IDR_MENU_DROPARROW, NULL}, | 173 {39, IDR_MENU_DROPARROW, NULL}, |
| 174 {40, IDR_TOOLBAR_BEZEL_HOVER, NULL}, | 174 {40, IDR_TOOLBAR_BEZEL_HOVER, NULL}, |
| 175 {41, IDR_TOOLBAR_BEZEL_PRESSED, NULL}, | 175 {41, IDR_TOOLBAR_BEZEL_PRESSED, NULL}, |
| 176 {42, IDR_TOOLS_BAR, NULL}, | 176 {42, IDR_TOOLS_BAR, NULL}, |
| 177 }; | 177 }; |
| 178 const size_t kPersistingImagesLength = arraysize(kPersistingImages); | 178 const size_t kPersistingImagesLength = arraysize(kPersistingImages); |
| 179 | 179 |
| 180 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | |
| 181 // Persistent theme ids for Windows. | |
| 182 const int PRS_THEME_FRAME_DESKTOP = 100; | |
| 183 const int PRS_THEME_FRAME_INACTIVE_DESKTOP = 101; | |
| 184 const int PRS_THEME_FRAME_INCOGNITO_DESKTOP = 102; | |
| 185 const int PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP = 103; | |
| 186 const int PRS_THEME_TOOLBAR_DESKTOP = 104; | |
| 187 const int PRS_THEME_TAB_BACKGROUND_DESKTOP = 105; | |
| 188 const int PRS_THEME_TAB_BACKGROUND_INCOGNITO_DESKTOP = 106; | |
| 189 | |
| 190 // Persistent theme to resource id mapping for Windows AURA. | |
| 191 PersistingImagesTable kPersistingImagesDesktopAura[] = { | |
| 192 { PRS_THEME_FRAME_DESKTOP, IDR_THEME_FRAME_DESKTOP, | |
| 193 "theme_frame" }, | |
| 194 { PRS_THEME_FRAME_INACTIVE_DESKTOP, IDR_THEME_FRAME_INACTIVE_DESKTOP, | |
| 195 "theme_frame_inactive" }, | |
| 196 { PRS_THEME_FRAME_INCOGNITO_DESKTOP, IDR_THEME_FRAME_INCOGNITO_DESKTOP, | |
| 197 "theme_frame_incognito" }, | |
| 198 { PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP, | |
| 199 IDR_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP, | |
| 200 "theme_frame_incognito_inactive" }, | |
| 201 { PRS_THEME_TOOLBAR_DESKTOP, IDR_THEME_TOOLBAR_DESKTOP, | |
| 202 "theme_toolbar" }, | |
| 203 { PRS_THEME_TAB_BACKGROUND_DESKTOP, IDR_THEME_TAB_BACKGROUND_DESKTOP, | |
| 204 "theme_tab_background" }, | |
| 205 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_DESKTOP, | |
| 206 IDR_THEME_TAB_BACKGROUND_INCOGNITO_DESKTOP, | |
| 207 "theme_tab_background_incognito" }, | |
| 208 }; | |
| 209 const size_t kPersistingImagesDesktopAuraLength = | |
| 210 arraysize(kPersistingImagesDesktopAura); | |
| 211 #endif | |
| 212 | |
| 213 int GetPersistentIDByNameHelper(const std::string& key, | 180 int GetPersistentIDByNameHelper(const std::string& key, |
| 214 const PersistingImagesTable* image_table, | 181 const PersistingImagesTable* image_table, |
| 215 size_t image_table_size) { | 182 size_t image_table_size) { |
| 216 for (size_t i = 0; i < image_table_size; ++i) { | 183 for (size_t i = 0; i < image_table_size; ++i) { |
| 217 if (image_table[i].key && | 184 if (image_table[i].key && |
| 218 base::LowerCaseEqualsASCII(key, image_table[i].key)) { | 185 base::LowerCaseEqualsASCII(key, image_table[i].key)) { |
| 219 return image_table[i].persistent_id; | 186 return image_table[i].persistent_id; |
| 220 } | 187 } |
| 221 } | 188 } |
| 222 return -1; | 189 return -1; |
| 223 } | 190 } |
| 224 | 191 |
| 225 int GetPersistentIDByName(const std::string& key) { | 192 int GetPersistentIDByName(const std::string& key) { |
| 226 return GetPersistentIDByNameHelper(key, | 193 return GetPersistentIDByNameHelper(key, |
| 227 kPersistingImages, | 194 kPersistingImages, |
| 228 kPersistingImagesLength); | 195 kPersistingImagesLength); |
| 229 } | 196 } |
| 230 | 197 |
| 231 int GetPersistentIDByIDR(int idr) { | 198 int GetPersistentIDByIDR(int idr) { |
| 232 static std::map<int,int>* lookup_table = new std::map<int,int>(); | 199 static std::map<int,int>* lookup_table = new std::map<int,int>(); |
| 233 if (lookup_table->empty()) { | 200 if (lookup_table->empty()) { |
| 234 for (size_t i = 0; i < kPersistingImagesLength; ++i) { | 201 for (size_t i = 0; i < kPersistingImagesLength; ++i) { |
| 235 int idr = kPersistingImages[i].idr_id; | 202 int idr = kPersistingImages[i].idr_id; |
| 236 int prs_id = kPersistingImages[i].persistent_id; | 203 int prs_id = kPersistingImages[i].persistent_id; |
| 237 (*lookup_table)[idr] = prs_id; | 204 (*lookup_table)[idr] = prs_id; |
| 238 } | 205 } |
| 239 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | |
| 240 for (size_t i = 0; i < kPersistingImagesDesktopAuraLength; ++i) { | |
| 241 int idr = kPersistingImagesDesktopAura[i].idr_id; | |
| 242 int prs_id = kPersistingImagesDesktopAura[i].persistent_id; | |
| 243 (*lookup_table)[idr] = prs_id; | |
| 244 } | |
| 245 #endif | |
| 246 } | 206 } |
| 247 std::map<int,int>::iterator it = lookup_table->find(idr); | 207 std::map<int,int>::iterator it = lookup_table->find(idr); |
| 248 return (it == lookup_table->end()) ? -1 : it->second; | 208 return (it == lookup_table->end()) ? -1 : it->second; |
| 249 } | 209 } |
| 250 | 210 |
| 251 // Returns the maximum persistent id. | 211 // Returns the maximum persistent id. |
| 252 int GetMaxPersistentId() { | 212 int GetMaxPersistentId() { |
| 253 static int max_prs_id = -1; | 213 static int max_prs_id = -1; |
| 254 if (max_prs_id == -1) { | 214 if (max_prs_id == -1) { |
| 255 for (size_t i = 0; i < kPersistingImagesLength; ++i) { | 215 for (size_t i = 0; i < kPersistingImagesLength; ++i) { |
| 256 if (kPersistingImages[i].persistent_id > max_prs_id) | 216 if (kPersistingImages[i].persistent_id > max_prs_id) |
| 257 max_prs_id = kPersistingImages[i].persistent_id; | 217 max_prs_id = kPersistingImages[i].persistent_id; |
| 258 } | 218 } |
| 259 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | |
| 260 for (size_t i = 0; i < kPersistingImagesDesktopAuraLength; ++i) { | |
| 261 if (kPersistingImagesDesktopAura[i].persistent_id > max_prs_id) | |
| 262 max_prs_id = kPersistingImagesDesktopAura[i].persistent_id; | |
| 263 } | |
| 264 #endif | |
| 265 } | 219 } |
| 266 return max_prs_id; | 220 return max_prs_id; |
| 267 } | 221 } |
| 268 | 222 |
| 269 // Returns true if the scales in |input| match those in |expected|. | 223 // Returns true if the scales in |input| match those in |expected|. |
| 270 // The order must match as the index is used in determining the raw id. | 224 // The order must match as the index is used in determining the raw id. |
| 271 bool InputScalesValid(const base::StringPiece& input, | 225 bool InputScalesValid(const base::StringPiece& input, |
| 272 const std::vector<ui::ScaleFactor>& expected) { | 226 const std::vector<ui::ScaleFactor>& expected) { |
| 273 size_t scales_size = static_cast<size_t>(input.size() / sizeof(float)); | 227 size_t scales_size = static_cast<size_t>(input.size() / sizeof(float)); |
| 274 if (scales_size != expected.size()) | 228 if (scales_size != expected.size()) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 // tint ID that should maybe be applied to it. | 321 // tint ID that should maybe be applied to it. |
| 368 IntToIntTable kFrameTintMap[] = { | 322 IntToIntTable kFrameTintMap[] = { |
| 369 { PRS_THEME_FRAME, ThemeProperties::TINT_FRAME }, | 323 { PRS_THEME_FRAME, ThemeProperties::TINT_FRAME }, |
| 370 { PRS_THEME_FRAME_INACTIVE, ThemeProperties::TINT_FRAME_INACTIVE }, | 324 { PRS_THEME_FRAME_INACTIVE, ThemeProperties::TINT_FRAME_INACTIVE }, |
| 371 { PRS_THEME_FRAME_OVERLAY, ThemeProperties::TINT_FRAME }, | 325 { PRS_THEME_FRAME_OVERLAY, ThemeProperties::TINT_FRAME }, |
| 372 { PRS_THEME_FRAME_OVERLAY_INACTIVE, | 326 { PRS_THEME_FRAME_OVERLAY_INACTIVE, |
| 373 ThemeProperties::TINT_FRAME_INACTIVE }, | 327 ThemeProperties::TINT_FRAME_INACTIVE }, |
| 374 { PRS_THEME_FRAME_INCOGNITO, ThemeProperties::TINT_FRAME_INCOGNITO }, | 328 { PRS_THEME_FRAME_INCOGNITO, ThemeProperties::TINT_FRAME_INCOGNITO }, |
| 375 { PRS_THEME_FRAME_INCOGNITO_INACTIVE, | 329 { PRS_THEME_FRAME_INCOGNITO_INACTIVE, |
| 376 ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE }, | 330 ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE }, |
| 377 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | |
| 378 { PRS_THEME_FRAME_DESKTOP, ThemeProperties::TINT_FRAME }, | |
| 379 { PRS_THEME_FRAME_INACTIVE_DESKTOP, ThemeProperties::TINT_FRAME_INACTIVE }, | |
| 380 { PRS_THEME_FRAME_INCOGNITO_DESKTOP, ThemeProperties::TINT_FRAME_INCOGNITO }, | |
| 381 { PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP, | |
| 382 ThemeProperties::TINT_FRAME_INCOGNITO_INACTIVE }, | |
| 383 #endif | |
| 384 }; | 331 }; |
| 385 | 332 |
| 386 // Mapping used in GenerateTabBackgroundImages() to associate what frame image | 333 // Mapping used in GenerateTabBackgroundImages() to associate what frame image |
| 387 // goes with which tab background. | 334 // goes with which tab background. |
| 388 IntToIntTable kTabBackgroundMap[] = { | 335 IntToIntTable kTabBackgroundMap[] = { |
| 389 { PRS_THEME_TAB_BACKGROUND, PRS_THEME_FRAME }, | 336 { PRS_THEME_TAB_BACKGROUND, PRS_THEME_FRAME }, |
| 390 { PRS_THEME_TAB_BACKGROUND_INCOGNITO, PRS_THEME_FRAME_INCOGNITO }, | 337 { PRS_THEME_TAB_BACKGROUND_INCOGNITO, PRS_THEME_FRAME_INCOGNITO }, |
| 391 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | |
| 392 { PRS_THEME_TAB_BACKGROUND_DESKTOP, PRS_THEME_FRAME_DESKTOP }, | |
| 393 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_DESKTOP, | |
| 394 PRS_THEME_FRAME_INCOGNITO_DESKTOP }, | |
| 395 #endif | |
| 396 }; | 338 }; |
| 397 | 339 |
| 398 struct CropEntry { | 340 struct CropEntry { |
| 399 int prs_id; | 341 int prs_id; |
| 400 | 342 |
| 401 // The maximum useful height of the image at |prs_id|. | 343 // The maximum useful height of the image at |prs_id|. |
| 402 int max_height; | 344 int max_height; |
| 403 | 345 |
| 404 // Whether cropping the image at |prs_id| should be skipped on OSes which | 346 // Whether cropping the image at |prs_id| should be skipped on OSes which |
| 405 // have a frame border to the left and right of the web contents. | 347 // have a frame border to the left and right of the web contents. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 416 struct CropEntry kImagesToCrop[] = { | 358 struct CropEntry kImagesToCrop[] = { |
| 417 { PRS_THEME_FRAME, 120, true }, | 359 { PRS_THEME_FRAME, 120, true }, |
| 418 { PRS_THEME_FRAME_INACTIVE, 120, true }, | 360 { PRS_THEME_FRAME_INACTIVE, 120, true }, |
| 419 { PRS_THEME_FRAME_INCOGNITO, 120, true }, | 361 { PRS_THEME_FRAME_INCOGNITO, 120, true }, |
| 420 { PRS_THEME_FRAME_INCOGNITO_INACTIVE, 120, true }, | 362 { PRS_THEME_FRAME_INCOGNITO_INACTIVE, 120, true }, |
| 421 { PRS_THEME_FRAME_OVERLAY, 120, true }, | 363 { PRS_THEME_FRAME_OVERLAY, 120, true }, |
| 422 { PRS_THEME_FRAME_OVERLAY_INACTIVE, 120, true }, | 364 { PRS_THEME_FRAME_OVERLAY_INACTIVE, 120, true }, |
| 423 { PRS_THEME_TOOLBAR, 200, false }, | 365 { PRS_THEME_TOOLBAR, 200, false }, |
| 424 { PRS_THEME_BUTTON_BACKGROUND, 60, false }, | 366 { PRS_THEME_BUTTON_BACKGROUND, 60, false }, |
| 425 { PRS_THEME_WINDOW_CONTROL_BACKGROUND, 50, false }, | 367 { PRS_THEME_WINDOW_CONTROL_BACKGROUND, 50, false }, |
| 426 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | |
| 427 { PRS_THEME_TOOLBAR_DESKTOP, 200, false } | |
| 428 #endif | |
| 429 }; | 368 }; |
| 430 | 369 |
| 431 | 370 |
| 432 // A list of images that don't need tinting or any other modification and can | 371 // A list of images that don't need tinting or any other modification and can |
| 433 // be byte-copied directly into the finished DataPack. This should contain the | 372 // be byte-copied directly into the finished DataPack. This should contain the |
| 434 // persistent IDs for all themeable image IDs that aren't in kFrameTintMap, | 373 // persistent IDs for all themeable image IDs that aren't in kFrameTintMap, |
| 435 // kTabBackgroundMap or kImagesToCrop. | 374 // kTabBackgroundMap or kImagesToCrop. |
| 436 const int kPreloadIDs[] = { | 375 const int kPreloadIDs[] = { |
| 437 PRS_THEME_NTP_BACKGROUND, | 376 PRS_THEME_NTP_BACKGROUND, |
| 438 PRS_THEME_NTP_ATTRIBUTION, | 377 PRS_THEME_NTP_ATTRIBUTION, |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 786 } | 725 } |
| 787 return pack; | 726 return pack; |
| 788 } | 727 } |
| 789 | 728 |
| 790 // static | 729 // static |
| 791 bool BrowserThemePack::IsPersistentImageID(int id) { | 730 bool BrowserThemePack::IsPersistentImageID(int id) { |
| 792 for (size_t i = 0; i < kPersistingImagesLength; ++i) | 731 for (size_t i = 0; i < kPersistingImagesLength; ++i) |
| 793 if (kPersistingImages[i].idr_id == id) | 732 if (kPersistingImages[i].idr_id == id) |
| 794 return true; | 733 return true; |
| 795 | 734 |
| 796 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | |
| 797 for (size_t i = 0; i < kPersistingImagesDesktopAuraLength; ++i) | |
| 798 if (kPersistingImagesDesktopAura[i].idr_id == id) | |
| 799 return true; | |
| 800 #endif | |
| 801 | |
| 802 return false; | 735 return false; |
| 803 } | 736 } |
| 804 | 737 |
| 805 bool BrowserThemePack::WriteToDisk(const base::FilePath& path) const { | 738 bool BrowserThemePack::WriteToDisk(const base::FilePath& path) const { |
| 806 // Add resources for each of the property arrays. | 739 // Add resources for each of the property arrays. |
| 807 RawDataForWriting resources; | 740 RawDataForWriting resources; |
| 808 resources[kHeaderID] = base::StringPiece( | 741 resources[kHeaderID] = base::StringPiece( |
| 809 reinterpret_cast<const char*>(header_), sizeof(BrowserThemePackHeader)); | 742 reinterpret_cast<const char*>(header_), sizeof(BrowserThemePackHeader)); |
| 810 resources[kTintsID] = base::StringPiece( | 743 resources[kTintsID] = base::StringPiece( |
| 811 reinterpret_cast<const char*>(tints_), | 744 reinterpret_cast<const char*>(tints_), |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1235 } | 1168 } |
| 1236 } | 1169 } |
| 1237 | 1170 |
| 1238 void BrowserThemePack::AddFileAtScaleToMap(const std::string& image_name, | 1171 void BrowserThemePack::AddFileAtScaleToMap(const std::string& image_name, |
| 1239 ui::ScaleFactor scale_factor, | 1172 ui::ScaleFactor scale_factor, |
| 1240 const base::FilePath& image_path, | 1173 const base::FilePath& image_path, |
| 1241 FilePathMap* file_paths) const { | 1174 FilePathMap* file_paths) const { |
| 1242 int id = GetPersistentIDByName(image_name); | 1175 int id = GetPersistentIDByName(image_name); |
| 1243 if (id != -1) | 1176 if (id != -1) |
| 1244 (*file_paths)[id][scale_factor] = image_path; | 1177 (*file_paths)[id][scale_factor] = image_path; |
| 1245 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | |
| 1246 id = GetPersistentIDByNameHelper(image_name, | |
| 1247 kPersistingImagesDesktopAura, | |
| 1248 kPersistingImagesDesktopAuraLength); | |
| 1249 if (id != -1) | |
| 1250 (*file_paths)[id][scale_factor] = image_path; | |
| 1251 #endif | |
| 1252 } | 1178 } |
| 1253 | 1179 |
| 1254 void BrowserThemePack::BuildSourceImagesArray(const FilePathMap& file_paths) { | 1180 void BrowserThemePack::BuildSourceImagesArray(const FilePathMap& file_paths) { |
| 1255 std::vector<int> ids; | 1181 std::vector<int> ids; |
| 1256 for (FilePathMap::const_iterator it = file_paths.begin(); | 1182 for (FilePathMap::const_iterator it = file_paths.begin(); |
| 1257 it != file_paths.end(); ++it) { | 1183 it != file_paths.end(); ++it) { |
| 1258 ids.push_back(it->first); | 1184 ids.push_back(it->first); |
| 1259 } | 1185 } |
| 1260 | 1186 |
| 1261 source_images_ = new int[ids.size() + 1]; | 1187 source_images_ = new int[ids.size() + 1]; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1363 ImageCache temp_output; | 1289 ImageCache temp_output; |
| 1364 | 1290 |
| 1365 for (size_t i = 0; i < arraysize(kFrameTintMap); ++i) { | 1291 for (size_t i = 0; i < arraysize(kFrameTintMap); ++i) { |
| 1366 int prs_id = kFrameTintMap[i].key; | 1292 int prs_id = kFrameTintMap[i].key; |
| 1367 gfx::Image frame; | 1293 gfx::Image frame; |
| 1368 // If there's no frame image provided for the specified id, then load | 1294 // If there's no frame image provided for the specified id, then load |
| 1369 // the default provided frame. If that's not provided, skip this whole | 1295 // the default provided frame. If that's not provided, skip this whole |
| 1370 // thing and just use the default images. | 1296 // thing and just use the default images. |
| 1371 int prs_base_id = 0; | 1297 int prs_base_id = 0; |
| 1372 | 1298 |
| 1373 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | |
| 1374 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP) { | |
| 1375 prs_base_id = images->count(PRS_THEME_FRAME_INCOGNITO_DESKTOP) ? | |
| 1376 PRS_THEME_FRAME_INCOGNITO_DESKTOP : PRS_THEME_FRAME_DESKTOP; | |
| 1377 } else if (prs_id == PRS_THEME_FRAME_INACTIVE_DESKTOP) { | |
| 1378 prs_base_id = PRS_THEME_FRAME_DESKTOP; | |
| 1379 } else if (prs_id == PRS_THEME_FRAME_INCOGNITO_DESKTOP && | |
| 1380 !images->count(PRS_THEME_FRAME_INCOGNITO_DESKTOP)) { | |
| 1381 prs_base_id = PRS_THEME_FRAME_DESKTOP; | |
| 1382 } | |
| 1383 #endif | |
| 1384 if (!prs_base_id) { | 1299 if (!prs_base_id) { |
| 1385 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE) { | 1300 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE) { |
| 1386 prs_base_id = images->count(PRS_THEME_FRAME_INCOGNITO) ? | 1301 prs_base_id = images->count(PRS_THEME_FRAME_INCOGNITO) ? |
| 1387 PRS_THEME_FRAME_INCOGNITO : PRS_THEME_FRAME; | 1302 PRS_THEME_FRAME_INCOGNITO : PRS_THEME_FRAME; |
| 1388 } else if (prs_id == PRS_THEME_FRAME_OVERLAY_INACTIVE) { | 1303 } else if (prs_id == PRS_THEME_FRAME_OVERLAY_INACTIVE) { |
| 1389 prs_base_id = PRS_THEME_FRAME_OVERLAY; | 1304 prs_base_id = PRS_THEME_FRAME_OVERLAY; |
| 1390 } else if (prs_id == PRS_THEME_FRAME_INACTIVE) { | 1305 } else if (prs_id == PRS_THEME_FRAME_INACTIVE) { |
| 1391 prs_base_id = PRS_THEME_FRAME; | 1306 prs_base_id = PRS_THEME_FRAME; |
| 1392 } else if (prs_id == PRS_THEME_FRAME_INCOGNITO && | 1307 } else if (prs_id == PRS_THEME_FRAME_INCOGNITO && |
| 1393 !images->count(PRS_THEME_FRAME_INCOGNITO)) { | 1308 !images->count(PRS_THEME_FRAME_INCOGNITO)) { |
| 1394 prs_base_id = PRS_THEME_FRAME; | 1309 prs_base_id = PRS_THEME_FRAME; |
| 1395 } else { | 1310 } else { |
| 1396 prs_base_id = prs_id; | 1311 prs_base_id = prs_id; |
| 1397 } | 1312 } |
| 1398 } | 1313 } |
| 1399 if (images->count(prs_id)) { | 1314 if (images->count(prs_id)) { |
| 1400 frame = (*images)[prs_id]; | 1315 frame = (*images)[prs_id]; |
| 1401 } else if (prs_base_id != prs_id && images->count(prs_base_id)) { | 1316 } else if (prs_base_id != prs_id && images->count(prs_base_id)) { |
| 1402 frame = (*images)[prs_base_id]; | 1317 frame = (*images)[prs_base_id]; |
| 1403 } else if (prs_base_id == PRS_THEME_FRAME_OVERLAY) { | 1318 } else if (prs_base_id == PRS_THEME_FRAME_OVERLAY) { |
| 1404 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | |
| 1405 if (images->count(PRS_THEME_FRAME_DESKTOP)) { | |
| 1406 #else | |
| 1407 if (images->count(PRS_THEME_FRAME)) { | 1319 if (images->count(PRS_THEME_FRAME)) { |
| 1408 #endif | |
| 1409 // If there is no theme overlay, don't tint the default frame, | 1320 // If there is no theme overlay, don't tint the default frame, |
| 1410 // because it will overwrite the custom frame image when we cache and | 1321 // because it will overwrite the custom frame image when we cache and |
| 1411 // reload from disk. | 1322 // reload from disk. |
| 1412 frame = gfx::Image(); | 1323 frame = gfx::Image(); |
| 1413 } | 1324 } |
| 1414 } else { | 1325 } else { |
| 1415 // If the theme doesn't specify an image, then apply the tint to | 1326 // If the theme doesn't specify an image, then apply the tint to |
| 1416 // the default frame. | 1327 // the default frame. |
| 1417 frame = rb.GetImageNamed(IDR_THEME_FRAME); | 1328 frame = rb.GetImageNamed(IDR_THEME_FRAME); |
| 1418 #if defined(USE_ASH) && !defined(OS_CHROMEOS) | |
| 1419 if (prs_id >= PRS_THEME_FRAME_DESKTOP && | |
| 1420 prs_id <= PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP) { | |
| 1421 frame = rb.GetImageNamed(IDR_THEME_FRAME_DESKTOP); | |
| 1422 } | |
| 1423 #endif | |
| 1424 } | 1329 } |
| 1425 if (!frame.IsEmpty()) { | 1330 if (!frame.IsEmpty()) { |
| 1426 temp_output[prs_id] = CreateHSLShiftedImage( | 1331 temp_output[prs_id] = CreateHSLShiftedImage( |
| 1427 frame, GetTintInternal(kFrameTintMap[i].value)); | 1332 frame, GetTintInternal(kFrameTintMap[i].value)); |
| 1428 } | 1333 } |
| 1429 } | 1334 } |
| 1430 MergeImageCaches(temp_output, images); | 1335 MergeImageCaches(temp_output, images); |
| 1431 } | 1336 } |
| 1432 | 1337 |
| 1433 void BrowserThemePack::CreateTintedButtons( | 1338 void BrowserThemePack::CreateTintedButtons( |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1636 false, | 1541 false, |
| 1637 &bitmap_data)) { | 1542 &bitmap_data)) { |
| 1638 NOTREACHED() << "Unable to encode theme image for prs_id=" | 1543 NOTREACHED() << "Unable to encode theme image for prs_id=" |
| 1639 << prs_id << " for scale_factor=" << scale_factors_[i]; | 1544 << prs_id << " for scale_factor=" << scale_factors_[i]; |
| 1640 break; | 1545 break; |
| 1641 } | 1546 } |
| 1642 image_memory_[scaled_raw_id] = | 1547 image_memory_[scaled_raw_id] = |
| 1643 base::RefCountedBytes::TakeVector(&bitmap_data); | 1548 base::RefCountedBytes::TakeVector(&bitmap_data); |
| 1644 } | 1549 } |
| 1645 } | 1550 } |
| OLD | NEW |