diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-10 22:28:17 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-10 22:28:17 +0000 |
commit | a42f2e2d7447f9ae1a65f7171c29b75bd3d14826 (patch) | |
tree | 91ccbbce3bbe159175855c4352cba71b884ec16a /chrome/browser/plugin_prefs_factory.cc | |
parent | 00475c046ebe17b9df0cf55d14afbebcb7f67437 (diff) | |
download | chromium_src-a42f2e2d7447f9ae1a65f7171c29b75bd3d14826.zip chromium_src-a42f2e2d7447f9ae1a65f7171c29b75bd3d14826.tar.gz chromium_src-a42f2e2d7447f9ae1a65f7171c29b75bd3d14826.tar.bz2 |
profile: Add a way for each ProfileKeyedServiceFactory to specify its user prefernces.
To allow us to compile individual features in/out of a chrome build, we need to
attack browser_prefs.cc, which is a giant static registration. This used to be
done through another big code path starting in ProfileImpl which call
browser::RegisterUserPrefs() which linked to other static methods. Now this is
done through overridding ProfileKeyedServiceFactory::RegisterUserPrefs(), and
there are no additional dependencies.
BUG=none
TEST=none
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=104412
Review URL: http://codereview.chromium.org/7901027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104806 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/plugin_prefs_factory.cc')
-rw-r--r-- | chrome/browser/plugin_prefs_factory.cc | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/chrome/browser/plugin_prefs_factory.cc b/chrome/browser/plugin_prefs_factory.cc new file mode 100644 index 0000000..3cac28a --- /dev/null +++ b/chrome/browser/plugin_prefs_factory.cc @@ -0,0 +1,95 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/plugin_prefs_factory.h" + +#include "base/path_service.h" +#include "chrome/browser/plugin_prefs.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_dependency_manager.h" +#include "chrome/browser/profiles/profile_keyed_service.h" +#include "chrome/common/chrome_paths.h" +#include "chrome/common/pref_names.h" + +namespace { + +} // namespace + +PluginPrefsWrapper::PluginPrefsWrapper(scoped_refptr<PluginPrefs> plugin_prefs) + : plugin_prefs_(plugin_prefs) { +} + +PluginPrefsWrapper::~PluginPrefsWrapper() {} + +void PluginPrefsWrapper::Shutdown() { + plugin_prefs_->ShutdownOnUIThread(); +} + +// static +PluginPrefsFactory* PluginPrefsFactory::GetInstance() { + return Singleton<PluginPrefsFactory>::get(); +} + +PluginPrefsWrapper* PluginPrefsFactory::GetWrapperForProfile( + Profile* profile) { + return static_cast<PluginPrefsWrapper*>(GetServiceForProfile(profile, true)); +} + +// static +ProfileKeyedService* PluginPrefsFactory::CreateWrapperForProfile( + Profile* profile) { + return GetInstance()->BuildServiceInstanceFor(profile); +} + +void PluginPrefsFactory::ForceRegisterPrefsForTest(PrefService* prefs) { + RegisterUserPrefs(prefs); +} + +PluginPrefsFactory::PluginPrefsFactory() + : ProfileKeyedServiceFactory(ProfileDependencyManager::GetInstance()) { +} + +PluginPrefsFactory::~PluginPrefsFactory() {} + +ProfileKeyedService* PluginPrefsFactory::BuildServiceInstanceFor( + Profile* profile) const { + scoped_refptr<PluginPrefs> plugin_prefs(new PluginPrefs()); + plugin_prefs->SetPrefs(profile->GetPrefs()); + return new PluginPrefsWrapper(plugin_prefs); +} + +void PluginPrefsFactory::RegisterUserPrefs(PrefService* prefs) { + FilePath internal_dir; + PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir); + prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory, + internal_dir, + PrefService::UNSYNCABLE_PREF); + prefs->RegisterBooleanPref(prefs::kPluginsEnabledInternalPDF, + false, + PrefService::UNSYNCABLE_PREF); + prefs->RegisterBooleanPref(prefs::kPluginsEnabledNaCl, + false, + PrefService::UNSYNCABLE_PREF); + prefs->RegisterListPref(prefs::kPluginsPluginsList, + PrefService::UNSYNCABLE_PREF); + prefs->RegisterListPref(prefs::kPluginsDisabledPlugins, + PrefService::UNSYNCABLE_PREF); + prefs->RegisterListPref(prefs::kPluginsDisabledPluginsExceptions, + PrefService::UNSYNCABLE_PREF); + prefs->RegisterListPref(prefs::kPluginsEnabledPlugins, + PrefService::UNSYNCABLE_PREF); +} + +bool PluginPrefsFactory::ServiceRedirectedInIncognito() { + return true; +} + +bool PluginPrefsFactory::ServiceIsNULLWhileTesting() { + return true; +} + +bool PluginPrefsFactory::ServiceIsCreatedWithProfile() { + return true; +} |