| 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 = 33; | 46 const int kThemePackVersion = 34; |
| 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(OS_WIN) | 165 #if defined(USE_ASH) && !defined(OS_CHROMEOS) |
| 166 // Persistent theme ids for Windows. | 166 // Persistent theme ids for Windows. |
| 167 const int PRS_THEME_FRAME_WIN = 100; | 167 const int PRS_THEME_FRAME_DESKTOP = 100; |
| 168 const int PRS_THEME_FRAME_INACTIVE_WIN = 101; | 168 const int PRS_THEME_FRAME_INACTIVE_DESKTOP = 101; |
| 169 const int PRS_THEME_FRAME_INCOGNITO_WIN = 102; | 169 const int PRS_THEME_FRAME_INCOGNITO_DESKTOP = 102; |
| 170 const int PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN = 103; | 170 const int PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP = 103; |
| 171 const int PRS_THEME_TOOLBAR_WIN = 104; | 171 const int PRS_THEME_TOOLBAR_DESKTOP = 104; |
| 172 const int PRS_THEME_TAB_BACKGROUND_WIN = 105; | 172 const int PRS_THEME_TAB_BACKGROUND_DESKTOP = 105; |
| 173 const int PRS_THEME_TAB_BACKGROUND_INCOGNITO_WIN = 106; | 173 const int PRS_THEME_TAB_BACKGROUND_INCOGNITO_DESKTOP = 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 kPersistingImagesWinDesktopAura[] = { | 176 PersistingImagesTable kPersistingImagesDesktopAura[] = { |
| 177 { PRS_THEME_FRAME_WIN, IDR_THEME_FRAME_WIN, | 177 { PRS_THEME_FRAME_DESKTOP, IDR_THEME_FRAME_DESKTOP, |
| 178 "theme_frame" }, | 178 "theme_frame" }, |
| 179 { PRS_THEME_FRAME_INACTIVE_WIN, IDR_THEME_FRAME_INACTIVE_WIN, | 179 { PRS_THEME_FRAME_INACTIVE_DESKTOP, IDR_THEME_FRAME_INACTIVE_DESKTOP, |
| 180 "theme_frame_inactive" }, | 180 "theme_frame_inactive" }, |
| 181 { PRS_THEME_FRAME_INCOGNITO_WIN, IDR_THEME_FRAME_INCOGNITO_WIN, | 181 { PRS_THEME_FRAME_INCOGNITO_DESKTOP, IDR_THEME_FRAME_INCOGNITO_DESKTOP, |
| 182 "theme_frame_incognito" }, | 182 "theme_frame_incognito" }, |
| 183 { PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN, | 183 { PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP, |
| 184 IDR_THEME_FRAME_INCOGNITO_INACTIVE_WIN, | 184 IDR_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP, |
| 185 "theme_frame_incognito_inactive" }, | 185 "theme_frame_incognito_inactive" }, |
| 186 { PRS_THEME_TOOLBAR_WIN, IDR_THEME_TOOLBAR_WIN, | 186 { PRS_THEME_TOOLBAR_DESKTOP, IDR_THEME_TOOLBAR_DESKTOP, |
| 187 "theme_toolbar" }, | 187 "theme_toolbar" }, |
| 188 { PRS_THEME_TAB_BACKGROUND_WIN, IDR_THEME_TAB_BACKGROUND_WIN, | 188 { PRS_THEME_TAB_BACKGROUND_DESKTOP, IDR_THEME_TAB_BACKGROUND_DESKTOP, |
| 189 "theme_tab_background" }, | 189 "theme_tab_background" }, |
| 190 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_WIN, | 190 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_DESKTOP, |
| 191 IDR_THEME_TAB_BACKGROUND_INCOGNITO_WIN, | 191 IDR_THEME_TAB_BACKGROUND_INCOGNITO_DESKTOP, |
| 192 "theme_tab_background_incognito" }, | 192 "theme_tab_background_incognito" }, |
| 193 }; | 193 }; |
| 194 const size_t kPersistingImagesWinDesktopAuraLength = | 194 const size_t kPersistingImagesDesktopAuraLength = |
| 195 arraysize(kPersistingImagesWinDesktopAura); | 195 arraysize(kPersistingImagesDesktopAura); |
| 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(OS_WIN) | 224 #if defined(USE_ASH) && !defined(OS_CHROMEOS) |
| 225 for (size_t i = 0; i < kPersistingImagesWinDesktopAuraLength; ++i) { | 225 for (size_t i = 0; i < kPersistingImagesDesktopAuraLength; ++i) { |
| 226 int idr = kPersistingImagesWinDesktopAura[i].idr_id; | 226 int idr = kPersistingImagesDesktopAura[i].idr_id; |
| 227 int prs_id = kPersistingImagesWinDesktopAura[i].persistent_id; | 227 int prs_id = kPersistingImagesDesktopAura[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(OS_WIN) | 344 #if defined(USE_ASH) && !defined(OS_CHROMEOS) |
| 345 { PRS_THEME_FRAME_WIN, ThemeProperties::TINT_FRAME }, | 345 { PRS_THEME_FRAME_DESKTOP, ThemeProperties::TINT_FRAME }, |
| 346 { PRS_THEME_FRAME_INACTIVE_WIN, ThemeProperties::TINT_FRAME_INACTIVE }, | 346 { PRS_THEME_FRAME_INACTIVE_DESKTOP, ThemeProperties::TINT_FRAME_INACTIVE }, |
| 347 { PRS_THEME_FRAME_INCOGNITO_WIN, ThemeProperties::TINT_FRAME_INCOGNITO }, | 347 { PRS_THEME_FRAME_INCOGNITO_DESKTOP, ThemeProperties::TINT_FRAME_INCOGNITO }, |
| 348 { PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN, | 348 { PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP, |
| 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(OS_WIN) | 358 #if defined(USE_ASH) && !defined(OS_CHROMEOS) |
| 359 { PRS_THEME_TAB_BACKGROUND_WIN, PRS_THEME_FRAME_WIN }, | 359 { PRS_THEME_TAB_BACKGROUND_DESKTOP, PRS_THEME_FRAME_DESKTOP }, |
| 360 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_WIN, PRS_THEME_FRAME_INCOGNITO_WIN }, | 360 { PRS_THEME_TAB_BACKGROUND_INCOGNITO_DESKTOP, |
| 361 PRS_THEME_FRAME_INCOGNITO_DESKTOP }, |
| 361 #endif | 362 #endif |
| 362 }; | 363 }; |
| 363 | 364 |
| 364 struct CropEntry { | 365 struct CropEntry { |
| 365 int prs_id; | 366 int prs_id; |
| 366 | 367 |
| 367 // The maximum useful height of the image at |prs_id|. | 368 // The maximum useful height of the image at |prs_id|. |
| 368 int max_height; | 369 int max_height; |
| 369 | 370 |
| 370 // Whether cropping the image at |prs_id| should be skipped on OSes which | 371 // Whether cropping the image at |prs_id| should be skipped on OSes which |
| (...skipping 11 matching lines...) Expand all Loading... |
| 382 struct CropEntry kImagesToCrop[] = { | 383 struct CropEntry kImagesToCrop[] = { |
| 383 { PRS_THEME_FRAME, 120, true }, | 384 { PRS_THEME_FRAME, 120, true }, |
| 384 { PRS_THEME_FRAME_INACTIVE, 120, true }, | 385 { PRS_THEME_FRAME_INACTIVE, 120, true }, |
| 385 { PRS_THEME_FRAME_INCOGNITO, 120, true }, | 386 { PRS_THEME_FRAME_INCOGNITO, 120, true }, |
| 386 { PRS_THEME_FRAME_INCOGNITO_INACTIVE, 120, true }, | 387 { PRS_THEME_FRAME_INCOGNITO_INACTIVE, 120, true }, |
| 387 { PRS_THEME_FRAME_OVERLAY, 120, true }, | 388 { PRS_THEME_FRAME_OVERLAY, 120, true }, |
| 388 { PRS_THEME_FRAME_OVERLAY_INACTIVE, 120, true }, | 389 { PRS_THEME_FRAME_OVERLAY_INACTIVE, 120, true }, |
| 389 { PRS_THEME_TOOLBAR, 200, false }, | 390 { PRS_THEME_TOOLBAR, 200, false }, |
| 390 { PRS_THEME_BUTTON_BACKGROUND, 60, false }, | 391 { PRS_THEME_BUTTON_BACKGROUND, 60, false }, |
| 391 { PRS_THEME_WINDOW_CONTROL_BACKGROUND, 50, false }, | 392 { PRS_THEME_WINDOW_CONTROL_BACKGROUND, 50, false }, |
| 392 #if defined(OS_WIN) | 393 #if defined(USE_ASH) && !defined(OS_CHROMEOS) |
| 393 { PRS_THEME_TOOLBAR_WIN, 200, false } | 394 { PRS_THEME_TOOLBAR_DESKTOP, 200, false } |
| 394 #endif | 395 #endif |
| 395 }; | 396 }; |
| 396 | 397 |
| 397 | 398 |
| 398 // A list of images that don't need tinting or any other modification and can | 399 // 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 | 400 // 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, | 401 // persistent IDs for all themeable image IDs that aren't in kFrameTintMap, |
| 401 // kTabBackgroundMap or kImagesToCrop. | 402 // kTabBackgroundMap or kImagesToCrop. |
| 402 const int kPreloadIDs[] = { | 403 const int kPreloadIDs[] = { |
| 403 PRS_THEME_NTP_BACKGROUND, | 404 PRS_THEME_NTP_BACKGROUND, |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 | 762 |
| 762 // static | 763 // static |
| 763 void BrowserThemePack::GetThemeableImageIDRs(std::set<int>* result) { | 764 void BrowserThemePack::GetThemeableImageIDRs(std::set<int>* result) { |
| 764 if (!result) | 765 if (!result) |
| 765 return; | 766 return; |
| 766 | 767 |
| 767 result->clear(); | 768 result->clear(); |
| 768 for (size_t i = 0; i < kPersistingImagesLength; ++i) | 769 for (size_t i = 0; i < kPersistingImagesLength; ++i) |
| 769 result->insert(kPersistingImages[i].idr_id); | 770 result->insert(kPersistingImages[i].idr_id); |
| 770 | 771 |
| 771 #if defined(OS_WIN) | 772 #if defined(USE_ASH) && !defined(OS_CHROMEOS) |
| 772 for (size_t i = 0; i < kPersistingImagesWinDesktopAuraLength; ++i) | 773 for (size_t i = 0; i < kPersistingImagesDesktopAuraLength; ++i) |
| 773 result->insert(kPersistingImagesWinDesktopAura[i].idr_id); | 774 result->insert(kPersistingImagesDesktopAura[i].idr_id); |
| 774 #endif | 775 #endif |
| 775 } | 776 } |
| 776 | 777 |
| 777 bool BrowserThemePack::WriteToDisk(const base::FilePath& path) const { | 778 bool BrowserThemePack::WriteToDisk(const base::FilePath& path) const { |
| 778 // Add resources for each of the property arrays. | 779 // Add resources for each of the property arrays. |
| 779 RawDataForWriting resources; | 780 RawDataForWriting resources; |
| 780 resources[kHeaderID] = base::StringPiece( | 781 resources[kHeaderID] = base::StringPiece( |
| 781 reinterpret_cast<const char*>(header_), sizeof(BrowserThemePackHeader)); | 782 reinterpret_cast<const char*>(header_), sizeof(BrowserThemePackHeader)); |
| 782 resources[kTintsID] = base::StringPiece( | 783 resources[kTintsID] = base::StringPiece( |
| 783 reinterpret_cast<const char*>(tints_), | 784 reinterpret_cast<const char*>(tints_), |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 } | 1202 } |
| 1202 } | 1203 } |
| 1203 | 1204 |
| 1204 void BrowserThemePack::AddFileAtScaleToMap(const std::string& image_name, | 1205 void BrowserThemePack::AddFileAtScaleToMap(const std::string& image_name, |
| 1205 ui::ScaleFactor scale_factor, | 1206 ui::ScaleFactor scale_factor, |
| 1206 const base::FilePath& image_path, | 1207 const base::FilePath& image_path, |
| 1207 FilePathMap* file_paths) const { | 1208 FilePathMap* file_paths) const { |
| 1208 int id = GetPersistentIDByName(image_name); | 1209 int id = GetPersistentIDByName(image_name); |
| 1209 if (id != -1) | 1210 if (id != -1) |
| 1210 (*file_paths)[id][scale_factor] = image_path; | 1211 (*file_paths)[id][scale_factor] = image_path; |
| 1211 #if defined(OS_WIN) | 1212 #if defined(USE_ASH) && !defined(OS_CHROMEOS) |
| 1212 id = GetPersistentIDByNameHelper(image_name, | 1213 id = GetPersistentIDByNameHelper(image_name, |
| 1213 kPersistingImagesWinDesktopAura, | 1214 kPersistingImagesDesktopAura, |
| 1214 kPersistingImagesWinDesktopAuraLength); | 1215 kPersistingImagesDesktopAuraLength); |
| 1215 if (id != -1) | 1216 if (id != -1) |
| 1216 (*file_paths)[id][scale_factor] = image_path; | 1217 (*file_paths)[id][scale_factor] = image_path; |
| 1217 #endif | 1218 #endif |
| 1218 } | 1219 } |
| 1219 | 1220 |
| 1220 void BrowserThemePack::BuildSourceImagesArray(const FilePathMap& file_paths) { | 1221 void BrowserThemePack::BuildSourceImagesArray(const FilePathMap& file_paths) { |
| 1221 std::vector<int> ids; | 1222 std::vector<int> ids; |
| 1222 for (FilePathMap::const_iterator it = file_paths.begin(); | 1223 for (FilePathMap::const_iterator it = file_paths.begin(); |
| 1223 it != file_paths.end(); ++it) { | 1224 it != file_paths.end(); ++it) { |
| 1224 ids.push_back(it->first); | 1225 ids.push_back(it->first); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 ImageCache temp_output; | 1330 ImageCache temp_output; |
| 1330 | 1331 |
| 1331 for (size_t i = 0; i < arraysize(kFrameTintMap); ++i) { | 1332 for (size_t i = 0; i < arraysize(kFrameTintMap); ++i) { |
| 1332 int prs_id = kFrameTintMap[i].key; | 1333 int prs_id = kFrameTintMap[i].key; |
| 1333 gfx::Image frame; | 1334 gfx::Image frame; |
| 1334 // If there's no frame image provided for the specified id, then load | 1335 // If there's no frame image provided for the specified id, then load |
| 1335 // the default provided frame. If that's not provided, skip this whole | 1336 // the default provided frame. If that's not provided, skip this whole |
| 1336 // thing and just use the default images. | 1337 // thing and just use the default images. |
| 1337 int prs_base_id = 0; | 1338 int prs_base_id = 0; |
| 1338 | 1339 |
| 1339 #if defined(OS_WIN) | 1340 #if defined(USE_ASH) && !defined(OS_CHROMEOS) |
| 1340 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN) { | 1341 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP) { |
| 1341 prs_base_id = images->count(PRS_THEME_FRAME_INCOGNITO_WIN) ? | 1342 prs_base_id = images->count(PRS_THEME_FRAME_INCOGNITO_DESKTOP) ? |
| 1342 PRS_THEME_FRAME_INCOGNITO_WIN : PRS_THEME_FRAME_WIN; | 1343 PRS_THEME_FRAME_INCOGNITO_DESKTOP : PRS_THEME_FRAME_DESKTOP; |
| 1343 } else if (prs_id == PRS_THEME_FRAME_INACTIVE_WIN) { | 1344 } else if (prs_id == PRS_THEME_FRAME_INACTIVE_DESKTOP) { |
| 1344 prs_base_id = PRS_THEME_FRAME_WIN; | 1345 prs_base_id = PRS_THEME_FRAME_DESKTOP; |
| 1345 } else if (prs_id == PRS_THEME_FRAME_INCOGNITO_WIN && | 1346 } else if (prs_id == PRS_THEME_FRAME_INCOGNITO_DESKTOP && |
| 1346 !images->count(PRS_THEME_FRAME_INCOGNITO_WIN)) { | 1347 !images->count(PRS_THEME_FRAME_INCOGNITO_DESKTOP)) { |
| 1347 prs_base_id = PRS_THEME_FRAME_WIN; | 1348 prs_base_id = PRS_THEME_FRAME_DESKTOP; |
| 1348 } | 1349 } |
| 1349 #endif | 1350 #endif |
| 1350 if (!prs_base_id) { | 1351 if (!prs_base_id) { |
| 1351 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE) { | 1352 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE) { |
| 1352 prs_base_id = images->count(PRS_THEME_FRAME_INCOGNITO) ? | 1353 prs_base_id = images->count(PRS_THEME_FRAME_INCOGNITO) ? |
| 1353 PRS_THEME_FRAME_INCOGNITO : PRS_THEME_FRAME; | 1354 PRS_THEME_FRAME_INCOGNITO : PRS_THEME_FRAME; |
| 1354 } else if (prs_id == PRS_THEME_FRAME_OVERLAY_INACTIVE) { | 1355 } else if (prs_id == PRS_THEME_FRAME_OVERLAY_INACTIVE) { |
| 1355 prs_base_id = PRS_THEME_FRAME_OVERLAY; | 1356 prs_base_id = PRS_THEME_FRAME_OVERLAY; |
| 1356 } else if (prs_id == PRS_THEME_FRAME_INACTIVE) { | 1357 } else if (prs_id == PRS_THEME_FRAME_INACTIVE) { |
| 1357 prs_base_id = PRS_THEME_FRAME; | 1358 prs_base_id = PRS_THEME_FRAME; |
| 1358 } else if (prs_id == PRS_THEME_FRAME_INCOGNITO && | 1359 } else if (prs_id == PRS_THEME_FRAME_INCOGNITO && |
| 1359 !images->count(PRS_THEME_FRAME_INCOGNITO)) { | 1360 !images->count(PRS_THEME_FRAME_INCOGNITO)) { |
| 1360 prs_base_id = PRS_THEME_FRAME; | 1361 prs_base_id = PRS_THEME_FRAME; |
| 1361 } else { | 1362 } else { |
| 1362 prs_base_id = prs_id; | 1363 prs_base_id = prs_id; |
| 1363 } | 1364 } |
| 1364 } | 1365 } |
| 1365 if (images->count(prs_id)) { | 1366 if (images->count(prs_id)) { |
| 1366 frame = (*images)[prs_id]; | 1367 frame = (*images)[prs_id]; |
| 1367 } else if (prs_base_id != prs_id && images->count(prs_base_id)) { | 1368 } else if (prs_base_id != prs_id && images->count(prs_base_id)) { |
| 1368 frame = (*images)[prs_base_id]; | 1369 frame = (*images)[prs_base_id]; |
| 1369 } else if (prs_base_id == PRS_THEME_FRAME_OVERLAY) { | 1370 } else if (prs_base_id == PRS_THEME_FRAME_OVERLAY) { |
| 1370 #if defined(OS_WIN) | 1371 #if defined(USE_ASH) && !defined(OS_CHROMEOS) |
| 1371 if (images->count(PRS_THEME_FRAME_WIN)) { | 1372 if (images->count(PRS_THEME_FRAME_DESKTOP)) { |
| 1372 #else | 1373 #else |
| 1373 if (images->count(PRS_THEME_FRAME)) { | 1374 if (images->count(PRS_THEME_FRAME)) { |
| 1374 #endif | 1375 #endif |
| 1375 // If there is no theme overlay, don't tint the default frame, | 1376 // If there is no theme overlay, don't tint the default frame, |
| 1376 // because it will overwrite the custom frame image when we cache and | 1377 // because it will overwrite the custom frame image when we cache and |
| 1377 // reload from disk. | 1378 // reload from disk. |
| 1378 frame = gfx::Image(); | 1379 frame = gfx::Image(); |
| 1379 } | 1380 } |
| 1380 } else { | 1381 } else { |
| 1381 // If the theme doesn't specify an image, then apply the tint to | 1382 // If the theme doesn't specify an image, then apply the tint to |
| 1382 // the default frame. | 1383 // the default frame. |
| 1383 frame = rb.GetImageNamed(IDR_THEME_FRAME); | 1384 frame = rb.GetImageNamed(IDR_THEME_FRAME); |
| 1384 #if defined(OS_WIN) && defined(USE_AURA) | 1385 #if defined(USE_ASH) && !defined(OS_CHROMEOS) |
| 1385 if (prs_id >= PRS_THEME_FRAME_WIN && | 1386 if (prs_id >= PRS_THEME_FRAME_DESKTOP && |
| 1386 prs_id <= PRS_THEME_FRAME_INCOGNITO_INACTIVE_WIN) { | 1387 prs_id <= PRS_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP) { |
| 1387 frame = rb.GetImageNamed(IDR_THEME_FRAME_WIN); | 1388 frame = rb.GetImageNamed(IDR_THEME_FRAME_DESKTOP); |
| 1388 } | 1389 } |
| 1389 #endif | 1390 #endif |
| 1390 } | 1391 } |
| 1391 if (!frame.IsEmpty()) { | 1392 if (!frame.IsEmpty()) { |
| 1392 temp_output[prs_id] = CreateHSLShiftedImage( | 1393 temp_output[prs_id] = CreateHSLShiftedImage( |
| 1393 frame, GetTintInternal(kFrameTintMap[i].value)); | 1394 frame, GetTintInternal(kFrameTintMap[i].value)); |
| 1394 } | 1395 } |
| 1395 } | 1396 } |
| 1396 MergeImageCaches(temp_output, images); | 1397 MergeImageCaches(temp_output, images); |
| 1397 } | 1398 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 false, | 1604 false, |
| 1604 &bitmap_data)) { | 1605 &bitmap_data)) { |
| 1605 NOTREACHED() << "Unable to encode theme image for prs_id=" | 1606 NOTREACHED() << "Unable to encode theme image for prs_id=" |
| 1606 << prs_id << " for scale_factor=" << scale_factors_[i]; | 1607 << prs_id << " for scale_factor=" << scale_factors_[i]; |
| 1607 break; | 1608 break; |
| 1608 } | 1609 } |
| 1609 image_memory_[scaled_raw_id] = | 1610 image_memory_[scaled_raw_id] = |
| 1610 base::RefCountedBytes::TakeVector(&bitmap_data); | 1611 base::RefCountedBytes::TakeVector(&bitmap_data); |
| 1611 } | 1612 } |
| 1612 } | 1613 } |
| OLD | NEW |