diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-21 13:54:08 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-21 13:54:08 +0000 |
commit | 74379bc51320fd98a47c98053a056b4ddd7271a7 (patch) | |
tree | 721fb4cbad36a304162745d8a0a5ee0930f054f0 /chrome/browser/pref_service.cc | |
parent | 7082b2329218da9a77fd6bc9587e86d0ed817196 (diff) | |
download | chromium_src-74379bc51320fd98a47c98053a056b4ddd7271a7.zip chromium_src-74379bc51320fd98a47c98053a056b4ddd7271a7.tar.gz chromium_src-74379bc51320fd98a47c98053a056b4ddd7271a7.tar.bz2 |
Adjust preference sync code to only sync user modifiable preferences.
Switch to the new preference value source checkers in Preference. While at it,
add a unit test and better test infrastructure for controlling preference
values in tests. Convert existing unit tests where appropriate.
BUG=48952
TEST=ProfileSyncServicePreferenceTest.ManagedPreferences
Review URL: http://codereview.chromium.org/3051001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53179 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/pref_service.cc')
-rw-r--r-- | chrome/browser/pref_service.cc | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/chrome/browser/pref_service.cc b/chrome/browser/pref_service.cc index 9db99bc..f441520 100644 --- a/chrome/browser/pref_service.cc +++ b/chrome/browser/pref_service.cc @@ -421,6 +421,25 @@ void PrefService::FireObserversIfChanged(const wchar_t* path, FireObservers(path); } +void PrefService::FireObservers(const wchar_t* path) { + DCHECK(CalledOnValidThread()); + + // Convert path to a std::wstring because the Details constructor requires a + // class. + std::wstring path_str(path); + PrefObserverMap::iterator observer_iterator = pref_observers_.find(path_str); + if (observer_iterator == pref_observers_.end()) + return; + + NotificationObserverList::Iterator it(*(observer_iterator->second)); + NotificationObserver* observer; + while ((observer = it.GetNext()) != NULL) { + observer->Observe(NotificationType::PREF_CHANGED, + Source<PrefService>(this), + Details<std::wstring>(&path_str)); + } +} + bool PrefService::PrefIsChanged(const wchar_t* path, const Value* old_value) { Value* new_value = NULL; @@ -791,25 +810,6 @@ Value* PrefService::GetPrefCopy(const wchar_t* path) { return pref->GetValue()->DeepCopy(); } -void PrefService::FireObservers(const wchar_t* path) { - DCHECK(CalledOnValidThread()); - - // Convert path to a std::wstring because the Details constructor requires a - // class. - std::wstring path_str(path); - PrefObserverMap::iterator observer_iterator = pref_observers_.find(path_str); - if (observer_iterator == pref_observers_.end()) - return; - - NotificationObserverList::Iterator it(*(observer_iterator->second)); - NotificationObserver* observer; - while ((observer = it.GetNext()) != NULL) { - observer->Observe(NotificationType::PREF_CHANGED, - Source<PrefService>(this), - Details<std::wstring>(&path_str)); - } -} - /////////////////////////////////////////////////////////////////////////////// // PrefService::Preference @@ -872,3 +872,7 @@ bool PrefService::Preference::IsExtensionControlled() const { bool PrefService::Preference::IsUserControlled() const { return pref_value_store_->PrefValueFromUserStore(name_.c_str()); } + +bool PrefService::Preference::IsUserModifiable() const { + return pref_value_store_->PrefValueUserModifiable(name_.c_str()); +} |