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

Side by Side Diff: chrome/browser/themes/theme_service.h

Issue 11411330: Have ExtensionService notify ThemeService directly for themes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase on head Created 8 years 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 | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/themes/theme_service.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_THEMES_THEME_SERVICE_H_ 5 #ifndef CHROME_BROWSER_THEMES_THEME_SERVICE_H_
6 #define CHROME_BROWSER_THEMES_THEME_SERVICE_H_ 6 #define CHROME_BROWSER_THEMES_THEME_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/threading/non_thread_safe.h" 16 #include "base/threading/non_thread_safe.h"
17 #include "chrome/browser/profiles/profile_keyed_service.h" 17 #include "chrome/browser/profiles/profile_keyed_service.h"
18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h"
20 #include "ui/base/theme_provider.h" 18 #include "ui/base/theme_provider.h"
21 19
22 class BrowserThemePack; 20 class BrowserThemePack;
23 class ThemeServiceTest; 21 class ThemeServiceTest;
24 class ThemeSyncableService; 22 class ThemeSyncableService;
25 class FilePath; 23 class FilePath;
26 class Profile; 24 class Profile;
27 25
28 namespace color_utils { 26 namespace color_utils {
29 struct HSL; 27 struct HSL;
(...skipping 12 matching lines...) Expand all
42 } 40 }
43 41
44 #ifdef __OBJC__ 42 #ifdef __OBJC__
45 @class NSString; 43 @class NSString;
46 // Sent whenever the browser theme changes. Object => NSValue wrapping the 44 // Sent whenever the browser theme changes. Object => NSValue wrapping the
47 // ThemeService that changed. 45 // ThemeService that changed.
48 extern "C" NSString* const kBrowserThemeDidChangeNotification; 46 extern "C" NSString* const kBrowserThemeDidChangeNotification;
49 #endif // __OBJC__ 47 #endif // __OBJC__
50 48
51 class ThemeService : public base::NonThreadSafe, 49 class ThemeService : public base::NonThreadSafe,
52 public content::NotificationObserver,
53 public ProfileKeyedService, 50 public ProfileKeyedService,
54 public ui::ThemeProvider { 51 public ui::ThemeProvider {
55 public: 52 public:
56 // Public constants used in ThemeService and its subclasses: 53 // Public constants used in ThemeService and its subclasses:
57 54
58 // Strings used in alignment properties. 55 // Strings used in alignment properties.
59 static const char* kAlignmentCenter; 56 static const char* kAlignmentCenter;
60 static const char* kAlignmentTop; 57 static const char* kAlignmentTop;
61 static const char* kAlignmentBottom; 58 static const char* kAlignmentBottom;
62 static const char* kAlignmentLeft; 59 static const char* kAlignmentLeft;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 virtual NSGradient* GetNSGradient(int id) const OVERRIDE; 173 virtual NSGradient* GetNSGradient(int id) const OVERRIDE;
177 #elif defined(OS_POSIX) && !defined(TOOLKIT_VIEWS) && !defined(OS_ANDROID) 174 #elif defined(OS_POSIX) && !defined(TOOLKIT_VIEWS) && !defined(OS_ANDROID)
178 // This mismatch between what this class defines and whether or not it 175 // This mismatch between what this class defines and whether or not it
179 // overrides ui::ThemeProvider is http://crbug.com/105040 . 176 // overrides ui::ThemeProvider is http://crbug.com/105040 .
180 // GdkPixbufs returned by GetPixbufNamed and GetRTLEnabledPixbufNamed are 177 // GdkPixbufs returned by GetPixbufNamed and GetRTLEnabledPixbufNamed are
181 // shared instances owned by the theme provider and should not be freed. 178 // shared instances owned by the theme provider and should not be freed.
182 virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) const OVERRIDE; 179 virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) const OVERRIDE;
183 #endif 180 #endif
184 181
185 // Set the current theme to the theme defined in |extension|. 182 // Set the current theme to the theme defined in |extension|.
183 // |extension| must already be added to this profile's
184 // ExtensionService.
186 virtual void SetTheme(const extensions::Extension* extension); 185 virtual void SetTheme(const extensions::Extension* extension);
187 186
188 // Reset the theme to default. 187 // Reset the theme to default.
189 virtual void UseDefaultTheme(); 188 virtual void UseDefaultTheme();
190 189
191 // Set the current theme to the native theme. On some platforms, the native 190 // Set the current theme to the native theme. On some platforms, the native
192 // theme is the default theme. 191 // theme is the default theme.
193 virtual void SetNativeTheme(); 192 virtual void SetNativeTheme();
194 193
195 // Whether we're using the chrome default theme. Virtual so linux can check 194 // Whether we're using the chrome default theme. Virtual so linux can check
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // Let all the browser views know that themes have changed in a platform way. 266 // Let all the browser views know that themes have changed in a platform way.
268 virtual void NotifyPlatformThemeChanged(); 267 virtual void NotifyPlatformThemeChanged();
269 #endif // OS_MACOSX 268 #endif // OS_MACOSX
270 269
271 // Clears the platform-specific caches. Do not call directly; it's called 270 // Clears the platform-specific caches. Do not call directly; it's called
272 // from ClearCaches(). 271 // from ClearCaches().
273 virtual void FreePlatformCaches(); 272 virtual void FreePlatformCaches();
274 273
275 Profile* profile() { return profile_; } 274 Profile* profile() { return profile_; }
276 275
277 // content::NotificationObserver:
278 virtual void Observe(int type,
279 const content::NotificationSource& source,
280 const content::NotificationDetails& details) OVERRIDE;
281
282 private: 276 private:
283 friend class ThemeServiceTest; 277 friend class ThemeServiceTest;
284 278
285 // Saves the filename of the cached theme pack. 279 // Saves the filename of the cached theme pack.
286 void SavePackName(const FilePath& pack_path); 280 void SavePackName(const FilePath& pack_path);
287 281
288 // Save the id of the last theme installed. 282 // Save the id of the last theme installed.
289 void SaveThemeID(const std::string& id); 283 void SaveThemeID(const std::string& id);
290 284
291 // Implementation of SetTheme() (and the fallback from LoadThemePrefs() in 285 // Implementation of SetTheme() (and the fallback from LoadThemePrefs() in
(...skipping 21 matching lines...) Expand all
313 #endif 307 #endif
314 308
315 ui::ResourceBundle& rb_; 309 ui::ResourceBundle& rb_;
316 Profile* profile_; 310 Profile* profile_;
317 311
318 scoped_refptr<BrowserThemePack> theme_pack_; 312 scoped_refptr<BrowserThemePack> theme_pack_;
319 313
320 // The number of infobars currently displayed. 314 // The number of infobars currently displayed.
321 int number_of_infobars_; 315 int number_of_infobars_;
322 316
323 content::NotificationRegistrar registrar_;
324
325 scoped_ptr<ThemeSyncableService> theme_syncable_service_; 317 scoped_ptr<ThemeSyncableService> theme_syncable_service_;
326 318
327 DISALLOW_COPY_AND_ASSIGN(ThemeService); 319 DISALLOW_COPY_AND_ASSIGN(ThemeService);
328 }; 320 };
329 321
330 #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_ 322 #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/themes/theme_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698