diff --git a/base/trace_event/trace_event_argument.cc b/base/trace_event/trace_event_argument.cc index c27a2f9ef3a6a6..1a5678c9c92cef 100644 --- a/base/trace_event/trace_event_argument.cc +++ b/base/trace_event/trace_event_argument.cc @@ -409,7 +409,7 @@ std::unique_ptr TracedValue::ToBaseValue() const { bool value; CHECK(it.ReadBool(&value)); if (cur_dict) { - cur_dict->SetBooleanWithoutPathExpansion(ReadKeyName(it), value); + cur_dict->SetKey(ReadKeyName(it), Value(value)); } else { cur_list->AppendBoolean(value); } diff --git a/base/values.cc b/base/values.cc index 5d9eaa298fdfdc..70d27e2135e119 100644 --- a/base/values.cc +++ b/base/values.cc @@ -741,11 +741,6 @@ Value* DictionaryValue::SetWithoutPathExpansion( return ((*dict_)[key.as_string()] = std::move(in_value)).get(); } -Value* DictionaryValue::SetBooleanWithoutPathExpansion(StringPiece path, - bool in_value) { - return SetWithoutPathExpansion(path, MakeUnique(in_value)); -} - Value* DictionaryValue::SetIntegerWithoutPathExpansion(StringPiece path, int in_value) { return SetWithoutPathExpansion(path, MakeUnique(in_value)); diff --git a/base/values.h b/base/values.h index fbb0647820a770..916e2116d089e6 100644 --- a/base/values.h +++ b/base/values.h @@ -306,19 +306,25 @@ class BASE_EXPORT DictionaryValue : public Value { // Like Set(), but without special treatment of '.'. This allows e.g. URLs to // be used as paths. + // DEPRECATED, use Value::SetKey(path, value) instead. Value* SetWithoutPathExpansion(StringPiece key, std::unique_ptr in_value); // Convenience forms of SetWithoutPathExpansion(). - Value* SetBooleanWithoutPathExpansion(StringPiece path, bool in_value); + // DEPRECATED, use Value::SetKey(path, Value(int)) instead. Value* SetIntegerWithoutPathExpansion(StringPiece path, int in_value); + // DEPRECATED, use Value::SetKey(path, Value(double)) instead. Value* SetDoubleWithoutPathExpansion(StringPiece path, double in_value); + // DEPRECATED, use Value::SetKey(path, Value(string)) instead. Value* SetStringWithoutPathExpansion(StringPiece path, StringPiece in_value); + // DEPRECATED, use Value::SetKey(path, Value(string16)) instead. Value* SetStringWithoutPathExpansion(StringPiece path, const string16& in_value); + // DEPRECATED, use Value::SetKey(path, Value(Type::DICTIONARY)) instead. DictionaryValue* SetDictionaryWithoutPathExpansion( StringPiece path, std::unique_ptr in_value); + // DEPRECATED, use Value::SetKey(path, Value(Type::LIST)) instead. ListValue* SetListWithoutPathExpansion(StringPiece path, std::unique_ptr in_value); @@ -355,22 +361,33 @@ class BASE_EXPORT DictionaryValue : public Value { // Like Get(), but without special treatment of '.'. This allows e.g. URLs to // be used as paths. + // DEPRECATED, use Value::FindKey(key) instead. bool GetWithoutPathExpansion(StringPiece key, const Value** out_value) const; + // DEPRECATED, use Value::FindKey(key) instead. bool GetWithoutPathExpansion(StringPiece key, Value** out_value); + // DEPRECATED, use Value::FindKey(key) and Value::GetBool() instead. bool GetBooleanWithoutPathExpansion(StringPiece key, bool* out_value) const; + // DEPRECATED, use Value::FindKey(key) and Value::GetInt() instead. bool GetIntegerWithoutPathExpansion(StringPiece key, int* out_value) const; + // DEPRECATED, use Value::FindKey(key) and Value::GetDouble() instead. bool GetDoubleWithoutPathExpansion(StringPiece key, double* out_value) const; + // DEPRECATED, use Value::FindKey(key) and Value::GetString() instead. bool GetStringWithoutPathExpansion(StringPiece key, std::string* out_value) const; + // DEPRECATED, use Value::FindKey(key) and Value::GetString() instead. bool GetStringWithoutPathExpansion(StringPiece key, string16* out_value) const; + // DEPRECATED, use Value::FindKey(key) and Value's Dictionary API instead. bool GetDictionaryWithoutPathExpansion( StringPiece key, const DictionaryValue** out_value) const; + // DEPRECATED, use Value::FindKey(key) and Value's Dictionary API instead. bool GetDictionaryWithoutPathExpansion(StringPiece key, DictionaryValue** out_value); + // DEPRECATED, use Value::FindKey(key) and Value::GetList() instead. bool GetListWithoutPathExpansion(StringPiece key, const ListValue** out_value) const; + // DEPRECATED, use Value::FindKey(key) and Value::GetList() instead. bool GetListWithoutPathExpansion(StringPiece key, ListValue** out_value); // Removes the Value with the specified path from this dictionary (or one diff --git a/base/values_unittest.cc b/base/values_unittest.cc index 00032a5db12e88..9f4d43b4364af0 100644 --- a/base/values_unittest.cc +++ b/base/values_unittest.cc @@ -824,13 +824,6 @@ TEST(ValuesTest, DictionarySetReturnsPointer) { EXPECT_EQ(Value::Type::NONE, blank_ptr->type()); } - { - DictionaryValue dict; - Value* bool_ptr = dict.SetBooleanWithoutPathExpansion("foo.bar", false); - EXPECT_EQ(Value::Type::BOOLEAN, bool_ptr->type()); - EXPECT_FALSE(bool_ptr->GetBool()); - } - { DictionaryValue dict; Value* int_ptr = dict.SetInteger("foo.bar", 42); diff --git a/chrome/browser/apps/drive/drive_app_mapping.cc b/chrome/browser/apps/drive/drive_app_mapping.cc index 96a913bf3c4fac..d3618e5cfa9110 100644 --- a/chrome/browser/apps/drive/drive_app_mapping.cc +++ b/chrome/browser/apps/drive/drive_app_mapping.cc @@ -31,7 +31,7 @@ std::unique_ptr CreateInfoDict( // Only writes non-default value. if (generated) - dict->SetBooleanWithoutPathExpansion(kKeyGenerated, true); + dict->SetKey(kKeyGenerated, base::Value(true)); return dict; } diff --git a/chrome/browser/chromeos/file_system_provider/registry.cc b/chrome/browser/chromeos/file_system_provider/registry.cc index 70cced131b3166..39f315dc6a3022 100644 --- a/chrome/browser/chromeos/file_system_provider/registry.cc +++ b/chrome/browser/chromeos/file_system_provider/registry.cc @@ -56,10 +56,10 @@ void Registry::RememberFileSystem( file_system_info.file_system_id()); file_system->SetStringWithoutPathExpansion(kPrefKeyDisplayName, file_system_info.display_name()); - file_system->SetBooleanWithoutPathExpansion(kPrefKeyWritable, - file_system_info.writable()); - file_system->SetBooleanWithoutPathExpansion( - kPrefKeySupportsNotifyTag, file_system_info.supports_notify_tag()); + file_system->SetKey(kPrefKeyWritable, + base::Value(file_system_info.writable())); + file_system->SetKey(kPrefKeySupportsNotifyTag, + base::Value(file_system_info.supports_notify_tag())); file_system->SetIntegerWithoutPathExpansion( kPrefKeyOpenedFilesLimit, file_system_info.opened_files_limit()); @@ -69,8 +69,7 @@ void Registry::RememberFileSystem( auto watcher = base::MakeUnique(); watcher->SetStringWithoutPathExpansion(kPrefKeyWatcherEntryPath, it.second.entry_path.value()); - watcher->SetBooleanWithoutPathExpansion(kPrefKeyWatcherRecursive, - it.second.recursive); + watcher->SetKey(kPrefKeyWatcherRecursive, base::Value(it.second.recursive)); watcher->SetStringWithoutPathExpansion(kPrefKeyWatcherLastTag, it.second.last_tag); auto persistent_origins_value = base::MakeUnique(); diff --git a/chrome/browser/chromeos/file_system_provider/registry_unittest.cc b/chrome/browser/chromeos/file_system_provider/registry_unittest.cc index 01f7cd46f8a617..6a73417e579e68 100644 --- a/chrome/browser/chromeos/file_system_provider/registry_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/registry_unittest.cc @@ -61,9 +61,9 @@ void RememberFakeFileSystem(TestingProfile* profile, file_system->SetStringWithoutPathExpansion(kPrefKeyFileSystemId, kFileSystemId); file_system->SetStringWithoutPathExpansion(kPrefKeyDisplayName, kDisplayName); - file_system->SetBooleanWithoutPathExpansion(kPrefKeyWritable, writable); - file_system->SetBooleanWithoutPathExpansion(kPrefKeySupportsNotifyTag, - supports_notify_tag); + file_system->SetKey(kPrefKeyWritable, base::Value(writable)); + file_system->SetKey(kPrefKeySupportsNotifyTag, + base::Value(supports_notify_tag)); file_system->SetIntegerWithoutPathExpansion(kPrefKeyOpenedFilesLimit, opened_files_limit); @@ -71,8 +71,8 @@ void RememberFakeFileSystem(TestingProfile* profile, auto watcher_value = base::MakeUnique(); watcher_value->SetStringWithoutPathExpansion(kPrefKeyWatcherEntryPath, watcher.entry_path.value()); - watcher_value->SetBooleanWithoutPathExpansion(kPrefKeyWatcherRecursive, - watcher.recursive); + watcher_value->SetKey(kPrefKeyWatcherRecursive, + base::Value(watcher.recursive)); watcher_value->SetStringWithoutPathExpansion(kPrefKeyWatcherLastTag, watcher.last_tag); auto persistent_origins_value = base::MakeUnique(); diff --git a/chrome/browser/chromeos/login/users/supervised_user_manager_impl.cc b/chrome/browser/chromeos/login/users/supervised_user_manager_impl.cc index e745b54520179f..49ca31a15877ee 100644 --- a/chrome/browser/chromeos/login/users/supervised_user_manager_impl.cc +++ b/chrome/browser/chromeos/login/users/supervised_user_manager_impl.cc @@ -278,9 +278,9 @@ void SupervisedUserManagerImpl::GetPasswordInformation( bool flag; if (GetUserBooleanValue(user_id, kSupervisedUserNeedPasswordUpdate, &flag)) - result->SetBooleanWithoutPathExpansion(kRequirePasswordUpdate, flag); + result->SetKey(kRequirePasswordUpdate, base::Value(flag)); if (GetUserBooleanValue(user_id, kSupervisedUserIncompleteKey, &flag)) - result->SetBooleanWithoutPathExpansion(kHasIncompleteKey, flag); + result->SetKey(kHasIncompleteKey, base::Value(flag)); std::string salt; if (GetUserStringValue(user_id, kSupervisedUserPasswordSalt, &salt)) @@ -359,7 +359,7 @@ void SupervisedUserManagerImpl::SetUserBooleanValue(const std::string& user_id, const bool value) { PrefService* local_state = g_browser_process->local_state(); DictionaryPrefUpdate update(local_state, key); - update->SetBooleanWithoutPathExpansion(user_id, value); + update->SetKey(user_id, base::Value(value)); } const user_manager::User* SupervisedUserManagerImpl::FindByDisplayName( diff --git a/chrome/browser/chromeos/options/vpn_config_view.cc b/chrome/browser/chromeos/options/vpn_config_view.cc index ab4d066e513eb7..750651346dbabc 100644 --- a/chrome/browser/chromeos/options/vpn_config_view.cc +++ b/chrome/browser/chromeos/options/vpn_config_view.cc @@ -378,8 +378,7 @@ bool VPNConfigView::Login() { bool only_policy_autoconnect = onc::PolicyAllowsOnlyPolicyNetworksToAutoconnect(!shared); if (only_policy_autoconnect) { - properties.SetBooleanWithoutPathExpansion(shill::kAutoConnectProperty, - false); + properties.SetKey(shill::kAutoConnectProperty, base::Value(false)); } NetworkConnect::Get()->CreateConfigurationAndConnect(&properties, shared); @@ -906,8 +905,8 @@ void VPNConfigView::SetConfigProperties( NOTREACHED(); break; } - properties->SetBooleanWithoutPathExpansion( - shill::kSaveCredentialsProperty, GetSaveCredentials()); + properties->SetKey(shill::kSaveCredentialsProperty, + base::Value(GetSaveCredentials())); } void VPNConfigView::Refresh() { diff --git a/chrome/browser/chromeos/options/wifi_config_view.cc b/chrome/browser/chromeos/options/wifi_config_view.cc index ae8b76a0b1bdd2..8638cfffb139c7 100644 --- a/chrome/browser/chromeos/options/wifi_config_view.cc +++ b/chrome/browser/chromeos/options/wifi_config_view.cc @@ -679,8 +679,7 @@ bool WifiConfigView::Login() { bool only_policy_autoconnect = onc::PolicyAllowsOnlyPolicyNetworksToAutoconnect(!share_network); if (only_policy_autoconnect) { - properties.SetBooleanWithoutPathExpansion(shill::kAutoConnectProperty, - false); + properties.SetKey(shill::kAutoConnectProperty, base::Value(false)); } if (service_path_.empty()) { @@ -691,8 +690,8 @@ bool WifiConfigView::Login() { shill_property_util::SetSSID(GetSsid(), &properties); properties.SetStringWithoutPathExpansion( shill::kModeProperty, shill::kModeManaged); - properties.SetBooleanWithoutPathExpansion( - shill::kSaveCredentialsProperty, GetSaveCredentials()); + properties.SetKey(shill::kSaveCredentialsProperty, + base::Value(GetSaveCredentials())); std::string security_class = shill::kSecurityNone; if (!eap_method_combobox_) { switch (security_combobox_->selected_index()) { @@ -730,8 +729,8 @@ bool WifiConfigView::Login() { } if (eap_method_combobox_) { SetEapProperties(&properties, true /* configured */); - properties.SetBooleanWithoutPathExpansion( - shill::kSaveCredentialsProperty, GetSaveCredentials()); + properties.SetKey(shill::kSaveCredentialsProperty, + base::Value(GetSaveCredentials())); } else { const std::string passphrase = GetPassphrase(); if (!passphrase.empty()) { @@ -891,8 +890,8 @@ void WifiConfigView::SetEapProperties(base::DictionaryValue* properties, SetEapClientCertProperties(properties); - properties->SetBooleanWithoutPathExpansion( - shill::kEapUseSystemCasProperty, GetEapUseSystemCas()); + properties->SetKey(shill::kEapUseSystemCasProperty, + base::Value(GetEapUseSystemCas())); if (!configured || passphrase_textfield_->changed()) { properties->SetStringWithoutPathExpansion( shill::kEapPasswordProperty, GetPassphrase()); diff --git a/chrome/browser/chromeos/options/wimax_config_view.cc b/chrome/browser/chromeos/options/wimax_config_view.cc index ec0cf562cff22f..b049a02f74edcd 100644 --- a/chrome/browser/chromeos/options/wimax_config_view.cc +++ b/chrome/browser/chromeos/options/wimax_config_view.cc @@ -155,8 +155,8 @@ bool WimaxConfigView::Login() { shill::kEapIdentityProperty, GetEapIdentity()); properties.SetStringWithoutPathExpansion( shill::kEapPasswordProperty, GetEapPassphrase()); - properties.SetBooleanWithoutPathExpansion( - shill::kSaveCredentialsProperty, GetSaveCredentials()); + properties.SetKey(shill::kSaveCredentialsProperty, + base::Value(GetSaveCredentials())); const bool share_default = true; bool share_network = GetShareNetwork(share_default); @@ -164,8 +164,7 @@ bool WimaxConfigView::Login() { bool only_policy_autoconnect = onc::PolicyAllowsOnlyPolicyNetworksToAutoconnect(!share_network); if (only_policy_autoconnect) { - properties.SetBooleanWithoutPathExpansion(shill::kAutoConnectProperty, - false); + properties.SetKey(shill::kAutoConnectProperty, base::Value(false)); } NetworkConnect::Get()->ConfigureNetworkIdAndConnect(wimax->guid(), properties, diff --git a/chrome/browser/chromeos/platform_keys/key_permissions.cc b/chrome/browser/chromeos/platform_keys/key_permissions.cc index 4957a74d2761c9..5e37002ac32c5f 100644 --- a/chrome/browser/chromeos/platform_keys/key_permissions.cc +++ b/chrome/browser/chromeos/platform_keys/key_permissions.cc @@ -283,12 +283,11 @@ KeyPermissions::PermissionsForExtension::KeyEntriesToState() { new_entry->SetStringWithoutPathExpansion(kStateStoreSPKI, entry.spki_b64); // Omit writing default values, namely |false|. if (entry.sign_once) { - new_entry->SetBooleanWithoutPathExpansion(kStateStoreSignOnce, - entry.sign_once); + new_entry->SetKey(kStateStoreSignOnce, base::Value(entry.sign_once)); } if (entry.sign_unlimited) { - new_entry->SetBooleanWithoutPathExpansion(kStateStoreSignUnlimited, - entry.sign_unlimited); + new_entry->SetKey(kStateStoreSignUnlimited, + base::Value(entry.sign_unlimited)); } new_state->Append(std::move(new_entry)); } diff --git a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc index 6a6a648c07941d..7aa039b0a3cbce 100644 --- a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc +++ b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc @@ -182,12 +182,11 @@ base::ListValue* ConstructFileSystemList( file_system_dict_value->SetStringWithoutPathExpansion( kDeviceIdKey, filesystems[i].transient_device_id); } - file_system_dict_value->SetBooleanWithoutPathExpansion( - kIsRemovableKey, filesystems[i].removable); - file_system_dict_value->SetBooleanWithoutPathExpansion( - kIsMediaDeviceKey, filesystems[i].media_device); - file_system_dict_value->SetBooleanWithoutPathExpansion( - kIsAvailableKey, true); + file_system_dict_value->SetKey(kIsRemovableKey, + base::Value(filesystems[i].removable)); + file_system_dict_value->SetKey(kIsMediaDeviceKey, + base::Value(filesystems[i].media_device)); + file_system_dict_value->SetKey(kIsAvailableKey, base::Value(true)); list->Append(std::move(file_system_dict_value)); diff --git a/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc b/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc index 918c0f4b162be8..b86fb43e0e57e1 100644 --- a/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc +++ b/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc @@ -880,12 +880,13 @@ IN_PROC_BROWSER_TEST_F(NetworkingPrivateChromeOSApiTest, CellularSimPuk) { IN_PROC_BROWSER_TEST_F(NetworkingPrivateChromeOSApiTest, GetGlobalPolicy) { base::DictionaryValue global_config; - global_config.SetBooleanWithoutPathExpansion( + global_config.SetKey( ::onc::global_network_config::kAllowOnlyPolicyNetworksToAutoconnect, - true); - global_config.SetBooleanWithoutPathExpansion( - ::onc::global_network_config::kAllowOnlyPolicyNetworksToConnect, false); - global_config.SetBooleanWithoutPathExpansion("SomeNewGlobalPolicy", false); + base::Value(true)); + global_config.SetKey( + ::onc::global_network_config::kAllowOnlyPolicyNetworksToConnect, + base::Value(false)); + global_config.SetKey("SomeNewGlobalPolicy", base::Value(false)); chromeos::NetworkHandler::Get() ->managed_network_configuration_handler() ->SetPolicy(::onc::ONC_SOURCE_DEVICE_POLICY, diff --git a/chrome/browser/extensions/api/notifications/notifications_api.cc b/chrome/browser/extensions/api/notifications/notifications_api.cc index 79360590416425..da49e6a03f2270 100644 --- a/chrome/browser/extensions/api/notifications/notifications_api.cc +++ b/chrome/browser/extensions/api/notifications/notifications_api.cc @@ -650,8 +650,8 @@ bool NotificationsGetAllFunction::RunNotificationsApi() { for (std::set::iterator iter = notification_ids.begin(); iter != notification_ids.end(); iter++) { - result->SetBooleanWithoutPathExpansion( - StripScopeFromIdentifier(extension_->id(), *iter), true); + result->SetKey(StripScopeFromIdentifier(extension_->id(), *iter), + base::Value(true)); } SetResult(std::move(result)); diff --git a/chrome/browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc b/chrome/browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc index 5364c9676d1d03..7f8e774024c6f0 100644 --- a/chrome/browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc +++ b/chrome/browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc @@ -195,8 +195,7 @@ class PlatformKeysTest : public ExtensionApiTest { { std::unique_ptr cert1_key_permission( new base::DictionaryValue); - cert1_key_permission->SetBooleanWithoutPathExpansion( - "allowCorporateKeyUsage", true); + cert1_key_permission->SetKey("allowCorporateKeyUsage", base::Value(true)); key_permissions_policy.SetWithoutPathExpansion( extension_->id(), std::move(cert1_key_permission)); } diff --git a/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc b/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc index d537b4dfbd84b3..9db94e8a306189 100644 --- a/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc +++ b/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc @@ -115,7 +115,7 @@ void SupervisedUserSharedSettingsService::SetValueInternal( key, base::MakeUnique()); } dict->SetWithoutPathExpansion(kValue, base::MakeUnique(value)); - dict->SetBooleanWithoutPathExpansion(kAcknowledged, acknowledged); + dict->SetKey(kAcknowledged, base::Value(acknowledged)); if (!sync_processor_) return; @@ -236,8 +236,8 @@ SupervisedUserSharedSettingsService::MergeDataAndStartSyncing( // Every setting we get from the server should have the acknowledged flag // set. DCHECK(supervised_user_shared_setting.acknowledged()); - dict->SetBooleanWithoutPathExpansion( - kAcknowledged, supervised_user_shared_setting.acknowledged()); + dict->SetKey(kAcknowledged, + base::Value(supervised_user_shared_setting.acknowledged())); callbacks_.Notify(su_id, key); if (pref_seen_keys.find(su_id) == pref_seen_keys.end()) @@ -348,8 +348,9 @@ syncer::SyncError SupervisedUserSharedSettingsService::ProcessSyncChanges( std::unique_ptr value = base::JSONReader::Read(supervised_user_shared_setting.value()); dict->SetWithoutPathExpansion(kValue, std::move(value)); - dict->SetBooleanWithoutPathExpansion( - kAcknowledged, supervised_user_shared_setting.acknowledged()); + dict->SetKey( + kAcknowledged, + base::Value(supervised_user_shared_setting.acknowledged())); break; } case SyncChange::ACTION_DELETE: { diff --git a/chrome/browser/supervised_user/supervised_user_browsertest.cc b/chrome/browser/supervised_user/supervised_user_browsertest.cc index 6af9d876f220eb..4bbd7014e9d8bf 100644 --- a/chrome/browser/supervised_user/supervised_user_browsertest.cc +++ b/chrome/browser/supervised_user/supervised_user_browsertest.cc @@ -343,7 +343,7 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest, // Set the host as allowed. std::unique_ptr dict(new base::DictionaryValue); - dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true); + dict->SetKey(allowed_url.host(), base::Value(true)); SupervisedUserSettingsService* supervised_user_settings_service = SupervisedUserSettingsServiceFactory::GetForProfile( browser()->profile()); @@ -406,7 +406,7 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserTest, GoBackOnDontProceed) { // Set the host as blocked and wait for the interstitial to appear. auto dict = base::MakeUnique(); - dict->SetBooleanWithoutPathExpansion(test_url.host(), false); + dict->SetKey(test_url.host(), base::Value(false)); SupervisedUserSettingsService* supervised_user_settings_service = SupervisedUserSettingsServiceFactory::GetForProfile( browser()->profile()); @@ -449,7 +449,7 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserTest, ClosingBlockedTabDoesNotCrash) { // Set the host as blocked and wait for the interstitial to appear. auto dict = base::MakeUnique(); - dict->SetBooleanWithoutPathExpansion(test_url.host(), false); + dict->SetKey(test_url.host(), base::Value(false)); SupervisedUserSettingsService* supervised_user_settings_service = SupervisedUserSettingsServiceFactory::GetForProfile(browser()->profile()); auto message_loop_runner = base::MakeRefCounted(); @@ -486,7 +486,7 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserTest, BlockThenUnblock) { // Set the host as blocked and wait for the interstitial to appear. auto dict = base::MakeUnique(); - dict->SetBooleanWithoutPathExpansion(test_url.host(), false); + dict->SetKey(test_url.host(), base::Value(false)); SupervisedUserSettingsService* supervised_user_settings_service = SupervisedUserSettingsServiceFactory::GetForProfile( browser()->profile()); @@ -504,7 +504,7 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserTest, BlockThenUnblock) { ASSERT_TRUE(ShownPageIsInterstitial(web_contents)); dict = base::MakeUnique(); - dict->SetBooleanWithoutPathExpansion(test_url.host(), true); + dict->SetKey(test_url.host(), base::Value(true)); supervised_user_settings_service->SetLocalSetting( supervised_users::kContentPackManualBehaviorHosts, std::move(dict)); ASSERT_EQ(SupervisedUserURLFilter::ALLOW, @@ -530,7 +530,7 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest, Unblock) { // Set the host as allowed. std::unique_ptr dict(new base::DictionaryValue); - dict->SetBooleanWithoutPathExpansion(test_url.host(), true); + dict->SetKey(test_url.host(), base::Value(true)); SupervisedUserSettingsService* supervised_user_settings_service = SupervisedUserSettingsServiceFactory::GetForProfile( browser()->profile()); diff --git a/chrome/browser/supervised_user/supervised_user_navigation_throttle_browsertest.cc b/chrome/browser/supervised_user/supervised_user_navigation_throttle_browsertest.cc index 179b75a6f5e332..2bb533f984fed5 100644 --- a/chrome/browser/supervised_user/supervised_user_navigation_throttle_browsertest.cc +++ b/chrome/browser/supervised_user/supervised_user_navigation_throttle_browsertest.cc @@ -51,7 +51,7 @@ class SupervisedUserNavigationThrottleTest : public InProcessBrowserTest { SupervisedUserSettingsService* settings_service = SupervisedUserSettingsServiceFactory::GetForProfile(profile); auto dict = base::MakeUnique(); - dict->SetBooleanWithoutPathExpansion(host, false); + dict->SetKey(host, base::Value(false)); settings_service->SetLocalSetting( supervised_users::kContentPackManualBehaviorHosts, std::move(dict)); } diff --git a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc index 767b2774a80b95..ec46dadb7ccc69 100644 --- a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc +++ b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc @@ -97,7 +97,7 @@ class SetNotificationsEnabledDeferred { DictionaryPrefUpdate update(prefs_, prefs::kArcSetNotificationsEnabledDeferred); base::DictionaryValue* const dict = update.Get(); - dict->SetBooleanWithoutPathExpansion(app_id, enabled); + dict->SetKey(app_id, base::Value(enabled)); } bool Get(const std::string& app_id, bool* enabled) { diff --git a/chrome/browser/ui/webui/policy_ui_handler.cc b/chrome/browser/ui/webui/policy_ui_handler.cc index 8f3a4dca664964..42f02b4d212a4b 100644 --- a/chrome/browser/ui/webui/policy_ui_handler.cc +++ b/chrome/browser/ui/webui/policy_ui_handler.cc @@ -632,7 +632,7 @@ void PolicyUIHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, void PolicyUIHandler::AddPolicyName(const std::string& name, base::DictionaryValue* names) const { - names->SetBooleanWithoutPathExpansion(name, true); + names->SetKey(name, base::Value(true)); } void PolicyUIHandler::SendPolicyNames() const { diff --git a/chromeos/components/tether/wifi_hotspot_connector.cc b/chromeos/components/tether/wifi_hotspot_connector.cc index 34740d2dcedcbc..3fd0a84bdd330c 100644 --- a/chromeos/components/tether/wifi_hotspot_connector.cc +++ b/chromeos/components/tether/wifi_hotspot_connector.cc @@ -197,11 +197,10 @@ base::DictionaryValue WifiHotspotConnector::CreateWifiPropertyDictionary( shill_property_util::SetSSID(ssid, &properties); properties.SetStringWithoutPathExpansion(shill::kGuidProperty, wifi_network_guid_); - properties.SetBooleanWithoutPathExpansion(shill::kAutoConnectProperty, false); + properties.SetKey(shill::kAutoConnectProperty, base::Value(false)); properties.SetStringWithoutPathExpansion(shill::kTypeProperty, shill::kTypeWifi); - properties.SetBooleanWithoutPathExpansion(shill::kSaveCredentialsProperty, - true); + properties.SetKey(shill::kSaveCredentialsProperty, base::Value(true)); if (password.empty()) { properties.SetStringWithoutPathExpansion(shill::kSecurityClassProperty, diff --git a/chromeos/dbus/fake_shill_device_client.cc b/chromeos/dbus/fake_shill_device_client.cc index 0cb8164ef00ae9..a371aa62d28405 100644 --- a/chromeos/dbus/fake_shill_device_client.cc +++ b/chromeos/dbus/fake_shill_device_client.cc @@ -398,8 +398,8 @@ void FakeShillDeviceClient::AddDevice(const std::string& device_path, properties->SetStringWithoutPathExpansion( shill::kDBusServiceProperty, modemmanager::kModemManager1ServiceName); if (type == shill::kTypeCellular) { - properties->SetBooleanWithoutPathExpansion( - shill::kCellularAllowRoamingProperty, false); + properties->SetKey(shill::kCellularAllowRoamingProperty, + base::Value(false)); } } @@ -504,8 +504,8 @@ void FakeShillDeviceClient::SetSimLockStatus(const std::string& device_path, status.type); simlock_dict->SetIntegerWithoutPathExpansion( shill::kSIMLockRetriesLeftProperty, status.retries_left); - simlock_dict->SetBooleanWithoutPathExpansion(shill::kSIMLockEnabledProperty, - status.lock_enabled); + simlock_dict->SetKey(shill::kSIMLockEnabledProperty, + base::Value(status.lock_enabled)); NotifyObserversPropertyChanged(dbus::ObjectPath(device_path), shill::kSIMLockStatusProperty); } diff --git a/chromeos/dbus/fake_shill_service_client.cc b/chromeos/dbus/fake_shill_service_client.cc index 363b1c7a7a5b02..dc7dc7a89c3a99 100644 --- a/chromeos/dbus/fake_shill_service_client.cc +++ b/chromeos/dbus/fake_shill_service_client.cc @@ -374,7 +374,7 @@ base::DictionaryValue* FakeShillServiceClient::SetServiceProperties( device_path); properties->SetStringWithoutPathExpansion(shill::kTypeProperty, type); properties->SetStringWithoutPathExpansion(shill::kStateProperty, state); - properties->SetBooleanWithoutPathExpansion(shill::kVisibleProperty, visible); + properties->SetKey(shill::kVisibleProperty, base::Value(visible)); if (type == shill::kTypeWifi) { properties->SetStringWithoutPathExpansion(shill::kSecurityClassProperty, shill::kSecurityNone); diff --git a/chromeos/dbus/shill_device_client_unittest.cc b/chromeos/dbus/shill_device_client_unittest.cc index fe717bd484654a..641bb2be98fa52 100644 --- a/chromeos/dbus/shill_device_client_unittest.cc +++ b/chromeos/dbus/shill_device_client_unittest.cc @@ -126,8 +126,7 @@ TEST_F(ShillDeviceClientTest, GetProperties) { // Set expectations. base::DictionaryValue value; - value.SetBooleanWithoutPathExpansion(shill::kCellularAllowRoamingProperty, - kValue); + value.SetKey(shill::kCellularAllowRoamingProperty, base::Value(kValue)); PrepareForMethodCall(shill::kGetPropertiesFunction, base::Bind(&ExpectNoArgument), response.get()); diff --git a/chromeos/dbus/shill_manager_client_unittest.cc b/chromeos/dbus/shill_manager_client_unittest.cc index 7a1ea81eeadf76..cd583384295d61 100644 --- a/chromeos/dbus/shill_manager_client_unittest.cc +++ b/chromeos/dbus/shill_manager_client_unittest.cc @@ -139,7 +139,7 @@ TEST_F(ShillManagerClientTest, GetProperties) { // Create the expected value. base::DictionaryValue value; - value.SetBooleanWithoutPathExpansion(shill::kOfflineModeProperty, true); + value.SetKey(shill::kOfflineModeProperty, base::Value(true)); // Set expectations. PrepareForMethodCall(shill::kGetPropertiesFunction, base::Bind(&ExpectNoArgument), diff --git a/chromeos/dbus/shill_profile_client_unittest.cc b/chromeos/dbus/shill_profile_client_unittest.cc index eb17a9a42c0702..6f63b570e4f5bd 100644 --- a/chromeos/dbus/shill_profile_client_unittest.cc +++ b/chromeos/dbus/shill_profile_client_unittest.cc @@ -167,7 +167,7 @@ TEST_F(ShillProfileClientTest, DeleteEntry) { // Create the expected value. base::DictionaryValue value; - value.SetBooleanWithoutPathExpansion(shill::kOfflineModeProperty, true); + value.SetKey(shill::kOfflineModeProperty, base::Value(true)); // Set expectations. PrepareForMethodCall(shill::kDeleteEntryFunction, base::Bind(&ExpectStringArgument, kExampleEntryPath), diff --git a/chromeos/geolocation/simple_geolocation_request.cc b/chromeos/geolocation/simple_geolocation_request.cc index ab15034468c4a7..fcda985bb9abb8 100644 --- a/chromeos/geolocation/simple_geolocation_request.cc +++ b/chromeos/geolocation/simple_geolocation_request.cc @@ -389,7 +389,7 @@ std::string SimpleGeolocationRequest::FormatRequestBody() const { return std::string(kSimpleGeolocationRequestBody); std::unique_ptr request(new base::DictionaryValue); - request->SetBooleanWithoutPathExpansion(kConsiderIp, true); + request->SetKey(kConsiderIp, base::Value(true)); if (wifi_data_) { auto wifi_access_points = base::MakeUnique(); diff --git a/chromeos/network/auto_connect_handler_unittest.cc b/chromeos/network/auto_connect_handler_unittest.cc index 078a9b32c38ec8..46d3a4cf4959ad 100644 --- a/chromeos/network/auto_connect_handler_unittest.cc +++ b/chromeos/network/auto_connect_handler_unittest.cc @@ -308,9 +308,9 @@ TEST_F(AutoConnectHandlerTest, ReconnectOnCertLoading) { // Applying the policy which restricts autoconnect should disconnect from the // shared, unmanaged network. base::DictionaryValue global_config; - global_config.SetBooleanWithoutPathExpansion( + global_config.SetKey( ::onc::global_network_config::kAllowOnlyPolicyNetworksToAutoconnect, - true); + base::Value(true)); SetupPolicy(std::string(), // no network configs base::DictionaryValue(), // no global config @@ -398,9 +398,9 @@ TEST_F(AutoConnectHandlerTest, DisconnectOnPolicyLoading) { EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); base::DictionaryValue global_config; - global_config.SetBooleanWithoutPathExpansion( + global_config.SetKey( ::onc::global_network_config::kAllowOnlyPolicyNetworksToAutoconnect, - true); + base::Value(true)); // Applying the policy which restricts autoconnect should disconnect from the // shared, unmanaged network. @@ -430,8 +430,9 @@ TEST_F(AutoConnectHandlerTest, EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); base::DictionaryValue global_config; - global_config.SetBooleanWithoutPathExpansion( - ::onc::global_network_config::kAllowOnlyPolicyNetworksToConnect, true); + global_config.SetKey( + ::onc::global_network_config::kAllowOnlyPolicyNetworksToConnect, + base::Value(true)); // Applying the policy which restricts autoconnect should disconnect from the // shared, unmanaged network. diff --git a/chromeos/network/network_connection_handler_impl_unittest.cc b/chromeos/network/network_connection_handler_impl_unittest.cc index 0131ceee060cf6..1a8550bce2e1ee 100644 --- a/chromeos/network/network_connection_handler_impl_unittest.cc +++ b/chromeos/network/network_connection_handler_impl_unittest.cc @@ -360,8 +360,9 @@ TEST_F(NetworkConnectionHandlerImplTest, NetworkConnectionHandlerConnectProhibited) { EXPECT_FALSE(ConfigureService(kConfigConnectable).empty()); base::DictionaryValue global_config; - global_config.SetBooleanWithoutPathExpansion( - ::onc::global_network_config::kAllowOnlyPolicyNetworksToConnect, true); + global_config.SetKey( + ::onc::global_network_config::kAllowOnlyPolicyNetworksToConnect, + base::Value(true)); SetupPolicy("[]", global_config, false /* load as device policy */); LoginToRegularUser(); Connect(kWifi0); diff --git a/chromeos/network/network_state.cc b/chromeos/network/network_state.cc index c6c7369860de1d..809fbd83e1c9a2 100644 --- a/chromeos/network/network_state.cc +++ b/chromeos/network/network_state.cc @@ -271,8 +271,8 @@ void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const { dictionary->SetIntegerWithoutPathExpansion(kTetherBatteryPercentage, battery_percentage()); dictionary->SetStringWithoutPathExpansion(kTetherCarrier, carrier()); - dictionary->SetBooleanWithoutPathExpansion(kTetherHasConnectedToHost, - tether_has_connected_to_host()); + dictionary->SetKey(kTetherHasConnectedToHost, + base::Value(tether_has_connected_to_host())); dictionary->SetIntegerWithoutPathExpansion(kTetherSignalStrength, signal_strength()); @@ -286,8 +286,7 @@ void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const { return; if (visible()) { - dictionary->SetBooleanWithoutPathExpansion(shill::kConnectableProperty, - connectable()); + dictionary->SetKey(shill::kConnectableProperty, base::Value(connectable())); dictionary->SetIntegerWithoutPathExpansion(shill::kSignalStrengthProperty, signal_strength()); } @@ -309,8 +308,8 @@ void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const { activation_state()); dictionary->SetStringWithoutPathExpansion(shill::kRoamingStateProperty, roaming()); - dictionary->SetBooleanWithoutPathExpansion(shill::kOutOfCreditsProperty, - cellular_out_of_credits()); + dictionary->SetKey(shill::kOutOfCreditsProperty, + base::Value(cellular_out_of_credits())); } } diff --git a/chromeos/network/network_util.cc b/chromeos/network/network_util.cc index 7ba8ecfef2293f..4ed4ec99ae0f66 100644 --- a/chromeos/network/network_util.cc +++ b/chromeos/network/network_util.cc @@ -176,9 +176,8 @@ std::unique_ptr TranslateNetworkStateToONC( if (device) { std::unique_ptr device_dict( new base::DictionaryValue); - device_dict->SetBooleanWithoutPathExpansion( - shill::kProviderRequiresRoamingProperty, - device->provider_requires_roaming()); + device_dict->SetKey(shill::kProviderRequiresRoamingProperty, + base::Value(device->provider_requires_roaming())); shill_dictionary->SetWithoutPathExpansion(shill::kDeviceProperty, std::move(device_dict)); } diff --git a/chromeos/network/onc/onc_merger.cc b/chromeos/network/onc/onc_merger.cc index f6ad5e828f1573..6069541d07ead0 100644 --- a/chromeos/network/onc/onc_merger.cc +++ b/chromeos/network/onc/onc_merger.cc @@ -57,7 +57,7 @@ void MarkRecommendedFieldnames(const base::DictionaryValue& policy, it != recommended_value->end(); ++it) { std::string entry; if (it->GetAsString(&entry)) - result->SetBooleanWithoutPathExpansion(entry, true); + result->SetKey(entry, base::Value(true)); } } @@ -451,12 +451,12 @@ class MergeToAugmented : public MergeToEffective { base::MakeUnique(*values.shared_setting)); } if (HasUserPolicy() && values.user_editable) { - augmented_value->SetBooleanWithoutPathExpansion( - ::onc::kAugmentationUserEditable, true); + augmented_value->SetKey(::onc::kAugmentationUserEditable, + base::Value(true)); } if (HasDevicePolicy() && values.device_editable) { - augmented_value->SetBooleanWithoutPathExpansion( - ::onc::kAugmentationDeviceEditable, true); + augmented_value->SetKey(::onc::kAugmentationDeviceEditable, + base::Value(true)); } if (augmented_value->empty()) augmented_value.reset(); diff --git a/chromeos/network/onc/onc_translator_onc_to_shill.cc b/chromeos/network/onc/onc_translator_onc_to_shill.cc index cc3714d9e5d384..05df1ce17e6688 100644 --- a/chromeos/network/onc/onc_translator_onc_to_shill.cc +++ b/chromeos/network/onc/onc_translator_onc_to_shill.cc @@ -237,8 +237,8 @@ void LocalTranslator::TranslateWiFi() { bool allow_gateway_arp_polling; if (onc_object_->GetBooleanWithoutPathExpansion( ::onc::wifi::kAllowGatewayARPPolling, &allow_gateway_arp_polling)) { - shill_dictionary_->SetBooleanWithoutPathExpansion( - shill::kLinkMonitorDisableProperty, !allow_gateway_arp_polling); + shill_dictionary_->SetKey(shill::kLinkMonitorDisableProperty, + base::Value(!allow_gateway_arp_polling)); } CopyFieldsAccordingToSignature(); diff --git a/chromeos/network/onc/onc_translator_shill_to_onc.cc b/chromeos/network/onc/onc_translator_shill_to_onc.cc index a6f77bc3ae5bff..f9962b195cf932 100644 --- a/chromeos/network/onc/onc_translator_shill_to_onc.cc +++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc @@ -357,8 +357,8 @@ void ShillToONCTranslator::TranslateWiFiWithState() { bool link_monitor_disable; if (shill_dictionary_->GetBooleanWithoutPathExpansion( shill::kLinkMonitorDisableProperty, &link_monitor_disable)) { - onc_object_->SetBooleanWithoutPathExpansion( - ::onc::wifi::kAllowGatewayARPPolling, !link_monitor_disable); + onc_object_->SetKey(::onc::wifi::kAllowGatewayARPPolling, + base::Value(!link_monitor_disable)); } CopyPropertiesAccordingToSignature(); @@ -490,8 +490,8 @@ void ShillToONCTranslator::TranslateNetworkWithState() { ::onc::network_config::kConnectionState, onc_state); // Only set 'RestrictedConnectivity' if captive portal state is true. if (NetworkState::NetworkStateIsCaptivePortal(*shill_dictionary_)) { - onc_object_->SetBooleanWithoutPathExpansion( - ::onc::network_config::kRestrictedConnectivity, true); + onc_object_->SetKey(::onc::network_config::kRestrictedConnectivity, + base::Value(true)); } } diff --git a/chromeos/network/policy_util.cc b/chromeos/network/policy_util.cc index 491f0a319557b2..c38557ae0bde4e 100644 --- a/chromeos/network/policy_util.cc +++ b/chromeos/network/policy_util.cc @@ -215,7 +215,7 @@ void ApplyGlobalAutoconnectPolicy( else NOTREACHED(); - auto_connect_dictionary->SetBooleanWithoutPathExpansion(policy_source, false); + auto_connect_dictionary->SetKey(policy_source, base::Value(false)); auto_connect_dictionary->SetStringWithoutPathExpansion( ::onc::kAugmentationEffectiveSetting, policy_source); } @@ -296,8 +296,8 @@ void SetShillPropertiesForGlobalPolicy( // If autoconnect is not explicitly set yet, it might automatically be enabled // by Shill. To prevent that, disable it explicitly. - shill_properties_to_update->SetBooleanWithoutPathExpansion( - shill::kAutoConnectProperty, false); + shill_properties_to_update->SetKey(shill::kAutoConnectProperty, + base::Value(false)); } std::unique_ptr CreateShillConfiguration( @@ -363,8 +363,8 @@ std::unique_ptr CreateShillConfiguration( if (network_policy && IsAutoConnectEnabledInPolicy(*network_policy)) { VLOG(1) << "Enable ManagedCredentials for managed network with GUID " << guid; - shill_dictionary->SetBooleanWithoutPathExpansion( - shill::kManagedCredentialsProperty, true); + shill_dictionary->SetKey(shill::kManagedCredentialsProperty, + base::Value(true)); } if (!network_policy && global_policy) { diff --git a/components/arc/net/arc_net_host_impl.cc b/components/arc/net/arc_net_host_impl.cc index 54e2e320e350c7..93369113e26537 100644 --- a/components/arc/net/arc_net_host_impl.cc +++ b/components/arc/net/arc_net_host_impl.cc @@ -504,8 +504,7 @@ void ArcNetHostImpl::CreateNetwork(mojom::WifiConfigurationPtr cfg, onc::network_config::kWiFi); wifi_dict->SetStringWithoutPathExpansion(onc::wifi::kHexSSID, cfg->hexssid.value()); - wifi_dict->SetBooleanWithoutPathExpansion(onc::wifi::kAutoConnect, - details->autoconnect); + wifi_dict->SetKey(onc::wifi::kAutoConnect, base::Value(details->autoconnect)); if (cfg->security.empty()) { wifi_dict->SetStringWithoutPathExpansion(onc::wifi::kSecurity, onc::wifi::kSecurityNone); diff --git a/components/proximity_auth/proximity_auth_local_state_pref_manager_unittest.cc b/components/proximity_auth/proximity_auth_local_state_pref_manager_unittest.cc index c5be80a6e88d4e..d8257d1d5dc6ca 100644 --- a/components/proximity_auth/proximity_auth_local_state_pref_manager_unittest.cc +++ b/components/proximity_auth/proximity_auth_local_state_pref_manager_unittest.cc @@ -58,11 +58,11 @@ class ProximityAuthLocalStatePrefManagerTest : public testing::Test { user1_prefs->SetIntegerWithoutPathExpansion( proximity_auth::prefs::kEasyUnlockProximityThreshold, kProximityThreshold1); - user1_prefs->SetBooleanWithoutPathExpansion( + user1_prefs->SetKey( proximity_auth::prefs::kProximityAuthIsChromeOSLoginEnabled, - kIsChromeOSLoginEnabled1); - user1_prefs->SetBooleanWithoutPathExpansion( - proximity_auth::prefs::kEasyUnlockAllowed, kIsEasyUnlockAllowed1); + base::Value(kIsChromeOSLoginEnabled1)); + user1_prefs->SetKey(proximity_auth::prefs::kEasyUnlockAllowed, + base::Value(kIsEasyUnlockAllowed1)); DictionaryPrefUpdate update1(&local_state_, prefs::kEasyUnlockLocalStateUserPrefs); update1->SetWithoutPathExpansion(user1_.GetUserEmail(), @@ -73,11 +73,11 @@ class ProximityAuthLocalStatePrefManagerTest : public testing::Test { user2_prefs->SetIntegerWithoutPathExpansion( proximity_auth::prefs::kEasyUnlockProximityThreshold, kProximityThreshold2); - user2_prefs->SetBooleanWithoutPathExpansion( + user2_prefs->SetKey( proximity_auth::prefs::kProximityAuthIsChromeOSLoginEnabled, - kIsChromeOSLoginEnabled2); - user2_prefs->SetBooleanWithoutPathExpansion( - proximity_auth::prefs::kEasyUnlockAllowed, kIsEasyUnlockAllowed2); + base::Value(kIsChromeOSLoginEnabled2)); + user2_prefs->SetKey(proximity_auth::prefs::kEasyUnlockAllowed, + base::Value(kIsEasyUnlockAllowed2)); DictionaryPrefUpdate update2(&local_state_, prefs::kEasyUnlockLocalStateUserPrefs); diff --git a/components/proximity_auth/proximity_auth_profile_pref_manager.cc b/components/proximity_auth/proximity_auth_profile_pref_manager.cc index 691c7e6af6ebca..dc9eb12f91cba5 100644 --- a/components/proximity_auth/proximity_auth_profile_pref_manager.cc +++ b/components/proximity_auth/proximity_auth_profile_pref_manager.cc @@ -79,12 +79,12 @@ void ProximityAuthProfilePrefManager::SyncPrefsToLocalState() { std::unique_ptr user_prefs_dict( new base::DictionaryValue()); - user_prefs_dict->SetBooleanWithoutPathExpansion(prefs::kEasyUnlockAllowed, - IsEasyUnlockAllowed()); + user_prefs_dict->SetKey(prefs::kEasyUnlockAllowed, + base::Value(IsEasyUnlockAllowed())); user_prefs_dict->SetIntegerWithoutPathExpansion( prefs::kEasyUnlockProximityThreshold, GetProximityThreshold()); - user_prefs_dict->SetBooleanWithoutPathExpansion( - prefs::kProximityAuthIsChromeOSLoginEnabled, IsChromeOSLoginEnabled()); + user_prefs_dict->SetKey(prefs::kProximityAuthIsChromeOSLoginEnabled, + base::Value(IsChromeOSLoginEnabled())); DictionaryPrefUpdate update(local_state_, prefs::kEasyUnlockLocalStateUserPrefs); diff --git a/components/signin/ios/browser/account_consistency_service.mm b/components/signin/ios/browser/account_consistency_service.mm index a56cc1b8626805..30fcf3fcdab523 100644 --- a/components/signin/ios/browser/account_consistency_service.mm +++ b/components/signin/ios/browser/account_consistency_service.mm @@ -373,7 +373,7 @@ DictionaryPrefUpdate update( case ADD_CHROME_CONNECTED_COOKIE: // Add request.domain to prefs, use |true| as a dummy value (that is // never used), as the dictionary is used as a set. - update->SetBooleanWithoutPathExpansion(request.domain, true); + update->SetKey(request.domain, base::Value(true)); break; case REMOVE_CHROME_CONNECTED_COOKIE: // Remove request.domain from prefs. diff --git a/components/user_manager/user_manager_base.cc b/components/user_manager/user_manager_base.cc index dddc4e56ac27bd..92e81fbf19a243 100644 --- a/components/user_manager/user_manager_base.cc +++ b/components/user_manager/user_manager_base.cc @@ -396,8 +396,8 @@ void UserManagerBase::SaveForceOnlineSignin(const AccountId& account_id, { DictionaryPrefUpdate force_online_update(GetLocalState(), kUserForceOnlineSignin); - force_online_update->SetBooleanWithoutPathExpansion( - account_id.GetUserEmail(), force_online_signin); + force_online_update->SetKey(account_id.GetUserEmail(), + base::Value(force_online_signin)); } GetLocalState()->CommitPendingWrite(); } diff --git a/dbus/values_util_unittest.cc b/dbus/values_util_unittest.cc index a4854dc40f47cd..25b516fe5ec550 100644 --- a/dbus/values_util_unittest.cc +++ b/dbus/values_util_unittest.cc @@ -339,7 +339,7 @@ TEST(ValuesUtilTest, PopDictionaryWithDottedStringKey) { // Create the expected value. base::DictionaryValue dictionary_value; - dictionary_value.SetBooleanWithoutPathExpansion(kKey1, kBoolValue); + dictionary_value.SetKey(kKey1, base::Value(kBoolValue)); dictionary_value.SetIntegerWithoutPathExpansion(kKey2, kInt32Value); dictionary_value.SetDoubleWithoutPathExpansion(kKey3, kDoubleValue); diff --git a/extensions/browser/api/networking_private/networking_private_chromeos.cc b/extensions/browser/api/networking_private/networking_private_chromeos.cc index 4611127869ace9..30de9358c2df20 100644 --- a/extensions/browser/api/networking_private/networking_private_chromeos.cc +++ b/extensions/browser/api/networking_private/networking_private_chromeos.cc @@ -266,7 +266,7 @@ void SetProxyEffectiveValue(base::DictionaryValue* dict, } dict->SetWithoutPathExpansion(::onc::kAugmentationActiveSetting, std::move(value)); - dict->SetBooleanWithoutPathExpansion(::onc::kAugmentationUserEditable, false); + dict->SetKey(::onc::kAugmentationUserEditable, base::Value(false)); } std::string GetProxySettingsType(const UIProxyConfig::Mode& mode) { diff --git a/media/base/video_frame_metadata.cc b/media/base/video_frame_metadata.cc index 5b65cd2f24fdad..b8bc5edfdcfc1a 100644 --- a/media/base/video_frame_metadata.cc +++ b/media/base/video_frame_metadata.cc @@ -31,7 +31,7 @@ bool VideoFrameMetadata::HasKey(Key key) const { } void VideoFrameMetadata::SetBoolean(Key key, bool value) { - dictionary_.SetBooleanWithoutPathExpansion(ToInternalKey(key), value); + dictionary_.SetKey(ToInternalKey(key), base::Value(value)); } void VideoFrameMetadata::SetInteger(Key key, int value) { diff --git a/services/preferences/pref_service_factory_unittest.cc b/services/preferences/pref_service_factory_unittest.cc index 9166e96a0d1f62..a87533999bbc42 100644 --- a/services/preferences/pref_service_factory_unittest.cc +++ b/services/preferences/pref_service_factory_unittest.cc @@ -419,7 +419,7 @@ TEST_F(PrefServiceFactoryTest, MultipleClients_SubPrefUpdates_Basic) { EXPECT_TRUE(out); }, [](ScopedDictionaryPrefUpdate* update) { - (*update)->SetBooleanWithoutPathExpansion("key.for.boolean", false); + (*update)->SetKey("key.for.boolean", base::Value(false)); bool out = 0; ASSERT_TRUE( (*update)->GetBooleanWithoutPathExpansion("key.for.boolean", &out)); diff --git a/services/preferences/public/cpp/dictionary_value_update.cc b/services/preferences/public/cpp/dictionary_value_update.cc index afd7ae85450f68..4fb6e719958587 100644 --- a/services/preferences/public/cpp/dictionary_value_update.cc +++ b/services/preferences/public/cpp/dictionary_value_update.cc @@ -86,6 +86,15 @@ std::unique_ptr DictionaryValueUpdate::SetDictionary( report_update_, dictionary_value, ConcatPath(path_, path)); } +void DictionaryValueUpdate::SetKey(base::StringPiece key, base::Value value) { + auto found = value_->FindKey(key); + if (found != value_->DictEnd() && found->second == value) + return; + + RecordKey(key); + value_->SetKey(key, std::move(value)); +} + void DictionaryValueUpdate::SetWithoutPathExpansion( base::StringPiece key, std::unique_ptr in_value) { @@ -98,12 +107,6 @@ void DictionaryValueUpdate::SetWithoutPathExpansion( value_->SetWithoutPathExpansion(key, std::move(in_value)); } -void DictionaryValueUpdate::SetBooleanWithoutPathExpansion( - base::StringPiece path, - bool in_value) { - SetWithoutPathExpansion(path, base::MakeUnique(in_value)); -} - void DictionaryValueUpdate::SetIntegerWithoutPathExpansion( base::StringPiece path, int in_value) { diff --git a/services/preferences/public/cpp/dictionary_value_update.h b/services/preferences/public/cpp/dictionary_value_update.h index fb3dc4d330213a..2de375074ff2ed 100644 --- a/services/preferences/public/cpp/dictionary_value_update.h +++ b/services/preferences/public/cpp/dictionary_value_update.h @@ -66,11 +66,11 @@ class DictionaryValueUpdate { // Like Set(), but without special treatment of '.'. This allows e.g. URLs to // be used as paths. + void SetKey(base::StringPiece key, base::Value value); void SetWithoutPathExpansion(base::StringPiece key, std::unique_ptr in_value); // Convenience forms of SetWithoutPathExpansion(). - void SetBooleanWithoutPathExpansion(base::StringPiece path, bool in_value); void SetIntegerWithoutPathExpansion(base::StringPiece path, int in_value); void SetDoubleWithoutPathExpansion(base::StringPiece path, double in_value); void SetStringWithoutPathExpansion(base::StringPiece path, diff --git a/tools/gn/desc_builder.cc b/tools/gn/desc_builder.cc index 965ec921f10a12..bcf4dc6c90660b 100644 --- a/tools/gn/desc_builder.cc +++ b/tools/gn/desc_builder.cc @@ -273,13 +273,12 @@ class TargetDescBuilder : public BaseDescBuilder { target_->visibility().AsValue()); if (what(variables::kTestonly)) - res->SetBooleanWithoutPathExpansion(variables::kTestonly, - target_->testonly()); + res->SetKey(variables::kTestonly, base::Value(target_->testonly())); if (is_binary_output) { if (what(variables::kCheckIncludes)) - res->SetBooleanWithoutPathExpansion(variables::kCheckIncludes, - target_->check_includes()); + res->SetKey(variables::kCheckIncludes, + base::Value(target_->check_includes())); if (what(variables::kAllowCircularIncludesFrom)) { auto labels = base::MakeUnique(); diff --git a/tools/ipc_fuzzer/fuzzer/fuzzer.cc b/tools/ipc_fuzzer/fuzzer/fuzzer.cc index 64056b0b9ab521..5581c1dc8c94d8 100644 --- a/tools/ipc_fuzzer/fuzzer/fuzzer.cc +++ b/tools/ipc_fuzzer/fuzzer/fuzzer.cc @@ -590,7 +590,7 @@ struct FuzzTraits { case base::Value::Type::BOOLEAN: { bool tmp; fuzzer->FuzzBool(&tmp); - p->SetBooleanWithoutPathExpansion(property, tmp); + p->SetKey(property, base::Value(tmp)); break; } case base::Value::Type::INTEGER: { diff --git a/tools/json_schema_compiler/test/simple_api_unittest.cc b/tools/json_schema_compiler/test/simple_api_unittest.cc index ef6f9e20518dbf..7a37dfb3682cdc 100644 --- a/tools/json_schema_compiler/test/simple_api_unittest.cc +++ b/tools/json_schema_compiler/test/simple_api_unittest.cc @@ -17,7 +17,7 @@ static std::unique_ptr CreateTestTypeDictionary() { value->SetDoubleWithoutPathExpansion("number", 1.1); value->SetIntegerWithoutPathExpansion("integer", 4); value->SetStringWithoutPathExpansion("string", "bling"); - value->SetBooleanWithoutPathExpansion("boolean", true); + value->SetKey("boolean", base::Value(true)); return value; }