diff options
author | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-12 16:48:49 +0000 |
---|---|---|
committer | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-12 16:48:49 +0000 |
commit | db198b2722f4592f6b76294f6a7f9c868e05bc15 (patch) | |
tree | ce5c93732e2d202548b6e2d69ab6a80cc06ca7ea /chrome/browser/pref_service.h | |
parent | ef40c4da832d2082dffe1262b0e2dbf64b5e8031 (diff) | |
download | chromium_src-db198b2722f4592f6b76294f6a7f9c868e05bc15.zip chromium_src-db198b2722f4592f6b76294f6a7f9c868e05bc15.tar.gz chromium_src-db198b2722f4592f6b76294f6a7f9c868e05bc15.tar.bz2 |
Add an ExtensionPrefStore, layered between the user prefs and the managed prefs, to manage preferences set by extensions.
Update various callers of the PrefValueStore constructor accordingly.
The initial user will be the proxy extension API.
BUG=266
TEST=covered by unit tests
Review URL: http://codereview.chromium.org/2823037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52088 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/pref_service.h')
-rw-r--r-- | chrome/browser/pref_service.h | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/chrome/browser/pref_service.h b/chrome/browser/pref_service.h index 2cb2fa2f..483624b 100644 --- a/chrome/browser/pref_service.h +++ b/chrome/browser/pref_service.h @@ -69,11 +69,21 @@ class PrefService : public NonThreadSafe { DISALLOW_COPY_AND_ASSIGN(Preference); }; - // Factory method that creates a new instance of a |PrefService|. + // Factory method that creates a new instance of a |PrefService| with + // all platform-applicable PrefStores (managed, extension, user, etc.). + // This is the usual way to create a new PrefService. static PrefService* CreatePrefService(const FilePath& pref_filename); - // The |PrefValueStore| provides preference values. + // Convenience factory method for use in unit tests. Creates a new + // PrefService that uses a PrefValueStore with user preferences at the given + // |pref_filename|, and no other PrefStores (i.e., no other types of + // preferences). + static PrefService* CreateUserPrefService(const FilePath& pref_filename); + + // This constructor is primarily used by tests. The |PrefValueStore| provides + // preference values. explicit PrefService(PrefValueStore* pref_value_store); + ~PrefService(); // Reloads the data from file. This should only be called when the importer @@ -181,8 +191,18 @@ class PrefService : public NonThreadSafe { // preference is not registered. const Preference* FindPreference(const wchar_t* pref_name) const; + // For the given pref_name, fire any observer of the pref only if |old_value| + // is different from the current value. Virtual so it can be mocked for a + // unit test. + virtual void FireObserversIfChanged(const wchar_t* pref_name, + const Value* old_value); + bool read_only() const { return pref_value_store_->ReadOnly(); } + protected: + // This should only be accessed by subclasses for unit-testing. + bool PrefIsChanged(const wchar_t* path, const Value* old_value); + private: // Add a preference to the PreferenceMap. If the pref already exists, return // false. This method takes ownership of |pref|. @@ -195,11 +215,6 @@ class PrefService : public NonThreadSafe { // For the given pref_name, fire any observer of the pref. void FireObservers(const wchar_t* pref_name); - // For the given pref_name, fire any observer of the pref only if |old_value| - // is different from the current value. - void FireObserversIfChanged(const wchar_t* pref_name, - const Value* old_value); - // Load from disk. Returns a non-zero error code on failure. PrefStore::PrefReadError LoadPersistentPrefs(); |