Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/theme_properties.h" | 5 #include "chrome/browser/themes/theme_properties.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
|
pkotwicz
2015/07/03 15:39:22
I don't think this include is necessary
jonross
2015/07/03 18:26:49
Done.
| |
| 7 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 9 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 10 #include "chrome/browser/themes/browser_theme_pack.h" | 11 #include "chrome/browser/themes/browser_theme_pack.h" |
| 11 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
| 13 #include "ui/base/resource/material_design/material_design_controller.h" | |
| 12 #include "ui/resources/grit/ui_resources.h" | 14 #include "ui/resources/grit/ui_resources.h" |
| 13 | 15 |
| 14 namespace { | 16 namespace { |
| 15 | 17 |
| 16 // ---------------------------------------------------------------------------- | 18 // ---------------------------------------------------------------------------- |
| 17 // Defaults for properties which are stored in the browser theme pack. If you | 19 // Defaults for properties which are stored in the browser theme pack. If you |
| 18 // change these defaults, you must increment the version number in | 20 // change these defaults, you must increment the version number in |
| 19 // browser_theme_pack.h | 21 // browser_theme_pack.h |
| 20 | 22 |
| 21 // Default colors. | 23 // Default colors. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 #if defined(OS_MACOSX) | 91 #if defined(OS_MACOSX) |
| 90 const SkColor kDefaultColorToolbarButtonStroke = SkColorSetARGB(75, 81, 81, 81); | 92 const SkColor kDefaultColorToolbarButtonStroke = SkColorSetARGB(75, 81, 81, 81); |
| 91 const SkColor kDefaultColorToolbarButtonStrokeInactive = | 93 const SkColor kDefaultColorToolbarButtonStrokeInactive = |
| 92 SkColorSetARGB(75, 99, 99, 99); | 94 SkColorSetARGB(75, 99, 99, 99); |
| 93 const SkColor kDefaultColorToolbarBezel = SkColorSetRGB(204, 204, 204); | 95 const SkColor kDefaultColorToolbarBezel = SkColorSetRGB(204, 204, 204); |
| 94 const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103); | 96 const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103); |
| 95 const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(163, 163, 163); | 97 const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(163, 163, 163); |
| 96 #endif | 98 #endif |
| 97 | 99 |
| 98 // ---------------------------------------------------------------------------- | 100 // ---------------------------------------------------------------------------- |
| 101 // Defaults for layout properties, which are not stored in the browser theme | |
| 102 // pack. | |
| 103 | |
| 104 // The edge graphics have some built-in spacing/shadowing, so we have to adjust | |
| 105 // our spacing to make it match. | |
| 106 const int kToolbarViewLeftEdgeSpacing = 3; | |
| 107 const int kToolbarViewRightEdgeSpacing = 2; | |
| 108 | |
| 109 // Ash doesn't use a rounded content area and its top edge has an extra shadow. | |
| 110 const int kToolbarViewContentShadowHeightAsh = 2; | |
| 111 | |
| 112 // Non-ash uses a rounded content area with no shadow in the assets. | |
| 113 const int kToolbarViewContentShadowHeight = 0; | |
| 114 | |
| 115 #if defined(ENABLE_TOPCHROME_MD) | |
| 116 const int kToolbarViewLeftEdgeSpacingMD = 4; | |
| 117 const int kToolbarViewLeftEdgeSpacingMDHybrid = 8; | |
| 118 | |
| 119 const int kToolbarViewRightEdgeSpacingMD = 4; | |
| 120 const int kToolbarViewRightEdgeSpacingMDHybrid = 8; | |
| 121 | |
| 122 const int kToolbarViewContentShadowHeightAshMD = 0; | |
| 123 const int kToolbarViewContentShadowHeightAshMDHybrid = 0; | |
| 124 | |
| 125 const int kToolbarViewContentShadowHeightMD = 0; | |
| 126 const int kToolbarViewContentShadowHeightMDHybrid = 0; | |
| 127 #endif | |
| 128 | |
| 129 // ---------------------------------------------------------------------------- | |
| 99 | 130 |
| 100 // Strings used in alignment properties. | 131 // Strings used in alignment properties. |
| 101 const char kAlignmentCenter[] = "center"; | 132 const char kAlignmentCenter[] = "center"; |
| 102 const char kAlignmentTop[] = "top"; | 133 const char kAlignmentTop[] = "top"; |
| 103 const char kAlignmentBottom[] = "bottom"; | 134 const char kAlignmentBottom[] = "bottom"; |
| 104 const char kAlignmentLeft[] = "left"; | 135 const char kAlignmentLeft[] = "left"; |
| 105 const char kAlignmentRight[] = "right"; | 136 const char kAlignmentRight[] = "right"; |
| 106 | 137 |
| 107 // Strings used in background tiling repetition properties. | 138 // Strings used in background tiling repetition properties. |
| 108 const char kTilingNoRepeat[] = "no-repeat"; | 139 const char kTilingNoRepeat[] = "no-repeat"; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 128 IDR_BROWSER_ACTIONS_OVERFLOW_P, | 159 IDR_BROWSER_ACTIONS_OVERFLOW_P, |
| 129 IDR_TOOLS, IDR_TOOLS_H, IDR_TOOLS_P, | 160 IDR_TOOLS, IDR_TOOLS_H, IDR_TOOLS_P, |
| 130 IDR_MENU_DROPARROW, | 161 IDR_MENU_DROPARROW, |
| 131 IDR_TOOLBAR_BEZEL_HOVER, IDR_TOOLBAR_BEZEL_PRESSED, IDR_TOOLS_BAR, | 162 IDR_TOOLBAR_BEZEL_HOVER, IDR_TOOLBAR_BEZEL_PRESSED, IDR_TOOLS_BAR, |
| 132 }; | 163 }; |
| 133 | 164 |
| 134 SkColor TintForUnderline(SkColor input) { | 165 SkColor TintForUnderline(SkColor input) { |
| 135 return SkColorSetA(input, SkColorGetA(input) / 3); | 166 return SkColorSetA(input, SkColorGetA(input) / 3); |
| 136 } | 167 } |
| 137 | 168 |
| 169 int GetDefaultDisplayPropertyInternal(int id) { | |
| 170 switch (id) { | |
| 171 case ThemeProperties::NTP_BACKGROUND_ALIGNMENT: | |
| 172 return kDefaultDisplayPropertyNTPAlignment; | |
| 173 case ThemeProperties::NTP_BACKGROUND_TILING: | |
| 174 return kDefaultDisplayPropertyNTPTiling; | |
| 175 case ThemeProperties::NTP_LOGO_ALTERNATE: | |
| 176 return kDefaultDisplayPropertyNTPAlternateLogo; | |
| 177 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_LEFT_EDGE_SPACING: | |
| 178 return kToolbarViewLeftEdgeSpacing; | |
| 179 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_RIGHT_EDGE_SPACING: | |
| 180 return kToolbarViewRightEdgeSpacing; | |
| 181 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT_ASH: | |
| 182 return kToolbarViewContentShadowHeightAsh; | |
| 183 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT: | |
| 184 return kToolbarViewContentShadowHeight; | |
| 185 } | |
| 186 | |
| 187 return -1; | |
| 188 } | |
| 189 | |
| 190 #if defined(ENABLE_TOPCHROME_MD) | |
| 191 int GetMaterialDefaultDisplayProperty(int id) { | |
| 192 switch (id) { | |
| 193 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_LEFT_EDGE_SPACING: | |
| 194 return kToolbarViewLeftEdgeSpacingMD; | |
| 195 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_RIGHT_EDGE_SPACING: | |
| 196 return kToolbarViewRightEdgeSpacingMD; | |
| 197 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT_ASH: | |
| 198 return kToolbarViewContentShadowHeightAshMD; | |
| 199 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT: | |
| 200 return kToolbarViewContentShadowHeightMD; | |
| 201 default: | |
| 202 return GetDefaultDisplayPropertyInternal(id); | |
| 203 } | |
| 204 | |
| 205 return -1; | |
| 206 } | |
| 207 | |
| 208 int GetMaterialHybridDefaultDisplayProperty(int id) { | |
| 209 switch (id) { | |
| 210 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_LEFT_EDGE_SPACING: | |
| 211 return kToolbarViewLeftEdgeSpacingMDHybrid; | |
| 212 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_RIGHT_EDGE_SPACING: | |
| 213 return kToolbarViewRightEdgeSpacingMDHybrid; | |
| 214 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT_ASH: | |
| 215 return kToolbarViewContentShadowHeightAshMDHybrid; | |
| 216 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT: | |
| 217 return kToolbarViewContentShadowHeightMDHybrid; | |
| 218 default: | |
| 219 return GetMaterialDefaultDisplayProperty(id); | |
| 220 } | |
| 221 return -1; | |
| 222 } | |
| 223 #endif | |
| 224 | |
| 138 } // namespace | 225 } // namespace |
| 139 | 226 |
| 140 // static | 227 // static |
| 141 int ThemeProperties::StringToAlignment(const std::string& alignment) { | 228 int ThemeProperties::StringToAlignment(const std::string& alignment) { |
| 142 std::vector<std::string> split; | 229 std::vector<std::string> split; |
| 143 base::SplitStringAlongWhitespace(alignment, &split); | 230 base::SplitStringAlongWhitespace(alignment, &split); |
| 144 | 231 |
| 145 int alignment_mask = 0; | 232 int alignment_mask = 0; |
| 146 for (std::vector<std::string>::iterator component(split.begin()); | 233 for (std::vector<std::string>::iterator component(split.begin()); |
| 147 component != split.end(); ++component) { | 234 component != split.end(); ++component) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 return kDefaultColorToolbarStrokeInactive; | 379 return kDefaultColorToolbarStrokeInactive; |
| 293 #endif | 380 #endif |
| 294 default: | 381 default: |
| 295 // Return a debugging red color. | 382 // Return a debugging red color. |
| 296 return SK_ColorRED; | 383 return SK_ColorRED; |
| 297 } | 384 } |
| 298 } | 385 } |
| 299 | 386 |
| 300 // static | 387 // static |
| 301 int ThemeProperties::GetDefaultDisplayProperty(int id) { | 388 int ThemeProperties::GetDefaultDisplayProperty(int id) { |
| 302 switch (id) { | 389 #if defined(ENABLE_TOPCHROME_MD) |
| 303 case NTP_BACKGROUND_ALIGNMENT: | 390 switch (ui::MaterialDesignController::GetMode()) { |
| 304 return kDefaultDisplayPropertyNTPAlignment; | 391 case (ui::MaterialDesignController::Mode::MATERIAL): |
| 305 case NTP_BACKGROUND_TILING: | 392 return GetMaterialDefaultDisplayProperty(id); |
| 306 return kDefaultDisplayPropertyNTPTiling; | 393 case (ui::MaterialDesignController::Mode::MATERIAL_HYBRID): |
| 307 case NTP_LOGO_ALTERNATE: | 394 return GetMaterialHybridDefaultDisplayProperty(id); |
| 308 return kDefaultDisplayPropertyNTPAlternateLogo; | 395 case (ui::MaterialDesignController::Mode::NON_MATERIAL): |
| 396 return GetDefaultDisplayPropertyInternal(id); | |
| 397 default: | |
|
pkotwicz
2015/07/03 15:39:22
Why the default statement?
jonross
2015/07/03 17:09:31
I've had some builds throw compilation errors if I
pkotwicz
2015/07/03 17:34:01
This could have to do with C++11 enum classes. We
jonross
2015/07/03 18:26:49
Done.
| |
| 398 NOTREACHED(); | |
| 399 break; | |
| 309 } | 400 } |
| 310 | 401 #endif |
| 311 return -1; | 402 return GetDefaultDisplayPropertyInternal(id); |
| 312 } | 403 } |
| OLD | NEW |