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

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

Issue 1885183002: Allow constexpr, and use it in a few places. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add guidance Created 4 years, 8 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
« no previous file with comments | « no previous file | styleguide/c++/c++11.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 const SkColor kDefaultColorToolbar[] = { 64 const SkColor kDefaultColorToolbar[] = {
65 SkColorSetRGB(223, 223, 223), SkColorSetRGB(242, 242, 242)}; 65 SkColorSetRGB(223, 223, 223), SkColorSetRGB(242, 242, 242)};
66 const SkColor kDefaultColorToolbarIncognito[] = { 66 const SkColor kDefaultColorToolbarIncognito[] = {
67 SkColorSetRGB(223, 223, 223), SkColorSetRGB(0x50, 0x50, 0x50)}; 67 SkColorSetRGB(223, 223, 223), SkColorSetRGB(0x50, 0x50, 0x50)};
68 #endif // OS_MACOSX 68 #endif // OS_MACOSX
69 const SkColor kDefaultDetachedBookmarkBarBackground[] = { 69 const SkColor kDefaultDetachedBookmarkBarBackground[] = {
70 SkColorSetRGB(0xF1, 0xF1, 0xF1), SK_ColorWHITE}; 70 SkColorSetRGB(0xF1, 0xF1, 0xF1), SK_ColorWHITE};
71 const SkColor kDefaultDetachedBookmarkBarBackgroundIncognito[] = { 71 const SkColor kDefaultDetachedBookmarkBarBackgroundIncognito[] = {
72 SkColorSetRGB(0xF1, 0xF1, 0xF1), SkColorSetRGB(0x32, 0x32, 0x32)}; 72 SkColorSetRGB(0xF1, 0xF1, 0xF1), SkColorSetRGB(0x32, 0x32, 0x32)};
73 73
74 const SkColor kDefaultColorTabText = SK_ColorBLACK; 74 constexpr SkColor kDefaultColorTabText = SK_ColorBLACK;
75 const SkColor kDefaultColorTabTextIncognito[] = {SK_ColorBLACK, SK_ColorWHITE}; 75 constexpr SkColor kDefaultColorTabTextIncognito[] = {kDefaultColorTabText,
76 SK_ColorWHITE};
76 77
77 #if defined(OS_MACOSX) 78 #if defined(OS_MACOSX)
78 const SkColor kDefaultColorBackgroundTabText[] = { 79 constexpr SkColor kDefaultColorBackgroundTabText[] = {SK_ColorBLACK,
79 SK_ColorBLACK, SK_ColorBLACK }; 80 SK_ColorBLACK};
80 const SkColor kDefaultColorBackgroundTabTextIncognito[] = { 81 constexpr SkColor kDefaultColorBackgroundTabTextIncognito[] = {
81 SK_ColorBLACK, SK_ColorWHITE }; 82 kDefaultColorBackgroundTabText[0], SK_ColorWHITE};
82 #else 83 #else
83 const SkColor kDefaultColorBackgroundTabText[] = { 84 const SkColor kDefaultColorBackgroundTabText[] = {
84 SkColorSetRGB(64, 64, 64), SK_ColorBLACK }; 85 SkColorSetRGB(64, 64, 64), SK_ColorBLACK };
85 const SkColor kDefaultColorBackgroundTabTextIncognito[] = { 86 const SkColor kDefaultColorBackgroundTabTextIncognito[] = {
86 SkColorSetRGB(64, 64, 64), SK_ColorWHITE }; 87 SkColorSetRGB(64, 64, 64), SK_ColorWHITE };
87 #endif // OS_MACOSX 88 #endif // OS_MACOSX
88 89
89 const SkColor kDefaultColorBookmarkText = SK_ColorBLACK; 90 constexpr SkColor kDefaultColorBookmarkText = SK_ColorBLACK;
90 const SkColor kDefaultColorBookmarkTextIncognito[] = {SK_ColorBLACK, 91 constexpr SkColor kDefaultColorBookmarkTextIncognito[] = {
91 SK_ColorWHITE}; 92 kDefaultColorBookmarkText, SK_ColorWHITE};
92 93
93 #if defined(OS_WIN) 94 #if defined(OS_WIN)
94 const SkColor kDefaultColorNTPBackground = 95 const SkColor kDefaultColorNTPBackground =
95 color_utils::GetSysSkColor(COLOR_WINDOW); 96 color_utils::GetSysSkColor(COLOR_WINDOW);
96 const SkColor kDefaultColorNTPText = 97 const SkColor kDefaultColorNTPText =
97 color_utils::GetSysSkColor(COLOR_WINDOWTEXT); 98 color_utils::GetSysSkColor(COLOR_WINDOWTEXT);
98 const SkColor kDefaultColorNTPLink = 99 const SkColor kDefaultColorNTPLink =
99 color_utils::GetSysSkColor(COLOR_HOTLIGHT); 100 color_utils::GetSysSkColor(COLOR_HOTLIGHT);
100 #else 101 #else
101 // TODO(beng): source from theme provider. 102 // TODO(beng): source from theme provider.
102 const SkColor kDefaultColorNTPBackground = SK_ColorWHITE; 103 constexpr SkColor kDefaultColorNTPBackground = SK_ColorWHITE;
103 const SkColor kDefaultColorNTPText = SK_ColorBLACK; 104 constexpr SkColor kDefaultColorNTPText = SK_ColorBLACK;
104 const SkColor kDefaultColorNTPLink = SkColorSetRGB(6, 55, 116); 105 const SkColor kDefaultColorNTPLink = SkColorSetRGB(6, 55, 116);
105 #endif // OS_WIN 106 #endif // OS_WIN
106 107
107 const SkColor kDefaultColorNTPHeader = SkColorSetRGB(150, 150, 150); 108 const SkColor kDefaultColorNTPHeader = SkColorSetRGB(150, 150, 150);
108 const SkColor kDefaultColorNTPSection = SkColorSetRGB(229, 229, 229); 109 const SkColor kDefaultColorNTPSection = SkColorSetRGB(229, 229, 229);
109 const SkColor kDefaultColorNTPSectionText = SK_ColorBLACK; 110 constexpr SkColor kDefaultColorNTPSectionText = SK_ColorBLACK;
110 const SkColor kDefaultColorNTPSectionLink = SkColorSetRGB(6, 55, 116); 111 const SkColor kDefaultColorNTPSectionLink = SkColorSetRGB(6, 55, 116);
111 const SkColor kDefaultColorButtonBackground = SkColorSetARGB(0, 0, 0, 0); 112 constexpr SkColor kDefaultColorButtonBackground = SK_ColorTRANSPARENT;
112 113
113 // Default tints. 114 // Default tints.
114 const color_utils::HSL kDefaultTintButtons = {-1, -1, -1}; 115 constexpr color_utils::HSL kDefaultTintButtons = {-1, -1, -1};
115 // In pre-md, reuse the normal tint for incognito. 116 constexpr color_utils::HSL kDefaultTintButtonsIncognito[] = {
116 const color_utils::HSL kDefaultTintButtonsIncognito[] = {{-1, -1, -1}, 117 kDefaultTintButtons, {-1, -1, 0.85}};
117 {-1, -1, 0.85}}; 118 constexpr color_utils::HSL kDefaultTintFrame = {-1, -1, -1};
118 const color_utils::HSL kDefaultTintFrame = {-1, -1, -1}; 119 constexpr color_utils::HSL kDefaultTintFrameInactive = {-1, -1, 0.75};
119 const color_utils::HSL kDefaultTintFrameInactive = {-1, -1, 0.75}; 120 constexpr color_utils::HSL kDefaultTintFrameIncognito = {-1, 0.2, 0.35};
120 const color_utils::HSL kDefaultTintFrameIncognito = {-1, 0.2, 0.35}; 121 constexpr color_utils::HSL kDefaultTintFrameIncognitoInactive = {-1, 0.3, 0.6};
121 const color_utils::HSL kDefaultTintFrameIncognitoInactive = {-1, 0.3, 0.6}; 122 constexpr color_utils::HSL kDefaultTintBackgroundTab = {-1, -1, 0.75};
122 const color_utils::HSL kDefaultTintBackgroundTab = {-1, -1, 0.75};
123 123
124 // ---------------------------------------------------------------------------- 124 // ----------------------------------------------------------------------------
125 // Defaults for properties which are not stored in the browser theme pack. 125 // Defaults for properties which are not stored in the browser theme pack.
126 126
127 const SkColor kDefaultColorControlBackground = SK_ColorWHITE; 127 constexpr SkColor kDefaultColorControlBackground = SK_ColorWHITE;
128 const SkColor kDefaultDetachedBookmarkBarSeparator[] = { 128 const SkColor kDefaultDetachedBookmarkBarSeparator[] = {
129 SkColorSetRGB(170, 170, 171), SkColorSetRGB(182, 180, 182)}; 129 SkColorSetRGB(170, 170, 171), SkColorSetRGB(182, 180, 182)};
130 const SkColor kDefaultDetachedBookmarkBarSeparatorIncognito[] = { 130 const SkColor kDefaultDetachedBookmarkBarSeparatorIncognito[] = {
131 SkColorSetRGB(170, 170, 171), SkColorSetRGB(0x28, 0x28, 0x28)}; 131 SkColorSetRGB(170, 170, 171), SkColorSetRGB(0x28, 0x28, 0x28)};
132 const SkColor kDefaultToolbarTopSeparator = SkColorSetA(SK_ColorBLACK, 0x40); 132 const SkColor kDefaultToolbarTopSeparator = SkColorSetA(SK_ColorBLACK, 0x40);
133 133
134 #if defined(OS_MACOSX) 134 #if defined(OS_MACOSX)
135 const SkColor kDefaultColorFrameVibrancyOverlay[] = { 135 const SkColor kDefaultColorFrameVibrancyOverlay[] = {
136 SkColorSetARGB(25, 0, 0, 0), SkColorSetARGB(230, 20, 22, 24)}; 136 SkColorSetARGB(25, 0, 0, 0), SkColorSetARGB(230, 20, 22, 24)};
137 const SkColor kDefaultColorToolbarInactive[] = { 137 const SkColor kDefaultColorToolbarInactive[] = {
(...skipping 14 matching lines...) Expand all
152 const SkColor kDefaultColorToolbarIncognitoStroke[] = { 152 const SkColor kDefaultColorToolbarIncognitoStroke[] = {
153 SkColorSetRGB(103, 103, 103), SkColorSetARGB(63, 0, 0, 0)}; 153 SkColorSetRGB(103, 103, 103), SkColorSetARGB(63, 0, 0, 0)};
154 const SkColor kDefaultColorToolbarStrokeTheme = 154 const SkColor kDefaultColorToolbarStrokeTheme =
155 SkColorSetARGB(102, 255, 255, 255); 155 SkColorSetARGB(102, 255, 255, 255);
156 const SkColor kDefaultColorToolbarStrokeThemeInactive = 156 const SkColor kDefaultColorToolbarStrokeThemeInactive =
157 SkColorSetARGB(102, 76, 76, 76); 157 SkColorSetARGB(102, 76, 76, 76);
158 #endif // OS_MACOSX 158 #endif // OS_MACOSX
159 // ---------------------------------------------------------------------------- 159 // ----------------------------------------------------------------------------
160 160
161 // Strings used in alignment properties. 161 // Strings used in alignment properties.
162 const char kAlignmentCenter[] = "center"; 162 constexpr char kAlignmentCenter[] = "center";
163 const char kAlignmentTop[] = "top"; 163 constexpr char kAlignmentTop[] = "top";
164 const char kAlignmentBottom[] = "bottom"; 164 constexpr char kAlignmentBottom[] = "bottom";
165 const char kAlignmentLeft[] = "left"; 165 constexpr char kAlignmentLeft[] = "left";
166 const char kAlignmentRight[] = "right"; 166 constexpr char kAlignmentRight[] = "right";
167 167
168 // Strings used in background tiling repetition properties. 168 // Strings used in background tiling repetition properties.
169 const char kTilingNoRepeat[] = "no-repeat"; 169 constexpr char kTilingNoRepeat[] = "no-repeat";
170 const char kTilingRepeatX[] = "repeat-x"; 170 constexpr char kTilingRepeatX[] = "repeat-x";
171 const char kTilingRepeatY[] = "repeat-y"; 171 constexpr char kTilingRepeatY[] = "repeat-y";
172 const char kTilingRepeat[] = "repeat"; 172 constexpr char kTilingRepeat[] = "repeat";
173 173
174 // The image resources that will be tinted by the 'button' tint value. 174 // The image resources that will be tinted by the 'button' tint value.
175 // If you change this list, you must increment the version number in 175 // If you change this list, you must increment the version number in
176 // browser_theme_pack.cc, and you should assign persistent IDs to the 176 // browser_theme_pack.cc, and you should assign persistent IDs to the
177 // data table at the start of said file or else tinted versions of 177 // data table at the start of said file or else tinted versions of
178 // these resources will not be created. 178 // these resources will not be created.
179 // 179 //
180 // TODO(erg): The cocoa port is the last user of the IDR_*_[HP] variants. These 180 // TODO(erg): The cocoa port is the last user of the IDR_*_[HP] variants. These
181 // should be removed once the cocoa port no longer uses them. 181 // should be removed once the cocoa port no longer uses them.
182 const int kToolbarButtonIDs[] = { 182 constexpr int kToolbarButtonIDs[] = {
183 IDR_BACK, IDR_BACK_D, IDR_BACK_H, IDR_BACK_P, 183 IDR_BACK,
184 IDR_FORWARD, IDR_FORWARD_D, IDR_FORWARD_H, IDR_FORWARD_P, 184 IDR_BACK_D,
185 IDR_HOME, IDR_HOME_H, IDR_HOME_P, 185 IDR_BACK_H,
186 IDR_RELOAD, IDR_RELOAD_H, IDR_RELOAD_P, 186 IDR_BACK_P,
187 IDR_STOP, IDR_STOP_D, IDR_STOP_H, IDR_STOP_P, 187 IDR_FORWARD,
188 IDR_BROWSER_ACTIONS_OVERFLOW, IDR_BROWSER_ACTIONS_OVERFLOW_H, 188 IDR_FORWARD_D,
189 IDR_BROWSER_ACTIONS_OVERFLOW_P, 189 IDR_FORWARD_H,
190 IDR_TOOLS, IDR_TOOLS_H, IDR_TOOLS_P, 190 IDR_FORWARD_P,
191 IDR_MENU_DROPARROW, 191 IDR_HOME,
192 IDR_TOOLBAR_BEZEL_HOVER, IDR_TOOLBAR_BEZEL_PRESSED, IDR_TOOLS_BAR, 192 IDR_HOME_H,
193 IDR_HOME_P,
194 IDR_RELOAD,
195 IDR_RELOAD_H,
196 IDR_RELOAD_P,
197 IDR_STOP,
198 IDR_STOP_D,
199 IDR_STOP_H,
200 IDR_STOP_P,
201 IDR_BROWSER_ACTIONS_OVERFLOW,
202 IDR_BROWSER_ACTIONS_OVERFLOW_H,
203 IDR_BROWSER_ACTIONS_OVERFLOW_P,
204 IDR_TOOLS,
205 IDR_TOOLS_H,
206 IDR_TOOLS_P,
207 IDR_MENU_DROPARROW,
208 IDR_TOOLBAR_BEZEL_HOVER,
209 IDR_TOOLBAR_BEZEL_PRESSED,
210 IDR_TOOLS_BAR,
193 }; 211 };
194 212
195 SkColor TintForUnderline(SkColor input) { 213 SkColor TintForUnderline(SkColor input) {
196 return SkColorSetA(input, SkColorGetA(input) / 3); 214 return SkColorSetA(input, SkColorGetA(input) / 3);
197 } 215 }
198 216
199 } // namespace 217 } // namespace
200 218
201 // static 219 // static
202 int ThemeProperties::StringToAlignment(const std::string& alignment) { 220 int ThemeProperties::StringToAlignment(const std::string& alignment) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 #endif 396 #endif
379 case COLOR_FRAME_INCOGNITO: 397 case COLOR_FRAME_INCOGNITO:
380 case COLOR_FRAME_INCOGNITO_INACTIVE: 398 case COLOR_FRAME_INCOGNITO_INACTIVE:
381 NOTREACHED() << "These values should be queried via their respective " 399 NOTREACHED() << "These values should be queried via their respective "
382 "non-incognito equivalents and an appropriate |otr| " 400 "non-incognito equivalents and an appropriate |otr| "
383 "value."; 401 "value.";
384 default: 402 default:
385 return gfx::kPlaceholderColor; 403 return gfx::kPlaceholderColor;
386 } 404 }
387 } 405 }
OLDNEW
« no previous file with comments | « no previous file | styleguide/c++/c++11.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698