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.h | |
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.h')
-rw-r--r-- | chrome/browser/plugin_prefs_factory.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/chrome/browser/plugin_prefs_factory.h b/chrome/browser/plugin_prefs_factory.h new file mode 100644 index 0000000..edb28a5 --- /dev/null +++ b/chrome/browser/plugin_prefs_factory.h @@ -0,0 +1,66 @@ +// 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. + +#ifndef CHROME_BROWSER_PLUGIN_PREFS_FACTORY_H_ +#define CHROME_BROWSER_PLUGIN_PREFS_FACTORY_H_ +#pragma once + +#include "base/compiler_specific.h" +#include "base/memory/singleton.h" +#include "chrome/browser/profiles/profile_keyed_service.h" +#include "chrome/browser/profiles/profile_keyed_service_factory.h" + +class PluginPrefs; +class PrefService; +class Profile; +class ProfileKeyedService; + +// A wrapper around PluginPrefs to own the reference to thre real object. +// +// This should totally go away; we need a generic bridge between PKSF and +// scope_refptrs. +class PluginPrefsWrapper : public ProfileKeyedService { + public: + explicit PluginPrefsWrapper(scoped_refptr<PluginPrefs> plugin_prefs); + virtual ~PluginPrefsWrapper(); + + PluginPrefs* plugin_prefs() { return plugin_prefs_.get(); } + + private: + // ProfileKeyedService methods: + virtual void Shutdown() OVERRIDE; + + scoped_refptr<PluginPrefs> plugin_prefs_; +}; + +class PluginPrefsFactory : public ProfileKeyedServiceFactory { + public: + static PluginPrefsFactory* GetInstance(); + + PluginPrefsWrapper* GetWrapperForProfile(Profile* profile); + + // Factory function for use with + // ProfileKeyedServiceFactory::SetTestingFactory. + static ProfileKeyedService* CreateWrapperForProfile(Profile* profile); + + // Some unit tests that deal with PluginPrefs don't run with a Profile. Let + // them still register their preferences. + void ForceRegisterPrefsForTest(PrefService* prefs); + + private: + friend struct DefaultSingletonTraits<PluginPrefsFactory>; + + PluginPrefsFactory(); + virtual ~PluginPrefsFactory(); + + // ProfileKeyedServiceFactory methods: + virtual ProfileKeyedService* BuildServiceInstanceFor( + Profile* profile) const OVERRIDE; + virtual void RegisterUserPrefs(PrefService* prefs) OVERRIDE; + virtual bool ServiceRedirectedInIncognito() OVERRIDE; + virtual bool ServiceIsNULLWhileTesting() OVERRIDE; + virtual bool ServiceIsCreatedWithProfile() OVERRIDE; +}; + +#endif // CHROME_BROWSER_PLUGIN_PREFS_FACTORY_H_ |