| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 constexpr char kAlignmentBottom[] = "bottom"; | 171 constexpr char kAlignmentBottom[] = "bottom"; |
| 172 constexpr char kAlignmentLeft[] = "left"; | 172 constexpr char kAlignmentLeft[] = "left"; |
| 173 constexpr char kAlignmentRight[] = "right"; | 173 constexpr char kAlignmentRight[] = "right"; |
| 174 | 174 |
| 175 // Strings used in background tiling repetition properties. | 175 // Strings used in background tiling repetition properties. |
| 176 constexpr char kTilingNoRepeat[] = "no-repeat"; | 176 constexpr char kTilingNoRepeat[] = "no-repeat"; |
| 177 constexpr char kTilingRepeatX[] = "repeat-x"; | 177 constexpr char kTilingRepeatX[] = "repeat-x"; |
| 178 constexpr char kTilingRepeatY[] = "repeat-y"; | 178 constexpr char kTilingRepeatY[] = "repeat-y"; |
| 179 constexpr char kTilingRepeat[] = "repeat"; | 179 constexpr char kTilingRepeat[] = "repeat"; |
| 180 | 180 |
| 181 // The image resources that will be tinted by the 'button' tint value. | |
| 182 // If you change this list, you must increment the version number in | |
| 183 // browser_theme_pack.cc, and you should assign persistent IDs to the | |
| 184 // data table at the start of said file or else tinted versions of | |
| 185 // these resources will not be created. | |
| 186 // | |
| 187 // TODO(erg): The cocoa port is the last user of the IDR_*_[HP] variants. These | |
| 188 // should be removed once the cocoa port no longer uses them. | |
| 189 constexpr int kToolbarButtonIDs[] = { | |
| 190 IDR_BACK, | |
| 191 IDR_BACK_D, | |
| 192 IDR_BACK_H, | |
| 193 IDR_BACK_P, | |
| 194 IDR_FORWARD, | |
| 195 IDR_FORWARD_D, | |
| 196 IDR_FORWARD_H, | |
| 197 IDR_FORWARD_P, | |
| 198 #if defined(OS_MACOSX) | |
| 199 IDR_HOME, | |
| 200 IDR_HOME_H, | |
| 201 IDR_HOME_P, | |
| 202 #endif | |
| 203 IDR_RELOAD, | |
| 204 IDR_RELOAD_H, | |
| 205 IDR_RELOAD_P, | |
| 206 IDR_STOP, | |
| 207 IDR_STOP_D, | |
| 208 IDR_STOP_H, | |
| 209 IDR_STOP_P, | |
| 210 IDR_TOOLS, | |
| 211 IDR_TOOLS_H, | |
| 212 IDR_TOOLS_P, | |
| 213 IDR_MENU_DROPARROW, | |
| 214 IDR_TOOLBAR_BEZEL_HOVER, | |
| 215 IDR_TOOLBAR_BEZEL_PRESSED, | |
| 216 IDR_TOOLS_BAR, | |
| 217 }; | |
| 218 | |
| 219 SkColor TintForUnderline(SkColor input) { | 181 SkColor TintForUnderline(SkColor input) { |
| 220 return SkColorSetA(input, SkColorGetA(input) / 3); | 182 return SkColorSetA(input, SkColorGetA(input) / 3); |
| 221 } | 183 } |
| 222 | 184 |
| 223 } // namespace | 185 } // namespace |
| 224 | 186 |
| 225 // static | 187 // static |
| 226 int ThemeProperties::StringToAlignment(const std::string& alignment) { | 188 int ThemeProperties::StringToAlignment(const std::string& alignment) { |
| 227 int alignment_mask = 0; | 189 int alignment_mask = 0; |
| 228 for (const std::string& component : base::SplitString( | 190 for (const std::string& component : base::SplitString( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 if (tiling == REPEAT_X) | 239 if (tiling == REPEAT_X) |
| 278 return kTilingRepeatX; | 240 return kTilingRepeatX; |
| 279 if (tiling == REPEAT_Y) | 241 if (tiling == REPEAT_Y) |
| 280 return kTilingRepeatY; | 242 return kTilingRepeatY; |
| 281 if (tiling == REPEAT) | 243 if (tiling == REPEAT) |
| 282 return kTilingRepeat; | 244 return kTilingRepeat; |
| 283 return kTilingNoRepeat; | 245 return kTilingNoRepeat; |
| 284 } | 246 } |
| 285 | 247 |
| 286 // static | 248 // static |
| 287 const std::set<int>& ThemeProperties::GetTintableToolbarButtons() { | |
| 288 CR_DEFINE_STATIC_LOCAL(std::set<int>, button_set, ()); | |
| 289 if (button_set.empty()) { | |
| 290 button_set = std::set<int>( | |
| 291 kToolbarButtonIDs, | |
| 292 kToolbarButtonIDs + arraysize(kToolbarButtonIDs)); | |
| 293 } | |
| 294 | |
| 295 return button_set; | |
| 296 } | |
| 297 | |
| 298 // static | |
| 299 color_utils::HSL ThemeProperties::GetDefaultTint(int id, bool otr) { | 249 color_utils::HSL ThemeProperties::GetDefaultTint(int id, bool otr) { |
| 300 switch (id) { | 250 switch (id) { |
| 301 case TINT_FRAME: | 251 case TINT_FRAME: |
| 302 return otr ? kDefaultTintFrameIncognito : kDefaultTintFrame; | 252 return otr ? kDefaultTintFrameIncognito : kDefaultTintFrame; |
| 303 case TINT_FRAME_INACTIVE: | 253 case TINT_FRAME_INACTIVE: |
| 304 return otr ? kDefaultTintFrameIncognitoInactive | 254 return otr ? kDefaultTintFrameIncognitoInactive |
| 305 : kDefaultTintFrameInactive; | 255 : kDefaultTintFrameInactive; |
| 306 case TINT_BUTTONS: { | 256 case TINT_BUTTONS: { |
| 307 const int mode = ui::MaterialDesignController::IsModeMaterial(); | 257 const int mode = ui::MaterialDesignController::IsModeMaterial(); |
| 308 return otr ? kDefaultTintButtonsIncognito[mode] : kDefaultTintButtons; | 258 return otr ? kDefaultTintButtonsIncognito[mode] : kDefaultTintButtons; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 #endif | 355 #endif |
| 406 case COLOR_FRAME_INCOGNITO: | 356 case COLOR_FRAME_INCOGNITO: |
| 407 case COLOR_FRAME_INCOGNITO_INACTIVE: | 357 case COLOR_FRAME_INCOGNITO_INACTIVE: |
| 408 NOTREACHED() << "These values should be queried via their respective " | 358 NOTREACHED() << "These values should be queried via their respective " |
| 409 "non-incognito equivalents and an appropriate |otr| " | 359 "non-incognito equivalents and an appropriate |otr| " |
| 410 "value."; | 360 "value."; |
| 411 default: | 361 default: |
| 412 return gfx::kPlaceholderColor; | 362 return gfx::kPlaceholderColor; |
| 413 } | 363 } |
| 414 } | 364 } |
| OLD | NEW |