Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / themes / theme_service_factory.cc
blob396d32ab9d261ac9a476fdeb1d2f4ba633c9fd5b
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
3 // found in the LICENSE file.
5 #include "chrome/browser/themes/theme_service_factory.h"
7 #include "base/logging.h"
8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/themes/theme_service.h"
13 #include "chrome/common/pref_names.h"
14 #include "components/keyed_service/content/browser_context_dependency_manager.h"
15 #include "components/user_prefs/pref_registry_syncable.h"
17 #if defined(USE_AURA) && defined(USE_X11) && !defined(OS_CHROMEOS)
18 #include "chrome/browser/themes/theme_service_aurax11.h"
19 #include "ui/views/linux_ui/linux_ui.h"
20 #endif
22 // static
23 ThemeService* ThemeServiceFactory::GetForProfile(Profile* profile) {
24 return static_cast<ThemeService*>(
25 GetInstance()->GetServiceForBrowserContext(profile, true));
28 // static
29 const extensions::Extension* ThemeServiceFactory::GetThemeForProfile(
30 Profile* profile) {
31 std::string id = GetForProfile(profile)->GetThemeID();
32 if (id == ThemeService::kDefaultThemeID)
33 return NULL;
35 return profile->GetExtensionService()->GetExtensionById(id, false);
38 // static
39 ThemeServiceFactory* ThemeServiceFactory::GetInstance() {
40 return Singleton<ThemeServiceFactory>::get();
43 ThemeServiceFactory::ThemeServiceFactory()
44 : BrowserContextKeyedServiceFactory(
45 "ThemeService",
46 BrowserContextDependencyManager::GetInstance()) {}
48 ThemeServiceFactory::~ThemeServiceFactory() {}
50 KeyedService* ThemeServiceFactory::BuildServiceInstanceFor(
51 content::BrowserContext* profile) const {
52 ThemeService* provider = NULL;
53 #if defined(USE_AURA) && defined(USE_X11) && !defined(OS_CHROMEOS)
54 provider = new ThemeServiceAuraX11;
55 #else
56 provider = new ThemeService;
57 #endif
58 provider->Init(static_cast<Profile*>(profile));
60 return provider;
63 void ThemeServiceFactory::RegisterProfilePrefs(
64 user_prefs::PrefRegistrySyncable* registry) {
65 #if defined(USE_X11) && !defined(OS_CHROMEOS)
66 bool default_uses_system_theme = false;
68 #if defined(USE_AURA) && defined(USE_X11) && !defined(OS_CHROMEOS)
69 const views::LinuxUI* linux_ui = views::LinuxUI::instance();
70 if (linux_ui)
71 default_uses_system_theme = linux_ui->GetDefaultUsesSystemTheme();
72 #endif
74 registry->RegisterBooleanPref(
75 prefs::kUsesSystemTheme,
76 default_uses_system_theme,
77 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
78 #endif
79 registry->RegisterFilePathPref(
80 prefs::kCurrentThemePackFilename,
81 base::FilePath(),
82 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
83 registry->RegisterStringPref(
84 prefs::kCurrentThemeID,
85 ThemeService::kDefaultThemeID,
86 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
87 registry->RegisterDictionaryPref(
88 prefs::kCurrentThemeImages,
89 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
90 registry->RegisterDictionaryPref(
91 prefs::kCurrentThemeColors,
92 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
93 registry->RegisterDictionaryPref(
94 prefs::kCurrentThemeTints,
95 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
96 registry->RegisterDictionaryPref(
97 prefs::kCurrentThemeDisplayProperties,
98 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
101 content::BrowserContext* ThemeServiceFactory::GetBrowserContextToUse(
102 content::BrowserContext* context) const {
103 return chrome::GetBrowserContextRedirectedInIncognito(context);
106 bool ThemeServiceFactory::ServiceIsCreatedWithBrowserContext() const {
107 return true;