Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Unified Diff: components/prefs/overlay_user_pref_store.cc

Issue 2692203007: Add PrefStore::GetValues (Closed)
Patch Set: Deal correctly with expanded keys Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/prefs/overlay_user_pref_store.cc
diff --git a/components/prefs/overlay_user_pref_store.cc b/components/prefs/overlay_user_pref_store.cc
index 2b2208ed8214408290c312125e5309689dfecaff..c545d0131375a5e9b5df1dd5981d6989b81c6ea3 100644
--- a/components/prefs/overlay_user_pref_store.cc
+++ b/components/prefs/overlay_user_pref_store.cc
@@ -47,6 +47,24 @@ bool OverlayUserPrefStore::GetValue(const std::string& key,
return underlay_->GetValue(GetUnderlayKey(key), result);
}
+std::unique_ptr<base::DictionaryValue> OverlayUserPrefStore::GetValues() const {
+ auto values = underlay_->GetValues();
+ auto overlay_values = overlay_.AsDictionaryValue();
+ for (const auto& overlay_mapping : overlay_to_underlay_names_map_) {
+ const std::string& overlay_key = overlay_mapping.first;
+ const std::string& underlay_key = overlay_mapping.first;
Sam McNally 2017/02/21 01:58:25 second
tibell 2017/02/21 02:11:07 Done.
+ std::unique_ptr<base::Value> out_value;
+ if (overlay_values->Remove(overlay_key, &out_value)) {
+ values->Set(overlay_key, std::move(out_value));
+ } else if (overlay_key != underlay_key) {
+ if (values->Remove(underlay_key, &out_value)) {
Sam McNally 2017/02/21 01:58:25 Merge this into the else if?
tibell 2017/02/21 02:11:07 Done. Reordered things to remove some if-statemen
+ values->Set(overlay_key, std::move(out_value));
+ }
+ }
+ }
+ return values;
+}
+
bool OverlayUserPrefStore::GetMutableValue(const std::string& key,
base::Value** result) {
if (!ShallBeStoredInOverlay(key))

Powered by Google App Engine
This is Rietveld 408576698