OLD | NEW |
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 // static | 21 // static |
22 ThemeService* ThemeServiceFactory::GetForProfile(Profile* profile) { | 22 ThemeService* ThemeServiceFactory::GetForProfile(Profile* profile) { |
23 return static_cast<ThemeService*>( | 23 return static_cast<ThemeService*>( |
24 GetInstance()->GetServiceForProfile(profile, true)); | 24 GetInstance()->GetServiceForBrowserContext(profile, true)); |
25 } | 25 } |
26 | 26 |
27 // static | 27 // static |
28 const extensions::Extension* ThemeServiceFactory::GetThemeForProfile( | 28 const extensions::Extension* ThemeServiceFactory::GetThemeForProfile( |
29 Profile* profile) { | 29 Profile* profile) { |
30 std::string id = GetForProfile(profile)->GetThemeID(); | 30 std::string id = GetForProfile(profile)->GetThemeID(); |
31 if (id == ThemeService::kDefaultThemeID) | 31 if (id == ThemeService::kDefaultThemeID) |
32 return NULL; | 32 return NULL; |
33 | 33 |
34 return profile->GetExtensionService()->GetExtensionById(id, false); | 34 return profile->GetExtensionService()->GetExtensionById(id, false); |
35 } | 35 } |
36 | 36 |
37 // static | 37 // static |
38 ThemeServiceFactory* ThemeServiceFactory::GetInstance() { | 38 ThemeServiceFactory* ThemeServiceFactory::GetInstance() { |
39 return Singleton<ThemeServiceFactory>::get(); | 39 return Singleton<ThemeServiceFactory>::get(); |
40 } | 40 } |
41 | 41 |
42 ThemeServiceFactory::ThemeServiceFactory() | 42 ThemeServiceFactory::ThemeServiceFactory() |
43 : ProfileKeyedServiceFactory("ThemeService", | 43 : BrowserContextKeyedServiceFactory( |
44 ProfileDependencyManager::GetInstance()) {} | 44 "ThemeService", |
| 45 BrowserContextDependencyManager::GetInstance()) {} |
45 | 46 |
46 ThemeServiceFactory::~ThemeServiceFactory() {} | 47 ThemeServiceFactory::~ThemeServiceFactory() {} |
47 | 48 |
48 ProfileKeyedService* ThemeServiceFactory::BuildServiceInstanceFor( | 49 BrowserContextKeyedService* ThemeServiceFactory::BuildServiceInstanceFor( |
49 content::BrowserContext* profile) const { | 50 content::BrowserContext* profile) const { |
50 ThemeService* provider = NULL; | 51 ThemeService* provider = NULL; |
51 #if defined(TOOLKIT_GTK) | 52 #if defined(TOOLKIT_GTK) |
52 provider = new GtkThemeService; | 53 provider = new GtkThemeService; |
53 #else | 54 #else |
54 provider = new ThemeService; | 55 provider = new ThemeService; |
55 #endif | 56 #endif |
56 provider->Init(static_cast<Profile*>(profile)); | 57 provider->Init(static_cast<Profile*>(profile)); |
57 | 58 |
58 return provider; | 59 return provider; |
(...skipping 27 matching lines...) Expand all Loading... |
86 registry->RegisterDictionaryPref( | 87 registry->RegisterDictionaryPref( |
87 prefs::kCurrentThemeDisplayProperties, | 88 prefs::kCurrentThemeDisplayProperties, |
88 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 89 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
89 } | 90 } |
90 | 91 |
91 content::BrowserContext* ThemeServiceFactory::GetBrowserContextToUse( | 92 content::BrowserContext* ThemeServiceFactory::GetBrowserContextToUse( |
92 content::BrowserContext* context) const { | 93 content::BrowserContext* context) const { |
93 return chrome::GetBrowserContextRedirectedInIncognito(context); | 94 return chrome::GetBrowserContextRedirectedInIncognito(context); |
94 } | 95 } |
95 | 96 |
96 bool ThemeServiceFactory::ServiceIsCreatedWithProfile() const { | 97 bool ThemeServiceFactory::ServiceIsCreatedWithBrowserContext() const { |
97 return true; | 98 return true; |
98 } | 99 } |
OLD | NEW |