diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-31 14:41:55 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-31 14:41:55 +0000 |
commit | 21d3a88076587737d437cfd5d0819f0dda10c823 (patch) | |
tree | 621bbcdb56ceacdb3cb286d895fb9711000b7eb8 /chrome/browser/profiles | |
parent | cdaf13d1e037f0119bc8724d0907e31a2729b233 (diff) | |
download | chromium_src-21d3a88076587737d437cfd5d0819f0dda10c823.zip chromium_src-21d3a88076587737d437cfd5d0819f0dda10c823.tar.gz chromium_src-21d3a88076587737d437cfd5d0819f0dda10c823.tar.bz2 |
Make PolicyService per-profile.
At the moment, all the policy services are identical, but this will allow us to add different policies per profile.
BUG=128318
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10444008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139783 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/profiles')
-rw-r--r-- | chrome/browser/profiles/off_the_record_profile_impl.cc | 4 | ||||
-rw-r--r-- | chrome/browser/profiles/off_the_record_profile_impl.h | 1 | ||||
-rw-r--r-- | chrome/browser/profiles/profile.h | 9 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl.cc | 23 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl.h | 8 |
5 files changed, 40 insertions, 5 deletions
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc index a7017e5..7c92c21 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.cc +++ b/chrome/browser/profiles/off_the_record_profile_impl.cc @@ -246,6 +246,10 @@ history::ShortcutsBackend* OffTheRecordProfileImpl::GetShortcutsBackend() { return NULL; } +policy::PolicyService* OffTheRecordProfileImpl::GetPolicyService() { + return profile_->GetPolicyService(); +} + PrefService* OffTheRecordProfileImpl::GetPrefs() { return prefs_; } diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h index 9fd2f1e..91b9059 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.h +++ b/chrome/browser/profiles/off_the_record_profile_impl.h @@ -52,6 +52,7 @@ class OffTheRecordProfileImpl : public Profile, virtual FaviconService* GetFaviconService(ServiceAccessType sat) OVERRIDE; virtual AutocompleteClassifier* GetAutocompleteClassifier() OVERRIDE; virtual history::ShortcutsBackend* GetShortcutsBackend() OVERRIDE; + virtual policy::PolicyService* GetPolicyService() OVERRIDE; virtual PrefService* GetPrefs() OVERRIDE; virtual PrefService* GetOffTheRecordPrefs() OVERRIDE; virtual net::URLRequestContextGetter* diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h index 8d75eee..fb8a28b 100644 --- a/chrome/browser/profiles/profile.h +++ b/chrome/browser/profiles/profile.h @@ -74,6 +74,10 @@ namespace net { class SSLConfigService; } +namespace policy { +class PolicyService; +} + class Profile : public content::BrowserContext { public: // Profile services are accessed with the following parameter. This parameter @@ -262,10 +266,11 @@ class Profile : public content::BrowserContext { // this profile need to be sure they refcount the returned value. virtual history::ShortcutsBackend* GetShortcutsBackend() = 0; + // Returns the PolicyService that provides policies for this profile. + virtual policy::PolicyService* GetPolicyService() = 0; // Retrieves a pointer to the PrefService that manages the preferences - // for this user profile. The PrefService is lazily created the first - // time that this method is called. + // for this user profile. virtual PrefService* GetPrefs() = 0; // Retrieves a pointer to the PrefService that manages the preferences diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index b8cf237..0612b82 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -51,6 +51,7 @@ #include "chrome/browser/net/ssl_config_service_manager.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/plugin_prefs.h" +#include "chrome/browser/policy/policy_service.h" #include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/prerender/prerender_manager_factory.h" @@ -85,13 +86,18 @@ #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +#if defined(ENABLE_CONFIGURATION_POLICY) +#include "chrome/browser/policy/browser_policy_connector.h" +#else +#include "chrome/browser/policy/policy_service_stub.h" +#endif // defined(ENABLE_CONFIGURATION_POLICY) + #if defined(OS_WIN) #include "chrome/installer/util/install_util.h" -#elif defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/enterprise_extension_observer.h" #endif #if defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/enterprise_extension_observer.h" #include "chrome/browser/chromeos/locale_change_guard.h" #include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/preferences.h" @@ -249,9 +255,16 @@ ProfileImpl::ProfileImpl(const FilePath& path, session_restore_enabled_ = !command_line->HasSwitch(switches::kDisableRestoreSessionState); +#if defined(ENABLE_CONFIGURATION_POLICY) + policy_service_.reset( + g_browser_process->browser_policy_connector()->CreatePolicyService(this)); +#else + policy_service_.reset(new policy::PolicyServiceStub()); +#endif if (create_mode == CREATE_MODE_ASYNCHRONOUS) { prefs_.reset(PrefService::CreatePrefService( GetPrefFilePath(), + policy_service_.get(), new ExtensionPrefStore( ExtensionPrefValueMapFactory::GetForProfile(this), false), true)); @@ -263,6 +276,7 @@ ProfileImpl::ProfileImpl(const FilePath& path, // Load prefs synchronously. prefs_.reset(PrefService::CreatePrefService( GetPrefFilePath(), + policy_service_.get(), new ExtensionPrefStore( ExtensionPrefValueMapFactory::GetForProfile(this), false), false)); @@ -673,6 +687,11 @@ bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { return (profile_version.CompareTo(arg_version) >= 0); } +policy::PolicyService* ProfileImpl::GetPolicyService() { + DCHECK(policy_service_.get()); // Should explicitly be initialized. + return policy_service_.get(); +} + PrefService* ProfileImpl::GetPrefs() { DCHECK(prefs_.get()); // Should explicitly be initialized. return prefs_.get(); diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h index 8662ea0..fc48a09 100644 --- a/chrome/browser/profiles/profile_impl.h +++ b/chrome/browser/profiles/profile_impl.h @@ -89,6 +89,7 @@ class ProfileImpl : public Profile, virtual HistoryService* GetHistoryServiceWithoutCreating() OVERRIDE; virtual AutocompleteClassifier* GetAutocompleteClassifier() OVERRIDE; virtual history::ShortcutsBackend* GetShortcutsBackend() OVERRIDE; + virtual policy::PolicyService* GetPolicyService() OVERRIDE; virtual PrefService* GetPrefs() OVERRIDE; virtual PrefService* GetOffTheRecordPrefs() OVERRIDE; virtual net::URLRequestContextGetter* @@ -191,8 +192,13 @@ class ProfileImpl : public Profile, // that the declaration occurs AFTER things it depends on as destruction // happens in reverse order of declaration. + // |prefs_| depends on |policy_service_|. + // TODO(bauerb): Once |prefs_| is a ProfileKeyedService, |policy_service_| + // should become one as well. + scoped_ptr<policy::PolicyService> policy_service_; + // Keep |prefs_| on top for destruction order because |extension_prefs_|, - // |net_pref_observer_|, |web_resource_service_|, and |io_data_| store + // |net_pref_observer_|, |promo_resource_service_|, |io_data_| an others store // pointers to |prefs_| and shall be destructed first. scoped_ptr<PrefService> prefs_; scoped_ptr<PrefService> otr_prefs_; |