summaryrefslogtreecommitdiffstats
path: root/chrome/browser/plugin_prefs.cc
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-10 22:28:17 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-10 22:28:17 +0000
commita42f2e2d7447f9ae1a65f7171c29b75bd3d14826 (patch)
tree91ccbbce3bbe159175855c4352cba71b884ec16a /chrome/browser/plugin_prefs.cc
parent00475c046ebe17b9df0cf55d14afbebcb7f67437 (diff)
downloadchromium_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.cc')
-rw-r--r--chrome/browser/plugin_prefs.cc108
1 files changed, 5 insertions, 103 deletions
diff --git a/chrome/browser/plugin_prefs.cc b/chrome/browser/plugin_prefs.cc
index dd7df34..b7bc00f 100644
--- a/chrome/browser/plugin_prefs.cc
+++ b/chrome/browser/plugin_prefs.cc
@@ -18,12 +18,10 @@
#include "base/values.h"
#include "base/version.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/plugin_prefs_factory.h"
#include "chrome/browser/prefs/scoped_user_pref_update.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/browser/profiles/profile_keyed_service_factory.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_content_client.h"
#include "chrome/common/chrome_notification_types.h"
@@ -38,67 +36,21 @@
namespace {
-class PluginPrefsWrapper : public ProfileKeyedService {
- public:
- explicit PluginPrefsWrapper(scoped_refptr<PluginPrefs> plugin_prefs)
- : plugin_prefs_(plugin_prefs) {}
- virtual ~PluginPrefsWrapper() {}
-
- PluginPrefs* plugin_prefs() { return plugin_prefs_.get(); }
-
- private:
- // ProfileKeyedService methods:
- virtual void Shutdown() OVERRIDE {
- plugin_prefs_->ShutdownOnUIThread();
- }
-
- scoped_refptr<PluginPrefs> plugin_prefs_;
-};
-
// Default state for a plug-in (not state of the default plug-in!).
// Accessed only on the UI thread.
base::LazyInstance<std::map<FilePath, bool> > g_default_plugin_state(
base::LINKER_INITIALIZED);
-}
+} // namespace
// How long to wait to save the plugin enabled information, which might need to
// go to disk.
#define kPluginUpdateDelayMs (60 * 1000)
-class PluginPrefs::Factory : public ProfileKeyedServiceFactory {
- public:
- static Factory* GetInstance();
-
- PluginPrefsWrapper* GetWrapperForProfile(Profile* profile);
-
- // Factory function for use with
- // ProfileKeyedServiceFactory::SetTestingFactory.
- static ProfileKeyedService* CreateWrapperForProfile(Profile* profile);
-
- private:
- friend struct DefaultSingletonTraits<Factory>;
-
- Factory();
- virtual ~Factory() {}
-
- // ProfileKeyedServiceFactory methods:
- virtual ProfileKeyedService* BuildServiceInstanceFor(
- Profile* profile) const OVERRIDE;
- virtual bool ServiceRedirectedInIncognito() OVERRIDE { return true; }
- virtual bool ServiceIsNULLWhileTesting() OVERRIDE { return true; }
- virtual bool ServiceIsCreatedWithProfile() OVERRIDE { return true; }
-};
-
-// static
-void PluginPrefs::Initialize() {
- Factory::GetInstance();
-}
-
// static
PluginPrefs* PluginPrefs::GetForProfile(Profile* profile) {
PluginPrefsWrapper* wrapper =
- Factory::GetInstance()->GetWrapperForProfile(profile);
+ PluginPrefsFactory::GetInstance()->GetWrapperForProfile(profile);
if (!wrapper)
return NULL;
return wrapper->plugin_prefs();
@@ -107,8 +59,8 @@ PluginPrefs* PluginPrefs::GetForProfile(Profile* profile) {
// static
PluginPrefs* PluginPrefs::GetForTestingProfile(Profile* profile) {
ProfileKeyedService* wrapper =
- Factory::GetInstance()->SetTestingFactoryAndUse(
- profile, &Factory::CreateWrapperForProfile);
+ PluginPrefsFactory::GetInstance()->SetTestingFactoryAndUse(
+ profile, &PluginPrefsFactory::CreateWrapperForProfile);
return static_cast<PluginPrefsWrapper*>(wrapper)->plugin_prefs();
}
@@ -504,33 +456,6 @@ void PluginPrefs::ShutdownOnUIThread() {
registrar_.RemoveAll();
}
-// static
-PluginPrefs::Factory* PluginPrefs::Factory::GetInstance() {
- return Singleton<PluginPrefs::Factory>::get();
-}
-
-PluginPrefsWrapper* PluginPrefs::Factory::GetWrapperForProfile(
- Profile* profile) {
- return static_cast<PluginPrefsWrapper*>(GetServiceForProfile(profile, true));
-}
-
-// static
-ProfileKeyedService* PluginPrefs::Factory::CreateWrapperForProfile(
- Profile* profile) {
- return GetInstance()->BuildServiceInstanceFor(profile);
-}
-
-PluginPrefs::Factory::Factory()
- : ProfileKeyedServiceFactory(ProfileDependencyManager::GetInstance()) {
-}
-
-ProfileKeyedService* PluginPrefs::Factory::BuildServiceInstanceFor(
- Profile* profile) const {
- scoped_refptr<PluginPrefs> plugin_prefs(new PluginPrefs());
- plugin_prefs->SetPrefs(profile->GetPrefs());
- return new PluginPrefsWrapper(plugin_prefs);
-}
-
PluginPrefs::PluginPrefs() : plugin_state_(g_default_plugin_state.Get()),
prefs_(NULL),
plugin_list_(NULL) {
@@ -618,26 +543,3 @@ void PluginPrefs::NotifyPluginStatusChanged() {
Source<PluginPrefs>(this),
NotificationService::NoDetails());
}
-
-/*static*/
-void PluginPrefs::RegisterPrefs(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);
-}