| 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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "chrome/browser/themes/browser_theme_pack.h" | 10 #include "chrome/browser/themes/browser_theme_pack.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 const SkColor kDefaultColorButtonBackground = SkColorSetARGB(0, 0, 0, 0); | 78 const SkColor kDefaultColorButtonBackground = SkColorSetARGB(0, 0, 0, 0); |
| 79 | 79 |
| 80 // Default tints. | 80 // Default tints. |
| 81 const color_utils::HSL kDefaultTintButtons = { -1, -1, -1 }; | 81 const color_utils::HSL kDefaultTintButtons = { -1, -1, -1 }; |
| 82 const color_utils::HSL kDefaultTintFrame = { -1, -1, -1 }; | 82 const color_utils::HSL kDefaultTintFrame = { -1, -1, -1 }; |
| 83 const color_utils::HSL kDefaultTintFrameInactive = { -1, -1, 0.75f }; | 83 const color_utils::HSL kDefaultTintFrameInactive = { -1, -1, 0.75f }; |
| 84 const color_utils::HSL kDefaultTintFrameIncognito = { -1, 0.2f, 0.35f }; | 84 const color_utils::HSL kDefaultTintFrameIncognito = { -1, 0.2f, 0.35f }; |
| 85 const color_utils::HSL kDefaultTintFrameIncognitoInactive = { -1, 0.3f, 0.6f }; | 85 const color_utils::HSL kDefaultTintFrameIncognitoInactive = { -1, 0.3f, 0.6f }; |
| 86 const color_utils::HSL kDefaultTintBackgroundTab = { -1, 0.5, 0.75 }; | 86 const color_utils::HSL kDefaultTintBackgroundTab = { -1, 0.5, 0.75 }; |
| 87 | 87 |
| 88 // Default display properties. | |
| 89 const int kDefaultDisplayPropertyNTPAlignment = | |
| 90 ThemeProperties::ALIGN_CENTER; | |
| 91 const int kDefaultDisplayPropertyNTPTiling = | |
| 92 ThemeProperties::NO_REPEAT; | |
| 93 // By default, we do not use the ntp alternate logo. | |
| 94 const int kDefaultDisplayPropertyNTPAlternateLogo = 0; | |
| 95 | |
| 96 // ---------------------------------------------------------------------------- | 88 // ---------------------------------------------------------------------------- |
| 97 // Defaults for properties which are not stored in the browser theme pack. | 89 // Defaults for properties which are not stored in the browser theme pack. |
| 98 | 90 |
| 99 const SkColor kDefaultColorControlBackground = SK_ColorWHITE; | 91 const SkColor kDefaultColorControlBackground = SK_ColorWHITE; |
| 100 const SkColor kDefaultColorToolbarSeparator[] = { | 92 const SkColor kDefaultColorToolbarSeparator[] = { |
| 101 SkColorSetRGB(170, 170, 171), SkColorSetRGB(182, 180, 182)}; | 93 SkColorSetRGB(170, 170, 171), SkColorSetRGB(182, 180, 182)}; |
| 102 | 94 |
| 103 #if defined(OS_MACOSX) | 95 #if defined(OS_MACOSX) |
| 104 const SkColor kDefaultColorToolbarButtonStroke = SkColorSetARGB(75, 81, 81, 81); | 96 const SkColor kDefaultColorToolbarButtonStroke = SkColorSetARGB(75, 81, 81, 81); |
| 105 const SkColor kDefaultColorToolbarButtonStrokeInactive = | 97 const SkColor kDefaultColorToolbarButtonStrokeInactive = |
| 106 SkColorSetARGB(75, 99, 99, 99); | 98 SkColorSetARGB(75, 99, 99, 99); |
| 107 const SkColor kDefaultColorToolbarBezel = SkColorSetRGB(204, 204, 204); | 99 const SkColor kDefaultColorToolbarBezel = SkColorSetRGB(204, 204, 204); |
| 108 const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103); | 100 const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103); |
| 109 const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(163, 163, 163); | 101 const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(163, 163, 163); |
| 110 #endif // OS_MACOSX | 102 #endif // OS_MACOSX |
| 111 | 103 |
| 112 // ---------------------------------------------------------------------------- | 104 // ---------------------------------------------------------------------------- |
| 113 // Defaults for layout properties which are not stored in the browser theme | |
| 114 // pack. The array indices here are the values of | |
| 115 // ui::MaterialDesignController::Mode, see | |
| 116 // ui/base/resource/material_design/material_design_controller.h | |
| 117 | |
| 118 // Additional horizontal padding applied on the trailing edge of icon-label | |
| 119 // views. | |
| 120 const int kIconLabelViewTrailingPadding[] = {2, 8, 8}; | |
| 121 | |
| 122 // The horizontal space between the edge and a bubble | |
| 123 const int kLocationBarBubbleHorizontalPadding[] = {1, 5, 5}; | |
| 124 | |
| 125 // The additional vertical padding of a bubble. | |
| 126 const int kLocationBarBubbleVerticalPadding[] = {1, 3, 3}; | |
| 127 | |
| 128 // The height to be occupied by the LocationBar. For | |
| 129 // MaterialDesignController::NON_MATERIAL the height is determined from image | |
| 130 // assets. | |
| 131 const int kLocationBarHeight[] = {0, 28, 32}; | |
| 132 | |
| 133 // Space between items in the location bar, as well as between items and the | |
| 134 // edges. | |
| 135 const int kLocationBarHorizontalPadding[] = {3, 6, 6}; | |
| 136 | |
| 137 // The Vertical padding of items in the location bar. | |
| 138 const int kLocationBarVerticalPadding[] = {2, 6, 6}; | |
| 139 | |
| 140 // The number of pixels in the omnibox dropdown border image interior to | |
| 141 // the actual border. | |
| 142 const int kOmniboxDropdownBorderInterior[] = {6, 0, 0}; | |
| 143 | |
| 144 // In an omnibox dropdown row, the minimum distance between the top and | |
| 145 // bottom of the row's icon and the top or bottom of the row edge. | |
| 146 const int kOmniboxDropdownMinIconVerticalPadding[] = {2, 4, 8}; | |
| 147 | |
| 148 // In an omnibox dropdown row, the minimum distance between the top and | |
| 149 // bottom of the row's text and the top or bottom of the row edge. | |
| 150 const int kOmniboxDropdownMinTextVerticalPadding[] = {3, 4, 8}; | |
| 151 | |
| 152 // The spacing between a ToolbarButton's image and its border. | |
| 153 const int kToolbarButtonBorderInset[] = {2, 6, 6}; | |
| 154 | |
| 155 // The minimum bottom vertical padding of the toolbar. | |
| 156 const int kToolbarViewBottomVerticalPadding[] = {5, 5, 5}; | |
| 157 | |
| 158 // Non-ash uses a rounded content area with no shadow in the assets. | |
| 159 const int kToolbarViewContentShadowHeight[] = {0, 0, 0}; | |
| 160 | |
| 161 // Ash doesn't use a rounded content area and its top edge has an extra shadow. | |
| 162 const int kToolbarViewContentShadowHeightAsh[] = {2, 0, 0}; | |
| 163 | |
| 164 // Additional horizontal padding between the elements in the toolbar. | |
| 165 const int kToolbarViewElementPadding[] = {0, 0, 8}; | |
| 166 | |
| 167 // Padding between the right-edge of the location bar and browser actions. | |
| 168 const int kToolbarViewLocationBarRightPadding[] = {0, 4, 8}; | |
| 169 | |
| 170 // The edge graphics have some built-in spacing/shadowing, so we have to adjust | |
| 171 // our spacing to make it match. | |
| 172 const int kToolbarViewLeftEdgeSpacing[] = {3, 4, 8}; | |
| 173 const int kToolbarViewRightEdgeSpacing[] = {2, 4, 8}; | |
| 174 | |
| 175 // The horizontal space between most items. | |
| 176 const int kToolbarViewStandardSpacing[] = {3, 4, 8}; | |
| 177 | |
| 178 // The minimum top vertical padding of the toolbar. | |
| 179 const int kToolbarViewTopVerticalPadding[] = {5, 4, 4}; | |
| 180 | |
| 181 // ---------------------------------------------------------------------------- | |
| 182 | 105 |
| 183 // Strings used in alignment properties. | 106 // Strings used in alignment properties. |
| 184 const char kAlignmentCenter[] = "center"; | 107 const char kAlignmentCenter[] = "center"; |
| 185 const char kAlignmentTop[] = "top"; | 108 const char kAlignmentTop[] = "top"; |
| 186 const char kAlignmentBottom[] = "bottom"; | 109 const char kAlignmentBottom[] = "bottom"; |
| 187 const char kAlignmentLeft[] = "left"; | 110 const char kAlignmentLeft[] = "left"; |
| 188 const char kAlignmentRight[] = "right"; | 111 const char kAlignmentRight[] = "right"; |
| 189 | 112 |
| 190 // Strings used in background tiling repetition properties. | 113 // Strings used in background tiling repetition properties. |
| 191 const char kTilingNoRepeat[] = "no-repeat"; | 114 const char kTilingNoRepeat[] = "no-repeat"; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 case COLOR_TOOLBAR_STROKE: | 310 case COLOR_TOOLBAR_STROKE: |
| 388 return kDefaultColorToolbarStroke; | 311 return kDefaultColorToolbarStroke; |
| 389 case COLOR_TOOLBAR_STROKE_INACTIVE: | 312 case COLOR_TOOLBAR_STROKE_INACTIVE: |
| 390 return kDefaultColorToolbarStrokeInactive; | 313 return kDefaultColorToolbarStrokeInactive; |
| 391 #endif | 314 #endif |
| 392 default: | 315 default: |
| 393 // Return a debugging red color. | 316 // Return a debugging red color. |
| 394 return SK_ColorRED; | 317 return SK_ColorRED; |
| 395 } | 318 } |
| 396 } | 319 } |
| 397 | |
| 398 // static | |
| 399 int ThemeProperties::GetDefaultDisplayProperty(int id) { | |
| 400 int mode = ui::MaterialDesignController::GetMode(); | |
| 401 switch (id) { | |
| 402 case NTP_BACKGROUND_ALIGNMENT: | |
| 403 return kDefaultDisplayPropertyNTPAlignment; | |
| 404 case NTP_BACKGROUND_TILING: | |
| 405 return kDefaultDisplayPropertyNTPTiling; | |
| 406 case NTP_LOGO_ALTERNATE: | |
| 407 return kDefaultDisplayPropertyNTPAlternateLogo; | |
| 408 case PROPERTY_ICON_LABEL_VIEW_TRAILING_PADDING: | |
| 409 return kIconLabelViewTrailingPadding[mode]; | |
| 410 case PROPERTY_LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING: | |
| 411 return kLocationBarBubbleHorizontalPadding[mode]; | |
| 412 case PROPERTY_LOCATION_BAR_BUBBLE_VERTICAL_PADDING: | |
| 413 return kLocationBarBubbleVerticalPadding[mode]; | |
| 414 case PROPERTY_LOCATION_BAR_HEIGHT: | |
| 415 return kLocationBarHeight[mode]; | |
| 416 case PROPERTY_LOCATION_BAR_HORIZONTAL_PADDING: | |
| 417 return kLocationBarHorizontalPadding[mode]; | |
| 418 case PROPERTY_LOCATION_BAR_VERTICAL_PADDING: | |
| 419 return kLocationBarVerticalPadding[mode]; | |
| 420 case PROPERTY_OMNIBOX_DROPDOWN_BORDER_INTERIOR: | |
| 421 return kOmniboxDropdownBorderInterior[mode]; | |
| 422 case PROPERTY_OMNIBOX_DROPDOWN_MIN_ICON_VERTICAL_PADDING: | |
| 423 return kOmniboxDropdownMinIconVerticalPadding[mode]; | |
| 424 case PROPERTY_OMNIBOX_DROPDOWN_MIN_TEXT_VERTICAL_PADDING: | |
| 425 return kOmniboxDropdownMinTextVerticalPadding[mode]; | |
| 426 case PROPERTY_TOOLBAR_BUTTON_BORDER_INSET: | |
| 427 return kToolbarButtonBorderInset[mode]; | |
| 428 case PROPERTY_TOOLBAR_VIEW_BOTTOM_VERTICAL_PADDING: | |
| 429 return kToolbarViewBottomVerticalPadding[mode]; | |
| 430 case PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT: | |
| 431 return kToolbarViewContentShadowHeight[mode]; | |
| 432 case PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT_ASH: | |
| 433 return kToolbarViewContentShadowHeightAsh[mode]; | |
| 434 case PROPERTY_TOOLBAR_VIEW_ELEMENT_PADDING: | |
| 435 return kToolbarViewElementPadding[mode]; | |
| 436 case PROPERTY_TOOLBAR_VIEW_LEFT_EDGE_SPACING: | |
| 437 return kToolbarViewLeftEdgeSpacing[mode]; | |
| 438 case PROPERTY_TOOLBAR_VIEW_LOCATION_BAR_RIGHT_PADDING: | |
| 439 return kToolbarViewLocationBarRightPadding[mode]; | |
| 440 case PROPERTY_TOOLBAR_VIEW_RIGHT_EDGE_SPACING: | |
| 441 return kToolbarViewRightEdgeSpacing[mode]; | |
| 442 case PROPERTY_TOOLBAR_VIEW_STANDARD_SPACING: | |
| 443 return kToolbarViewStandardSpacing[mode]; | |
| 444 case PROPERTY_TOOLBAR_VIEW_TOP_VERTICAL_PADDING: | |
| 445 return kToolbarViewTopVerticalPadding[mode]; | |
| 446 default: | |
| 447 return -1; | |
| 448 } | |
| 449 } | |
| OLD | NEW |