File: theme_properties.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (241 lines) | stat: -rw-r--r-- 9,184 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_THEMES_THEME_PROPERTIES_H_
#define CHROME_BROWSER_THEMES_THEME_PROPERTIES_H_

#include <set>
#include <string>

#include "build/build_config.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/color_utils.h"

// Static only class for querying which properties / images are themeable and
// the defaults of these properties.
// All methods are thread safe unless indicated otherwise.
class ThemeProperties {
 public:
  // ---------------------------------------------------------------------------
  // The int values of the enums below are used as keys to store properties in
  // the browser theme pack.
  //
  // /!\ If you make any changes to these enums, you must also increment
  // kThemePackVersion in browser_theme_pack.cc, or else themes will display
  // incorrectly.

  enum OverwritableByUserThemeProperty {
    // Instead of using the INCOGNITO variants directly, most code should
    // use the original color ID in an incognito-aware context (such as
    // GetDefaultColor).  This comment applies to other properties tagged
    // INCOGNITO below as well.
    COLOR_BOOKMARK_TEXT,
    COLOR_CONTROL_BUTTON_BACKGROUND,
    COLOR_FRAME_ACTIVE,
    COLOR_FRAME_ACTIVE_INCOGNITO,
    COLOR_FRAME_INACTIVE,
    COLOR_FRAME_INACTIVE_INCOGNITO,
    COLOR_NTP_BACKGROUND,
    COLOR_NTP_LINK,
    COLOR_NTP_HEADER,
    COLOR_NTP_TEXT,
    COLOR_OMNIBOX_BACKGROUND,
    COLOR_OMNIBOX_TEXT,
    COLOR_TAB_BACKGROUND_INACTIVE_FRAME_ACTIVE,
    COLOR_TAB_BACKGROUND_INACTIVE_FRAME_ACTIVE_INCOGNITO,
    COLOR_TAB_BACKGROUND_INACTIVE_FRAME_INACTIVE,
    COLOR_TAB_BACKGROUND_INACTIVE_FRAME_INACTIVE_INCOGNITO,
    COLOR_TAB_FOREGROUND_ACTIVE_FRAME_ACTIVE,
    COLOR_TAB_FOREGROUND_INACTIVE_FRAME_ACTIVE,
    COLOR_TAB_FOREGROUND_INACTIVE_FRAME_ACTIVE_INCOGNITO,
    COLOR_TAB_FOREGROUND_INACTIVE_FRAME_INACTIVE,
    COLOR_TAB_FOREGROUND_INACTIVE_FRAME_INACTIVE_INCOGNITO,
    COLOR_TOOLBAR,
    COLOR_TOOLBAR_BUTTON_ICON,
    COLOR_TOOLBAR_TEXT,

    TINT_BACKGROUND_TAB,
    TINT_BUTTONS,
    TINT_FRAME,
    TINT_FRAME_INACTIVE,
    TINT_FRAME_INCOGNITO,
    TINT_FRAME_INCOGNITO_INACTIVE,

    NTP_BACKGROUND_ALIGNMENT,
    NTP_BACKGROUND_TILING,
    NTP_LOGO_ALTERNATE,

    // /!\ If you make any changes to this enum, you must also increment
    // kThemePackVersion in browser_theme_pack.cc, or else themes will display
    // incorrectly.
  };

  // A bitfield mask for alignments.
  enum Alignment {
    ALIGN_CENTER = 0,
    ALIGN_LEFT = 1 << 0,
    ALIGN_TOP = 1 << 1,
    ALIGN_RIGHT = 1 << 2,
    ALIGN_BOTTOM = 1 << 3,
  };

  // Background tiling choices.
  enum Tiling { NO_REPEAT = 0, REPEAT_X = 1, REPEAT_Y = 2, REPEAT = 3 };

  // --------------------------------------------------------------------------
  // The int value of the properties in NotOverwritableByUserThemeProperties
  // has no special meaning. Modify the enum to your heart's content.
  // The enum takes on values >= 1000 as not to overlap with
  // OverwritableByUserThemeProperties.
  //
  // /!\ If you make any changes to this enum, you must also increment
  // kThemePackVersion in browser_theme_pack.cc, or else themes will display
  // incorrectly.
  enum NotOverwritableByUserThemeProperty {
    // The color of the border drawn around the location bar.
    COLOR_LOCATION_BAR_BORDER = 1000,
    COLOR_LOCATION_BAR_BORDER_OPAQUE,

    COLOR_TOOLBAR_BUTTON_BORDER,
    COLOR_TOOLBAR_BUTTON_ICON_HOVERED,
    COLOR_TOOLBAR_BUTTON_ICON_INACTIVE,
    COLOR_TOOLBAR_BUTTON_ICON_PRESSED,
    COLOR_TOOLBAR_BUTTON_TEXT,

    // The color of the line separating the bottom of the toolbar from the
    // contents.
    COLOR_TOOLBAR_CONTENT_AREA_SEPARATOR,

    // Opaque base color for toolbar button ink drops.
    COLOR_TOOLBAR_INK_DROP,

    // The color of the line separating the top of the toolbar from the region
    // above. For a tabbed browser window, this is the line along the bottom
    // edge of the tabstrip.
    COLOR_TOOLBAR_TOP_SEPARATOR_FRAME_ACTIVE,
    COLOR_TOOLBAR_TOP_SEPARATOR_FRAME_INACTIVE,

    // /!\ If you make any changes to this enum, you must also increment
    // kThemePackVersion in browser_theme_pack.cc, or else themes will display
    // incorrectly.

    // Colors of vertical separators, such as on the bookmark bar or on the DL
    // shelf.
    COLOR_TOOLBAR_VERTICAL_SEPARATOR,

    // Colors used for the active tab.
    COLOR_TAB_BACKGROUND_ACTIVE_FRAME_ACTIVE,
    COLOR_TAB_BACKGROUND_ACTIVE_FRAME_INACTIVE,
    COLOR_TAB_BACKGROUND_ACTIVE_FRAME_ACTIVE_INCOGNITO,
    COLOR_TAB_BACKGROUND_ACTIVE_FRAME_INACTIVE_INCOGNITO,

    COLOR_TAB_FOREGROUND_ACTIVE_FRAME_INACTIVE,
    COLOR_TAB_FOREGROUND_ACTIVE_FRAME_ACTIVE_INCOGNITO,
    COLOR_TAB_FOREGROUND_ACTIVE_FRAME_INACTIVE_INCOGNITO,

    // Colors used for the stroke around tabs.
    COLOR_TAB_STROKE_FRAME_ACTIVE,
    COLOR_TAB_STROKE_FRAME_INACTIVE,

    // The throbber colors for tabs or anything on a toolbar (currently, only
    // the download shelf). Do not use directly; only for use inside
    // browser_theme_pack.cc.
    COLOR_TAB_THROBBER_SPINNING,
    COLOR_TAB_THROBBER_WAITING,

    // /!\ If you make any changes to this enum, you must also increment
    // kThemePackVersion in browser_theme_pack.cc, or else themes will display
    // incorrectly.

    // Calculated representative colors for the background of window control
    // buttons.
    COLOR_WINDOW_CONTROL_BUTTON_BACKGROUND_ACTIVE,
    COLOR_WINDOW_CONTROL_BUTTON_BACKGROUND_INACTIVE,
    COLOR_WINDOW_CONTROL_BUTTON_BACKGROUND_INCOGNITO_ACTIVE,
    COLOR_WINDOW_CONTROL_BUTTON_BACKGROUND_INCOGNITO_INACTIVE,

    COLOR_NTP_LOGO,
    COLOR_NTP_SECTION_BORDER,
    COLOR_NTP_TEXT_LIGHT,

#if BUILDFLAG(IS_WIN)
    // The colors of the 1px border around the window on Windows 10.
    COLOR_ACCENT_BORDER_ACTIVE,
    COLOR_ACCENT_BORDER_INACTIVE,
#endif  // BUILDFLAG(IS_WIN)

    SHOULD_FILL_BACKGROUND_TAB_COLOR,

    // Colors for in-product help promo bubbles.
    COLOR_FEATURE_PROMO_BUBBLE_BACKGROUND,
    COLOR_FEATURE_PROMO_BUBBLE_BUTTON_BORDER,
    COLOR_FEATURE_PROMO_BUBBLE_CLOSE_BUTTON_INK_DROP,
    COLOR_FEATURE_PROMO_BUBBLE_DEFAULT_BUTTON_BACKGROUND,
    COLOR_FEATURE_PROMO_BUBBLE_DEFAULT_BUTTON_FOREGROUND,
    COLOR_FEATURE_PROMO_BUBBLE_FOREGROUND,

    // Colors used for the Bookmark bar
    COLOR_BOOKMARK_BAR_BACKGROUND,
    // If COLOR_TOOLBAR_BUTTON_ICON is defined in the custom theme, that color
    // will be returned, otherwise it will be transparent so the default
    // favicon color is retained.
    COLOR_BOOKMARK_FAVICON,
    COLOR_BOOKMARK_SEPARATOR,

    // Colors used for the frame caption/foreground
    COLOR_FRAME_CAPTION_ACTIVE,
    COLOR_FRAME_CAPTION_INACTIVE,

    // Colors used for the FlyingIndicator
    COLOR_FLYING_INDICATOR_BACKGROUND,
    COLOR_FLYING_INDICATOR_FOREGROUND,

    // /!\ If you make any changes to this enum, you must also increment
    // kThemePackVersion in browser_theme_pack.cc, or else themes will display
    // incorrectly.
  };

  // Themes are hardcoded to draw frame images as if they start this many DIPs
  // above the top of the tabstrip, no matter how much space actually exists.
  // This aids with backwards compatibility (for some themes; Chrome's behavior
  // has been inconsistent over time), provides a consistent alignment point for
  // theme authors, and ensures the frame image won't need to be mirrored above
  // the tabs in Refresh (since frame heights above the tabs are never greater
  // than this).
  static constexpr int kFrameHeightAboveTabs = 16;

  ThemeProperties() = delete;
  ThemeProperties(const ThemeProperties&) = delete;
  ThemeProperties& operator=(const ThemeProperties&) = delete;

  // Used by the browser theme pack to parse alignments from something like
  // "top left" into a bitmask of Alignment.
  static int StringToAlignment(const std::string& alignment);

  // Used by the browser theme pack to parse alignments from something like
  // "no-repeat" into a Tiling value.
  static int StringToTiling(const std::string& tiling);

  // Converts a bitmask of Alignment into a string like "top left". The result
  // is used to generate a CSS value.
  static std::string AlignmentToString(int alignment);

  // Converts a Tiling into a string like "no-repeat". The result is used to
  // generate a CSS value.
  static std::string TilingToString(int tiling);

  // Returns the default tint for the given tint |id| TINT_* enum value.
  // Returns an HSL value of {-1, -1, -1} if |id| is invalid.
  static color_utils::HSL GetDefaultTint(int id,
                                         bool incognito,
                                         bool dark_mode = false);

  // Returns the default color for the given color |id| COLOR_* enum value.
  // Returns gfx::kPlaceholderColor if |id| is invalid.
  static SkColor GetDefaultColor(int id,
                                 bool incognito,
                                 bool dark_mode = false);
};

#endif  // CHROME_BROWSER_THEMES_THEME_PROPERTIES_H_