| Index: components/prefs/pref_service.cc
|
| diff --git a/components/prefs/pref_service.cc b/components/prefs/pref_service.cc
|
| index 6858839110b158b139c7e68fed680e5f50ddeb75..4ebea533478d97c4b6fa87b0f41abfae99dd0f61 100644
|
| --- a/components/prefs/pref_service.cc
|
| +++ b/components/prefs/pref_service.cc
|
| @@ -193,37 +193,27 @@ bool PrefService::HasPrefPath(const std::string& path) const {
|
| return pref && !pref->IsDefaultValue();
|
| }
|
|
|
| -std::unique_ptr<base::DictionaryValue> PrefService::GetPreferenceValues()
|
| - const {
|
| - DCHECK(CalledOnValidThread());
|
| - std::unique_ptr<base::DictionaryValue> out(new base::DictionaryValue);
|
| - for (const auto& it : *pref_registry_) {
|
| - out->Set(it.first, GetPreferenceValue(it.first)->CreateDeepCopy());
|
| - }
|
| - return out;
|
| -}
|
| -
|
| -std::unique_ptr<base::DictionaryValue>
|
| -PrefService::GetPreferenceValuesOmitDefaults() const {
|
| +void PrefService::IteratePreferenceValues(
|
| + base::RepeatingCallback<void(const std::string& key,
|
| + const base::Value& value)> callback) const {
|
| DCHECK(CalledOnValidThread());
|
| - std::unique_ptr<base::DictionaryValue> out(new base::DictionaryValue);
|
| - for (const auto& it : *pref_registry_) {
|
| - const Preference* pref = FindPreference(it.first);
|
| - if (pref->IsDefaultValue())
|
| - continue;
|
| - out->Set(it.first, pref->GetValue()->CreateDeepCopy());
|
| - }
|
| - return out;
|
| + for (const auto& it : *pref_registry_)
|
| + callback.Run(it.first, *GetPreferenceValue(it.first));
|
| }
|
|
|
| -std::unique_ptr<base::DictionaryValue>
|
| -PrefService::GetPreferenceValuesWithoutPathExpansion() const {
|
| +std::unique_ptr<base::DictionaryValue> PrefService::GetPreferenceValues(
|
| + IncludeDefaults include_defaults) const {
|
| DCHECK(CalledOnValidThread());
|
| std::unique_ptr<base::DictionaryValue> out(new base::DictionaryValue);
|
| for (const auto& it : *pref_registry_) {
|
| - const base::Value* value = GetPreferenceValue(it.first);
|
| - DCHECK(value);
|
| - out->SetWithoutPathExpansion(it.first, value->CreateDeepCopy());
|
| + if (include_defaults == INCLUDE_DEFAULTS) {
|
| + out->Set(it.first, GetPreferenceValue(it.first)->CreateDeepCopy());
|
| + } else {
|
| + const Preference* pref = FindPreference(it.first);
|
| + if (pref->IsDefaultValue())
|
| + continue;
|
| + out->Set(it.first, pref->GetValue()->CreateDeepCopy());
|
| + }
|
| }
|
| return out;
|
| }
|
|
|