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

Side by Side Diff: chrome/browser/themes/theme_service_factory.cc

Issue 19471005: Add custom default theme support and create a managed user default theme. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix bugs. Created 7 years, 5 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
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 #include "chrome/browser/themes/theme_service_factory.h" 5 #include "chrome/browser/themes/theme_service_factory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/profiles/incognito_helpers.h" 10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/themes/theme_service.h" 12 #include "chrome/browser/themes/theme_service.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 14 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
15 #include "components/user_prefs/pref_registry_syncable.h" 15 #include "components/user_prefs/pref_registry_syncable.h"
16 16
17 #if defined(TOOLKIT_GTK) 17 #if defined(TOOLKIT_GTK)
18 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 18 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
19 #endif 19 #endif
20 20
21 #if defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS) 21 #if defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
22 #include "chrome/browser/themes/theme_service_aurax11.h" 22 #include "chrome/browser/themes/theme_service_aurax11.h"
23 #include "ui/linux_ui/linux_ui.h" 23 #include "ui/linux_ui/linux_ui.h"
24 #endif 24 #endif
25 25
26 #if defined(ENABLE_MANAGED_USERS)
27 #include "chrome/browser/managed_mode/managed_user_service.h"
28 #include "chrome/browser/managed_mode/managed_user_theme.h"
29 #endif
30
26 // static 31 // static
27 ThemeService* ThemeServiceFactory::GetForProfile(Profile* profile) { 32 ThemeService* ThemeServiceFactory::GetForProfile(Profile* profile) {
28 return static_cast<ThemeService*>( 33 return static_cast<ThemeService*>(
29 GetInstance()->GetServiceForBrowserContext(profile, true)); 34 GetInstance()->GetServiceForBrowserContext(profile, true));
30 } 35 }
31 36
32 // static 37 // static
33 const extensions::Extension* ThemeServiceFactory::GetThemeForProfile( 38 const extensions::Extension* ThemeServiceFactory::GetThemeForProfile(
34 Profile* profile) { 39 Profile* profile) {
35 std::string id = GetForProfile(profile)->GetThemeID(); 40 std::string id = GetForProfile(profile)->GetThemeID();
(...skipping 20 matching lines...) Expand all
56 ThemeService* provider = NULL; 61 ThemeService* provider = NULL;
57 #if defined(TOOLKIT_GTK) 62 #if defined(TOOLKIT_GTK)
58 provider = new GtkThemeService; 63 provider = new GtkThemeService;
59 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS) 64 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
60 provider = new ThemeServiceAuraX11; 65 provider = new ThemeServiceAuraX11;
61 #else 66 #else
62 provider = new ThemeService; 67 provider = new ThemeService;
63 #endif 68 #endif
64 provider->Init(static_cast<Profile*>(profile)); 69 provider->Init(static_cast<Profile*>(profile));
65 70
71 #if defined(ENABLE_MANAGED_USERS)
72 if (ManagedUserService::ProfileIsManaged(static_cast<Profile*>(profile)) &&
73 provider->UsingDefaultTheme()) {
74 provider->SetCustomDefaultTheme(new ManagedUserTheme);
75 }
76 #endif
77
66 return provider; 78 return provider;
67 } 79 }
68 80
69 void ThemeServiceFactory::RegisterProfilePrefs( 81 void ThemeServiceFactory::RegisterProfilePrefs(
70 user_prefs::PrefRegistrySyncable* registry) { 82 user_prefs::PrefRegistrySyncable* registry) {
71 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 83 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
72 bool default_uses_system_theme = false; 84 bool default_uses_system_theme = false;
73 85
74 #if defined(TOOLKIT_GTK) 86 #if defined(TOOLKIT_GTK)
75 default_uses_system_theme = GtkThemeService::DefaultUsesSystemTheme(); 87 default_uses_system_theme = GtkThemeService::DefaultUsesSystemTheme();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 119 }
108 120
109 content::BrowserContext* ThemeServiceFactory::GetBrowserContextToUse( 121 content::BrowserContext* ThemeServiceFactory::GetBrowserContextToUse(
110 content::BrowserContext* context) const { 122 content::BrowserContext* context) const {
111 return chrome::GetBrowserContextRedirectedInIncognito(context); 123 return chrome::GetBrowserContextRedirectedInIncognito(context);
112 } 124 }
113 125
114 bool ThemeServiceFactory::ServiceIsCreatedWithBrowserContext() const { 126 bool ThemeServiceFactory::ServiceIsCreatedWithBrowserContext() const {
115 return true; 127 return true;
116 } 128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698