diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-09 15:10:17 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-09 15:10:17 +0000 |
commit | f2d1f61006eac0f8a051fa485b2cffb6b6fa74e0 (patch) | |
tree | f848fcb564eaff40eeebcf7044da9972f798bd2b /chrome/browser/prefs/pref_service_mock_builder.h | |
parent | ba99ca24c0ba8f0e154dbd74d8a43a55736630e1 (diff) | |
download | chromium_src-f2d1f61006eac0f8a051fa485b2cffb6b6fa74e0.zip chromium_src-f2d1f61006eac0f8a051fa485b2cffb6b6fa74e0.tar.gz chromium_src-f2d1f61006eac0f8a051fa485b2cffb6b6fa74e0.tar.bz2 |
Sanitize PrefStore interface.
This reworks the PrefStore interface, specifically:
- Split up the interface into PrefStore, which only provides reading functionality, and the derived PersistentPrefStore for the actual user pref store
- Remove the hurt-me-plenty prefs() function from PrefStore, instead provide Get/Set/Remove operations
- Remove special handling of default and user pref store from PrefValueStore and put it into PrefService
- Pref change notification handling now almost exclusively handled through PrefValueStore
- Adjust all consumers of these interfaces (but keep ConfigurationPolicyPrefStore untouched, that's up next on the list)
BUG=64232
TEST=existing unit tests
Review URL: http://codereview.chromium.org/5646003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/prefs/pref_service_mock_builder.h')
-rw-r--r-- | chrome/browser/prefs/pref_service_mock_builder.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/chrome/browser/prefs/pref_service_mock_builder.h b/chrome/browser/prefs/pref_service_mock_builder.h new file mode 100644 index 0000000..c17040e --- /dev/null +++ b/chrome/browser/prefs/pref_service_mock_builder.h @@ -0,0 +1,69 @@ +// Copyright (c) 2010 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_PREFS_PREF_SERVICE_MOCK_BUILDER_H_ +#define CHROME_BROWSER_PREFS_PREF_SERVICE_MOCK_BUILDER_H_ +#pragma once + +#include "base/basictypes.h" +#include "base/scoped_ptr.h" +#include "chrome/common/persistent_pref_store.h" +#include "chrome/common/pref_store.h" + +class CommandLine; +class FilePath; +class PrefService; +class Profile; + +namespace policy { +class ConfigurationPolicyProvider; +} + +// A helper that allows convenient building of custom PrefServices in tests. +class PrefServiceMockBuilder { + public: + PrefServiceMockBuilder(); + + // Functions for setting the various parameters of the PrefService to build. + // These take ownership of the |store| parameter. + PrefServiceMockBuilder& WithManagedPlatformPrefs(PrefStore* store); + PrefServiceMockBuilder& WithDeviceManagementPrefs(PrefStore* store); + PrefServiceMockBuilder& WithExtensionPrefs(PrefStore* store); + PrefServiceMockBuilder& WithCommandLinePrefs(PrefStore* store); + PrefServiceMockBuilder& WithUserPrefs(PersistentPrefStore* store); + PrefServiceMockBuilder& WithRecommendedPrefs(PrefStore* store); + + // Set up policy pref stores using the given policy provider. + PrefServiceMockBuilder& WithManagedPlatformProvider( + policy::ConfigurationPolicyProvider* provider); + PrefServiceMockBuilder& WithDeviceManagementProvider( + policy::ConfigurationPolicyProvider* provider); + PrefServiceMockBuilder& WithRecommendedProvider( + policy::ConfigurationPolicyProvider* provider); + + // Specifies to use an actual command-line backed command-line pref store. + PrefServiceMockBuilder& WithCommandLine(CommandLine* command_line); + + // Specifies to use an actual file-backed user pref store. + PrefServiceMockBuilder& WithUserFilePrefs(const FilePath& prefs_file); + + // Sets the profile to pass to the PrefService. + PrefServiceMockBuilder& WithRecommendedPrefs(Profile* profile); + + // Creates the PrefService, invalidating the entire builder configuration. + PrefService* Create(); + + private: + scoped_ptr<PrefStore> managed_platform_prefs_; + scoped_ptr<PrefStore> device_management_prefs_; + scoped_ptr<PrefStore> extension_prefs_; + scoped_ptr<PrefStore> command_line_prefs_; + scoped_ptr<PersistentPrefStore> user_prefs_; + scoped_ptr<PrefStore> recommended_prefs_; + Profile* profile_; + + DISALLOW_COPY_AND_ASSIGN(PrefServiceMockBuilder); +}; + +#endif // CHROME_BROWSER_PREFS_PREF_SERVICE_MOCK_BUILDER_H_ |