Skip to content

Commit

Permalink
Remove base::Value::SetBooleanWithoutPathExpansion
Browse files Browse the repository at this point in the history
This change removes the deprecated SetBooleanWithoutPathExpansion from
base::Value. Existing usages are replaced by SetKey(key, Value(bool)).

Bug: 646113
Change-Id: I4d7f1a60909765ec6a956360312c11b32173429f
Reviewed-on: https://chromium-review.googlesource.com/590448
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: Brett Wilson <brettw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491549}
  • Loading branch information
jdoerrie authored and Commit Bot committed Aug 2, 2017
1 parent 47f0193 commit 1e4eeb8
Show file tree
Hide file tree
Showing 50 changed files with 157 additions and 158 deletions.
2 changes: 1 addition & 1 deletion base/trace_event/trace_event_argument.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ std::unique_ptr<base::Value> 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);
}
Expand Down
5 changes: 0 additions & 5 deletions base/values.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Value>(in_value));
}

Value* DictionaryValue::SetIntegerWithoutPathExpansion(StringPiece path,
int in_value) {
return SetWithoutPathExpansion(path, MakeUnique<Value>(in_value));
Expand Down
19 changes: 18 additions & 1 deletion base/values.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Value> 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<DictionaryValue> in_value);
// DEPRECATED, use Value::SetKey(path, Value(Type::LIST)) instead.
ListValue* SetListWithoutPathExpansion(StringPiece path,
std::unique_ptr<ListValue> in_value);

Expand Down Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions base/values_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/apps/drive/drive_app_mapping.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ std::unique_ptr<base::DictionaryValue> CreateInfoDict(

// Only writes non-default value.
if (generated)
dict->SetBooleanWithoutPathExpansion(kKeyGenerated, true);
dict->SetKey(kKeyGenerated, base::Value(true));
return dict;
}

Expand Down
11 changes: 5 additions & 6 deletions chrome/browser/chromeos/file_system_provider/registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -69,8 +69,7 @@ void Registry::RememberFileSystem(
auto watcher = base::MakeUnique<base::DictionaryValue>();
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<base::ListValue>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ 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);

// Remember watchers.
auto watcher_value = base::MakeUnique<base::DictionaryValue>();
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<base::ListValue>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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(
Expand Down
7 changes: 3 additions & 4 deletions chrome/browser/chromeos/options/vpn_config_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -906,8 +905,8 @@ void VPNConfigView::SetConfigProperties(
NOTREACHED();
break;
}
properties->SetBooleanWithoutPathExpansion(
shill::kSaveCredentialsProperty, GetSaveCredentials());
properties->SetKey(shill::kSaveCredentialsProperty,
base::Value(GetSaveCredentials()));
}

void VPNConfigView::Refresh() {
Expand Down
15 changes: 7 additions & 8 deletions chrome/browser/chromeos/options/wifi_config_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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()) {
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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());
Expand Down
7 changes: 3 additions & 4 deletions chrome/browser/chromeos/options/wimax_config_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,16 @@ 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);

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,
Expand Down
7 changes: 3 additions & 4 deletions chrome/browser/chromeos/platform_keys/key_permissions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,8 @@ bool NotificationsGetAllFunction::RunNotificationsApi() {

for (std::set<std::string>::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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ class PlatformKeysTest : public ExtensionApiTest {
{
std::unique_ptr<base::DictionaryValue> 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void SupervisedUserSharedSettingsService::SetValueInternal(
key, base::MakeUnique<base::DictionaryValue>());
}
dict->SetWithoutPathExpansion(kValue, base::MakeUnique<base::Value>(value));
dict->SetBooleanWithoutPathExpansion(kAcknowledged, acknowledged);
dict->SetKey(kAcknowledged, base::Value(acknowledged));

if (!sync_processor_)
return;
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -348,8 +348,9 @@ syncer::SyncError SupervisedUserSharedSettingsService::ProcessSyncChanges(
std::unique_ptr<Value> 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: {
Expand Down
Loading

0 comments on commit 1e4eeb8

Please sign in to comment.