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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_THEMES_THEME_PROPERTIES_H_ 6 #define CHROME_BROWSER_THEMES_THEME_PROPERTIES_H_ 7 8 #include <set> 9 #include <string> 10 11 #include "base/macros.h" 12 #include "build/build_config.h" 13 #include "third_party/skia/include/core/SkColor.h" 14 #include "ui/gfx/color_utils.h" 15 16 // Static only class for querying which properties / images are themeable and 17 // the defaults of these properties. 18 // All methods are thread safe unless indicated otherwise. 19 class ThemeProperties { 20 public: 21 // --------------------------------------------------------------------------- 22 // The int values of OverwritableByUserThemeProperties, Alignment, and Tiling 23 // are used as a key to store the property in the browser theme pack. If you 24 // modify any of these enums, increment the version number in 25 // browser_theme_pack.cc. 26 27 enum OverwritableByUserThemeProperty { 28 COLOR_FRAME_ACTIVE, 29 COLOR_FRAME_INACTIVE, 30 // Instead of using the INCOGNITO variants directly, most code should 31 // use the original color ID in an incognito-aware context (such as 32 // GetDefaultColor). This comment applies to other properties tagged 33 // INCOGNITO below as well. 34 COLOR_FRAME_ACTIVE_INCOGNITO, 35 COLOR_FRAME_INACTIVE_INCOGNITO, 36 COLOR_TAB_BACKGROUND_INACTIVE_FRAME_ACTIVE, 37 COLOR_TAB_BACKGROUND_INACTIVE_FRAME_INACTIVE, 38 COLOR_TAB_BACKGROUND_INACTIVE_FRAME_ACTIVE_INCOGNITO, 39 COLOR_TAB_BACKGROUND_INACTIVE_FRAME_INACTIVE_INCOGNITO, 40 COLOR_TOOLBAR, 41 COLOR_TAB_FOREGROUND_ACTIVE_FRAME_ACTIVE, 42 COLOR_TAB_FOREGROUND_INACTIVE_FRAME_ACTIVE, 43 COLOR_TAB_FOREGROUND_INACTIVE_FRAME_INACTIVE, 44 COLOR_TAB_FOREGROUND_INACTIVE_FRAME_ACTIVE_INCOGNITO, 45 COLOR_TAB_FOREGROUND_INACTIVE_FRAME_INACTIVE_INCOGNITO, 46 COLOR_BOOKMARK_TEXT, 47 COLOR_NTP_BACKGROUND, 48 COLOR_NTP_TEXT, 49 COLOR_NTP_LINK, 50 COLOR_NTP_HEADER, 51 COLOR_CONTROL_BUTTON_BACKGROUND, 52 COLOR_TOOLBAR_BUTTON_ICON, 53 COLOR_OMNIBOX_TEXT, 54 COLOR_OMNIBOX_BACKGROUND, 55 56 TINT_BUTTONS, 57 TINT_FRAME, 58 TINT_FRAME_INACTIVE, 59 TINT_FRAME_INCOGNITO, 60 TINT_FRAME_INCOGNITO_INACTIVE, 61 TINT_BACKGROUND_TAB, 62 63 NTP_BACKGROUND_ALIGNMENT, 64 NTP_BACKGROUND_TILING, 65 NTP_LOGO_ALTERNATE, 66 }; 67 68 // A bitfield mask for alignments. 69 enum Alignment { 70 ALIGN_CENTER = 0, 71 ALIGN_LEFT = 1 << 0, 72 ALIGN_TOP = 1 << 1, 73 ALIGN_RIGHT = 1 << 2, 74 ALIGN_BOTTOM = 1 << 3, 75 }; 76 77 // Background tiling choices. 78 enum Tiling { 79 NO_REPEAT = 0, 80 REPEAT_X = 1, 81 REPEAT_Y = 2, 82 REPEAT = 3 83 }; 84 85 // -------------------------------------------------------------------------- 86 // The int value of the properties in NotOverwritableByUserThemeProperties 87 // has no special meaning. Modify the enum to your heart's content. 88 // The enum takes on values >= 1000 as not to overlap with 89 // OverwritableByUserThemeProperties. 90 enum NotOverwritableByUserThemeProperty { 91 // The color of the border drawn around the location bar. 92 COLOR_LOCATION_BAR_BORDER = 1000, 93 94 // The color of the line separating the bottom of the toolbar from the 95 // contents. 96 COLOR_TOOLBAR_CONTENT_AREA_SEPARATOR, 97 98 // The color of a toolbar button's icon when it is being hovered or pressed. 99 COLOR_TOOLBAR_BUTTON_ICON_HOVERED, 100 COLOR_TOOLBAR_BUTTON_ICON_PRESSED, 101 102 // The color of a disabled toolbar button's icon. 103 COLOR_TOOLBAR_BUTTON_ICON_INACTIVE, 104 105 // The color of the line separating the top of the toolbar from the region 106 // above. For a tabbed browser window, this is the line along the bottom 107 // edge of the tabstrip, the stroke around the tabs, and the new tab button 108 // stroke/shadow color. 109 COLOR_TOOLBAR_TOP_SEPARATOR, 110 COLOR_TOOLBAR_TOP_SEPARATOR_INACTIVE, 111 112 // Colors of vertical separators, such as on the bookmark bar or on the DL 113 // shelf. 114 COLOR_TOOLBAR_VERTICAL_SEPARATOR, 115 116 // Opaque base color for toolbar button ink drops. 117 COLOR_TOOLBAR_INK_DROP, 118 119 // Color used for various 'shelves' and 'bars'. 120 COLOR_DOWNLOAD_SHELF, 121 COLOR_INFOBAR, 122 COLOR_STATUS_BUBBLE, 123 124 // Colors used when displaying hover cards. 125 COLOR_HOVER_CARD_NO_PREVIEW_FOREGROUND, 126 COLOR_HOVER_CARD_NO_PREVIEW_BACKGROUND, 127 128 // Colors used for the active tab. 129 COLOR_TAB_BACKGROUND_ACTIVE_FRAME_ACTIVE, 130 COLOR_TAB_BACKGROUND_ACTIVE_FRAME_INACTIVE, 131 COLOR_TAB_BACKGROUND_ACTIVE_FRAME_ACTIVE_INCOGNITO, 132 COLOR_TAB_BACKGROUND_ACTIVE_FRAME_INACTIVE_INCOGNITO, 133 134 COLOR_TAB_FOREGROUND_ACTIVE_FRAME_INACTIVE, 135 COLOR_TAB_FOREGROUND_ACTIVE_FRAME_ACTIVE_INCOGNITO, 136 COLOR_TAB_FOREGROUND_ACTIVE_FRAME_INACTIVE_INCOGNITO, 137 138 // The throbber colors for tabs or anything on a toolbar (currently, only 139 // the download shelf). If you're adding a throbber elsewhere, such as in 140 // a dialog or bubble, you likely want 141 // NativeTheme::kColorId_ThrobberSpinningColor. 142 COLOR_TAB_THROBBER_SPINNING, 143 COLOR_TAB_THROBBER_WAITING, 144 145 // The colors used by the various alert indicator icons in the tab. 146 COLOR_TAB_ALERT_AUDIO, 147 COLOR_TAB_ALERT_RECORDING, 148 COLOR_TAB_PIP_PLAYING, 149 COLOR_TAB_ALERT_CAPTURING, 150 151 // Note: All tab group color ids must be grouped together consecutively and 152 // grouped together by use (eg grouped by dialog, context menu etc). 153 // This permits range checking and reduces redundant code. If you change or 154 // add to any of the below color ids, change the relevant code in 155 // ThemeHelper. 156 157 // The colors used for tab groups in the tabstrip. 158 COLOR_TAB_GROUP_TABSTRIP_FRAME_ACTIVE_GREY, 159 COLOR_TAB_GROUP_TABSTRIP_FRAME_ACTIVE_BLUE, 160 COLOR_TAB_GROUP_TABSTRIP_FRAME_ACTIVE_RED, 161 COLOR_TAB_GROUP_TABSTRIP_FRAME_ACTIVE_YELLOW, 162 COLOR_TAB_GROUP_TABSTRIP_FRAME_ACTIVE_GREEN, 163 COLOR_TAB_GROUP_TABSTRIP_FRAME_ACTIVE_PINK, 164 COLOR_TAB_GROUP_TABSTRIP_FRAME_ACTIVE_PURPLE, 165 COLOR_TAB_GROUP_TABSTRIP_FRAME_ACTIVE_CYAN, 166 COLOR_TAB_GROUP_TABSTRIP_FRAME_INACTIVE_GREY, 167 COLOR_TAB_GROUP_TABSTRIP_FRAME_INACTIVE_BLUE, 168 COLOR_TAB_GROUP_TABSTRIP_FRAME_INACTIVE_RED, 169 COLOR_TAB_GROUP_TABSTRIP_FRAME_INACTIVE_YELLOW, 170 COLOR_TAB_GROUP_TABSTRIP_FRAME_INACTIVE_GREEN, 171 COLOR_TAB_GROUP_TABSTRIP_FRAME_INACTIVE_PINK, 172 COLOR_TAB_GROUP_TABSTRIP_FRAME_INACTIVE_PURPLE, 173 COLOR_TAB_GROUP_TABSTRIP_FRAME_INACTIVE_CYAN, 174 // The colors used for tab groups in the bubble dialog view. 175 COLOR_TAB_GROUP_DIALOG_GREY, 176 COLOR_TAB_GROUP_DIALOG_BLUE, 177 COLOR_TAB_GROUP_DIALOG_RED, 178 COLOR_TAB_GROUP_DIALOG_YELLOW, 179 COLOR_TAB_GROUP_DIALOG_GREEN, 180 COLOR_TAB_GROUP_DIALOG_PINK, 181 COLOR_TAB_GROUP_DIALOG_PURPLE, 182 COLOR_TAB_GROUP_DIALOG_CYAN, 183 // The colors used for tab groups in the context submenu. 184 COLOR_TAB_GROUP_CONTEXT_MENU_GREY, 185 COLOR_TAB_GROUP_CONTEXT_MENU_BLUE, 186 COLOR_TAB_GROUP_CONTEXT_MENU_RED, 187 COLOR_TAB_GROUP_CONTEXT_MENU_YELLOW, 188 COLOR_TAB_GROUP_CONTEXT_MENU_GREEN, 189 COLOR_TAB_GROUP_CONTEXT_MENU_PINK, 190 COLOR_TAB_GROUP_CONTEXT_MENU_PURPLE, 191 COLOR_TAB_GROUP_CONTEXT_MENU_CYAN, 192 193 // Calculated representative colors for the background of window control 194 // buttons. 195 COLOR_WINDOW_CONTROL_BUTTON_BACKGROUND_ACTIVE, 196 COLOR_WINDOW_CONTROL_BUTTON_BACKGROUND_INACTIVE, 197 COLOR_WINDOW_CONTROL_BUTTON_BACKGROUND_INCOGNITO_ACTIVE, 198 COLOR_WINDOW_CONTROL_BUTTON_BACKGROUND_INCOGNITO_INACTIVE, 199 200 COLOR_NTP_TEXT_LIGHT, 201 COLOR_NTP_LOGO, 202 // Color for the background of the most visited/custom link tile. 203 COLOR_NTP_SHORTCUT, 204 205 #if defined(OS_WIN) 206 // The colors of the 1px border around the window on Windows 10. 207 COLOR_ACCENT_BORDER_ACTIVE, 208 COLOR_ACCENT_BORDER_INACTIVE, 209 #endif // OS_WIN 210 211 SHOULD_FILL_BACKGROUND_TAB_COLOR, 212 213 // Colors for in-product help promo bubbles. 214 COLOR_FEATURE_PROMO_BUBBLE_TEXT, 215 COLOR_FEATURE_PROMO_BUBBLE_BACKGROUND, 216 217 COLOR_OMNIBOX_BACKGROUND_HOVERED, 218 COLOR_OMNIBOX_SELECTED_KEYWORD, 219 COLOR_OMNIBOX_TEXT_DIMMED, 220 COLOR_OMNIBOX_RESULTS_BG, 221 COLOR_OMNIBOX_RESULTS_BG_HOVERED, 222 COLOR_OMNIBOX_RESULTS_BG_SELECTED, 223 COLOR_OMNIBOX_RESULTS_TEXT_SELECTED, 224 COLOR_OMNIBOX_RESULTS_TEXT_DIMMED, 225 COLOR_OMNIBOX_RESULTS_TEXT_DIMMED_SELECTED, 226 COLOR_OMNIBOX_RESULTS_ICON, 227 COLOR_OMNIBOX_RESULTS_ICON_SELECTED, 228 COLOR_OMNIBOX_RESULTS_URL, 229 COLOR_OMNIBOX_RESULTS_URL_SELECTED, 230 COLOR_OMNIBOX_RESULTS_FOCUS_BAR, 231 COLOR_OMNIBOX_RESULTS_BUTTON_BORDER, 232 COLOR_OMNIBOX_BUBBLE_OUTLINE, 233 COLOR_OMNIBOX_BUBBLE_OUTLINE_EXPERIMENTAL_KEYWORD_MODE, 234 COLOR_OMNIBOX_SECURITY_CHIP_DEFAULT, 235 COLOR_OMNIBOX_SECURITY_CHIP_SECURE, 236 COLOR_OMNIBOX_SECURITY_CHIP_DANGEROUS, 237 }; 238 239 // Themes are hardcoded to draw frame images as if they start this many DIPs 240 // above the top of the tabstrip, no matter how much space actually exists. 241 // This aids with backwards compatibility (for some themes; Chrome's behavior 242 // has been inconsistent over time), provides a consistent alignment point for 243 // theme authors, and ensures the frame image won't need to be mirrored above 244 // the tabs in Refresh (since frame heights above the tabs are never greater 245 // than this). 246 static constexpr int kFrameHeightAboveTabs = 16; 247 248 // Used by the browser theme pack to parse alignments from something like 249 // "top left" into a bitmask of Alignment. 250 static int StringToAlignment(const std::string& alignment); 251 252 // Used by the browser theme pack to parse alignments from something like 253 // "no-repeat" into a Tiling value. 254 static int StringToTiling(const std::string& tiling); 255 256 // Converts a bitmask of Alignment into a string like "top left". The result 257 // is used to generate a CSS value. 258 static std::string AlignmentToString(int alignment); 259 260 // Converts a Tiling into a string like "no-repeat". The result is used to 261 // generate a CSS value. 262 static std::string TilingToString(int tiling); 263 264 // Returns the default tint for the given tint |id| TINT_* enum value. 265 // Returns an HSL value of {-1, -1, -1} if |id| is invalid. 266 static color_utils::HSL GetDefaultTint(int id, 267 bool incognito, 268 bool dark_mode = false); 269 270 // Returns the default color for the given color |id| COLOR_* enum value. 271 // Returns gfx::kPlaceholderColor if |id| is invalid. 272 static SkColor GetDefaultColor(int id, 273 bool incognito, 274 bool dark_mode = false); 275 276 private: 277 DISALLOW_IMPLICIT_CONSTRUCTORS(ThemeProperties); 278 }; 279 280 #endif // CHROME_BROWSER_THEMES_THEME_PROPERTIES_H_ 281