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

Side by Side Diff: chrome/browser/browser_theme_provider.h

Issue 115910: Allow themes to change the background of the new tab page.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « app/theme_provider.h ('k') | chrome/browser/browser_theme_provider.cc » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_
6 #define CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_ 6 #define CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 22 matching lines...) Expand all
33 33
34 enum { 34 enum {
35 COLOR_FRAME, 35 COLOR_FRAME,
36 COLOR_FRAME_INACTIVE, 36 COLOR_FRAME_INACTIVE,
37 COLOR_FRAME_INCOGNITO, 37 COLOR_FRAME_INCOGNITO,
38 COLOR_FRAME_INCOGNITO_INACTIVE, 38 COLOR_FRAME_INCOGNITO_INACTIVE,
39 COLOR_TOOLBAR, 39 COLOR_TOOLBAR,
40 COLOR_TAB_TEXT, 40 COLOR_TAB_TEXT,
41 COLOR_BACKGROUND_TAB_TEXT, 41 COLOR_BACKGROUND_TAB_TEXT,
42 COLOR_BOOKMARK_TEXT, 42 COLOR_BOOKMARK_TEXT,
43 COLOR_NTP_BACKGROUND,
43 COLOR_NTP_TEXT, 44 COLOR_NTP_TEXT,
44 COLOR_NTP_LINK, 45 COLOR_NTP_LINK,
45 COLOR_NTP_SECTION, 46 COLOR_NTP_SECTION,
46 TINT_BUTTONS, 47 TINT_BUTTONS,
47 TINT_FRAME, 48 TINT_FRAME,
48 TINT_FRAME_INACTIVE, 49 TINT_FRAME_INACTIVE,
49 TINT_FRAME_INCOGNITO, 50 TINT_FRAME_INCOGNITO,
50 TINT_FRAME_INCOGNITO_INACTIVE, 51 TINT_FRAME_INCOGNITO_INACTIVE,
51 TINT_BACKGROUND_TAB 52 TINT_BACKGROUND_TAB,
53 NTP_BACKGROUND_ALIGNMENT
52 }; 54 };
53 55
56 // A bitfield mask for alignments.
57 typedef enum {
58 ALIGN_CENTER = 0x0,
59 ALIGN_LEFT = 0x1,
60 ALIGN_TOP = 0x2,
61 ALIGN_RIGHT = 0x4,
62 ALIGN_BOTTOM = 0x8,
63 } AlignmentMasks;
64
54 void Init(Profile* profile); 65 void Init(Profile* profile);
55 66
56 // ThemeProvider implementation. 67 // ThemeProvider implementation.
57 virtual SkBitmap* GetBitmapNamed(int id); 68 virtual SkBitmap* GetBitmapNamed(int id);
58 virtual SkColor GetColor(int id); 69 virtual SkColor GetColor(int id);
70 virtual bool GetDisplayProperty(int id, int* result);
59 virtual bool ShouldUseNativeFrame(); 71 virtual bool ShouldUseNativeFrame();
60 #if defined(OS_LINUX) 72 #if defined(OS_LINUX)
61 virtual GdkPixbuf* GetPixbufNamed(int id); 73 virtual GdkPixbuf* GetPixbufNamed(int id);
62 #endif 74 #endif
63 75
64 // Set the current theme to the theme defined in |extension|. 76 // Set the current theme to the theme defined in |extension|.
65 void SetTheme(Extension* extension); 77 void SetTheme(Extension* extension);
66 78
67 // Reset the theme to default. 79 // Reset the theme to default.
68 void UseDefaultTheme(); 80 void UseDefaultTheme();
69 81
82 // Convert a bitfield alignment into a string like "top left". Public so that
83 // it can be used to generate CSS values. Takes a bitfield of AlignmentMasks.
84 static std::string AlignmentToString(int alignment);
85
86 // Parse alignments from something like "top left" into a bitfield of
87 // AlignmentMasks
88 static int StringToAlignment(const std::string &alignment);
89
70 private: 90 private:
71 typedef std::map<const int, std::string> ImageMap; 91 typedef std::map<const int, std::string> ImageMap;
72 typedef std::map<const std::string, SkColor> ColorMap; 92 typedef std::map<const std::string, SkColor> ColorMap;
73 typedef std::map<const std::string, skia::HSL> TintMap; 93 typedef std::map<const std::string, skia::HSL> TintMap;
94 typedef std::map<const std::string, int> DisplayPropertyMap;
74 95
75 // Loads a bitmap from the theme, which may be tinted or 96 // Loads a bitmap from the theme, which may be tinted or
76 // otherwise modified, or an application default. 97 // otherwise modified, or an application default.
77 SkBitmap* LoadThemeBitmap(int id); 98 SkBitmap* LoadThemeBitmap(int id);
78 99
79 // Get the specified tint - |id| is one of the TINT_* enum values. 100 // Get the specified tint - |id| is one of the TINT_* enum values.
80 skia::HSL GetTint(int id); 101 skia::HSL GetTint(int id);
81 102
82 // Tint |bitmap| with the tint specified by |hsl_id| 103 // Tint |bitmap| with the tint specified by |hsl_id|
83 SkBitmap TintBitmap(const SkBitmap& bitmap, int hsl_id); 104 SkBitmap TintBitmap(const SkBitmap& bitmap, int hsl_id);
84 105
85 // The following load data from specified dictionaries (either from 106 // The following load data from specified dictionaries (either from
86 // preferences or from an extension manifest) and update our theme 107 // preferences or from an extension manifest) and update our theme
87 // data appropriately. 108 // data appropriately.
88 // Allow any ResourceBundle image to be overridden. |images| should 109 // Allow any ResourceBundle image to be overridden. |images| should
89 // contain keys defined in ThemeResourceMap, and values as paths to 110 // contain keys defined in ThemeResourceMap, and values as paths to
90 // the images on-disk. 111 // the images on-disk.
91 void SetImageData(DictionaryValue* images, 112 void SetImageData(DictionaryValue* images,
92 FilePath images_path); 113 FilePath images_path);
93 // Set our theme colors. The keys of |colors| are any of the kColor* 114 // Set our theme colors. The keys of |colors| are any of the kColor*
94 // constants, and the values are a three-item list containing 8-bit 115 // constants, and the values are a three-item list containing 8-bit
95 // RGB values. 116 // RGB values.
96 void SetColorData(DictionaryValue* colors); 117 void SetColorData(DictionaryValue* colors);
118
97 // Set tint data for our images and colors. The keys of |tints| are 119 // Set tint data for our images and colors. The keys of |tints| are
98 // any of the kTint* contstants, and the values are a three-item list 120 // any of the kTint* contstants, and the values are a three-item list
99 // containing real numbers in the range 0-1 (and -1 for 'null'). 121 // containing real numbers in the range 0-1 (and -1 for 'null').
100 void SetTintData(DictionaryValue* tints); 122 void SetTintData(DictionaryValue* tints);
101 123
124 // Set miscellaneous display properties. While these can be defined as
125 // strings, they are currently stored as integers.
126 void SetDisplayPropertyData(DictionaryValue* display_properties);
127
102 // Generate any frame colors that weren't specified. 128 // Generate any frame colors that weren't specified.
103 void GenerateFrameColors(); 129 void GenerateFrameColors();
104 130
105 // Generate any frame images that weren't specified. The resulting images 131 // Generate any frame images that weren't specified. The resulting images
106 // will be stored in our cache. 132 // will be stored in our cache.
107 void GenerateFrameImages(); 133 void GenerateFrameImages();
108 134
109 // Create any images that aren't pregenerated (e.g. background tab images). 135 // Create any images that aren't pregenerated (e.g. background tab images).
110 SkBitmap* GenerateBitmap(int id); 136 SkBitmap* GenerateBitmap(int id);
111 137
112 // Save our data - when saving images we need the original dictionary 138 // Save our data - when saving images we need the original dictionary
113 // from the extension because it contains the text ids that we want to save. 139 // from the extension because it contains the text ids that we want to save.
114 void SaveImageData(DictionaryValue* images); 140 void SaveImageData(DictionaryValue* images);
115 void SaveColorData(); 141 void SaveColorData();
116 void SaveTintData(); 142 void SaveTintData();
143 void SaveDisplayPropertyData();
117 144
118 // Let all the browser views know that themes have changed. 145 // Let all the browser views know that themes have changed.
119 void NotifyThemeChanged(); 146 void NotifyThemeChanged();
120 147
121 // Load theme data from preferences. 148 // Load theme data from preferences.
122 void LoadThemePrefs(); 149 void LoadThemePrefs();
123 150
124 // Frees generated images and clears the image cache. 151 // Frees generated images and clears the image cache.
125 void FreeImages(); 152 void FreeImages();
126 153
127 // Cached images. We cache all retrieved and generated bitmaps and keep 154 // Cached images. We cache all retrieved and generated bitmaps and keep
128 // track of the pointers. 155 // track of the pointers.
129 typedef std::map<int, SkBitmap*> ImageCache; 156 typedef std::map<int, SkBitmap*> ImageCache;
130 ImageCache image_cache_; 157 ImageCache image_cache_;
131 #if defined(OS_LINUX) 158 #if defined(OS_LINUX)
132 typedef std::map<int, GdkPixbuf*> GdkPixbufMap; 159 typedef std::map<int, GdkPixbuf*> GdkPixbufMap;
133 GdkPixbufMap gdk_pixbufs_; 160 GdkPixbufMap gdk_pixbufs_;
134 #endif 161 #endif
135 162
136 // List of generate images that aren't stored in ResourceBundles image cache 163 // List of generate images that aren't stored in ResourceBundles image cache
137 // and need to be freed. 164 // and need to be freed.
138 std::vector<SkBitmap*> generated_images_; 165 std::vector<SkBitmap*> generated_images_;
139 166
140 ResourceBundle& rb_; 167 ResourceBundle& rb_;
141 Profile* profile_; 168 Profile* profile_;
142 169
143 ImageMap images_; 170 ImageMap images_;
144 ColorMap colors_; 171 ColorMap colors_;
145 TintMap tints_; 172 TintMap tints_;
173 DisplayPropertyMap display_properties_;
146 174
147 DISALLOW_COPY_AND_ASSIGN(BrowserThemeProvider); 175 DISALLOW_COPY_AND_ASSIGN(BrowserThemeProvider);
148 }; 176 };
149 177
150 #endif // CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_ 178 #endif // CHROME_BROWSER_BROWSER_THEME_PROVIDER_H_
OLDNEW
« no previous file with comments | « app/theme_provider.h ('k') | chrome/browser/browser_theme_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698