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/keyed_service/content/browser_context_dependency_manager.h" | 14 #include "components/keyed_service/content/browser_context_dependency_manager.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) | |
18 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | |
19 #endif | |
20 | |
21 #if defined(USE_AURA) && defined(USE_X11) && !defined(OS_CHROMEOS) | 17 #if defined(USE_AURA) && defined(USE_X11) && !defined(OS_CHROMEOS) |
22 #include "chrome/browser/themes/theme_service_aurax11.h" | 18 #include "chrome/browser/themes/theme_service_aurax11.h" |
23 #include "ui/views/linux_ui/linux_ui.h" | 19 #include "ui/views/linux_ui/linux_ui.h" |
24 #endif | 20 #endif |
25 | 21 |
26 // static | 22 // static |
27 ThemeService* ThemeServiceFactory::GetForProfile(Profile* profile) { | 23 ThemeService* ThemeServiceFactory::GetForProfile(Profile* profile) { |
28 return static_cast<ThemeService*>( | 24 return static_cast<ThemeService*>( |
29 GetInstance()->GetServiceForBrowserContext(profile, true)); | 25 GetInstance()->GetServiceForBrowserContext(profile, true)); |
30 } | 26 } |
(...skipping 16 matching lines...) Expand all Loading... |
47 ThemeServiceFactory::ThemeServiceFactory() | 43 ThemeServiceFactory::ThemeServiceFactory() |
48 : BrowserContextKeyedServiceFactory( | 44 : BrowserContextKeyedServiceFactory( |
49 "ThemeService", | 45 "ThemeService", |
50 BrowserContextDependencyManager::GetInstance()) {} | 46 BrowserContextDependencyManager::GetInstance()) {} |
51 | 47 |
52 ThemeServiceFactory::~ThemeServiceFactory() {} | 48 ThemeServiceFactory::~ThemeServiceFactory() {} |
53 | 49 |
54 KeyedService* ThemeServiceFactory::BuildServiceInstanceFor( | 50 KeyedService* ThemeServiceFactory::BuildServiceInstanceFor( |
55 content::BrowserContext* profile) const { | 51 content::BrowserContext* profile) const { |
56 ThemeService* provider = NULL; | 52 ThemeService* provider = NULL; |
57 #if defined(TOOLKIT_GTK) | 53 #if defined(USE_AURA) && defined(USE_X11) && !defined(OS_CHROMEOS) |
58 provider = new GtkThemeService; | |
59 #elif defined(USE_AURA) && defined(USE_X11) && !defined(OS_CHROMEOS) | |
60 provider = new ThemeServiceAuraX11; | 54 provider = new ThemeServiceAuraX11; |
61 #else | 55 #else |
62 provider = new ThemeService; | 56 provider = new ThemeService; |
63 #endif | 57 #endif |
64 provider->Init(static_cast<Profile*>(profile)); | 58 provider->Init(static_cast<Profile*>(profile)); |
65 | 59 |
66 return provider; | 60 return provider; |
67 } | 61 } |
68 | 62 |
69 void ThemeServiceFactory::RegisterProfilePrefs( | 63 void ThemeServiceFactory::RegisterProfilePrefs( |
70 user_prefs::PrefRegistrySyncable* registry) { | 64 user_prefs::PrefRegistrySyncable* registry) { |
71 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 65 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
72 bool default_uses_system_theme = false; | 66 bool default_uses_system_theme = false; |
73 | 67 |
74 #if defined(TOOLKIT_GTK) | 68 #if defined(USE_AURA) && defined(USE_X11) && !defined(OS_CHROMEOS) |
75 default_uses_system_theme = GtkThemeService::DefaultUsesSystemTheme(); | |
76 #elif defined(USE_AURA) && defined(USE_X11) && !defined(OS_CHROMEOS) | |
77 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); | 69 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); |
78 if (linux_ui) | 70 if (linux_ui) |
79 default_uses_system_theme = linux_ui->GetDefaultUsesSystemTheme(); | 71 default_uses_system_theme = linux_ui->GetDefaultUsesSystemTheme(); |
80 #endif | 72 #endif |
81 | 73 |
82 registry->RegisterBooleanPref( | 74 registry->RegisterBooleanPref( |
83 prefs::kUsesSystemTheme, | 75 prefs::kUsesSystemTheme, |
84 default_uses_system_theme, | 76 default_uses_system_theme, |
85 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 77 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
86 #endif | 78 #endif |
(...skipping 20 matching lines...) Expand all Loading... |
107 } | 99 } |
108 | 100 |
109 content::BrowserContext* ThemeServiceFactory::GetBrowserContextToUse( | 101 content::BrowserContext* ThemeServiceFactory::GetBrowserContextToUse( |
110 content::BrowserContext* context) const { | 102 content::BrowserContext* context) const { |
111 return chrome::GetBrowserContextRedirectedInIncognito(context); | 103 return chrome::GetBrowserContextRedirectedInIncognito(context); |
112 } | 104 } |
113 | 105 |
114 bool ThemeServiceFactory::ServiceIsCreatedWithBrowserContext() const { | 106 bool ThemeServiceFactory::ServiceIsCreatedWithBrowserContext() const { |
115 return true; | 107 return true; |
116 } | 108 } |
OLD | NEW |