• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/basictypes.h"
12 #include "third_party/skia/include/core/SkColor.h"
13 #include "ui/gfx/color_utils.h"
14 
15 // Static only class for querying which properties / images are themeable and
16 // the defaults of these properties.
17 // All methods are thread safe unless indicated otherwise.
18 class ThemeProperties {
19  public:
20   // ---------------------------------------------------------------------------
21   // The int values of OverwritableByUserThemeProperties, Alignment, and Tiling
22   // are used as a key to store the property in the browser theme pack. If you
23   // modify any of these enums, increment the version number in
24   // browser_theme_pack.h
25 
26   enum OverwritableByUserThemeProperty {
27     COLOR_FRAME,
28     COLOR_FRAME_INACTIVE,
29     COLOR_FRAME_INCOGNITO,
30     COLOR_FRAME_INCOGNITO_INACTIVE,
31     COLOR_TOOLBAR,
32     COLOR_TAB_TEXT,
33     COLOR_BACKGROUND_TAB_TEXT,
34     COLOR_BOOKMARK_TEXT,
35     COLOR_NTP_BACKGROUND,
36     COLOR_NTP_TEXT,
37     COLOR_NTP_LINK,
38     COLOR_NTP_LINK_UNDERLINE,
39     COLOR_NTP_HEADER,
40     COLOR_NTP_SECTION,
41     COLOR_NTP_SECTION_TEXT,
42     COLOR_NTP_SECTION_LINK,
43     COLOR_NTP_SECTION_LINK_UNDERLINE,
44     COLOR_BUTTON_BACKGROUND,
45 
46     TINT_BUTTONS,
47     TINT_FRAME,
48     TINT_FRAME_INACTIVE,
49     TINT_FRAME_INCOGNITO,
50     TINT_FRAME_INCOGNITO_INACTIVE,
51     TINT_BACKGROUND_TAB,
52 
53     NTP_BACKGROUND_ALIGNMENT,
54     NTP_BACKGROUND_TILING,
55     NTP_LOGO_ALTERNATE
56   };
57 
58   // A bitfield mask for alignments.
59   enum Alignment {
60     ALIGN_CENTER = 0,
61     ALIGN_LEFT   = 1 << 0,
62     ALIGN_TOP    = 1 << 1,
63     ALIGN_RIGHT  = 1 << 2,
64     ALIGN_BOTTOM = 1 << 3,
65   };
66 
67   // Background tiling choices.
68   enum Tiling {
69     NO_REPEAT = 0,
70     REPEAT_X = 1,
71     REPEAT_Y = 2,
72     REPEAT = 3
73   };
74 
75   // --------------------------------------------------------------------------
76   // The int value of the properties in NotOverwritableByUserThemeProperties
77   // has no special meaning. Modify the enum to your heart's content.
78   // The enum takes on values >= 1000 as not to overlap with
79   // OverwritableByUserThemeProperties.
80   enum NotOverwritableByUserThemeProperty {
81     COLOR_CONTROL_BACKGROUND = 1000,
82     COLOR_TOOLBAR_SEPARATOR,
83 
84     // These colors don't have constant default values. They are derived from
85     // the runtime value of other colors.
86     COLOR_NTP_SECTION_HEADER_TEXT,
87     COLOR_NTP_SECTION_HEADER_TEXT_HOVER,
88     COLOR_NTP_SECTION_HEADER_RULE,
89     COLOR_NTP_SECTION_HEADER_RULE_LIGHT,
90     COLOR_NTP_TEXT_LIGHT,
91     COLOR_SUPERVISED_USER_LABEL,
92     COLOR_SUPERVISED_USER_LABEL_BACKGROUND,
93     COLOR_SUPERVISED_USER_LABEL_BORDER,
94 
95     COLOR_STATUS_BAR_TEXT,
96 
97 #if defined(OS_MACOSX)
98     COLOR_TOOLBAR_BEZEL,
99     COLOR_TOOLBAR_STROKE,
100     COLOR_TOOLBAR_STROKE_INACTIVE,
101     COLOR_TOOLBAR_BUTTON_STROKE,
102     COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE,
103     GRADIENT_FRAME_INCOGNITO,
104     GRADIENT_FRAME_INCOGNITO_INACTIVE,
105     GRADIENT_TOOLBAR,
106     GRADIENT_TOOLBAR_INACTIVE,
107     GRADIENT_TOOLBAR_BUTTON,
108     GRADIENT_TOOLBAR_BUTTON_INACTIVE,
109     GRADIENT_TOOLBAR_BUTTON_PRESSED,
110     GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE
111 #endif  // OS_MACOSX
112   };
113 
114   // Used by the browser theme pack to parse alignments from something like
115   // "top left" into a bitmask of Alignment.
116   static int StringToAlignment(const std::string& alignment);
117 
118   // Used by the browser theme pack to parse alignments from something like
119   // "no-repeat" into a Tiling value.
120   static int StringToTiling(const std::string& tiling);
121 
122   // Converts a bitmask of Alignment into a string like "top left". The result
123   // is used to generate a CSS value.
124   static std::string AlignmentToString(int alignment);
125 
126   // Converts a Tiling into a string like "no-repeat". The result is used to
127   // generate a CSS value.
128   static std::string TilingToString(int tiling);
129 
130   // Returns true if the image is themeable.
131   static bool IsThemeableImage(int resource_id);
132 
133   // Returns the set of IDR_* resources that should be tinted.
134   // This method is not thread safe.
135   static const std::set<int>& GetTintableToolbarButtons();
136 
137   // Returns the default tint for the given tint |id| TINT_* enum value.
138   // Returns an HSL value of {-1, -1, -1} if |id| is invalid.
139   static color_utils::HSL GetDefaultTint(int id);
140 
141   // Returns the default color for the given color |id| COLOR_* enum value.
142   // Returns SK_ColorRED if |id| is invalid.
143   static SkColor GetDefaultColor(int id);
144 
145   // Returns the default value for the given property |id|. Returns -1 if |id|
146   // is invalid.
147   static int GetDefaultDisplayProperty(int id);
148 
149  private:
150   DISALLOW_IMPLICIT_CONSTRUCTORS(ThemeProperties);
151 };
152 
153 #endif  // CHROME_BROWSER_THEMES_THEME_PROPERTIES_H_
154