Skip to content

Commit

Permalink
Replace GetList/TakeList with GetListDeprecated/TakeListDeprecated
Browse files Browse the repository at this point in the history
Chromium change:

https://source.chromium.org/chromium/chromium/src/+/60e6b2d9538d743e7aaac58f46e996e6031b8a86

commit 60e6b2d9538d743e7aaac58f46e996e6031b8a86
Author: Daniel Cheng <[email protected]>
Date:   Sat Feb 5 01:08:46 2022 +0000

    base::Value: Remove GetList(), TakeList(), and TakeDict().

    Also remove (a lot of) new uses of GetList() that crept in. There is
    also one use of GetList() in a third-party code generator that was
    missed in previous iterations. Since the file is checked directly into
    Chrome, the usage is removed in this CL, but upstream will need to be
    updated before the next roll.

    Bug: 1291666, 1294416
  • Loading branch information
emerick authored and mariospr committed Mar 7, 2022
1 parent beafcdf commit fe9b3d9
Show file tree
Hide file tree
Showing 93 changed files with 283 additions and 265 deletions.
2 changes: 1 addition & 1 deletion browser/brave_ads/ads_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2100,7 +2100,7 @@ void AdsServiceImpl::RecordP2AEvent(const std::string& name,
break;
}

for (auto& item : list->GetList()) {
for (auto& item : list->GetListDeprecated()) {
RecordInWeeklyStorageAndEmitP2AHistogramAnswer(profile_->GetPrefs(),
item.GetString());
}
Expand Down
10 changes: 6 additions & 4 deletions browser/brave_shields/ad_block_service_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2228,8 +2228,9 @@ IN_PROC_BROWSER_TEST_F(DefaultCookieListFlagEnabledTest, ListEnabled) {
->GetRegionalLists();
// Although never explicitly enabled, it should be presented as enabled by
// default at first.
ASSERT_EQ(1UL, lists->GetList().size());
EXPECT_EQ(true, lists->GetList()[0].FindKey("enabled")->GetBool());
ASSERT_EQ(1UL, lists->GetListDeprecated().size());
EXPECT_EQ(true,
lists->GetListDeprecated()[0].FindKey("enabled")->GetBool());
}

// Enable the filter list, and then disable it again.
Expand All @@ -2253,7 +2254,8 @@ IN_PROC_BROWSER_TEST_F(DefaultCookieListFlagEnabledTest, ListEnabled) {
->regional_service_manager()
->GetRegionalLists();
// It should be actually disabled now.
ASSERT_EQ(1UL, lists->GetList().size());
EXPECT_EQ(false, lists->GetList()[0].FindKey("enabled")->GetBool());
ASSERT_EQ(1UL, lists->GetListDeprecated().size());
EXPECT_EQ(false,
lists->GetListDeprecated()[0].FindKey("enabled")->GetBool());
}
}
2 changes: 1 addition & 1 deletion browser/brave_wallet/external_wallets_importer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void ExternalWalletsImporter::GetMnemonic(bool is_legacy_crypto_wallets,

const std::string* mnemonic = nullptr;
absl::optional<int> number_of_accounts = absl::nullopt;
for (const auto& keyring : keyrings->GetList()) {
for (const auto& keyring : keyrings->GetListDeprecated()) {
DCHECK(keyring.is_dict());
const auto* type = keyring.FindStringKey("type");
if (!type) {
Expand Down
6 changes: 3 additions & 3 deletions browser/brave_wallet/keyring_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1600,13 +1600,13 @@ TEST_F(KeyringServiceUnitTest, ImportedAccounts) {
KeyringService::GetPrefForKeyring(GetPrefs(), kImportedAccounts,
mojom::kDefaultKeyringId);
ASSERT_TRUE(imported_accounts_value);
EXPECT_EQ(imported_accounts_value->GetList()[0]
EXPECT_EQ(imported_accounts_value->GetListDeprecated()[0]
.FindKey(kAccountAddress)
->GetString(),
imported_accounts[0].address);
// private key is encrypted
const std::string encrypted_private_key =
imported_accounts_value->GetList()[0]
imported_accounts_value->GetListDeprecated()[0]
.FindKey(kEncryptedPrivateKey)
->GetString();
EXPECT_FALSE(encrypted_private_key.empty());
Expand Down Expand Up @@ -1676,7 +1676,7 @@ TEST_F(KeyringServiceUnitTest, ImportedAccountFromJson) {
mojom::kDefaultKeyringId);
ASSERT_TRUE(imported_accounts_value);
const std::string encrypted_private_key =
imported_accounts_value->GetList()[0]
imported_accounts_value->GetListDeprecated()[0]
.FindKey(kEncryptedPrivateKey)
->GetString();
EXPECT_FALSE(encrypted_private_key.empty());
Expand Down
2 changes: 1 addition & 1 deletion browser/net/brave_network_audit_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class BraveNetworkAuditTest : public InProcessBrowserTest {
// Ensure it has an "events" property.
base::Value* events = main->FindListPath("events");
ASSERT_TRUE(events && events->is_list());
ASSERT_FALSE(events->GetList().empty());
ASSERT_FALSE(events->GetListDeprecated().empty());

EXPECT_TRUE(PerformNetworkAuditProcess(events))
<< "network-audit FAILED. Import " << net_log_path_.AsUTF8Unsafe()
Expand Down
4 changes: 2 additions & 2 deletions browser/themes/brave_theme_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
TEST(BraveThemeServiceTest, GetBraveThemeListTest) {
dark_mode::SetUseSystemDarkModeEnabledForTest(true);
base::Value list = dark_mode::GetBraveDarkModeTypeList();
EXPECT_EQ(3UL, list.GetList().size());
EXPECT_EQ(3UL, list.GetListDeprecated().size());

dark_mode::SetUseSystemDarkModeEnabledForTest(false);
list = dark_mode::GetBraveDarkModeTypeList();
EXPECT_EQ(2UL, list.GetList().size());
EXPECT_EQ(2UL, list.GetListDeprecated().size());
}

TEST(BraveThemePropertiesTest, LastBraveThemeIDTest) {
Expand Down
2 changes: 1 addition & 1 deletion browser/ui/omnibox/brave_omnibox_client_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ BraveOmniboxClientImpl::BraveOmniboxClientImpl(
// Record initial search count p3a value.
const base::Value* search_p3a =
profile_->GetPrefs()->GetList(kSearchCountPrefName);
if (search_p3a->GetList().size() == 0) {
if (search_p3a->GetListDeprecated().size() == 0) {
RecordSearchEventP3A(0);
}
}
Expand Down
4 changes: 2 additions & 2 deletions browser/ui/webui/brave_rewards_internals_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -445,14 +445,14 @@ void RewardsInternalsDOMHandler::OnGetAdDiagnostics(const bool success,
if (success && !json.empty()) {
absl::optional<base::Value> serialized_json = base::JSONReader::Read(json);
if (serialized_json && serialized_json->is_list() &&
!serialized_json->GetList().empty()) {
!serialized_json->GetListDeprecated().empty()) {
diagnostics = std::move(*serialized_json);
}
}

#if DCHECK_IS_ON()
DCHECK(diagnostics.is_list()) << "Diagnostics should be a list";
for (const auto& entry : diagnostics.GetList()) {
for (const auto& entry : diagnostics.GetListDeprecated()) {
DCHECK(entry.is_dict()) << "Diagnostics entry should be a dictionary";
DCHECK(entry.FindKey("key")) << "Diagnostics entry should have 'key' key";
DCHECK(entry.FindKey("value"))
Expand Down
34 changes: 17 additions & 17 deletions browser/ui/webui/settings/brave_wallet_handler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ TEST(TestBraveWalletHandler, RemoveEthereumChain) {
args.Append(base::Value("id"));
args.Append(base::Value("chain_id"));

handler.RemoveEthereumChain(args.GetList());
handler.RemoveEthereumChain(args.GetListDeprecated());
const auto& data = *handler.web_ui()->call_data()[0];
ASSERT_TRUE(data.arg3()->is_bool());
EXPECT_EQ(data.arg3()->GetBool(), true);
Expand Down Expand Up @@ -202,7 +202,7 @@ TEST(TestBraveWalletHandler, AddEthereumChain) {
handler.SetEthChainIdInterceptor(chain1.rpc_urls.front(), "0x999");
base::RunLoop loop;
handler.SetChainCallbackForTesting(loop.QuitClosure());
handler.AddEthereumChain(args.GetList());
handler.AddEthereumChain(args.GetListDeprecated());
loop.Run();
{
std::vector<brave_wallet::mojom::NetworkInfoPtr> result;
Expand All @@ -215,7 +215,7 @@ TEST(TestBraveWalletHandler, AddEthereumChain) {
handler.prefs()->GetDictionary(kBraveWalletUserAssets);
const base::Value* list = assets_pref->FindKey("0x999");
ASSERT_TRUE(list->is_list());
base::Value::ConstListView asset_list = list->GetList();
base::Value::ConstListView asset_list = list->GetListDeprecated();
ASSERT_EQ(asset_list.size(), 1u);

EXPECT_EQ(*asset_list[0].FindStringKey("contract_address"), "");
Expand All @@ -230,12 +230,12 @@ TEST(TestBraveWalletHandler, AddEthereumChain) {
auto args2 = base::ListValue();
args2.Append(base::Value("id"));
args2.Append(base::Value(json_string));
handler.AddEthereumChain(args2.GetList());
handler.AddEthereumChain(args2.GetListDeprecated());
const auto& data = *handler.web_ui()->call_data()[1];
ASSERT_TRUE(data.arg1()->is_string());
EXPECT_EQ(data.arg1()->GetString(), "id");

auto arg3_list = data.arg3()->GetList();
auto arg3_list = data.arg3()->GetListDeprecated();
ASSERT_EQ(arg3_list.size(), 2UL);
EXPECT_EQ(arg3_list[0].GetBool(), false);
std::string error_message =
Expand Down Expand Up @@ -274,13 +274,13 @@ TEST(TestBraveWalletHandler, AddEthereumChainWrongNetwork) {
handler.SetEthChainIdInterceptor(chain1.rpc_urls.front(), "0x11");
base::RunLoop loop;
handler.SetChainCallbackForTesting(loop.QuitClosure());
handler.AddEthereumChain(args.GetList());
handler.AddEthereumChain(args.GetListDeprecated());
loop.Run();
const auto& data = *handler.web_ui()->call_data()[0];
ASSERT_TRUE(data.arg1()->is_string());
EXPECT_EQ(data.arg1()->GetString(), "id");

auto arg3_list = data.arg3()->GetList();
auto arg3_list = data.arg3()->GetListDeprecated();
ASSERT_EQ(arg3_list.size(), 2UL);
EXPECT_EQ(arg3_list[0].GetBool(), false);
std::string error_message = l10n_util::GetStringFUTF8(
Expand All @@ -300,7 +300,7 @@ TEST(TestBraveWalletHandler, AddEthereumChainFail) {
auto args = base::ListValue();
args.Append(base::Value("id"));
args.Append(base::Value(""));
handler.AddEthereumChain(args.GetList());
handler.AddEthereumChain(args.GetListDeprecated());

{
std::vector<brave_wallet::mojom::NetworkInfoPtr> result;
Expand All @@ -311,12 +311,12 @@ TEST(TestBraveWalletHandler, AddEthereumChainFail) {
auto args2 = base::ListValue();
args2.Append(base::Value("id"));
args2.Append(base::Value(R"({"chain_name\":"a","rpcUrl":["http://u.c"]})"));
handler.AddEthereumChain(args2.GetList());
handler.AddEthereumChain(args2.GetListDeprecated());
const auto& data = *handler.web_ui()->call_data()[0];
ASSERT_TRUE(data.arg1()->is_string());
EXPECT_EQ(data.arg1()->GetString(), "id");

auto arg3_list = data.arg3()->GetList();
auto arg3_list = data.arg3()->GetListDeprecated();
ASSERT_EQ(arg3_list.size(), 2UL);
EXPECT_EQ(arg3_list[0].GetBool(), false);
std::string error_message =
Expand Down Expand Up @@ -358,21 +358,21 @@ TEST(TestBraveWalletHandler, GetNetworkList) {
}
auto args = base::ListValue();
args.Append(base::Value("id"));
handler.GetCustomNetworksList(args.GetList());
handler.GetCustomNetworksList(args.GetListDeprecated());
const auto& data = *handler.web_ui()->call_data()[0];
ASSERT_TRUE(data.arg1()->is_string());
EXPECT_EQ(data.arg1()->GetString(), "id");
ASSERT_TRUE(data.arg3()->is_string());
absl::optional<base::Value> expected_list =
base::JSONReader::Read(data.arg3()->GetString());
ASSERT_TRUE(expected_list);
auto expected_chain1 =
brave_wallet::ValueToEthNetworkInfo(expected_list.value().GetList()[0]);
auto expected_chain1 = brave_wallet::ValueToEthNetworkInfo(
expected_list.value().GetListDeprecated()[0]);
ASSERT_TRUE(expected_chain1);
EXPECT_EQ(*expected_chain1, chain1);

auto expected_chain2 =
brave_wallet::ValueToEthNetworkInfo(expected_list.value().GetList()[1]);
auto expected_chain2 = brave_wallet::ValueToEthNetworkInfo(
expected_list.value().GetListDeprecated()[1]);
ASSERT_TRUE(expected_chain2);
EXPECT_EQ(*expected_chain2, chain2);
}
Expand Down Expand Up @@ -413,7 +413,7 @@ TEST(TestBraveWalletHandler, SetActiveNetwork) {
args.Append(base::Value("id"));
args.Append(base::Value("chain_id2"));

handler.SetActiveNetwork(args.GetList());
handler.SetActiveNetwork(args.GetListDeprecated());
const auto& data = *handler.web_ui()->call_data()[0];
ASSERT_TRUE(data.arg3()->is_bool());
EXPECT_EQ(data.arg3()->GetBool(), true);
Expand All @@ -427,7 +427,7 @@ TEST(TestBraveWalletHandler, SetActiveNetwork) {
args.Append(base::Value("id"));
args.Append(base::Value("unknown_chain_id"));

handler.SetActiveNetwork(args.GetList());
handler.SetActiveNetwork(args.GetListDeprecated());
const auto& data = *handler.web_ui()->call_data()[1];
ASSERT_TRUE(data.arg3()->is_bool());
EXPECT_EQ(data.arg3()->GetBool(), false);
Expand Down
2 changes: 1 addition & 1 deletion chromium_src/chrome/browser/importer/importer_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void AddChromeToProfiles(std::vector<importer::SourceProfile>* profiles,
base::ListValue* chrome_profiles,
const base::FilePath& user_data_folder,
const std::string& brand) {
for (const auto& value : chrome_profiles->GetList()) {
for (const auto& value : chrome_profiles->GetListDeprecated()) {
const base::DictionaryValue* dict;
if (!value.GetAsDictionary(&dict))
continue;
Expand Down
10 changes: 5 additions & 5 deletions components/binance/browser/binance_json_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ bool BinanceJSONParser::GetAccountBalancesFromJSON(
return false;
}

for (const base::Value &val : pv_arr->GetList()) {
for (const base::Value& val : pv_arr->GetListDeprecated()) {
const base::Value* asset = val.FindKey("asset");
const base::Value* free_amount = val.FindKey("free");
const base::Value* btc_val = val.FindKey("btcValuation");
Expand Down Expand Up @@ -323,14 +323,14 @@ bool BinanceJSONParser::GetConvertAssetsFromJSON(const std::string& json,

const base::Value* data_arr = records_v->FindKey("data");
if (data_arr && data_arr->is_list()) {
for (const base::Value &val : data_arr->GetList()) {
for (const base::Value& val : data_arr->GetListDeprecated()) {
const base::Value* asset_code = val.FindKey("assetCode");
if (asset_code && asset_code->is_string()) {
std::vector<std::map<std::string, std::string>> sub_selectors;
std::string asset_symbol = asset_code->GetString();
const base::Value* selectors = val.FindKey("subSelector");
if (selectors && selectors->is_list()) {
for (const base::Value &selector : selectors->GetList()) {
for (const base::Value& selector : selectors->GetListDeprecated()) {
std::map<std::string, std::string> sub_selector;
const base::Value* sub_code = selector.FindKey("assetCode");
const base::Value* min_limit = selector.FindKey("perTimeMinLimit");
Expand Down Expand Up @@ -430,7 +430,7 @@ bool BinanceJSONParser::GetCoinNetworksFromJSON(
return false;
}

for (const base::Value &coin : data_arr->GetList()) {
for (const base::Value& coin : data_arr->GetListDeprecated()) {
const base::Value* coin_name = coin.FindKey("coin");
if (!coin_name || !coin_name->is_string()) {
return false;
Expand All @@ -441,7 +441,7 @@ bool BinanceJSONParser::GetCoinNetworksFromJSON(
return false;
}

for (const base::Value &network : network_list->GetList()) {
for (const base::Value& network : network_list->GetListDeprecated()) {
const base::Value* network_name = network.FindKey("network");
const base::Value* is_default = network.FindKey("isDefault");
const bool default_valid =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void ResourceComponent::OnGetManifest(const std::string& component_id,
return;
}

for (const auto& resource_value : resource_values->GetList()) {
for (const auto& resource_value : resource_values->GetListDeprecated()) {
ResourceInfo resource;

const std::string* id = resource_value.FindStringPath(kResourceIdPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ParseMappings(const base::StringPiece entities, bool discard_irrelevant) {
}

// Collect the mappings
for (auto& entity : document->GetList()) {
for (auto& entity : document->GetListDeprecated()) {
const std::string* entity_name = entity.FindStringPath("name");
if (!entity_name)
continue;
Expand All @@ -54,7 +54,7 @@ ParseMappings(const base::StringPiece entities, bool discard_irrelevant) {
if (!entity_domains)
continue;

for (auto& entity_domain_it : entity_domains->GetList()) {
for (auto& entity_domain_it : entity_domains->GetListDeprecated()) {
if (!entity_domain_it.is_string()) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ bool BraveReferralsHeaders::GetMatchingReferralHeaders(
LOG(WARNING) << "Failed to retrieve 'headers' key from referral headers";
continue;
}
for (const auto& domain_value : domains_list->GetList()) {
for (const auto& domain_value : domains_list->GetListDeprecated()) {
URLPattern url_pattern(URLPattern::SCHEME_HTTPS |
URLPattern::SCHEME_HTTP);
url_pattern.SetScheme("*");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,20 @@ void RewardsNotificationServiceImpl::ReadRewardsNotificationsJSON() {
return;
}

ReadRewardsNotifications(list->GetList());
ReadRewardsNotifications(list->GetListDeprecated());
return;
}

base::Value* notifications =
dictionary->FindKeyOfType("notifications", base::Value::Type::LIST);
if (notifications) {
ReadRewardsNotifications(notifications->GetList());
ReadRewardsNotifications(notifications->GetListDeprecated());
}

base::Value* displayed =
dictionary->FindKeyOfType("displayed", base::Value::Type::LIST);
if (displayed) {
for (const auto& it : displayed->GetList()) {
for (const auto& it : displayed->GetListDeprecated()) {
rewards_notifications_displayed_.push_back(it.GetString());
}
}
Expand Down Expand Up @@ -204,7 +204,7 @@ void RewardsNotificationServiceImpl::ReadRewardsNotifications(
const base::Value* args =
it->FindKeyOfType("args", base::Value::Type::LIST);
if (args) {
for (auto& arg : args->GetList()) {
for (auto& arg : args->GetListDeprecated()) {
std::string arg_string = arg.GetString();
notification_args.push_back(arg_string);
}
Expand Down
2 changes: 1 addition & 1 deletion components/brave_rewards/browser/rewards_p3a.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void ExtractAndLogStats(const base::DictionaryValue& dict) {
if (!grants_value->is_list()) {
LOG(WARNING) << "Bad grant value in ledger_state.";
} else {
const auto& grants = grants_value->GetList();
const auto& grants = grants_value->GetListDeprecated();
// Sum all grants.
for (const auto& grant : grants) {
if (!grant.is_dict()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ std::vector<double> GetSiteBannerTipOptions(content::WebContents* context) {
content::ISOLATED_WORLD_ID_CONTENT_END).ExtractList();

std::vector<double> result;
for (const auto& value : options.GetList()) {
for (const auto& value : options.GetListDeprecated()) {
result.push_back(value.GetDouble());
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ base::Value AdBlockRegionalServiceManager::HiddenClassIdSelectors(
it->second->HiddenClassIdSelectors(classes, ids, exceptions);
DCHECK(next_value.is_list());

for (auto i = next_value.GetList().begin(); i < next_value.GetList().end();
i++) {
for (auto i = next_value.GetListDeprecated().begin();
i < next_value.GetListDeprecated().end(); i++) {
first_value.Append(std::move(*i));
}
}
Expand Down
Loading

0 comments on commit fe9b3d9

Please sign in to comment.