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 #if defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 22 #include "chrome/browser/themes/theme_service_aurax11.h" |
| 23 #include "ui/linux_ui/linux_ui.h" |
| 24 #endif |
| 25 |
21 // static | 26 // static |
22 ThemeService* ThemeServiceFactory::GetForProfile(Profile* profile) { | 27 ThemeService* ThemeServiceFactory::GetForProfile(Profile* profile) { |
23 return static_cast<ThemeService*>( | 28 return static_cast<ThemeService*>( |
24 GetInstance()->GetServiceForBrowserContext(profile, true)); | 29 GetInstance()->GetServiceForBrowserContext(profile, true)); |
25 } | 30 } |
26 | 31 |
27 // static | 32 // static |
28 const extensions::Extension* ThemeServiceFactory::GetThemeForProfile( | 33 const extensions::Extension* ThemeServiceFactory::GetThemeForProfile( |
29 Profile* profile) { | 34 Profile* profile) { |
30 std::string id = GetForProfile(profile)->GetThemeID(); | 35 std::string id = GetForProfile(profile)->GetThemeID(); |
(...skipping 13 matching lines...) Expand all Loading... |
44 "ThemeService", | 49 "ThemeService", |
45 BrowserContextDependencyManager::GetInstance()) {} | 50 BrowserContextDependencyManager::GetInstance()) {} |
46 | 51 |
47 ThemeServiceFactory::~ThemeServiceFactory() {} | 52 ThemeServiceFactory::~ThemeServiceFactory() {} |
48 | 53 |
49 BrowserContextKeyedService* ThemeServiceFactory::BuildServiceInstanceFor( | 54 BrowserContextKeyedService* ThemeServiceFactory::BuildServiceInstanceFor( |
50 content::BrowserContext* profile) const { | 55 content::BrowserContext* profile) const { |
51 ThemeService* provider = NULL; | 56 ThemeService* provider = NULL; |
52 #if defined(TOOLKIT_GTK) | 57 #if defined(TOOLKIT_GTK) |
53 provider = new GtkThemeService; | 58 provider = new GtkThemeService; |
| 59 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 60 provider = new ThemeServiceAuraX11; |
54 #else | 61 #else |
55 provider = new ThemeService; | 62 provider = new ThemeService; |
56 #endif | 63 #endif |
57 provider->Init(static_cast<Profile*>(profile)); | 64 provider->Init(static_cast<Profile*>(profile)); |
58 | 65 |
59 return provider; | 66 return provider; |
60 } | 67 } |
61 | 68 |
62 void ThemeServiceFactory::RegisterUserPrefs( | 69 void ThemeServiceFactory::RegisterUserPrefs( |
63 user_prefs::PrefRegistrySyncable* registry) { | 70 user_prefs::PrefRegistrySyncable* registry) { |
| 71 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 72 bool default_uses_system_theme = false; |
| 73 |
64 #if defined(TOOLKIT_GTK) | 74 #if defined(TOOLKIT_GTK) |
| 75 default_uses_system_theme = GtkThemeService::DefaultUsesSystemTheme(); |
| 76 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 77 const ui::LinuxUI* linux_ui = ui::LinuxUI::instance(); |
| 78 if (linux_ui) |
| 79 default_uses_system_theme = linux_ui->GetDefaultUsesSystemTheme(); |
| 80 #endif |
| 81 |
65 registry->RegisterBooleanPref( | 82 registry->RegisterBooleanPref( |
66 prefs::kUsesSystemTheme, | 83 prefs::kUsesSystemTheme, |
67 GtkThemeService::DefaultUsesSystemTheme(), | 84 default_uses_system_theme, |
68 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 85 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
69 #endif | 86 #endif |
70 registry->RegisterFilePathPref( | 87 registry->RegisterFilePathPref( |
71 prefs::kCurrentThemePackFilename, | 88 prefs::kCurrentThemePackFilename, |
72 base::FilePath(), | 89 base::FilePath(), |
73 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 90 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
74 registry->RegisterStringPref( | 91 registry->RegisterStringPref( |
75 prefs::kCurrentThemeID, | 92 prefs::kCurrentThemeID, |
76 ThemeService::kDefaultThemeID, | 93 ThemeService::kDefaultThemeID, |
77 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 94 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
(...skipping 12 matching lines...) Expand all Loading... |
90 } | 107 } |
91 | 108 |
92 content::BrowserContext* ThemeServiceFactory::GetBrowserContextToUse( | 109 content::BrowserContext* ThemeServiceFactory::GetBrowserContextToUse( |
93 content::BrowserContext* context) const { | 110 content::BrowserContext* context) const { |
94 return chrome::GetBrowserContextRedirectedInIncognito(context); | 111 return chrome::GetBrowserContextRedirectedInIncognito(context); |
95 } | 112 } |
96 | 113 |
97 bool ThemeServiceFactory::ServiceIsCreatedWithBrowserContext() const { | 114 bool ThemeServiceFactory::ServiceIsCreatedWithBrowserContext() const { |
98 return true; | 115 return true; |
99 } | 116 } |
OLD | NEW |