Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/themes/browser_theme_pack.cc

Issue 2667753004: Themes: Remove unused IDs from ThemeProperties (Closed)
Patch Set: Remove COLOR_NTP_SECTION Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 30 matching lines...) Expand all
41 41
42 using content::BrowserThread; 42 using content::BrowserThread;
43 using extensions::Extension; 43 using extensions::Extension;
44 44
45 namespace { 45 namespace {
46 46
47 // Version number of the current theme pack. We just throw out and rebuild 47 // Version number of the current theme pack. We just throw out and rebuild
48 // theme packs that aren't int-equal to this. Increment this number if you 48 // theme packs that aren't int-equal to this. Increment this number if you
49 // change default theme assets or if you need themes to recreate their generated 49 // change default theme assets or if you need themes to recreate their generated
50 // images (which are cached). 50 // images (which are cached).
51 const int kThemePackVersion = 45; 51 const int kThemePackVersion = 46;
52 52
53 // IDs that are in the DataPack won't clash with the positive integer 53 // IDs that are in the DataPack won't clash with the positive integer
54 // uint16_t. kHeaderID should always have the maximum value because we want the 54 // uint16_t. kHeaderID should always have the maximum value because we want the
55 // "header" to be written last. That way we can detect whether the pack was 55 // "header" to be written last. That way we can detect whether the pack was
56 // successfully written and ignore and regenerate if it was only partially 56 // successfully written and ignore and regenerate if it was only partially
57 // written (i.e. chrome crashed on a different thread while writing the pack). 57 // written (i.e. chrome crashed on a different thread while writing the pack).
58 const int kMaxID = 0x0000FFFF; // Max unsigned 16-bit int. 58 const int kMaxID = 0x0000FFFF; // Max unsigned 16-bit int.
59 const int kHeaderID = kMaxID - 1; 59 const int kHeaderID = kMaxID - 1;
60 const int kTintsID = kMaxID - 2; 60 const int kTintsID = kMaxID - 2;
61 const int kColorsID = kMaxID - 3; 61 const int kColorsID = kMaxID - 3;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 { "frame_incognito", ThemeProperties::COLOR_FRAME_INCOGNITO }, 228 { "frame_incognito", ThemeProperties::COLOR_FRAME_INCOGNITO },
229 { "frame_incognito_inactive", 229 { "frame_incognito_inactive",
230 ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE }, 230 ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE },
231 { "toolbar", ThemeProperties::COLOR_TOOLBAR }, 231 { "toolbar", ThemeProperties::COLOR_TOOLBAR },
232 { "tab_text", ThemeProperties::COLOR_TAB_TEXT }, 232 { "tab_text", ThemeProperties::COLOR_TAB_TEXT },
233 { "tab_background_text", ThemeProperties::COLOR_BACKGROUND_TAB_TEXT }, 233 { "tab_background_text", ThemeProperties::COLOR_BACKGROUND_TAB_TEXT },
234 { "bookmark_text", ThemeProperties::COLOR_BOOKMARK_TEXT }, 234 { "bookmark_text", ThemeProperties::COLOR_BOOKMARK_TEXT },
235 { "ntp_background", ThemeProperties::COLOR_NTP_BACKGROUND }, 235 { "ntp_background", ThemeProperties::COLOR_NTP_BACKGROUND },
236 { "ntp_text", ThemeProperties::COLOR_NTP_TEXT }, 236 { "ntp_text", ThemeProperties::COLOR_NTP_TEXT },
237 { "ntp_link", ThemeProperties::COLOR_NTP_LINK }, 237 { "ntp_link", ThemeProperties::COLOR_NTP_LINK },
238 { "ntp_link_underline", ThemeProperties::COLOR_NTP_LINK_UNDERLINE },
239 { "ntp_header", ThemeProperties::COLOR_NTP_HEADER }, 238 { "ntp_header", ThemeProperties::COLOR_NTP_HEADER },
240 { "ntp_section", ThemeProperties::COLOR_NTP_SECTION },
241 { "ntp_section_text", ThemeProperties::COLOR_NTP_SECTION_TEXT },
242 { "ntp_section_link", ThemeProperties::COLOR_NTP_SECTION_LINK },
243 { "ntp_section_link_underline",
244 ThemeProperties::COLOR_NTP_SECTION_LINK_UNDERLINE },
245 { "button_background", ThemeProperties::COLOR_BUTTON_BACKGROUND }, 239 { "button_background", ThemeProperties::COLOR_BUTTON_BACKGROUND },
246 }; 240 };
247 const size_t kColorTableLength = arraysize(kColorTable); 241 const size_t kColorTableLength = arraysize(kColorTable);
248 242
249 // Strings used by themes to identify display properties keys in JSON. 243 // Strings used by themes to identify display properties keys in JSON.
250 const StringToIntTable kDisplayProperties[] = { 244 const StringToIntTable kDisplayProperties[] = {
251 { "ntp_background_alignment", 245 { "ntp_background_alignment",
252 ThemeProperties::NTP_BACKGROUND_ALIGNMENT }, 246 ThemeProperties::NTP_BACKGROUND_ALIGNMENT },
253 { "ntp_background_repeat", ThemeProperties::NTP_BACKGROUND_TILING }, 247 { "ntp_background_repeat", ThemeProperties::NTP_BACKGROUND_TILING },
254 { "ntp_logo_alternate", ThemeProperties::NTP_LOGO_ALTERNATE }, 248 { "ntp_logo_alternate", ThemeProperties::NTP_LOGO_ALTERNATE },
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 (alpha_int == 0 || alpha_int == 1)) { 956 (alpha_int == 0 || alpha_int == 1)) {
963 color = SkColorSetARGB(alpha_int ? 255 : 0, r, g, b); 957 color = SkColorSetARGB(alpha_int ? 255 : 0, r, g, b);
964 } else { 958 } else {
965 // Invalid entry for part 4. 959 // Invalid entry for part 4.
966 continue; 960 continue;
967 } 961 }
968 } else { 962 } else {
969 color = SkColorSetRGB(r, g, b); 963 color = SkColorSetRGB(r, g, b);
970 } 964 }
971 965
972 int id = GetIntForString(iter.key(), kColorTable, kColorTableLength); 966 if (iter.key() == "ntp_section") {
973 if (id != -1) { 967 // Allow ntp_section to provide a fallback value for ntp_header.
Evan Stade 2017/02/01 21:47:23 nit: We no longer use ntp_section, but to support
Tom (Use chromium acct) 2017/02/01 23:09:30 Done.
974 (*temp_colors)[id] = color; 968 if (!temp_colors->count(ThemeProperties::COLOR_NTP_HEADER))
969 (*temp_colors)[ThemeProperties::COLOR_NTP_HEADER] = color;
970 } else {
971 int id = GetIntForString(iter.key(), kColorTable, kColorTableLength);
972 if (id != -1) {
Evan Stade 2017/02/01 21:47:23 nit: no curlies
Tom (Use chromium acct) 2017/02/01 23:09:30 Done.
973 (*temp_colors)[id] = color;
974 }
975 } 975 }
976 } 976 }
977 } 977 }
978 } 978 }
979 } 979 }
980 980
981 void BrowserThemePack::GenerateMissingColors( 981 void BrowserThemePack::GenerateMissingColors(
982 std::map<int, SkColor>* colors) { 982 std::map<int, SkColor>* colors) {
983 // Generate link colors, if missing. (See GetColor()).
984 if (!colors->count(ThemeProperties::COLOR_NTP_HEADER) &&
985 colors->count(ThemeProperties::COLOR_NTP_SECTION)) {
986 (*colors)[ThemeProperties::COLOR_NTP_HEADER] =
987 (*colors)[ThemeProperties::COLOR_NTP_SECTION];
988 }
989
990 if (!colors->count(ThemeProperties::COLOR_NTP_SECTION_LINK_UNDERLINE) &&
991 colors->count(ThemeProperties::COLOR_NTP_SECTION_LINK)) {
992 SkColor color_section_link =
993 (*colors)[ThemeProperties::COLOR_NTP_SECTION_LINK];
994 (*colors)[ThemeProperties::COLOR_NTP_SECTION_LINK_UNDERLINE] =
995 SkColorSetA(color_section_link, SkColorGetA(color_section_link) / 3);
996 }
997
998 if (!colors->count(ThemeProperties::COLOR_NTP_LINK_UNDERLINE) &&
999 colors->count(ThemeProperties::COLOR_NTP_LINK)) {
1000 SkColor color_link = (*colors)[ThemeProperties::COLOR_NTP_LINK];
1001 (*colors)[ThemeProperties::COLOR_NTP_LINK_UNDERLINE] =
1002 SkColorSetA(color_link, SkColorGetA(color_link) / 3);
1003 }
1004
1005 // Generate frame colors, if missing. (See GenerateFrameColors()). 983 // Generate frame colors, if missing. (See GenerateFrameColors()).
1006 SkColor frame; 984 SkColor frame;
1007 std::map<int, SkColor>::const_iterator it = 985 std::map<int, SkColor>::const_iterator it =
1008 colors->find(ThemeProperties::COLOR_FRAME); 986 colors->find(ThemeProperties::COLOR_FRAME);
1009 if (it != colors->end()) { 987 if (it != colors->end()) {
1010 frame = it->second; 988 frame = it->second;
1011 } else { 989 } else {
1012 frame = 990 frame =
1013 ThemeProperties::GetDefaultColor(ThemeProperties::COLOR_FRAME, false); 991 ThemeProperties::GetDefaultColor(ThemeProperties::COLOR_FRAME, false);
1014 } 992 }
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 false, 1430 false,
1453 &bitmap_data)) { 1431 &bitmap_data)) {
1454 NOTREACHED() << "Unable to encode theme image for prs_id=" 1432 NOTREACHED() << "Unable to encode theme image for prs_id="
1455 << prs_id << " for scale_factor=" << scale_factors_[i]; 1433 << prs_id << " for scale_factor=" << scale_factors_[i];
1456 break; 1434 break;
1457 } 1435 }
1458 image_memory_[scaled_raw_id] = 1436 image_memory_[scaled_raw_id] =
1459 base::RefCountedBytes::TakeVector(&bitmap_data); 1437 base::RefCountedBytes::TakeVector(&bitmap_data);
1460 } 1438 }
1461 } 1439 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698