12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file. 42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/themes/theme_properties.h" 62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/scoped_ptr.h" 82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/strings/string_split.h" 9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string_util.h" 102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/themes/browser_theme_pack.h" 112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "grit/theme_resources.h" 122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "grit/ui_resources.h" 132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace { 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// ---------------------------------------------------------------------------- 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Defaults for properties which are stored in the browser theme pack. If you 182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// change these defaults, you must increment the version number in 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// browser_theme_pack.h 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Default colors. 2258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#if defined(OS_CHROMEOS) 232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Used for theme fallback colors. 242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorFrame = SkColorSetRGB(109, 109, 109); 252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorFrameInactive = SkColorSetRGB(176, 176, 176); 262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#else 272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorFrame = SkColorSetRGB(66, 116, 201); 282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorFrameInactive = SkColorSetRGB(161, 182, 228); 292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif // USE_AURA 302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorFrameIncognito = SkColorSetRGB(83, 106, 139); 312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorFrameIncognitoInactive = 322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) SkColorSetRGB(126, 139, 156); 332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_MACOSX) 342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorToolbar = SkColorSetRGB(230, 230, 230); 352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#else 362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorToolbar = SkColorSetRGB(223, 223, 223); 372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorTabText = SK_ColorBLACK; 392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_MACOSX) 402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorBackgroundTabText = SK_ColorBLACK; 412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#else 422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorBackgroundTabText = SkColorSetRGB(64, 64, 64); 432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorBookmarkText = SK_ColorBLACK; 452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_WIN) 462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorNTPBackground = 472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) color_utils::GetSysSkColor(COLOR_WINDOW); 482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorNTPText = 492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) color_utils::GetSysSkColor(COLOR_WINDOWTEXT); 502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorNTPLink = 512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) color_utils::GetSysSkColor(COLOR_HOTLIGHT); 522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#else 532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// TODO(beng): source from theme provider. 542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorNTPBackground = SK_ColorWHITE; 552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorNTPText = SK_ColorBLACK; 562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorNTPLink = SkColorSetRGB(6, 55, 116); 572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorNTPHeader = SkColorSetRGB(150, 150, 150); 592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorNTPSection = SkColorSetRGB(229, 229, 229); 602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorNTPSectionText = SK_ColorBLACK; 612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorNTPSectionLink = SkColorSetRGB(6, 55, 116); 622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorButtonBackground = SkColorSetARGB(0, 0, 0, 0); 632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Default tints. 652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const color_utils::HSL kDefaultTintButtons = { -1, -1, -1 }; 662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const color_utils::HSL kDefaultTintFrame = { -1, -1, -1 }; 672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const color_utils::HSL kDefaultTintFrameInactive = { -1, -1, 0.75f }; 682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const color_utils::HSL kDefaultTintFrameIncognito = { -1, 0.2f, 0.35f }; 692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const color_utils::HSL kDefaultTintFrameIncognitoInactive = { -1, 0.3f, 0.6f }; 702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const color_utils::HSL kDefaultTintBackgroundTab = { -1, 0.5, 0.75 }; 712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Default display properties. 732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const int kDefaultDisplayPropertyNTPAlignment = 74424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) ThemeProperties::ALIGN_CENTER; 752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const int kDefaultDisplayPropertyNTPTiling = 762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ThemeProperties::NO_REPEAT; 77424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// By default, we do not use the ntp alternate logo. 78424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)const int kDefaultDisplayPropertyNTPAlternateLogo = 0; 792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// ---------------------------------------------------------------------------- 812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Defaults for properties which are not stored in the browser theme pack. 822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorControlBackground = SK_ColorWHITE; 842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorToolbarSeparator = SkColorSetRGB(170, 170, 171); 852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_MACOSX) 872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorToolbarButtonStroke = SkColorSetARGB(75, 81, 81, 81); 882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorToolbarButtonStrokeInactive = 892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) SkColorSetARGB(75, 99, 99, 99); 902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorToolbarBezel = SkColorSetRGB(204, 204, 204); 912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103); 922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(163, 163, 163); 932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// ---------------------------------------------------------------------------- 962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Strings used in alignment properties. 982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const char* kAlignmentCenter = "center"; 992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const char* kAlignmentTop = "top"; 1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const char* kAlignmentBottom = "bottom"; 1012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const char* kAlignmentLeft = "left"; 1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const char* kAlignmentRight = "right"; 1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Strings used in background tiling repetition properties. 1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const char* kTilingNoRepeat = "no-repeat"; 1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const char* kTilingRepeatX = "repeat-x"; 1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const char* kTilingRepeatY = "repeat-y"; 1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const char* kTilingRepeat = "repeat"; 1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// The image resources that will be tinted by the 'button' tint value. 1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// If you change this list, you must increment the version number in 1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// browser_theme_pack.cc, and you should assign persistent IDs to the 1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// data table at the start of said file or else tinted versions of 1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// these resources will not be created. 1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const int kToolbarButtonIDs[] = { 1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IDR_BACK, IDR_BACK_D, IDR_BACK_H, IDR_BACK_P, 1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IDR_FORWARD, IDR_FORWARD_D, IDR_FORWARD_H, IDR_FORWARD_P, 1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IDR_HOME, IDR_HOME_H, IDR_HOME_P, 1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IDR_RELOAD, IDR_RELOAD_H, IDR_RELOAD_P, 1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IDR_STOP, IDR_STOP_D, IDR_STOP_H, IDR_STOP_P, 1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IDR_BROWSER_ACTIONS_OVERFLOW, IDR_BROWSER_ACTIONS_OVERFLOW_H, 1222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IDR_BROWSER_ACTIONS_OVERFLOW_P, 1232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IDR_TOOLS, IDR_TOOLS_H, IDR_TOOLS_P, 1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IDR_MENU_DROPARROW, 1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) IDR_THROBBER, IDR_THROBBER_WAITING, IDR_THROBBER_LIGHT, 126c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) IDR_TOOLBAR_BEZEL_HOVER, IDR_TOOLBAR_BEZEL_PRESSED, IDR_TOOLS_BAR, 1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)SkColor TintForUnderline(SkColor input) { 1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return SkColorSetA(input, SkColorGetA(input) / 3); 1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} // namespace 1342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static 1362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)int ThemeProperties::StringToAlignment(const std::string& alignment) { 1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) std::vector<std::string> split; 1382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::SplitStringAlongWhitespace(alignment, &split); 1392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int alignment_mask = 0; 1412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) for (std::vector<std::string>::iterator component(split.begin()); 1422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) component != split.end(); ++component) { 1432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (LowerCaseEqualsASCII(*component, kAlignmentTop)) 1442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) alignment_mask |= ALIGN_TOP; 1452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) else if (LowerCaseEqualsASCII(*component, kAlignmentBottom)) 1462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) alignment_mask |= ALIGN_BOTTOM; 1472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) else if (LowerCaseEqualsASCII(*component, kAlignmentLeft)) 1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) alignment_mask |= ALIGN_LEFT; 1492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) else if (LowerCaseEqualsASCII(*component, kAlignmentRight)) 1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) alignment_mask |= ALIGN_RIGHT; 1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return alignment_mask; 1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static 1562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)int ThemeProperties::StringToTiling(const std::string& tiling) { 1572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const char* component = tiling.c_str(); 1582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (base::strcasecmp(component, kTilingRepeatX) == 0) 1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return REPEAT_X; 1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (base::strcasecmp(component, kTilingRepeatY) == 0) 1622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return REPEAT_Y; 1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (base::strcasecmp(component, kTilingRepeat) == 0) 1642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return REPEAT; 1652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // NO_REPEAT is the default choice. 1662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return NO_REPEAT; 1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static 1702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)std::string ThemeProperties::AlignmentToString(int alignment) { 1712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Convert from an AlignmentProperty back into a string. 1722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) std::string vertical_string(kAlignmentCenter); 1732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) std::string horizontal_string(kAlignmentCenter); 1742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (alignment & ALIGN_TOP) 1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) vertical_string = kAlignmentTop; 1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) else if (alignment & ALIGN_BOTTOM) 1782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) vertical_string = kAlignmentBottom; 1792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (alignment & ALIGN_LEFT) 1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) horizontal_string = kAlignmentLeft; 1822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) else if (alignment & ALIGN_RIGHT) 1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) horizontal_string = kAlignmentRight; 1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return horizontal_string + " " + vertical_string; 1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static 1892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)std::string ThemeProperties::TilingToString(int tiling) { 1902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Convert from a TilingProperty back into a string. 1912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (tiling == REPEAT_X) 1922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kTilingRepeatX; 1932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (tiling == REPEAT_Y) 1942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kTilingRepeatY; 1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (tiling == REPEAT) 1962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kTilingRepeat; 1972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kTilingNoRepeat; 1982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static 2012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool ThemeProperties::IsThemeableImage(int id) { 2022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // TODO(pkotwicz): Cache results to improve lookup speed. 2032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) std::set<int> themeable_idrs; 2042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) BrowserThemePack::GetThemeableImageIDRs(&themeable_idrs); 2052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return themeable_idrs.find(id) != themeable_idrs.end(); 2062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static 2092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const std::set<int>& ThemeProperties::GetTintableToolbarButtons() { 2102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CR_DEFINE_STATIC_LOCAL(std::set<int>, button_set, ()); 2112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (button_set.empty()) { 2122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) button_set = std::set<int>( 2132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) kToolbarButtonIDs, 2142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) kToolbarButtonIDs + arraysize(kToolbarButtonIDs)); 2152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 2162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return button_set; 2182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static 2212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)color_utils::HSL ThemeProperties::GetDefaultTint(int id) { 2222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) switch (id) { 2232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case TINT_FRAME: 2242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultTintFrame; 2252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case TINT_FRAME_INACTIVE: 2262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultTintFrameInactive; 2272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case TINT_FRAME_INCOGNITO: 2282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultTintFrameIncognito; 2292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case TINT_FRAME_INCOGNITO_INACTIVE: 2302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultTintFrameIncognitoInactive; 2312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case TINT_BUTTONS: 2322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultTintButtons; 2332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case TINT_BACKGROUND_TAB: 2342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultTintBackgroundTab; 2352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) default: 2362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) color_utils::HSL result = {-1, -1, -1}; 2372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return result; 2382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 2392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static 2422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)SkColor ThemeProperties::GetDefaultColor(int id) { 2432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) switch (id) { 2442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Properties stored in theme pack. 2452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_FRAME: 2462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorFrame; 2472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_FRAME_INACTIVE: 2482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorFrameInactive; 2492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_FRAME_INCOGNITO: 2502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorFrameIncognito; 2512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_FRAME_INCOGNITO_INACTIVE: 2522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorFrameIncognitoInactive; 2532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_TOOLBAR: 2542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorToolbar; 2552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_TAB_TEXT: 2562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorTabText; 2572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_BACKGROUND_TAB_TEXT: 2582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorBackgroundTabText; 2592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_BOOKMARK_TEXT: 2602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorBookmarkText; 2612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_NTP_BACKGROUND: 2622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorNTPBackground; 2632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_NTP_TEXT: 2642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorNTPText; 2652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_NTP_LINK: 2662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorNTPLink; 2672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_NTP_LINK_UNDERLINE: 2682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return TintForUnderline(kDefaultColorNTPLink); 2692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_NTP_HEADER: 2702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorNTPHeader; 2712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_NTP_SECTION: 2722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorNTPSection; 2732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_NTP_SECTION_TEXT: 2742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorNTPSectionText; 2752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_NTP_SECTION_LINK: 2762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorNTPSectionLink; 2772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_NTP_SECTION_LINK_UNDERLINE: 2782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return TintForUnderline(kDefaultColorNTPSectionLink); 2792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_BUTTON_BACKGROUND: 2802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorButtonBackground; 2812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Properties not stored in theme pack. 2832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_CONTROL_BACKGROUND: 2842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorControlBackground; 2852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_TOOLBAR_SEPARATOR: 2862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorToolbarSeparator; 2872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_MACOSX) 2882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_TOOLBAR_BUTTON_STROKE: 2892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorToolbarButtonStroke; 2902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE: 2912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorToolbarButtonStrokeInactive; 2922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_TOOLBAR_BEZEL: 2932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorToolbarBezel; 2942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_TOOLBAR_STROKE: 2952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorToolbarStroke; 2962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case COLOR_TOOLBAR_STROKE_INACTIVE: 2972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return kDefaultColorToolbarStrokeInactive; 2982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 2992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) default: 3002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Return a debugging red color. 3012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return SK_ColorRED; 3022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 3032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 3042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static 306424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)int ThemeProperties::GetDefaultDisplayProperty(int id) { 3072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) switch (id) { 3082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case NTP_BACKGROUND_ALIGNMENT: 309424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) return kDefaultDisplayPropertyNTPAlignment; 3102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case NTP_BACKGROUND_TILING: 311424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) return kDefaultDisplayPropertyNTPTiling; 3122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case NTP_LOGO_ALTERNATE: 313424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) return kDefaultDisplayPropertyNTPAlternateLogo; 3142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 3152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 316424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) return -1; 3172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 318