summaryrefslogtreecommitdiff
path: root/chromium/components/prefs
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-04-05 17:15:33 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-04-11 07:47:18 +0000
commit7324afb043a0b1e623d8e8eb906cdc53bdeb4685 (patch)
treea3fe2d74ea9c9e142c390dac4ca0e219382ace46 /chromium/components/prefs
parent6a4cabb866f66d4128a97cdc6d9d08ce074f1247 (diff)
downloadqtwebengine-chromium-7324afb043a0b1e623d8e8eb906cdc53bdeb4685.tar.gz
BASELINE: Update Chromium to 58.0.3029.54
Change-Id: I67f57065a7afdc8e4614adb5c0230281428df4d1 Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'chromium/components/prefs')
-rw-r--r--chromium/components/prefs/command_line_pref_store.cc5
-rw-r--r--chromium/components/prefs/default_pref_store.cc4
-rw-r--r--chromium/components/prefs/default_pref_store.h2
-rw-r--r--chromium/components/prefs/in_memory_pref_store.cc4
-rw-r--r--chromium/components/prefs/in_memory_pref_store.h1
-rw-r--r--chromium/components/prefs/in_memory_pref_store_unittest.cc13
-rw-r--r--chromium/components/prefs/json_pref_store.cc4
-rw-r--r--chromium/components/prefs/json_pref_store.h1
-rw-r--r--chromium/components/prefs/json_pref_store_unittest.cc5
-rw-r--r--chromium/components/prefs/overlay_user_pref_store.cc18
-rw-r--r--chromium/components/prefs/overlay_user_pref_store.h1
-rw-r--r--chromium/components/prefs/overlay_user_pref_store_unittest.cc127
-rw-r--r--chromium/components/prefs/pref_change_registrar_unittest.cc6
-rw-r--r--chromium/components/prefs/pref_registry_simple.cc12
-rw-r--r--chromium/components/prefs/pref_service.cc6
-rw-r--r--chromium/components/prefs/pref_service_unittest.cc5
-rw-r--r--chromium/components/prefs/pref_store.h5
-rw-r--r--chromium/components/prefs/pref_value_map.cc14
-rw-r--r--chromium/components/prefs/pref_value_map.h4
-rw-r--r--chromium/components/prefs/pref_value_map_unittest.cc4
-rw-r--r--chromium/components/prefs/pref_value_store_unittest.cc4
-rw-r--r--chromium/components/prefs/testing_pref_store.cc10
-rw-r--r--chromium/components/prefs/testing_pref_store.h1
-rw-r--r--chromium/components/prefs/value_map_pref_store.cc4
-rw-r--r--chromium/components/prefs/value_map_pref_store.h1
25 files changed, 173 insertions, 88 deletions
diff --git a/chromium/components/prefs/command_line_pref_store.cc b/chromium/components/prefs/command_line_pref_store.cc
index f8a503e5441..49278c19f2a 100644
--- a/chromium/components/prefs/command_line_pref_store.cc
+++ b/chromium/components/prefs/command_line_pref_store.cc
@@ -60,7 +60,7 @@ void CommandLinePrefStore::ApplyIntegerSwitches(
continue;
}
SetValue(integer_switch[i].preference_path,
- base::MakeUnique<base::FundamentalValue>(int_value),
+ base::MakeUnique<base::Value>(int_value),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
}
}
@@ -72,8 +72,7 @@ void CommandLinePrefStore::ApplyBooleanSwitches(
for (size_t i = 0; i < size; ++i) {
if (command_line_->HasSwitch(boolean_switch_map[i].switch_name)) {
SetValue(boolean_switch_map[i].preference_path,
- base::MakeUnique<base::FundamentalValue>(
- boolean_switch_map[i].set_value),
+ base::MakeUnique<base::Value>(boolean_switch_map[i].set_value),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
}
}
diff --git a/chromium/components/prefs/default_pref_store.cc b/chromium/components/prefs/default_pref_store.cc
index 468c11c7483..0e9c87c0838 100644
--- a/chromium/components/prefs/default_pref_store.cc
+++ b/chromium/components/prefs/default_pref_store.cc
@@ -17,6 +17,10 @@ bool DefaultPrefStore::GetValue(const std::string& key,
return prefs_.GetValue(key, result);
}
+std::unique_ptr<base::DictionaryValue> DefaultPrefStore::GetValues() const {
+ return prefs_.AsDictionaryValue();
+}
+
void DefaultPrefStore::AddObserver(PrefStore::Observer* observer) {
observers_.AddObserver(observer);
}
diff --git a/chromium/components/prefs/default_pref_store.h b/chromium/components/prefs/default_pref_store.h
index 3481713f893..c06cd6c10de 100644
--- a/chromium/components/prefs/default_pref_store.h
+++ b/chromium/components/prefs/default_pref_store.h
@@ -5,6 +5,7 @@
#ifndef COMPONENTS_PREFS_DEFAULT_PREF_STORE_H_
#define COMPONENTS_PREFS_DEFAULT_PREF_STORE_H_
+#include <memory>
#include <string>
#include "base/macros.h"
@@ -24,6 +25,7 @@ class COMPONENTS_PREFS_EXPORT DefaultPrefStore : public PrefStore {
// PrefStore implementation:
bool GetValue(const std::string& key,
const base::Value** result) const override;
+ std::unique_ptr<base::DictionaryValue> GetValues() const override;
void AddObserver(PrefStore::Observer* observer) override;
void RemoveObserver(PrefStore::Observer* observer) override;
bool HasObservers() const override;
diff --git a/chromium/components/prefs/in_memory_pref_store.cc b/chromium/components/prefs/in_memory_pref_store.cc
index d0d35582523..a0a9c35d47b 100644
--- a/chromium/components/prefs/in_memory_pref_store.cc
+++ b/chromium/components/prefs/in_memory_pref_store.cc
@@ -18,6 +18,10 @@ bool InMemoryPrefStore::GetValue(const std::string& key,
return prefs_.GetValue(key, value);
}
+std::unique_ptr<base::DictionaryValue> InMemoryPrefStore::GetValues() const {
+ return prefs_.AsDictionaryValue();
+}
+
bool InMemoryPrefStore::GetMutableValue(const std::string& key,
base::Value** value) {
return prefs_.GetValue(key, value);
diff --git a/chromium/components/prefs/in_memory_pref_store.h b/chromium/components/prefs/in_memory_pref_store.h
index 042137c3ce1..5529622fdd0 100644
--- a/chromium/components/prefs/in_memory_pref_store.h
+++ b/chromium/components/prefs/in_memory_pref_store.h
@@ -26,6 +26,7 @@ class COMPONENTS_PREFS_EXPORT InMemoryPrefStore : public PersistentPrefStore {
// PrefStore implementation.
bool GetValue(const std::string& key,
const base::Value** result) const override;
+ std::unique_ptr<base::DictionaryValue> GetValues() const override;
void AddObserver(PrefStore::Observer* observer) override;
void RemoveObserver(PrefStore::Observer* observer) override;
bool HasObservers() const override;
diff --git a/chromium/components/prefs/in_memory_pref_store_unittest.cc b/chromium/components/prefs/in_memory_pref_store_unittest.cc
index a31757d796a..822aa8f0f0c 100644
--- a/chromium/components/prefs/in_memory_pref_store_unittest.cc
+++ b/chromium/components/prefs/in_memory_pref_store_unittest.cc
@@ -28,12 +28,12 @@ TEST_F(InMemoryPrefStoreTest, SetGetValue) {
EXPECT_FALSE(store_->GetValue(kTestPref, &value));
EXPECT_FALSE(store_->GetMutableValue(kTestPref, &mutable_value));
- store_->SetValue(kTestPref, base::MakeUnique<base::FundamentalValue>(42),
+ store_->SetValue(kTestPref, base::MakeUnique<base::Value>(42),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_TRUE(store_->GetValue(kTestPref, &value));
- EXPECT_TRUE(base::FundamentalValue(42).Equals(value));
+ EXPECT_TRUE(base::Value(42).Equals(value));
EXPECT_TRUE(store_->GetMutableValue(kTestPref, &mutable_value));
- EXPECT_TRUE(base::FundamentalValue(42).Equals(mutable_value));
+ EXPECT_TRUE(base::Value(42).Equals(mutable_value));
store_->RemoveValue(kTestPref, WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_FALSE(store_->GetValue(kTestPref, &value));
@@ -58,7 +58,7 @@ TEST_F(InMemoryPrefStoreTest, CallObserver) {
store_->AddObserver(&observer_);
// Triggers on SetValue.
- store_->SetValue(kTestPref, base::MakeUnique<base::FundamentalValue>(42),
+ store_->SetValue(kTestPref, base::MakeUnique<base::Value>(42),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
observer_.VerifyAndResetChangedKey(kTestPref);
@@ -67,8 +67,7 @@ TEST_F(InMemoryPrefStoreTest, CallObserver) {
observer_.VerifyAndResetChangedKey(kTestPref);
// But not SetValueSilently.
- store_->SetValueSilently(kTestPref,
- base::MakeUnique<base::FundamentalValue>(42),
+ store_->SetValueSilently(kTestPref, base::MakeUnique<base::Value>(42),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_EQ(0u, observer_.changed_keys.size());
@@ -80,7 +79,7 @@ TEST_F(InMemoryPrefStoreTest, CallObserver) {
// Doesn't make call on removed observers.
store_->RemoveObserver(&observer_);
- store_->SetValue(kTestPref, base::MakeUnique<base::FundamentalValue>(42),
+ store_->SetValue(kTestPref, base::MakeUnique<base::Value>(42),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
store_->RemoveValue(kTestPref, WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_EQ(0u, observer_.changed_keys.size());
diff --git a/chromium/components/prefs/json_pref_store.cc b/chromium/components/prefs/json_pref_store.cc
index 026606a7b76..a9a39227d3f 100644
--- a/chromium/components/prefs/json_pref_store.cc
+++ b/chromium/components/prefs/json_pref_store.cc
@@ -190,6 +190,10 @@ bool JsonPrefStore::GetValue(const std::string& key,
return true;
}
+std::unique_ptr<base::DictionaryValue> JsonPrefStore::GetValues() const {
+ return prefs_->CreateDeepCopy();
+}
+
void JsonPrefStore::AddObserver(PrefStore::Observer* observer) {
DCHECK(CalledOnValidThread());
diff --git a/chromium/components/prefs/json_pref_store.h b/chromium/components/prefs/json_pref_store.h
index 170ccb1161d..8c1164ca8ba 100644
--- a/chromium/components/prefs/json_pref_store.h
+++ b/chromium/components/prefs/json_pref_store.h
@@ -84,6 +84,7 @@ class COMPONENTS_PREFS_EXPORT JsonPrefStore
// PrefStore overrides:
bool GetValue(const std::string& key,
const base::Value** result) const override;
+ std::unique_ptr<base::DictionaryValue> GetValues() const override;
void AddObserver(PrefStore::Observer* observer) override;
void RemoveObserver(PrefStore::Observer* observer) override;
bool HasObservers() const override;
diff --git a/chromium/components/prefs/json_pref_store_unittest.cc b/chromium/components/prefs/json_pref_store_unittest.cc
index 99f12a73ac6..f404d2a0398 100644
--- a/chromium/components/prefs/json_pref_store_unittest.cc
+++ b/chromium/components/prefs/json_pref_store_unittest.cc
@@ -241,8 +241,7 @@ void RunBasicJsonPrefStoreTest(JsonPrefStore* pref_store,
EXPECT_TRUE(actual->GetAsBoolean(&boolean));
EXPECT_TRUE(boolean);
- pref_store->SetValue(kNewWindowsInTabs,
- base::MakeUnique<FundamentalValue>(false),
+ pref_store->SetValue(kNewWindowsInTabs, base::MakeUnique<Value>(false),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_TRUE(pref_store->GetValue(kNewWindowsInTabs, &actual));
EXPECT_TRUE(actual->GetAsBoolean(&boolean));
@@ -252,7 +251,7 @@ void RunBasicJsonPrefStoreTest(JsonPrefStore* pref_store,
int integer = 0;
EXPECT_TRUE(actual->GetAsInteger(&integer));
EXPECT_EQ(20, integer);
- pref_store->SetValue(kMaxTabs, base::MakeUnique<FundamentalValue>(10),
+ pref_store->SetValue(kMaxTabs, base::MakeUnique<Value>(10),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_TRUE(pref_store->GetValue(kMaxTabs, &actual));
EXPECT_TRUE(actual->GetAsInteger(&integer));
diff --git a/chromium/components/prefs/overlay_user_pref_store.cc b/chromium/components/prefs/overlay_user_pref_store.cc
index 2b2208ed821..ddc47c8f351 100644
--- a/chromium/components/prefs/overlay_user_pref_store.cc
+++ b/chromium/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.second;
+ std::unique_ptr<base::Value> out_value;
+ if (overlay_key != underlay_key) {
+ values->Remove(underlay_key, &out_value);
+ }
+ overlay_values->Remove(overlay_key, &out_value);
+ if (out_value) {
+ values->Set(overlay_key, std::move(out_value));
+ }
+ }
+ return values;
+}
+
bool OverlayUserPrefStore::GetMutableValue(const std::string& key,
base::Value** result) {
if (!ShallBeStoredInOverlay(key))
diff --git a/chromium/components/prefs/overlay_user_pref_store.h b/chromium/components/prefs/overlay_user_pref_store.h
index e3ad88e1668..7d9eb3071a5 100644
--- a/chromium/components/prefs/overlay_user_pref_store.h
+++ b/chromium/components/prefs/overlay_user_pref_store.h
@@ -38,6 +38,7 @@ class COMPONENTS_PREFS_EXPORT OverlayUserPrefStore : public PersistentPrefStore,
bool IsInitializationComplete() const override;
bool GetValue(const std::string& key,
const base::Value** result) const override;
+ std::unique_ptr<base::DictionaryValue> GetValues() const override;
// Methods of PersistentPrefStore.
bool GetMutableValue(const std::string& key, base::Value** result) override;
diff --git a/chromium/components/prefs/overlay_user_pref_store_unittest.cc b/chromium/components/prefs/overlay_user_pref_store_unittest.cc
index d722aeab6e0..5dded13ca04 100644
--- a/chromium/components/prefs/overlay_user_pref_store_unittest.cc
+++ b/chromium/components/prefs/overlay_user_pref_store_unittest.cc
@@ -19,9 +19,11 @@ namespace {
const char kBrowserWindowPlacement[] = "browser.window_placement";
const char kShowBookmarkBar[] = "bookmark_bar.show_on_all_tabs";
+const char kSharedKey[] = "sync_promo.show_on_first_run_allowed";
const char* const overlay_key = kBrowserWindowPlacement;
const char* const regular_key = kShowBookmarkBar;
+const char* const shared_key = kSharedKey;
// With the removal of the kWebKitGlobalXXX prefs, we'll no longer have real
// prefs using the overlay pref store, so make up keys here.
const char mapped_overlay_key[] = "test.per_tab.javascript_enabled";
@@ -35,6 +37,7 @@ class OverlayUserPrefStoreTest : public testing::Test {
: underlay_(new TestingPrefStore()),
overlay_(new OverlayUserPrefStore(underlay_.get())) {
overlay_->RegisterOverlayPref(overlay_key);
+ overlay_->RegisterOverlayPref(shared_key);
overlay_->RegisterOverlayPref(mapped_overlay_key, mapped_underlay_key);
}
@@ -49,22 +52,22 @@ TEST_F(OverlayUserPrefStoreTest, Observer) {
overlay_->AddObserver(&obs);
// Check that underlay first value is reported.
- underlay_->SetValue(overlay_key, base::MakeUnique<FundamentalValue>(42),
+ underlay_->SetValue(overlay_key, base::MakeUnique<Value>(42),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
obs.VerifyAndResetChangedKey(overlay_key);
// Check that underlay overwriting is reported.
- underlay_->SetValue(overlay_key, base::MakeUnique<FundamentalValue>(43),
+ underlay_->SetValue(overlay_key, base::MakeUnique<Value>(43),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
obs.VerifyAndResetChangedKey(overlay_key);
// Check that overwriting change in overlay is reported.
- overlay_->SetValue(overlay_key, base::MakeUnique<FundamentalValue>(44),
+ overlay_->SetValue(overlay_key, base::MakeUnique<Value>(44),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
obs.VerifyAndResetChangedKey(overlay_key);
// Check that hidden underlay change is not reported.
- underlay_->SetValue(overlay_key, base::MakeUnique<FundamentalValue>(45),
+ underlay_->SetValue(overlay_key, base::MakeUnique<Value>(45),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_TRUE(obs.changed_keys.empty());
@@ -79,17 +82,16 @@ TEST_F(OverlayUserPrefStoreTest, Observer) {
obs.VerifyAndResetChangedKey(overlay_key);
// Check respecting of silence.
- overlay_->SetValueSilently(overlay_key,
- base::MakeUnique<FundamentalValue>(46),
+ overlay_->SetValueSilently(overlay_key, base::MakeUnique<Value>(46),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_TRUE(obs.changed_keys.empty());
overlay_->RemoveObserver(&obs);
// Check successful unsubscription.
- underlay_->SetValue(overlay_key, base::MakeUnique<FundamentalValue>(47),
+ underlay_->SetValue(overlay_key, base::MakeUnique<Value>(47),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
- overlay_->SetValue(overlay_key, base::MakeUnique<FundamentalValue>(48),
+ overlay_->SetValue(overlay_key, base::MakeUnique<Value>(48),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_TRUE(obs.changed_keys.empty());
}
@@ -99,34 +101,34 @@ TEST_F(OverlayUserPrefStoreTest, GetAndSet) {
EXPECT_FALSE(overlay_->GetValue(overlay_key, &value));
EXPECT_FALSE(underlay_->GetValue(overlay_key, &value));
- underlay_->SetValue(overlay_key, base::MakeUnique<FundamentalValue>(42),
+ underlay_->SetValue(overlay_key, base::MakeUnique<Value>(42),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
// Value shines through:
EXPECT_TRUE(overlay_->GetValue(overlay_key, &value));
- EXPECT_TRUE(base::FundamentalValue(42).Equals(value));
+ EXPECT_TRUE(base::Value(42).Equals(value));
EXPECT_TRUE(underlay_->GetValue(overlay_key, &value));
- EXPECT_TRUE(base::FundamentalValue(42).Equals(value));
+ EXPECT_TRUE(base::Value(42).Equals(value));
- overlay_->SetValue(overlay_key, base::MakeUnique<FundamentalValue>(43),
+ overlay_->SetValue(overlay_key, base::MakeUnique<Value>(43),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_TRUE(overlay_->GetValue(overlay_key, &value));
- EXPECT_TRUE(base::FundamentalValue(43).Equals(value));
+ EXPECT_TRUE(base::Value(43).Equals(value));
EXPECT_TRUE(underlay_->GetValue(overlay_key, &value));
- EXPECT_TRUE(base::FundamentalValue(42).Equals(value));
+ EXPECT_TRUE(base::Value(42).Equals(value));
overlay_->RemoveValue(overlay_key,
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
// Value shines through:
EXPECT_TRUE(overlay_->GetValue(overlay_key, &value));
- EXPECT_TRUE(base::FundamentalValue(42).Equals(value));
+ EXPECT_TRUE(base::Value(42).Equals(value));
EXPECT_TRUE(underlay_->GetValue(overlay_key, &value));
- EXPECT_TRUE(base::FundamentalValue(42).Equals(value));
+ EXPECT_TRUE(base::Value(42).Equals(value));
}
// Check that GetMutableValue does not return the dictionary of the underlay.
@@ -161,29 +163,29 @@ TEST_F(OverlayUserPrefStoreTest, GlobalPref) {
const Value* value = NULL;
// Check that underlay first value is reported.
- underlay_->SetValue(regular_key, base::WrapUnique(new FundamentalValue(42)),
+ underlay_->SetValue(regular_key, base::WrapUnique(new Value(42)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
obs.VerifyAndResetChangedKey(regular_key);
// Check that underlay overwriting is reported.
- underlay_->SetValue(regular_key, base::WrapUnique(new FundamentalValue(43)),
+ underlay_->SetValue(regular_key, base::WrapUnique(new Value(43)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
obs.VerifyAndResetChangedKey(regular_key);
// Check that we get this value from the overlay
EXPECT_TRUE(overlay_->GetValue(regular_key, &value));
- EXPECT_TRUE(base::FundamentalValue(43).Equals(value));
+ EXPECT_TRUE(base::Value(43).Equals(value));
// Check that overwriting change in overlay is reported.
- overlay_->SetValue(regular_key, base::WrapUnique(new FundamentalValue(44)),
+ overlay_->SetValue(regular_key, base::WrapUnique(new Value(44)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
obs.VerifyAndResetChangedKey(regular_key);
// Check that we get this value from the overlay and the underlay.
EXPECT_TRUE(overlay_->GetValue(regular_key, &value));
- EXPECT_TRUE(base::FundamentalValue(44).Equals(value));
+ EXPECT_TRUE(base::Value(44).Equals(value));
EXPECT_TRUE(underlay_->GetValue(regular_key, &value));
- EXPECT_TRUE(base::FundamentalValue(44).Equals(value));
+ EXPECT_TRUE(base::Value(44).Equals(value));
// Check that overlay remove is reported.
overlay_->RemoveValue(regular_key,
@@ -195,17 +197,16 @@ TEST_F(OverlayUserPrefStoreTest, GlobalPref) {
EXPECT_FALSE(underlay_->GetValue(regular_key, &value));
// Check respecting of silence.
- overlay_->SetValueSilently(regular_key,
- base::WrapUnique(new FundamentalValue(46)),
+ overlay_->SetValueSilently(regular_key, base::WrapUnique(new Value(46)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_TRUE(obs.changed_keys.empty());
overlay_->RemoveObserver(&obs);
// Check successful unsubscription.
- underlay_->SetValue(regular_key, base::WrapUnique(new FundamentalValue(47)),
+ underlay_->SetValue(regular_key, base::WrapUnique(new Value(47)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
- overlay_->SetValue(regular_key, base::WrapUnique(new FundamentalValue(48)),
+ overlay_->SetValue(regular_key, base::WrapUnique(new Value(48)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_TRUE(obs.changed_keys.empty());
}
@@ -219,42 +220,38 @@ TEST_F(OverlayUserPrefStoreTest, NamesMapping) {
// Check that if there is no override in the overlay, changing underlay value
// is reported as changing an overlay value.
- underlay_->SetValue(mapped_underlay_key,
- base::WrapUnique(new FundamentalValue(42)),
+ underlay_->SetValue(mapped_underlay_key, base::WrapUnique(new Value(42)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
obs.VerifyAndResetChangedKey(mapped_overlay_key);
// Check that underlay overwriting is reported.
- underlay_->SetValue(mapped_underlay_key,
- base::WrapUnique(new FundamentalValue(43)),
+ underlay_->SetValue(mapped_underlay_key, base::WrapUnique(new Value(43)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
obs.VerifyAndResetChangedKey(mapped_overlay_key);
// Check that we get this value from the overlay with both keys
EXPECT_TRUE(overlay_->GetValue(mapped_overlay_key, &value));
- EXPECT_TRUE(base::FundamentalValue(43).Equals(value));
+ EXPECT_TRUE(base::Value(43).Equals(value));
// In this case, overlay reads directly from the underlay.
EXPECT_TRUE(overlay_->GetValue(mapped_underlay_key, &value));
- EXPECT_TRUE(base::FundamentalValue(43).Equals(value));
+ EXPECT_TRUE(base::Value(43).Equals(value));
// Check that overwriting change in overlay is reported.
- overlay_->SetValue(mapped_overlay_key,
- base::WrapUnique(new FundamentalValue(44)),
+ overlay_->SetValue(mapped_overlay_key, base::WrapUnique(new Value(44)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
obs.VerifyAndResetChangedKey(mapped_overlay_key);
// Check that we get an overriden value from overlay, while reading the
// value from underlay still holds an old value.
EXPECT_TRUE(overlay_->GetValue(mapped_overlay_key, &value));
- EXPECT_TRUE(base::FundamentalValue(44).Equals(value));
+ EXPECT_TRUE(base::Value(44).Equals(value));
EXPECT_TRUE(overlay_->GetValue(mapped_underlay_key, &value));
- EXPECT_TRUE(base::FundamentalValue(43).Equals(value));
+ EXPECT_TRUE(base::Value(43).Equals(value));
EXPECT_TRUE(underlay_->GetValue(mapped_underlay_key, &value));
- EXPECT_TRUE(base::FundamentalValue(43).Equals(value));
+ EXPECT_TRUE(base::Value(43).Equals(value));
// Check that hidden underlay change is not reported.
- underlay_->SetValue(mapped_underlay_key,
- base::WrapUnique(new FundamentalValue(45)),
+ underlay_->SetValue(mapped_underlay_key, base::WrapUnique(new Value(45)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_TRUE(obs.changed_keys.empty());
@@ -274,18 +271,16 @@ TEST_F(OverlayUserPrefStoreTest, NamesMapping) {
// Check respecting of silence.
overlay_->SetValueSilently(mapped_overlay_key,
- base::WrapUnique(new FundamentalValue(46)),
+ base::WrapUnique(new Value(46)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_TRUE(obs.changed_keys.empty());
overlay_->RemoveObserver(&obs);
// Check successful unsubscription.
- underlay_->SetValue(mapped_underlay_key,
- base::WrapUnique(new FundamentalValue(47)),
+ underlay_->SetValue(mapped_underlay_key, base::WrapUnique(new Value(47)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
- overlay_->SetValue(mapped_overlay_key,
- base::WrapUnique(new FundamentalValue(48)),
+ overlay_->SetValue(mapped_overlay_key, base::WrapUnique(new Value(48)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
EXPECT_TRUE(obs.changed_keys.empty());
}
@@ -293,20 +288,56 @@ TEST_F(OverlayUserPrefStoreTest, NamesMapping) {
// Check that mutable values are removed correctly.
TEST_F(OverlayUserPrefStoreTest, ClearMutableValues) {
// Set in overlay and underlay the same preference.
- underlay_->SetValue(overlay_key, base::WrapUnique(new FundamentalValue(42)),
+ underlay_->SetValue(overlay_key, base::WrapUnique(new Value(42)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
- overlay_->SetValue(overlay_key, base::WrapUnique(new FundamentalValue(43)),
+ overlay_->SetValue(overlay_key, base::WrapUnique(new Value(43)),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
const Value* value = nullptr;
// Check that an overlay preference is returned.
EXPECT_TRUE(overlay_->GetValue(overlay_key, &value));
- EXPECT_TRUE(base::FundamentalValue(43).Equals(value));
+ EXPECT_TRUE(base::Value(43).Equals(value));
overlay_->ClearMutableValues();
// Check that an underlay preference is returned.
EXPECT_TRUE(overlay_->GetValue(overlay_key, &value));
- EXPECT_TRUE(base::FundamentalValue(42).Equals(value));
+ EXPECT_TRUE(base::Value(42).Equals(value));
+}
+
+TEST_F(OverlayUserPrefStoreTest, GetValues) {
+ // To check merge behavior, create underlay and overlay so each has a key the
+ // other doesn't have and they have one key in common.
+ underlay_->SetValue(regular_key, base::WrapUnique(new Value(42)),
+ WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
+ overlay_->SetValue(overlay_key, base::WrapUnique(new Value(43)),
+ WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
+ underlay_->SetValue(shared_key, base::WrapUnique(new Value(42)),
+ WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
+ overlay_->SetValue(shared_key, base::WrapUnique(new Value(43)),
+ WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
+ underlay_->SetValue(mapped_underlay_key, base::WrapUnique(new Value(42)),
+ WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
+ overlay_->SetValue(mapped_overlay_key, base::WrapUnique(new Value(43)),
+ WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
+
+ auto values = overlay_->GetValues();
+ const Value* value = nullptr;
+ // Check that an overlay preference is returned.
+ ASSERT_TRUE(values->Get(overlay_key, &value));
+ EXPECT_TRUE(base::Value(43).Equals(value));
+
+ // Check that an underlay preference is returned.
+ ASSERT_TRUE(values->Get(regular_key, &value));
+ EXPECT_TRUE(base::Value(42).Equals(value));
+
+ // Check that the overlay is preferred.
+ ASSERT_TRUE(values->Get(shared_key, &value));
+ EXPECT_TRUE(base::Value(43).Equals(value));
+
+ // Check that mapping works.
+ ASSERT_TRUE(values->Get(mapped_overlay_key, &value));
+ EXPECT_TRUE(base::Value(43).Equals(value));
+ EXPECT_FALSE(values->Get(mapped_underlay_key, &value));
}
} // namespace base
diff --git a/chromium/components/prefs/pref_change_registrar_unittest.cc b/chromium/components/prefs/pref_change_registrar_unittest.cc
index 2b4e59f2ea1..68b62cd2fed 100644
--- a/chromium/components/prefs/pref_change_registrar_unittest.cc
+++ b/chromium/components/prefs/pref_change_registrar_unittest.cc
@@ -160,8 +160,7 @@ TEST_F(ObserveSetOfPreferencesTest, IsManaged) {
pref_service_->SetManagedPref(kHomePage,
new StringValue("http://crbug.com"));
EXPECT_TRUE(pref_set->IsManaged());
- pref_service_->SetManagedPref(kHomePageIsNewTabPage,
- new FundamentalValue(true));
+ pref_service_->SetManagedPref(kHomePageIsNewTabPage, new Value(true));
EXPECT_TRUE(pref_set->IsManaged());
pref_service_->RemoveManagedPref(kHomePage);
EXPECT_TRUE(pref_set->IsManaged());
@@ -186,8 +185,7 @@ TEST_F(ObserveSetOfPreferencesTest, Observe) {
Mock::VerifyAndClearExpectations(this);
EXPECT_CALL(*this, OnPreferenceChanged(kHomePageIsNewTabPage));
- pref_service_->SetUserPref(kHomePageIsNewTabPage,
- new FundamentalValue(true));
+ pref_service_->SetUserPref(kHomePageIsNewTabPage, new Value(true));
Mock::VerifyAndClearExpectations(this);
EXPECT_CALL(*this, OnPreferenceChanged(_)).Times(0);
diff --git a/chromium/components/prefs/pref_registry_simple.cc b/chromium/components/prefs/pref_registry_simple.cc
index 4874261babc..ef15ce01d24 100644
--- a/chromium/components/prefs/pref_registry_simple.cc
+++ b/chromium/components/prefs/pref_registry_simple.cc
@@ -16,19 +16,19 @@ PrefRegistrySimple::~PrefRegistrySimple() {
void PrefRegistrySimple::RegisterBooleanPref(const std::string& path,
bool default_value) {
- RegisterPrefAndNotify(path, new base::FundamentalValue(default_value),
+ RegisterPrefAndNotify(path, new base::Value(default_value),
NO_REGISTRATION_FLAGS);
}
void PrefRegistrySimple::RegisterIntegerPref(const std::string& path,
int default_value) {
- RegisterPrefAndNotify(path, new base::FundamentalValue(default_value),
+ RegisterPrefAndNotify(path, new base::Value(default_value),
NO_REGISTRATION_FLAGS);
}
void PrefRegistrySimple::RegisterDoublePref(const std::string& path,
double default_value) {
- RegisterPrefAndNotify(path, new base::FundamentalValue(default_value),
+ RegisterPrefAndNotify(path, new base::Value(default_value),
NO_REGISTRATION_FLAGS);
}
@@ -82,19 +82,19 @@ void PrefRegistrySimple::RegisterUint64Pref(const std::string& path,
void PrefRegistrySimple::RegisterBooleanPref(const std::string& path,
bool default_value,
uint32_t flags) {
- RegisterPrefAndNotify(path, new base::FundamentalValue(default_value), flags);
+ RegisterPrefAndNotify(path, new base::Value(default_value), flags);
}
void PrefRegistrySimple::RegisterIntegerPref(const std::string& path,
int default_value,
uint32_t flags) {
- RegisterPrefAndNotify(path, new base::FundamentalValue(default_value), flags);
+ RegisterPrefAndNotify(path, new base::Value(default_value), flags);
}
void PrefRegistrySimple::RegisterDoublePref(const std::string& path,
double default_value,
uint32_t flags) {
- RegisterPrefAndNotify(path, new base::FundamentalValue(default_value), flags);
+ RegisterPrefAndNotify(path, new base::Value(default_value), flags);
}
void PrefRegistrySimple::RegisterStringPref(const std::string& path,
diff --git a/chromium/components/prefs/pref_service.cc b/chromium/components/prefs/pref_service.cc
index d0274b17c8c..b42529b19ce 100644
--- a/chromium/components/prefs/pref_service.cc
+++ b/chromium/components/prefs/pref_service.cc
@@ -389,15 +389,15 @@ void PrefService::Set(const std::string& path, const base::Value& value) {
}
void PrefService::SetBoolean(const std::string& path, bool value) {
- SetUserPrefValue(path, new base::FundamentalValue(value));
+ SetUserPrefValue(path, new base::Value(value));
}
void PrefService::SetInteger(const std::string& path, int value) {
- SetUserPrefValue(path, new base::FundamentalValue(value));
+ SetUserPrefValue(path, new base::Value(value));
}
void PrefService::SetDouble(const std::string& path, double value) {
- SetUserPrefValue(path, new base::FundamentalValue(value));
+ SetUserPrefValue(path, new base::Value(value));
}
void PrefService::SetString(const std::string& path, const std::string& value) {
diff --git a/chromium/components/prefs/pref_service_unittest.cc b/chromium/components/prefs/pref_service_unittest.cc
index 5229b97ee8f..8c97e5e7a6d 100644
--- a/chromium/components/prefs/pref_service_unittest.cc
+++ b/chromium/components/prefs/pref_service_unittest.cc
@@ -178,7 +178,7 @@ TEST(PrefServiceTest, GetValueAndGetRecommendedValue) {
ASSERT_FALSE(value);
// Set a user-set value.
- prefs.SetUserPref(kPrefName, new base::FundamentalValue(kUserValue));
+ prefs.SetUserPref(kPrefName, new base::Value(kUserValue));
// Check that GetValue() returns the user-set value.
value = pref->GetValue();
@@ -193,8 +193,7 @@ TEST(PrefServiceTest, GetValueAndGetRecommendedValue) {
ASSERT_FALSE(value);
// Set a recommended value.
- prefs.SetRecommendedPref(kPrefName,
- new base::FundamentalValue(kRecommendedValue));
+ prefs.SetRecommendedPref(kPrefName, new base::Value(kRecommendedValue));
// Check that GetValue() returns the user-set value.
value = pref->GetValue();
diff --git a/chromium/components/prefs/pref_store.h b/chromium/components/prefs/pref_store.h
index ef2bc494d15..7964f1f0093 100644
--- a/chromium/components/prefs/pref_store.h
+++ b/chromium/components/prefs/pref_store.h
@@ -5,6 +5,7 @@
#ifndef COMPONENTS_PREFS_PREF_STORE_H_
#define COMPONENTS_PREFS_PREF_STORE_H_
+#include <memory>
#include <string>
#include "base/macros.h"
@@ -12,6 +13,7 @@
#include "components/prefs/base_prefs_export.h"
namespace base {
+class DictionaryValue;
class Value;
}
@@ -52,6 +54,9 @@ class COMPONENTS_PREFS_EXPORT PrefStore : public base::RefCounted<PrefStore> {
virtual bool GetValue(const std::string& key,
const base::Value** result) const = 0;
+ // Get all the values. Never returns a null pointer.
+ virtual std::unique_ptr<base::DictionaryValue> GetValues() const = 0;
+
protected:
friend class base::RefCounted<PrefStore>;
virtual ~PrefStore() {}
diff --git a/chromium/components/prefs/pref_value_map.cc b/chromium/components/prefs/pref_value_map.cc
index f0392d25284..a0352670400 100644
--- a/chromium/components/prefs/pref_value_map.cc
+++ b/chromium/components/prefs/pref_value_map.cc
@@ -92,7 +92,7 @@ bool PrefValueMap::GetBoolean(const std::string& key,
}
void PrefValueMap::SetBoolean(const std::string& key, bool value) {
- SetValue(key, base::MakeUnique<base::FundamentalValue>(value));
+ SetValue(key, base::MakeUnique<base::Value>(value));
}
bool PrefValueMap::GetString(const std::string& key,
@@ -112,11 +112,11 @@ bool PrefValueMap::GetInteger(const std::string& key, int* value) const {
}
void PrefValueMap::SetInteger(const std::string& key, const int value) {
- SetValue(key, base::MakeUnique<base::FundamentalValue>(value));
+ SetValue(key, base::MakeUnique<base::Value>(value));
}
void PrefValueMap::SetDouble(const std::string& key, const double value) {
- SetValue(key, base::MakeUnique<base::FundamentalValue>(value));
+ SetValue(key, base::MakeUnique<base::Value>(value));
}
void PrefValueMap::GetDifferingKeys(
@@ -157,3 +157,11 @@ void PrefValueMap::GetDifferingKeys(
for ( ; other_pref != other_prefs.end(); ++other_pref)
differing_keys->push_back(other_pref->first);
}
+
+std::unique_ptr<base::DictionaryValue> PrefValueMap::AsDictionaryValue() const {
+ auto dictionary = base::MakeUnique<base::DictionaryValue>();
+ for (const auto& value : prefs_) {
+ dictionary->Set(value.first, value.second->CreateDeepCopy());
+ }
+ return dictionary;
+}
diff --git a/chromium/components/prefs/pref_value_map.h b/chromium/components/prefs/pref_value_map.h
index b0ffbd15fdd..bad10cf9784 100644
--- a/chromium/components/prefs/pref_value_map.h
+++ b/chromium/components/prefs/pref_value_map.h
@@ -14,6 +14,7 @@
#include "components/prefs/base_prefs_export.h"
namespace base {
+class DictionaryValue;
class Value;
}
@@ -83,6 +84,9 @@ class COMPONENTS_PREFS_EXPORT PrefValueMap {
void GetDifferingKeys(const PrefValueMap* other,
std::vector<std::string>* differing_keys) const;
+ // Copies the map into a dictionary value.
+ std::unique_ptr<base::DictionaryValue> AsDictionaryValue() const;
+
private:
Map prefs_;
diff --git a/chromium/components/prefs/pref_value_map_unittest.cc b/chromium/components/prefs/pref_value_map_unittest.cc
index a0004090287..f6912da8816 100644
--- a/chromium/components/prefs/pref_value_map_unittest.cc
+++ b/chromium/components/prefs/pref_value_map_unittest.cc
@@ -27,7 +27,7 @@ TEST(PrefValueMapTest, SetValue) {
TEST(PrefValueMapTest, GetAndSetIntegerValue) {
PrefValueMap map;
- ASSERT_TRUE(map.SetValue("key", base::MakeUnique<FundamentalValue>(5)));
+ ASSERT_TRUE(map.SetValue("key", base::MakeUnique<Value>(5)));
int int_value = 0;
EXPECT_TRUE(map.GetInteger("key", &int_value));
@@ -40,7 +40,7 @@ TEST(PrefValueMapTest, GetAndSetIntegerValue) {
TEST(PrefValueMapTest, SetDoubleValue) {
PrefValueMap map;
- ASSERT_TRUE(map.SetValue("key", base::MakeUnique<FundamentalValue>(5.5)));
+ ASSERT_TRUE(map.SetValue("key", base::MakeUnique<Value>(5.5)));
const Value* result = NULL;
ASSERT_TRUE(map.GetValue("key", &result));
diff --git a/chromium/components/prefs/pref_value_store_unittest.cc b/chromium/components/prefs/pref_value_store_unittest.cc
index 23fc686e17c..7ef66eb5693 100644
--- a/chromium/components/prefs/pref_value_store_unittest.cc
+++ b/chromium/components/prefs/pref_value_store_unittest.cc
@@ -321,7 +321,7 @@ TEST_F(PrefValueStoreTest, GetValue) {
// Test getting a preference value that the |PrefValueStore|
// does not contain.
- base::FundamentalValue tmp_dummy_value(true);
+ base::Value tmp_dummy_value(true);
value = &tmp_dummy_value;
ASSERT_FALSE(pref_value_store_->GetValue(prefs::kMissingPref,
base::Value::Type::STRING, &value));
@@ -386,7 +386,7 @@ TEST_F(PrefValueStoreTest, GetRecommendedValue) {
actual_str_value);
// Test getting recommended value when no recommended value is present.
- base::FundamentalValue tmp_dummy_value(true);
+ base::Value tmp_dummy_value(true);
value = &tmp_dummy_value;
ASSERT_FALSE(pref_value_store_->GetRecommendedValue(
prefs::kDefaultPref,
diff --git a/chromium/components/prefs/testing_pref_store.cc b/chromium/components/prefs/testing_pref_store.cc
index 1e775824a6a..8f6f2098d47 100644
--- a/chromium/components/prefs/testing_pref_store.cc
+++ b/chromium/components/prefs/testing_pref_store.cc
@@ -24,6 +24,10 @@ bool TestingPrefStore::GetValue(const std::string& key,
return prefs_.GetValue(key, value);
}
+std::unique_ptr<base::DictionaryValue> TestingPrefStore::GetValues() const {
+ return prefs_.AsDictionaryValue();
+}
+
bool TestingPrefStore::GetMutableValue(const std::string& key,
base::Value** value) {
return prefs_.GetValue(key, value);
@@ -125,13 +129,11 @@ void TestingPrefStore::SetString(const std::string& key,
}
void TestingPrefStore::SetInteger(const std::string& key, int value) {
- SetValue(key, base::MakeUnique<base::FundamentalValue>(value),
- DEFAULT_PREF_WRITE_FLAGS);
+ SetValue(key, base::MakeUnique<base::Value>(value), DEFAULT_PREF_WRITE_FLAGS);
}
void TestingPrefStore::SetBoolean(const std::string& key, bool value) {
- SetValue(key, base::MakeUnique<base::FundamentalValue>(value),
- DEFAULT_PREF_WRITE_FLAGS);
+ SetValue(key, base::MakeUnique<base::Value>(value), DEFAULT_PREF_WRITE_FLAGS);
}
bool TestingPrefStore::GetString(const std::string& key,
diff --git a/chromium/components/prefs/testing_pref_store.h b/chromium/components/prefs/testing_pref_store.h
index 2bf2c8f72b1..2e685e4fde6 100644
--- a/chromium/components/prefs/testing_pref_store.h
+++ b/chromium/components/prefs/testing_pref_store.h
@@ -25,6 +25,7 @@ class TestingPrefStore : public PersistentPrefStore {
// Overriden from PrefStore.
bool GetValue(const std::string& key,
const base::Value** result) const override;
+ std::unique_ptr<base::DictionaryValue> GetValues() const override;
void AddObserver(PrefStore::Observer* observer) override;
void RemoveObserver(PrefStore::Observer* observer) override;
bool HasObservers() const override;
diff --git a/chromium/components/prefs/value_map_pref_store.cc b/chromium/components/prefs/value_map_pref_store.cc
index 8b828b10d5c..c31d7c771cc 100644
--- a/chromium/components/prefs/value_map_pref_store.cc
+++ b/chromium/components/prefs/value_map_pref_store.cc
@@ -17,6 +17,10 @@ bool ValueMapPrefStore::GetValue(const std::string& key,
return prefs_.GetValue(key, value);
}
+std::unique_ptr<base::DictionaryValue> ValueMapPrefStore::GetValues() const {
+ return prefs_.AsDictionaryValue();
+}
+
void ValueMapPrefStore::AddObserver(PrefStore::Observer* observer) {
observers_.AddObserver(observer);
}
diff --git a/chromium/components/prefs/value_map_pref_store.h b/chromium/components/prefs/value_map_pref_store.h
index 8310a9bad14..34d10959572 100644
--- a/chromium/components/prefs/value_map_pref_store.h
+++ b/chromium/components/prefs/value_map_pref_store.h
@@ -25,6 +25,7 @@ class COMPONENTS_PREFS_EXPORT ValueMapPrefStore : public WriteablePrefStore {
// PrefStore overrides:
bool GetValue(const std::string& key,
const base::Value** value) const override;
+ std::unique_ptr<base::DictionaryValue> GetValues() const override;
void AddObserver(PrefStore::Observer* observer) override;
void RemoveObserver(PrefStore::Observer* observer) override;
bool HasObservers() const override;