summaryrefslogtreecommitdiff
path: root/chromium/components/autofill/core/browser/geo
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-09-01 11:08:40 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-10-01 12:16:21 +0000
commit03c549e0392f92c02536d3f86d5e1d8dfa3435ac (patch)
treefe49d170a929b34ba82cd10db1a0bd8e3760fa4b /chromium/components/autofill/core/browser/geo
parent5d013f5804a0d91fcf6c626b2d6fb6eca5c845b0 (diff)
downloadqtwebengine-chromium-03c549e0392f92c02536d3f86d5e1d8dfa3435ac.tar.gz
BASELINE: Update Chromium to 91.0.4472.160
Change-Id: I0def1f08a2412aeed79a9ab95dd50eb5c3f65f31 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/autofill/core/browser/geo')
-rw-r--r--chromium/components/autofill/core/browser/geo/address_i18n.cc4
-rw-r--r--chromium/components/autofill/core/browser/geo/address_i18n.h4
-rw-r--r--chromium/components/autofill/core/browser/geo/alternative_state_name_map.cc4
-rw-r--r--chromium/components/autofill/core/browser/geo/alternative_state_name_map.h9
-rw-r--r--chromium/components/autofill/core/browser/geo/alternative_state_name_map_unittest.cc26
-rw-r--r--chromium/components/autofill/core/browser/geo/alternative_state_name_map_updater_unittest.cc64
-rw-r--r--chromium/components/autofill/core/browser/geo/autofill_country.cc6
-rw-r--r--chromium/components/autofill/core/browser/geo/autofill_country.h11
-rw-r--r--chromium/components/autofill/core/browser/geo/autofill_country_unittest.cc10
-rw-r--r--chromium/components/autofill/core/browser/geo/country_names.cc4
-rw-r--r--chromium/components/autofill/core/browser/geo/country_names.h5
-rw-r--r--chromium/components/autofill/core/browser/geo/country_names_for_locale.cc8
-rw-r--r--chromium/components/autofill/core/browser/geo/country_names_for_locale.h3
-rw-r--r--chromium/components/autofill/core/browser/geo/country_names_for_locale_unittest.cc19
-rw-r--r--chromium/components/autofill/core/browser/geo/country_names_unittest.cc54
-rw-r--r--chromium/components/autofill/core/browser/geo/phone_number_i18n.cc60
-rw-r--r--chromium/components/autofill/core/browser/geo/phone_number_i18n.h49
-rw-r--r--chromium/components/autofill/core/browser/geo/phone_number_i18n_fuzzer.cc9
-rw-r--r--chromium/components/autofill/core/browser/geo/phone_number_i18n_unittest.cc121
-rw-r--r--chromium/components/autofill/core/browser/geo/state_names.cc18
-rw-r--r--chromium/components/autofill/core/browser/geo/state_names.h13
21 files changed, 237 insertions, 264 deletions
diff --git a/chromium/components/autofill/core/browser/geo/address_i18n.cc b/chromium/components/autofill/core/browser/geo/address_i18n.cc
index d02f02c6a89..3843023f34c 100644
--- a/chromium/components/autofill/core/browser/geo/address_i18n.cc
+++ b/chromium/components/autofill/core/browser/geo/address_i18n.cc
@@ -19,7 +19,7 @@ namespace i18n {
namespace {
-base::string16 GetInfoHelper(const AutofillProfile& profile,
+std::u16string GetInfoHelper(const AutofillProfile& profile,
const std::string& app_locale,
const AutofillType& type) {
return profile.GetInfo(type, app_locale);
@@ -31,7 +31,7 @@ using ::i18n::addressinput::AddressData;
using ::i18n::addressinput::AddressField;
std::unique_ptr<AddressData> CreateAddressData(
- const base::RepeatingCallback<base::string16(const AutofillType&)>&
+ const base::RepeatingCallback<std::u16string(const AutofillType&)>&
get_info) {
auto address_data = std::make_unique<AddressData>();
address_data->recipient =
diff --git a/chromium/components/autofill/core/browser/geo/address_i18n.h b/chromium/components/autofill/core/browser/geo/address_i18n.h
index 87e25a534a4..16b5cc8db89 100644
--- a/chromium/components/autofill/core/browser/geo/address_i18n.h
+++ b/chromium/components/autofill/core/browser/geo/address_i18n.h
@@ -6,9 +6,9 @@
#define COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_ADDRESS_I18N_H_
#include <memory>
+#include <string>
#include "base/callback_forward.h"
-#include "base/strings/string16.h"
#include "components/autofill/core/browser/field_types.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_field.h"
@@ -28,7 +28,7 @@ namespace i18n {
// Creates an AddressData object for internationalized address display or
// validation using |get_info| for field values.
std::unique_ptr<::i18n::addressinput::AddressData> CreateAddressData(
- const base::RepeatingCallback<base::string16(const AutofillType&)>&
+ const base::RepeatingCallback<std::u16string(const AutofillType&)>&
get_info);
// Creates an |AddressData| from |profile|.
diff --git a/chromium/components/autofill/core/browser/geo/alternative_state_name_map.cc b/chromium/components/autofill/core/browser/geo/alternative_state_name_map.cc
index 614000521de..a6c9e3ad499 100644
--- a/chromium/components/autofill/core/browser/geo/alternative_state_name_map.cc
+++ b/chromium/components/autofill/core/browser/geo/alternative_state_name_map.cc
@@ -30,7 +30,7 @@ AlternativeStateNameMap* AlternativeStateNameMap::GetInstance() {
// static
AlternativeStateNameMap::StateName AlternativeStateNameMap::NormalizeStateName(
const StateName& text) {
- base::string16 normalized_text;
+ std::u16string normalized_text;
base::RemoveChars(text.value(), base::ASCIIToUTF16(kCharsToStrip),
&normalized_text);
return StateName(normalized_text);
@@ -40,7 +40,7 @@ AlternativeStateNameMap::StateName AlternativeStateNameMap::NormalizeStateName(
base::Optional<AlternativeStateNameMap::CanonicalStateName>
AlternativeStateNameMap::GetCanonicalStateName(
const std::string& country_code,
- const base::string16& state_name) {
+ const std::u16string& state_name) {
return AlternativeStateNameMap::GetInstance()->GetCanonicalStateName(
AlternativeStateNameMap::CountryCode(country_code),
AlternativeStateNameMap::StateName(state_name));
diff --git a/chromium/components/autofill/core/browser/geo/alternative_state_name_map.h b/chromium/components/autofill/core/browser/geo/alternative_state_name_map.h
index 5af1556d6ec..0b3687e2aee 100644
--- a/chromium/components/autofill/core/browser/geo/alternative_state_name_map.h
+++ b/chromium/components/autofill/core/browser/geo/alternative_state_name_map.h
@@ -5,13 +5,14 @@
#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_ALTERNATIVE_STATE_NAME_MAP_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_ALTERNATIVE_STATE_NAME_MAP_H_
+#include <string>
+
#include "components/autofill/core/browser/proto/states.pb.h"
#include "base/i18n/case_conversion.h"
#include "base/no_destructor.h"
#include "base/optional.h"
#include "base/sequence_checker.h"
-#include "base/strings/string16.h"
#include "base/types/strong_alias.h"
namespace autofill {
@@ -71,13 +72,13 @@ class AlternativeStateNameMap {
// Represents either a canonical state name, or an abbreviation, or an
// alternative name or normalized state name from the profile.
- using StateName = base::StrongAlias<class StateNameTag, base::string16>;
+ using StateName = base::StrongAlias<class StateNameTag, std::u16string>;
// States can be represented as different strings (different spellings,
// translations, abbreviations). All representations of a single state in a
// single country are mapped to the same canonical name.
using CanonicalStateName =
- base::StrongAlias<class CanonicalStateNameTag, base::string16>;
+ base::StrongAlias<class CanonicalStateNameTag, std::u16string>;
static AlternativeStateNameMap* GetInstance();
@@ -89,7 +90,7 @@ class AlternativeStateNameMap {
// |state_name| if present.
static base::Optional<AlternativeStateNameMap::CanonicalStateName>
GetCanonicalStateName(const std::string& country_code,
- const base::string16& state_name);
+ const std::u16string& state_name);
~AlternativeStateNameMap() = delete;
AlternativeStateNameMap(const AlternativeStateNameMap&) = delete;
diff --git a/chromium/components/autofill/core/browser/geo/alternative_state_name_map_unittest.cc b/chromium/components/autofill/core/browser/geo/alternative_state_name_map_unittest.cc
index 04523a93b18..15cea81e118 100644
--- a/chromium/components/autofill/core/browser/geo/alternative_state_name_map_unittest.cc
+++ b/chromium/components/autofill/core/browser/geo/alternative_state_name_map_unittest.cc
@@ -34,14 +34,11 @@ TEST(AlternativeStateNameMapTest, StateCanonicalString) {
base::nullopt);
}
- EXPECT_EQ(AlternativeStateNameMap::GetCanonicalStateName(
- "US", base::ASCIIToUTF16("Bavaria")),
+ EXPECT_EQ(AlternativeStateNameMap::GetCanonicalStateName("US", u"Bavaria"),
base::nullopt);
- EXPECT_EQ(AlternativeStateNameMap::GetCanonicalStateName(
- "DE", base::ASCIIToUTF16("")),
+ EXPECT_EQ(AlternativeStateNameMap::GetCanonicalStateName("DE", u""),
base::nullopt);
- EXPECT_EQ(AlternativeStateNameMap::GetCanonicalStateName(
- "", base::ASCIIToUTF16("")),
+ EXPECT_EQ(AlternativeStateNameMap::GetCanonicalStateName("", u""),
base::nullopt);
}
@@ -51,11 +48,9 @@ TEST(AlternativeStateNameMapTest, SeparateEntryForDifferentCounties) {
test::ClearAlternativeStateNameMapForTesting();
test::PopulateAlternativeStateNameMapForTesting("DE");
test::PopulateAlternativeStateNameMapForTesting("US");
- EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName(
- "DE", base::ASCIIToUTF16("Bavaria")),
+ EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName("DE", u"Bavaria"),
base::nullopt);
- EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName(
- "US", base::ASCIIToUTF16("Bavaria")),
+ EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName("US", u"Bavaria"),
base::nullopt);
}
@@ -86,14 +81,13 @@ TEST(AlternativeStateNameMapTest, GetEntry) {
test::PopulateAlternativeStateNameMapForTesting();
AlternativeStateNameMap* alternative_state_name_map =
AlternativeStateNameMap::GetInstance();
- EXPECT_EQ(
- alternative_state_name_map->GetEntry(
- AlternativeStateNameMap::CountryCode("DE"),
- AlternativeStateNameMap::StateName(base::ASCIIToUTF16("Random"))),
- base::nullopt);
+ EXPECT_EQ(alternative_state_name_map->GetEntry(
+ AlternativeStateNameMap::CountryCode("DE"),
+ AlternativeStateNameMap::StateName(u"Random")),
+ base::nullopt);
auto entry = alternative_state_name_map->GetEntry(
AlternativeStateNameMap::CountryCode("DE"),
- AlternativeStateNameMap::StateName(base::ASCIIToUTF16("Bavaria")));
+ AlternativeStateNameMap::StateName(u"Bavaria"));
EXPECT_NE(entry, base::nullopt);
ASSERT_TRUE(entry->has_canonical_name());
EXPECT_EQ(entry->canonical_name(), "Bavaria");
diff --git a/chromium/components/autofill/core/browser/geo/alternative_state_name_map_updater_unittest.cc b/chromium/components/autofill/core/browser/geo/alternative_state_name_map_updater_unittest.cc
index 7633ea97630..3a520a2f1e5 100644
--- a/chromium/components/autofill/core/browser/geo/alternative_state_name_map_updater_unittest.cc
+++ b/chromium/components/autofill/core/browser/geo/alternative_state_name_map_updater_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "components/autofill/core/browser/geo/alternative_state_name_map_updater.h"
+#include "base/callback_helpers.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
@@ -94,14 +95,14 @@ TEST_F(AlternativeStateNameMapUpdaterTest, EntryAddedToStateMap) {
test::ClearAlternativeStateNameMapForTesting();
std::string states_data = test::CreateStatesProtoAsString();
std::vector<AlternativeStateNameMap::StateName> test_strings = {
- AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria")),
- AlternativeStateNameMap::StateName(ASCIIToUTF16("Bayern")),
- AlternativeStateNameMap::StateName(ASCIIToUTF16("B.Y")),
- AlternativeStateNameMap::StateName(ASCIIToUTF16("Bav-aria")),
- AlternativeStateNameMap::StateName(UTF8ToUTF16("amapá")),
- AlternativeStateNameMap::StateName(ASCIIToUTF16("Broen")),
- AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria is in Germany")),
- AlternativeStateNameMap::StateName(ASCIIToUTF16("BA is in Germany"))};
+ AlternativeStateNameMap::StateName(u"Bavaria"),
+ AlternativeStateNameMap::StateName(u"Bayern"),
+ AlternativeStateNameMap::StateName(u"B.Y"),
+ AlternativeStateNameMap::StateName(u"Bav-aria"),
+ AlternativeStateNameMap::StateName(u"amapá"),
+ AlternativeStateNameMap::StateName(u"Broen"),
+ AlternativeStateNameMap::StateName(u"Bavaria is in Germany"),
+ AlternativeStateNameMap::StateName(u"BA is in Germany")};
std::vector<bool> state_data_present = {true, true, true, true,
false, false, false, false};
@@ -128,15 +129,14 @@ TEST_F(AlternativeStateNameMapUpdaterTest, TestLoadStatesData) {
WritePathToPref(GetPath());
CountryToStateNamesListMapping country_to_state_names_list_mapping = {
{AlternativeStateNameMap::CountryCode("DE"),
- {AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria"))}}};
+ {AlternativeStateNameMap::StateName(u"Bavaria")}}};
base::RunLoop run_loop;
alternative_state_name_map_updater_->LoadStatesDataForTesting(
country_to_state_names_list_mapping, autofill_client_.GetPrefs(),
run_loop.QuitClosure());
run_loop.Run();
- EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName(
- "DE", ASCIIToUTF16("Bavaria")),
+ EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName("DE", u"Bavaria"),
base::nullopt);
}
@@ -152,7 +152,7 @@ TEST_F(AlternativeStateNameMapUpdaterTest, NoTaskIsPosted) {
CountryToStateNamesListMapping country_to_state_names_list_mapping = {
{AlternativeStateNameMap::CountryCode("DEE"),
- {AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria"))}}};
+ {AlternativeStateNameMap::StateName(u"Bavaria")}}};
base::RunLoop run_loop;
alternative_state_name_map_updater_->LoadStatesDataForTesting(
country_to_state_names_list_mapping, autofill_client_.GetPrefs(),
@@ -178,7 +178,7 @@ TEST_F(AlternativeStateNameMapUpdaterTest, TestLoadStatesDataUTF8) {
CountryToStateNamesListMapping country_to_state_names_list_mapping = {
{AlternativeStateNameMap::CountryCode("ES"),
- {AlternativeStateNameMap::StateName(ASCIIToUTF16("Parana"))}}};
+ {AlternativeStateNameMap::StateName(u"Parana")}}};
base::RunLoop run_loop;
alternative_state_name_map_updater_->LoadStatesDataForTesting(
@@ -189,7 +189,7 @@ TEST_F(AlternativeStateNameMapUpdaterTest, TestLoadStatesDataUTF8) {
base::Optional<StateEntry> entry1 =
AlternativeStateNameMap::GetInstance()->GetEntry(
AlternativeStateNameMap::CountryCode("ES"),
- AlternativeStateNameMap::StateName(UTF8ToUTF16("Paraná")));
+ AlternativeStateNameMap::StateName(u"Paraná"));
EXPECT_NE(entry1, base::nullopt);
EXPECT_EQ(entry1->canonical_name(), "Paraná");
EXPECT_THAT(entry1->abbreviations(),
@@ -200,7 +200,7 @@ TEST_F(AlternativeStateNameMapUpdaterTest, TestLoadStatesDataUTF8) {
base::Optional<StateEntry> entry2 =
AlternativeStateNameMap::GetInstance()->GetEntry(
AlternativeStateNameMap::CountryCode("ES"),
- AlternativeStateNameMap::StateName(UTF8ToUTF16("Parana")));
+ AlternativeStateNameMap::StateName(u"Parana"));
EXPECT_NE(entry2, base::nullopt);
EXPECT_EQ(entry2->canonical_name(), "Paraná");
EXPECT_THAT(entry2->abbreviations(),
@@ -228,9 +228,9 @@ TEST_F(AlternativeStateNameMapUpdaterTest,
CountryToStateNamesListMapping country_to_state_names = {
{AlternativeStateNameMap::CountryCode("ES"),
- {AlternativeStateNameMap::StateName(ASCIIToUTF16("Parana"))}},
+ {AlternativeStateNameMap::StateName(u"Parana")}},
{AlternativeStateNameMap::CountryCode("DE"),
- {AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria"))}}};
+ {AlternativeStateNameMap::StateName(u"Bavaria")}}};
base::RunLoop run_loop;
alternative_state_name_map_updater_->LoadStatesDataForTesting(
@@ -241,7 +241,7 @@ TEST_F(AlternativeStateNameMapUpdaterTest,
base::Optional<StateEntry> entry1 =
AlternativeStateNameMap::GetInstance()->GetEntry(
AlternativeStateNameMap::CountryCode("ES"),
- AlternativeStateNameMap::StateName(UTF8ToUTF16("Paraná")));
+ AlternativeStateNameMap::StateName(u"Paraná"));
EXPECT_NE(entry1, base::nullopt);
EXPECT_EQ(entry1->canonical_name(), "Paraná");
EXPECT_THAT(entry1->abbreviations(),
@@ -252,7 +252,7 @@ TEST_F(AlternativeStateNameMapUpdaterTest,
base::Optional<StateEntry> entry2 =
AlternativeStateNameMap::GetInstance()->GetEntry(
AlternativeStateNameMap::CountryCode("DE"),
- AlternativeStateNameMap::StateName(UTF8ToUTF16("Bavaria")));
+ AlternativeStateNameMap::StateName(u"Bavaria"));
EXPECT_NE(entry2, base::nullopt);
EXPECT_EQ(entry2->canonical_name(), "Bavaria");
EXPECT_THAT(entry2->abbreviations(),
@@ -264,15 +264,15 @@ TEST_F(AlternativeStateNameMapUpdaterTest,
// Tests the |StateNameMapUpdater::ContainsState()| functionality.
TEST_F(AlternativeStateNameMapUpdaterTest, ContainsState) {
EXPECT_TRUE(AlternativeStateNameMapUpdater::ContainsStateForTesting(
- {AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria")),
- AlternativeStateNameMap::StateName(ASCIIToUTF16("Bayern")),
- AlternativeStateNameMap::StateName(ASCIIToUTF16("BY"))},
- AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria"))));
+ {AlternativeStateNameMap::StateName(u"Bavaria"),
+ AlternativeStateNameMap::StateName(u"Bayern"),
+ AlternativeStateNameMap::StateName(u"BY")},
+ AlternativeStateNameMap::StateName(u"Bavaria")));
EXPECT_FALSE(AlternativeStateNameMapUpdater::ContainsStateForTesting(
- {AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria")),
- AlternativeStateNameMap::StateName(ASCIIToUTF16("Bayern")),
- AlternativeStateNameMap::StateName(ASCIIToUTF16("BY"))},
- AlternativeStateNameMap::StateName(ASCIIToUTF16("California"))));
+ {AlternativeStateNameMap::StateName(u"Bavaria"),
+ AlternativeStateNameMap::StateName(u"Bayern"),
+ AlternativeStateNameMap::StateName(u"BY")},
+ AlternativeStateNameMap::StateName(u"California")));
}
// Tests that the |AlternativeStateNameMap| is populated with the help of the
@@ -286,8 +286,8 @@ TEST_F(AlternativeStateNameMapUpdaterTest,
test::CreateStatesProtoAsString());
AutofillProfile profile;
- profile.SetInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("Bavaria"), "en-US");
- profile.SetInfo(ADDRESS_HOME_COUNTRY, base::ASCIIToUTF16("DE"), "en-US");
+ profile.SetInfo(ADDRESS_HOME_STATE, u"Bavaria", "en-US");
+ profile.SetInfo(ADDRESS_HOME_COUNTRY, u"DE", "en-US");
base::RunLoop run_loop;
MockAlternativeStateNameMapUpdater mock_alternative_state_name_updater(
@@ -300,10 +300,8 @@ TEST_F(AlternativeStateNameMapUpdaterTest,
EXPECT_FALSE(
AlternativeStateNameMap::GetInstance()->IsLocalisedStateNamesMapEmpty());
- EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName(
- "DE", base::ASCIIToUTF16("Bavaria")),
- AlternativeStateNameMap::CanonicalStateName(
- base::ASCIIToUTF16("Bayern")));
+ EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName("DE", u"Bavaria"),
+ AlternativeStateNameMap::CanonicalStateName(u"Bayern"));
}
} // namespace autofill
diff --git a/chromium/components/autofill/core/browser/geo/autofill_country.cc b/chromium/components/autofill/core/browser/geo/autofill_country.cc
index b415b59908b..2dc8e9792c0 100644
--- a/chromium/components/autofill/core/browser/geo/autofill_country.cc
+++ b/chromium/components/autofill/core/browser/geo/autofill_country.cc
@@ -75,9 +75,9 @@ const std::string AutofillCountry::CountryCodeForLocale(
}
AutofillCountry::AutofillCountry(const std::string& country_code,
- const base::string16& name,
- const base::string16& postal_code_label,
- const base::string16& state_label)
+ const std::u16string& name,
+ const std::u16string& postal_code_label,
+ const std::u16string& state_label)
: country_code_(country_code), name_(name) {}
// Prints a formatted log of a |AutofillCountry| to a |LogBuffer|.
diff --git a/chromium/components/autofill/core/browser/geo/autofill_country.h b/chromium/components/autofill/core/browser/geo/autofill_country.h
index c1d3a3eb1b7..eaab92d0328 100644
--- a/chromium/components/autofill/core/browser/geo/autofill_country.h
+++ b/chromium/components/autofill/core/browser/geo/autofill_country.h
@@ -9,7 +9,6 @@
#include <vector>
#include "base/macros.h"
-#include "base/strings/string16.h"
#include "components/autofill/core/browser/geo/country_data.h"
namespace autofill {
@@ -30,7 +29,7 @@ class AutofillCountry {
static const std::string CountryCodeForLocale(const std::string& locale);
const std::string& country_code() const { return country_code_; }
- const base::string16& name() const { return name_; }
+ const std::u16string& name() const { return name_; }
// City is expected in a complete address for this country.
bool requires_city() const {
@@ -61,15 +60,15 @@ class AutofillCountry {
private:
AutofillCountry(const std::string& country_code,
- const base::string16& name,
- const base::string16& postal_code_label,
- const base::string16& state_label);
+ const std::u16string& name,
+ const std::u16string& postal_code_label,
+ const std::u16string& state_label);
// The two-letter ISO-3166 country code.
std::string country_code_;
// The country's name, localized to the app locale.
- base::string16 name_;
+ std::u16string name_;
// Required fields for an address import for the country.
RequiredFieldsForAddressImport required_fields_for_address_import_;
diff --git a/chromium/components/autofill/core/browser/geo/autofill_country_unittest.cc b/chromium/components/autofill/core/browser/geo/autofill_country_unittest.cc
index 39892b620ea..5ee6e2dc0ec 100644
--- a/chromium/components/autofill/core/browser/geo/autofill_country_unittest.cc
+++ b/chromium/components/autofill/core/browser/geo/autofill_country_unittest.cc
@@ -23,24 +23,24 @@ namespace autofill {
TEST(AutofillCountryTest, AutofillCountry) {
AutofillCountry united_states_en("US", "en_US");
EXPECT_EQ("US", united_states_en.country_code());
- EXPECT_EQ(ASCIIToUTF16("United States"), united_states_en.name());
+ EXPECT_EQ(u"United States", united_states_en.name());
AutofillCountry united_states_es("US", "es");
EXPECT_EQ("US", united_states_es.country_code());
- EXPECT_EQ(ASCIIToUTF16("Estados Unidos"), united_states_es.name());
+ EXPECT_EQ(u"Estados Unidos", united_states_es.name());
AutofillCountry great_britain_uk_alias("UK", "en_GB");
EXPECT_EQ("GB", great_britain_uk_alias.country_code());
EXPECT_EQ("GB", great_britain_uk_alias.country_code());
- EXPECT_EQ(ASCIIToUTF16("United Kingdom"), great_britain_uk_alias.name());
+ EXPECT_EQ(u"United Kingdom", great_britain_uk_alias.name());
AutofillCountry canada_en("CA", "en_US");
EXPECT_EQ("CA", canada_en.country_code());
- EXPECT_EQ(ASCIIToUTF16("Canada"), canada_en.name());
+ EXPECT_EQ(u"Canada", canada_en.name());
AutofillCountry canada_hu("CA", "hu");
EXPECT_EQ("CA", canada_hu.country_code());
- EXPECT_EQ(ASCIIToUTF16("Kanada"), canada_hu.name());
+ EXPECT_EQ(u"Kanada", canada_hu.name());
}
// Test locale to country code mapping.
diff --git a/chromium/components/autofill/core/browser/geo/country_names.cc b/chromium/components/autofill/core/browser/geo/country_names.cc
index a5db1d0573d..24124430176 100644
--- a/chromium/components/autofill/core/browser/geo/country_names.cc
+++ b/chromium/components/autofill/core/browser/geo/country_names.cc
@@ -89,7 +89,7 @@ CountryNames::CountryNames() : CountryNames(g_application_locale.Get()) {
CountryNames::~CountryNames() = default;
const std::string CountryNames::GetCountryCode(
- const base::string16& country) const {
+ const std::u16string& country) const {
// First, check common country names, including 2- and 3-letter country codes.
std::string country_utf8 = base::UTF16ToUTF8(base::ToUpperASCII(country));
const auto result = common_names_.find(country_utf8);
@@ -107,7 +107,7 @@ const std::string CountryNames::GetCountryCode(
}
const std::string CountryNames::GetCountryCodeForLocalizedCountryName(
- const base::string16& country,
+ const std::u16string& country,
const std::string& locale_name) {
// Do an unconditional lookup using the default and app_locale.
// Chances are that the name of the country matches the localized one.
diff --git a/chromium/components/autofill/core/browser/geo/country_names.h b/chromium/components/autofill/core/browser/geo/country_names.h
index 92a68c8a49e..1a3a7ac72a6 100644
--- a/chromium/components/autofill/core/browser/geo/country_names.h
+++ b/chromium/components/autofill/core/browser/geo/country_names.h
@@ -12,7 +12,6 @@
#include "base/containers/mru_cache.h"
#include "base/macros.h"
-#include "base/strings/string16.h"
#include "base/synchronization/lock.h"
#include "components/autofill/core/browser/geo/country_names_for_locale.h"
@@ -38,14 +37,14 @@ class CountryNames {
// Returns the country code corresponding to the |country_name| queried for
// the application and default locale.
- const std::string GetCountryCode(const base::string16& country_name) const;
+ const std::string GetCountryCode(const std::u16string& country_name) const;
// Returns the country code for a |country_name| provided with a
// |locale_name|. If no country code can be determined, an empty string is
// returned. The purpose of this method is to translate country names from a
// locale different to one the instance was constructed for.
const std::string GetCountryCodeForLocalizedCountryName(
- const base::string16& country_name,
+ const std::u16string& country_name,
const std::string& locale_name);
#if defined(UNIT_TEST)
diff --git a/chromium/components/autofill/core/browser/geo/country_names_for_locale.cc b/chromium/components/autofill/core/browser/geo/country_names_for_locale.cc
index 2f9a69dafbc..7a9ad244fd6 100644
--- a/chromium/components/autofill/core/browser/geo/country_names_for_locale.cc
+++ b/chromium/components/autofill/core/browser/geo/country_names_for_locale.cc
@@ -5,10 +5,10 @@
#include "components/autofill/core/browser/geo/country_names_for_locale.h"
#include <map>
+#include <string>
#include <utility>
#include "base/check_op.h"
-#include "base/strings/string16.h"
#include "components/autofill/core/browser/geo/country_data.h"
#include "components/autofill/core/common/autofill_l10n_util.h"
#include "third_party/icu/source/common/unicode/locid.h"
@@ -22,7 +22,7 @@ namespace {
// effect. |buffer_size| should specify the |buffer|'s size, and is updated if
// the |buffer| is resized.
const std::string GetSortKey(const icu::Collator& collator,
- const base::string16& str,
+ const std::u16string& str,
std::unique_ptr<uint8_t[]>* buffer,
int32_t* buffer_size) {
DCHECK(buffer);
@@ -77,7 +77,7 @@ std::map<std::string, std::string> GetLocalizedNames(
for (const std::string& country_code :
CountryDataMap::GetInstance()->country_codes()) {
- base::string16 country_name =
+ std::u16string country_name =
l10n_util::GetDisplayNameForCountry(country_code, locale);
std::string sort_key =
GetSortKey(*collator, country_name, &buffer, &buffer_size);
@@ -102,7 +102,7 @@ CountryNamesForLocale::CountryNamesForLocale(CountryNamesForLocale&& source)
localized_names_(std::move(source.localized_names_)) {}
const std::string CountryNamesForLocale::GetCountryCode(
- const base::string16& country_name) const {
+ const std::u16string& country_name) const {
// As recommended[1] by ICU, initialize the buffer size to four times the
// source string length.
// [1] http://userguide.icu-project.org/collation/api#TOC-Examples
diff --git a/chromium/components/autofill/core/browser/geo/country_names_for_locale.h b/chromium/components/autofill/core/browser/geo/country_names_for_locale.h
index 4c04eb3a510..4498e21a2b7 100644
--- a/chromium/components/autofill/core/browser/geo/country_names_for_locale.h
+++ b/chromium/components/autofill/core/browser/geo/country_names_for_locale.h
@@ -9,7 +9,6 @@
#include <memory>
#include <string>
-#include "base/strings/string16.h"
#include "third_party/icu/source/i18n/unicode/coll.h"
namespace autofill {
@@ -26,7 +25,7 @@ class CountryNamesForLocale {
// Returns the country code corresponding to the |country_name| localized to
// |locale_name_|. Returns an empty string if no matching country code can be
// found.
- const std::string GetCountryCode(const base::string16& country_name) const;
+ const std::string GetCountryCode(const std::u16string& country_name) const;
private:
// Returns an ICU collator -- i.e. string comparator -- appropriate for the
diff --git a/chromium/components/autofill/core/browser/geo/country_names_for_locale_unittest.cc b/chromium/components/autofill/core/browser/geo/country_names_for_locale_unittest.cc
index 7c1f994329b..e62db32f409 100644
--- a/chromium/components/autofill/core/browser/geo/country_names_for_locale_unittest.cc
+++ b/chromium/components/autofill/core/browser/geo/country_names_for_locale_unittest.cc
@@ -5,7 +5,6 @@
#include <string>
#include <utility>
-#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/geo/country_names_for_locale.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -31,10 +30,10 @@ class TestCountryNamesForLocale : public CountryNamesForLocale {
// Test that the correct country code is returned for various locales.
TEST(CountryNamesForLocaleTest, GetCountryCode) {
TestCountryNamesForLocale en_us_names("en_US");
- EXPECT_EQ("US", en_us_names.GetCountryCode(ASCIIToUTF16("United States")));
+ EXPECT_EQ("US", en_us_names.GetCountryCode(u"United States"));
TestCountryNamesForLocale de_names("de");
- EXPECT_EQ("DE", de_names.GetCountryCode(ASCIIToUTF16("Deutschland")));
+ EXPECT_EQ("DE", de_names.GetCountryCode(u"Deutschland"));
}
// Test that supplying an non-empty but invalid locale reverts back to 'en_US'
@@ -43,8 +42,7 @@ TEST(CountryNamesForLocaleTest, EmptyCountryCodeForInvalidLocale) {
TestCountryNamesForLocale not_a_locale_names("not_a_locale");
// The creation of an non-empty invalid locale reverts back to "en_US".
- EXPECT_EQ("US",
- not_a_locale_names.GetCountryCode(ASCIIToUTF16("United States")));
+ EXPECT_EQ("US", not_a_locale_names.GetCountryCode(u"United States"));
}
// The behavior depends on the platform. On Android the locale reverts back to
@@ -53,33 +51,32 @@ TEST(CountryNamesForLocaleTest, EmptyCountryCodeForInvalidLocale) {
// Test that an empty string is returned for an empty locale.
TEST(CountryNamesForLocaleTest, EmptyCountryCodeForEmptyLocale) {
TestCountryNamesForLocale empty_locale_names("");
- EXPECT_EQ("",
- empty_locale_names.GetCountryCode(ASCIIToUTF16("United States")));
+ EXPECT_EQ("", empty_locale_names.GetCountryCode(u"United States"));
}
#endif
// Test that an empty string is returned for an empty country name.
TEST(CountryNamesForLocaleTest, EmptyCountryCodeForEmptyCountryName) {
TestCountryNamesForLocale de_names("de");
- EXPECT_EQ("", de_names.GetCountryCode(ASCIIToUTF16("")));
+ EXPECT_EQ("", de_names.GetCountryCode(u""));
}
// Test that an empty string is returned for an invalid country name.
TEST(CountryNamesForLocaleTest, EmptyCountryCodeForInvalidCountryName) {
TestCountryNamesForLocale de_names("de");
- EXPECT_EQ("", de_names.GetCountryCode(ASCIIToUTF16("ThisISNotACountry")));
+ EXPECT_EQ("", de_names.GetCountryCode(u"ThisISNotACountry"));
}
// Test that an instance is correctly constructed using the move semantics.
TEST(CountryNamesForLocaleTest, MoveConstructior) {
// Construct a working |CountryNamesForLocale| instance.
TestCountryNamesForLocale de_names("de");
- EXPECT_EQ("DE", de_names.GetCountryCode(ASCIIToUTF16("Deutschland")));
+ EXPECT_EQ("DE", de_names.GetCountryCode(u"Deutschland"));
// Construct another instance using the move semantics.
TestCountryNamesForLocale moved_names(std::move(de_names));
// Test that the new instance returns the correct values.
- EXPECT_EQ("DE", moved_names.GetCountryCode(ASCIIToUTF16("Deutschland")));
+ EXPECT_EQ("DE", moved_names.GetCountryCode(u"Deutschland"));
}
} // namespace autofill
diff --git a/chromium/components/autofill/core/browser/geo/country_names_unittest.cc b/chromium/components/autofill/core/browser/geo/country_names_unittest.cc
index 2f971cb599c..9cfc1accd67 100644
--- a/chromium/components/autofill/core/browser/geo/country_names_unittest.cc
+++ b/chromium/components/autofill/core/browser/geo/country_names_unittest.cc
@@ -5,7 +5,6 @@
#include <string>
#include <utility>
-#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/geo/country_names.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -28,57 +27,52 @@ class TestCountryNames : public CountryNames {
// Test mapping of localized country names to country codes.
TEST(CountryNamesTest, GetCountryCode_BasicMapping) {
TestCountryNames en_us_names("en_US");
- EXPECT_EQ("US", en_us_names.GetCountryCode(ASCIIToUTF16("United States")));
- EXPECT_EQ("CA", en_us_names.GetCountryCode(ASCIIToUTF16("Canada")));
+ EXPECT_EQ("US", en_us_names.GetCountryCode(u"United States"));
+ EXPECT_EQ("CA", en_us_names.GetCountryCode(u"Canada"));
}
TEST(CountryNamesTest, GetCountryCode_CaseInsensitiveMapping) {
- EXPECT_EQ("US", TestCountryNames("en_US").GetCountryCode(
- ASCIIToUTF16("united states")));
+ EXPECT_EQ("US", TestCountryNames("en_US").GetCountryCode(u"united states"));
}
TEST(CountryNamesTest, GetCountryCode_CodesMapToThemselves) {
TestCountryNames en_us_names("en_US");
TestCountryNames fr_ca_names("fr_CA");
- EXPECT_EQ("US", en_us_names.GetCountryCode(ASCIIToUTF16("US")));
- EXPECT_EQ("HU", en_us_names.GetCountryCode(ASCIIToUTF16("hu")));
- EXPECT_EQ("CA", fr_ca_names.GetCountryCode(ASCIIToUTF16("CA")));
- EXPECT_EQ("MX", fr_ca_names.GetCountryCode(ASCIIToUTF16("mx")));
+ EXPECT_EQ("US", en_us_names.GetCountryCode(u"US"));
+ EXPECT_EQ("HU", en_us_names.GetCountryCode(u"hu"));
+ EXPECT_EQ("CA", fr_ca_names.GetCountryCode(u"CA"));
+ EXPECT_EQ("MX", fr_ca_names.GetCountryCode(u"mx"));
}
TEST(CountryNamesTest, GetCountryCode_BasicSynonyms) {
TestCountryNames en_us_names("en_US");
- EXPECT_EQ("US", en_us_names.GetCountryCode(
- ASCIIToUTF16("United States of America")));
- EXPECT_EQ("US", en_us_names.GetCountryCode(ASCIIToUTF16("USA")));
+ EXPECT_EQ("US", en_us_names.GetCountryCode(u"United States of America"));
+ EXPECT_EQ("US", en_us_names.GetCountryCode(u"USA"));
}
TEST(CountryNamesTest, GetCountryCode_OtherLocales) {
- EXPECT_EQ("US", TestCountryNames("es").GetCountryCode(
- ASCIIToUTF16("Estados Unidos")));
- EXPECT_EQ("IT",
- TestCountryNames("it").GetCountryCode(ASCIIToUTF16("Italia")));
- EXPECT_EQ("DE",
- TestCountryNames("nl").GetCountryCode(ASCIIToUTF16("duitsland")));
+ EXPECT_EQ("US", TestCountryNames("es").GetCountryCode(u"Estados Unidos"));
+ EXPECT_EQ("IT", TestCountryNames("it").GetCountryCode(u"Italia"));
+ EXPECT_EQ("DE", TestCountryNames("nl").GetCountryCode(u"duitsland"));
}
TEST(CountryNamesTest, GetCountryCode_EnUsFallback) {
TestCountryNames es_names("es");
- EXPECT_EQ("US", es_names.GetCountryCode(ASCIIToUTF16("United States")));
- EXPECT_EQ("US", es_names.GetCountryCode(ASCIIToUTF16("united states")));
- EXPECT_EQ("US", es_names.GetCountryCode(ASCIIToUTF16("USA")));
+ EXPECT_EQ("US", es_names.GetCountryCode(u"United States"));
+ EXPECT_EQ("US", es_names.GetCountryCode(u"united states"));
+ EXPECT_EQ("US", es_names.GetCountryCode(u"USA"));
}
TEST(CountryNamesTest, GetCountryCodeForLocalizedCountryName) {
// Initialize with the default locale.
TestCountryNames names("en_US");
- EXPECT_EQ("AM", names.GetCountryCodeForLocalizedCountryName(
- ASCIIToUTF16("Armenien"), "de"));
+ EXPECT_EQ("AM",
+ names.GetCountryCodeForLocalizedCountryName(u"Armenien", "de"));
// Check that there is no cache by requesting the same result twice.
- EXPECT_EQ("AM", names.GetCountryCodeForLocalizedCountryName(
- ASCIIToUTF16("Armenien"), "de"));
- EXPECT_EQ("AZ", names.GetCountryCodeForLocalizedCountryName(
- ASCIIToUTF16("Azerbeidzjan"), "nl"));
+ EXPECT_EQ("AM",
+ names.GetCountryCodeForLocalizedCountryName(u"Armenien", "de"));
+ EXPECT_EQ("AZ",
+ names.GetCountryCodeForLocalizedCountryName(u"Azerbeidzjan", "nl"));
}
TEST(CountryNamesTest, GetCachedCountryCodeForLocalizedCountryName) {
@@ -89,8 +83,8 @@ TEST(CountryNamesTest, GetCachedCountryCodeForLocalizedCountryName) {
EXPECT_FALSE(names.IsCountryNamesForLocaleCachedForTesting("de"));
// Make a lookup of the entry that should result in a cache write.
- EXPECT_EQ("AM", names.GetCountryCodeForLocalizedCountryName(
- ASCIIToUTF16("Armenien"), "de"));
+ EXPECT_EQ("AM",
+ names.GetCountryCodeForLocalizedCountryName(u"Armenien", "de"));
// Verify that the entry is cached.
EXPECT_TRUE(names.IsCountryNamesForLocaleCachedForTesting("de"));
@@ -99,7 +93,7 @@ TEST(CountryNamesTest, GetCachedCountryCodeForLocalizedCountryName) {
// Test mapping of an empty country name to an country code.
TEST(CountryNamesTest, EmptyCountryNameHasEmptyCountryCode) {
std::string country_code =
- TestCountryNames("en").GetCountryCode(base::string16());
+ TestCountryNames("en").GetCountryCode(std::u16string());
EXPECT_TRUE(country_code.empty()) << country_code;
}
diff --git a/chromium/components/autofill/core/browser/geo/phone_number_i18n.cc b/chromium/components/autofill/core/browser/geo/phone_number_i18n.cc
index 0e1d01ee171..d936d62e091 100644
--- a/chromium/components/autofill/core/browser/geo/phone_number_i18n.cc
+++ b/chromium/components/autofill/core/browser/geo/phone_number_i18n.cc
@@ -4,6 +4,7 @@
#include "components/autofill/core/browser/geo/phone_number_i18n.h"
+#include <memory>
#include <utility>
#include "base/check_op.h"
@@ -57,9 +58,9 @@ std::string SanitizeRegion(const std::string& region,
// in explicitly, as |number| might have an implicit country code set, even
// though the original input lacked a country code.
void FormatValidatedNumber(const ::i18n::phonenumbers::PhoneNumber& number,
- const base::string16& country_code,
- base::string16* formatted_number,
- base::string16* normalized_number) {
+ const std::u16string& country_code,
+ std::u16string* formatted_number,
+ std::u16string* normalized_number) {
PhoneNumberUtil::PhoneNumberFormat format =
country_code.empty() ? PhoneNumberUtil::NATIONAL
: PhoneNumberUtil::INTERNATIONAL;
@@ -143,11 +144,11 @@ bool IsValidPhoneNumber(const std::string& phone_number,
// Parses the number stored in |value| as it should be interpreted in the given
// |default_region|, and stores the results into the remaining arguments.
// The |default_region| should be sanitized prior to calling this function.
-bool ParsePhoneNumber(const base::string16& value,
+bool ParsePhoneNumber(const std::u16string& value,
const std::string& default_region,
- base::string16* country_code,
- base::string16* city_code,
- base::string16* number,
+ std::u16string* country_code,
+ std::u16string* city_code,
+ std::u16string* number,
std::string* inferred_region,
::i18n::phonenumbers::PhoneNumber* i18n_number) {
country_code->clear();
@@ -224,32 +225,32 @@ bool ParsePhoneNumber(const base::string16& value,
return true;
}
-base::string16 NormalizePhoneNumber(const base::string16& value,
+std::u16string NormalizePhoneNumber(const std::u16string& value,
const std::string& region) {
DCHECK_EQ(2u, region.size());
- base::string16 country_code, unused_city_code, unused_number;
+ std::u16string country_code, unused_city_code, unused_number;
std::string unused_region;
::i18n::phonenumbers::PhoneNumber phone_number;
if (!ParsePhoneNumber(value, region, &country_code, &unused_city_code,
&unused_number, &unused_region, &phone_number)) {
- return base::string16(); // Parsing failed - do not store phone.
+ return std::u16string(); // Parsing failed - do not store phone.
}
- base::string16 normalized_number;
+ std::u16string normalized_number;
FormatValidatedNumber(phone_number, country_code, nullptr,
&normalized_number);
return normalized_number;
}
-bool ConstructPhoneNumber(const base::string16& country_code,
- const base::string16& city_code,
- const base::string16& number,
+bool ConstructPhoneNumber(const std::u16string& country_code,
+ const std::u16string& city_code,
+ const std::u16string& number,
const std::string& region,
- base::string16* whole_number) {
+ std::u16string* whole_number) {
DCHECK_EQ(2u, region.size());
whole_number->clear();
- base::string16 unused_country_code, unused_city_code, unused_number;
+ std::u16string unused_country_code, unused_city_code, unused_number;
std::string unused_region;
::i18n::phonenumbers::PhoneNumber phone_number;
if (!ParsePhoneNumber(country_code + city_code + number, region,
@@ -262,8 +263,8 @@ bool ConstructPhoneNumber(const base::string16& country_code,
return true;
}
-bool PhoneNumbersMatch(const base::string16& number_a,
- const base::string16& number_b,
+bool PhoneNumbersMatch(const std::u16string& number_a,
+ const std::u16string& number_b,
const std::string& raw_region,
const std::string& app_locale) {
if (number_a.empty() && number_b.empty()) {
@@ -307,7 +308,7 @@ bool PhoneNumbersMatch(const base::string16& number_a,
return false;
}
-base::string16 GetFormattedPhoneNumberForDisplay(const AutofillProfile& profile,
+std::u16string GetFormattedPhoneNumberForDisplay(const AutofillProfile& profile,
const std::string& locale) {
// Since the "+" is removed for some country's phone numbers, try to add a "+"
// and see if it is a valid phone number for a country.
@@ -365,7 +366,7 @@ std::string FormatPhoneForResponse(const std::string& phone_number,
return phone_number;
}
-PhoneObject::PhoneObject(const base::string16& number,
+PhoneObject::PhoneObject(const std::u16string& number,
const std::string& region) {
DCHECK_EQ(2u, region.size());
// TODO(isherman): Autofill profiles should always have a |region| set, but in
@@ -396,7 +397,7 @@ PhoneObject::PhoneObject() {}
PhoneObject::~PhoneObject() {}
-const base::string16& PhoneObject::GetFormattedNumber() const {
+const std::u16string& PhoneObject::GetFormattedNumber() const {
if (i18n_number_ && formatted_number_.empty()) {
FormatValidatedNumber(*i18n_number_, country_code_, &formatted_number_,
&whole_number_);
@@ -405,15 +406,15 @@ const base::string16& PhoneObject::GetFormattedNumber() const {
return formatted_number_;
}
-base::string16 PhoneObject::GetNationallyFormattedNumber() const {
- base::string16 formatted = whole_number_;
+std::u16string PhoneObject::GetNationallyFormattedNumber() const {
+ std::u16string formatted = whole_number_;
if (i18n_number_)
- FormatValidatedNumber(*i18n_number_, base::string16(), &formatted, nullptr);
+ FormatValidatedNumber(*i18n_number_, std::u16string(), &formatted, nullptr);
return formatted;
}
-const base::string16& PhoneObject::GetWholeNumber() const {
+const std::u16string& PhoneObject::GetWholeNumber() const {
if (i18n_number_ && whole_number_.empty()) {
FormatValidatedNumber(*i18n_number_, country_code_, &formatted_number_,
&whole_number_);
@@ -428,11 +429,12 @@ PhoneObject& PhoneObject::operator=(const PhoneObject& other) {
region_ = other.region_;
- if (other.i18n_number_)
- i18n_number_.reset(
- new ::i18n::phonenumbers::PhoneNumber(*other.i18n_number_));
- else
+ if (other.i18n_number_) {
+ i18n_number_ = std::make_unique<::i18n::phonenumbers::PhoneNumber>(
+ *other.i18n_number_);
+ } else {
i18n_number_.reset();
+ }
country_code_ = other.country_code_;
city_code_ = other.city_code_;
diff --git a/chromium/components/autofill/core/browser/geo/phone_number_i18n.h b/chromium/components/autofill/core/browser/geo/phone_number_i18n.h
index 539bc6fcfb6..e5158ae4535 100644
--- a/chromium/components/autofill/core/browser/geo/phone_number_i18n.h
+++ b/chromium/components/autofill/core/browser/geo/phone_number_i18n.h
@@ -10,7 +10,6 @@
#include <vector>
#include "base/compiler_specific.h"
-#include "base/strings/string16.h"
namespace i18n {
namespace phonenumbers {
@@ -54,18 +53,18 @@ bool IsPossiblePhoneNumber(const std::string& phone_number,
// |default_region| if |value| has an international country code, for example).
// This is an internal function, exposed in the header file so that it can be
// tested.
-bool ParsePhoneNumber(const base::string16& value,
+bool ParsePhoneNumber(const std::u16string& value,
const std::string& default_region,
- base::string16* country_code,
- base::string16* city_code,
- base::string16* number,
+ std::u16string* country_code,
+ std::u16string* city_code,
+ std::u16string* number,
std::string* inferred_region,
::i18n::phonenumbers::PhoneNumber* i18n_number)
WARN_UNUSED_RESULT;
// Normalizes phone number, by changing digits in the extended fonts
// (such as \xFF1x) into '0'-'9'. Also strips out non-digit characters.
-base::string16 NormalizePhoneNumber(const base::string16& value,
+std::u16string NormalizePhoneNumber(const std::u16string& value,
const std::string& default_region);
// Constructs whole phone number from parts.
@@ -76,16 +75,16 @@ base::string16 NormalizePhoneNumber(const base::string16& value,
// |whole_number| - constructed whole number.
// Separator characters are stripped before parsing the digits.
// Returns true if parsing was successful, false otherwise.
-bool ConstructPhoneNumber(const base::string16& country_code,
- const base::string16& city_code,
- const base::string16& number,
+bool ConstructPhoneNumber(const std::u16string& country_code,
+ const std::u16string& city_code,
+ const std::u16string& number,
const std::string& default_region,
- base::string16* whole_number) WARN_UNUSED_RESULT;
+ std::u16string* whole_number) WARN_UNUSED_RESULT;
// Returns true if |number_a| and |number_b| parse to the same phone number in
// the given |region|.
-bool PhoneNumbersMatch(const base::string16& number_a,
- const base::string16& number_b,
+bool PhoneNumbersMatch(const std::u16string& number_a,
+ const std::u16string& number_b,
const std::string& region,
const std::string& app_locale);
@@ -93,7 +92,7 @@ bool PhoneNumbersMatch(const base::string16& number_a,
// If it's a valid number for the profile's country or for the |locale| given
// as a fallback, returns the number in international format; otherwise returns
// the raw number string from profile.
-base::string16 GetFormattedPhoneNumberForDisplay(const AutofillProfile& profile,
+std::u16string GetFormattedPhoneNumberForDisplay(const AutofillProfile& profile,
const std::string& locale);
// Returns |phone_number| in i18n::phonenumbers::PhoneNumberUtil::
@@ -121,20 +120,20 @@ std::string FormatPhoneForResponse(const std::string& phone_number,
// The cached phone number, does parsing only once, improves performance.
class PhoneObject {
public:
- PhoneObject(const base::string16& number, const std::string& default_region);
+ PhoneObject(const std::u16string& number, const std::string& default_region);
PhoneObject(const PhoneObject&);
PhoneObject();
~PhoneObject();
const std::string& region() const { return region_; }
- const base::string16& country_code() const { return country_code_; }
- const base::string16& city_code() const { return city_code_; }
- const base::string16& number() const { return number_; }
+ const std::u16string& country_code() const { return country_code_; }
+ const std::u16string& city_code() const { return city_code_; }
+ const std::u16string& number() const { return number_; }
- const base::string16& GetFormattedNumber() const;
- base::string16 GetNationallyFormattedNumber() const;
- const base::string16& GetWholeNumber() const;
+ const std::u16string& GetFormattedNumber() const;
+ std::u16string GetNationallyFormattedNumber() const;
+ const std::u16string& GetWholeNumber() const;
PhoneObject& operator=(const PhoneObject& other);
@@ -147,17 +146,17 @@ class PhoneObject {
// The parsed number and its components.
//
std::unique_ptr<::i18n::phonenumbers::PhoneNumber> i18n_number_;
- base::string16 city_code_;
- base::string16 country_code_;
- base::string16 number_;
+ std::u16string city_code_;
+ std::u16string country_code_;
+ std::u16string number_;
// Pretty printed version of the whole number, or empty if parsing failed.
// Set on first request.
- mutable base::string16 formatted_number_;
+ mutable std::u16string formatted_number_;
// The whole number, normalized to contain only digits if possible.
// Set on first request.
- mutable base::string16 whole_number_;
+ mutable std::u16string whole_number_;
};
} // namespace i18n
diff --git a/chromium/components/autofill/core/browser/geo/phone_number_i18n_fuzzer.cc b/chromium/components/autofill/core/browser/geo/phone_number_i18n_fuzzer.cc
index 77a3805f0f8..1cf4a92b41a 100644
--- a/chromium/components/autofill/core/browser/geo/phone_number_i18n_fuzzer.cc
+++ b/chromium/components/autofill/core/browser/geo/phone_number_i18n_fuzzer.cc
@@ -9,7 +9,6 @@
#include "base/at_exit.h"
#include "base/i18n/icu_util.h"
-#include "base/strings/string16.h"
#include "components/autofill/core/browser/geo/phone_number_i18n.h"
#include "third_party/libphonenumber/phonenumber_api.h"
@@ -30,11 +29,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
return 0;
std::string default_region(reinterpret_cast<const char*>(data), 2);
- base::string16 value(reinterpret_cast<const base::char16*>(data + 2),
+ std::u16string value(reinterpret_cast<const char16_t*>(data + 2),
(size - 2) / 2);
- base::string16 dummy_country_code;
- base::string16 dummy_city_code;
- base::string16 dummy_number;
+ std::u16string dummy_country_code;
+ std::u16string dummy_city_code;
+ std::u16string dummy_number;
std::string dummy_inferred_region;
::i18n::phonenumbers::PhoneNumber dummy_i18n_number;
diff --git a/chromium/components/autofill/core/browser/geo/phone_number_i18n_unittest.cc b/chromium/components/autofill/core/browser/geo/phone_number_i18n_unittest.cc
index 4f4e36e3357..5b5148fb6fc 100644
--- a/chromium/components/autofill/core/browser/geo/phone_number_i18n_unittest.cc
+++ b/chromium/components/autofill/core/browser/geo/phone_number_i18n_unittest.cc
@@ -6,8 +6,9 @@
#include <stddef.h>
+#include <string>
+
#include "base/macros.h"
-#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/field_types.h"
@@ -26,26 +27,26 @@ using i18n::PhoneNumbersMatch;
TEST(PhoneNumberI18NTest, NormalizePhoneNumber) {
// "Large" digits.
- base::string16 phone1(
+ std::u16string phone1(
UTF8ToUTF16("\xEF\xBC\x91\xEF\xBC\x96\xEF\xBC\x95\xEF\xBC\x90"
"\xEF\xBC\x97\xEF\xBC\x94\xEF\xBC\x99\xEF\xBC\x98"
"\xEF\xBC\x93\xEF\xBC\x92\xEF\xBC\x93"));
- EXPECT_EQ(NormalizePhoneNumber(phone1, "US"), ASCIIToUTF16("16507498323"));
+ EXPECT_EQ(NormalizePhoneNumber(phone1, "US"), u"16507498323");
// Devanagari script digits.
- base::string16 phone2(
+ std::u16string phone2(
UTF8ToUTF16("\xD9\xA1\xD9\xA6\xD9\xA5\xD9\xA0\xD9\xA8\xD9\xA3"
"\xD9\xA2\xD9\xA3\xD9\xA7\xD9\xA4\xD9\xA9"));
- EXPECT_EQ(NormalizePhoneNumber(phone2, "US"), ASCIIToUTF16("16508323749"));
+ EXPECT_EQ(NormalizePhoneNumber(phone2, "US"), u"16508323749");
- base::string16 phone3(UTF8ToUTF16("16503334\xef\xbc\x92\x35\xd9\xa5"));
- EXPECT_EQ(NormalizePhoneNumber(phone3, "US"), ASCIIToUTF16("16503334255"));
+ std::u16string phone3(UTF8ToUTF16("16503334\xef\xbc\x92\x35\xd9\xa5"));
+ EXPECT_EQ(NormalizePhoneNumber(phone3, "US"), u"16503334255");
- base::string16 phone4(UTF8ToUTF16("+1(650)2346789"));
- EXPECT_EQ(NormalizePhoneNumber(phone4, "US"), ASCIIToUTF16("16502346789"));
+ std::u16string phone4(u"+1(650)2346789");
+ EXPECT_EQ(NormalizePhoneNumber(phone4, "US"), u"16502346789");
- base::string16 phone5(UTF8ToUTF16("6502346789"));
- EXPECT_EQ(NormalizePhoneNumber(phone5, "US"), ASCIIToUTF16("6502346789"));
+ std::u16string phone5(u"6502346789");
+ EXPECT_EQ(NormalizePhoneNumber(phone5, "US"), u"6502346789");
}
struct ParseNumberTestCase {
@@ -76,7 +77,7 @@ TEST_P(ParseNumberTest, ParsePhoneNumber) {
auto test_case = GetParam();
SCOPED_TRACE("Testing phone number " + test_case.input);
- base::string16 country_code, city_code, number;
+ std::u16string country_code, city_code, number;
std::string deduced_region;
::i18n::phonenumbers::PhoneNumber unused_i18n_number;
EXPECT_EQ(
@@ -190,79 +191,69 @@ INSTANTIATE_TEST_SUITE_P(
"", "DE"}));
TEST(PhoneNumberI18NTest, ConstructPhoneNumber) {
- base::string16 number;
- EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("1"), ASCIIToUTF16("650"),
- ASCIIToUTF16("2345678"), "US", &number));
- EXPECT_EQ(ASCIIToUTF16("1 650-234-5678"), number);
- EXPECT_TRUE(ConstructPhoneNumber(base::string16(), ASCIIToUTF16("650"),
- ASCIIToUTF16("2345678"), "US", &number));
- EXPECT_EQ(ASCIIToUTF16("(650) 234-5678"), number);
- EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("1"), base::string16(),
- ASCIIToUTF16("6502345678"), "US", &number));
- EXPECT_EQ(ASCIIToUTF16("1 650-234-5678"), number);
- EXPECT_TRUE(ConstructPhoneNumber(base::string16(), base::string16(),
- ASCIIToUTF16("6502345678"), "US", &number));
- EXPECT_EQ(ASCIIToUTF16("(650) 234-5678"), number);
-
- EXPECT_FALSE(ConstructPhoneNumber(base::string16(), ASCIIToUTF16("650"),
- ASCIIToUTF16("234567890"), "US", &number));
- EXPECT_EQ(base::string16(), number);
+ std::u16string number;
+ EXPECT_TRUE(ConstructPhoneNumber(u"1", u"650", u"2345678", "US", &number));
+ EXPECT_EQ(u"1 650-234-5678", number);
+ EXPECT_TRUE(ConstructPhoneNumber(std::u16string(), u"650", u"2345678", "US",
+ &number));
+ EXPECT_EQ(u"(650) 234-5678", number);
+ EXPECT_TRUE(ConstructPhoneNumber(u"1", std::u16string(), u"6502345678", "US",
+ &number));
+ EXPECT_EQ(u"1 650-234-5678", number);
+ EXPECT_TRUE(ConstructPhoneNumber(std::u16string(), std::u16string(),
+ u"6502345678", "US", &number));
+ EXPECT_EQ(u"(650) 234-5678", number);
+
+ EXPECT_FALSE(ConstructPhoneNumber(std::u16string(), u"650", u"234567890",
+ "US", &number));
+ EXPECT_EQ(std::u16string(), number);
// Italian number
- EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("39"), ASCIIToUTF16("347"),
- ASCIIToUTF16("2345678"), "IT", &number));
- EXPECT_EQ(ASCIIToUTF16("+39 347 234 5678"), number);
- EXPECT_TRUE(ConstructPhoneNumber(base::string16(), ASCIIToUTF16("347"),
- ASCIIToUTF16("2345678"), "IT", &number));
- EXPECT_EQ(ASCIIToUTF16("347 234 5678"), number);
+ EXPECT_TRUE(ConstructPhoneNumber(u"39", u"347", u"2345678", "IT", &number));
+ EXPECT_EQ(u"+39 347 234 5678", number);
+ EXPECT_TRUE(ConstructPhoneNumber(std::u16string(), u"347", u"2345678", "IT",
+ &number));
+ EXPECT_EQ(u"347 234 5678", number);
// German number.
- EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("49"), ASCIIToUTF16("024"),
- ASCIIToUTF16("2345678901"), "DE", &number));
- EXPECT_EQ(ASCIIToUTF16("+49 2423 45678901"), number);
- EXPECT_TRUE(ConstructPhoneNumber(base::string16(), ASCIIToUTF16("024"),
- ASCIIToUTF16("2345678901"), "DE", &number));
- EXPECT_EQ(ASCIIToUTF16("02423 45678901"), number);
+ EXPECT_TRUE(
+ ConstructPhoneNumber(u"49", u"024", u"2345678901", "DE", &number));
+ EXPECT_EQ(u"+49 2423 45678901", number);
+ EXPECT_TRUE(ConstructPhoneNumber(std::u16string(), u"024", u"2345678901",
+ "DE", &number));
+ EXPECT_EQ(u"02423 45678901", number);
}
TEST(PhoneNumberI18NTest, PhoneNumbersMatch) {
// Same numbers, defined country code.
- EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
- ASCIIToUTF16("4158889999"), "US", "en-US"));
+ EXPECT_TRUE(PhoneNumbersMatch(u"4158889999", u"4158889999", "US", "en-US"));
// Same numbers, undefined country code.
- EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
- ASCIIToUTF16("4158889999"), std::string(),
- "en-US"));
+ EXPECT_TRUE(
+ PhoneNumbersMatch(u"4158889999", u"4158889999", std::string(), "en-US"));
// Numbers differ by country code only.
- EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"),
- ASCIIToUTF16("4158889999"), "US", "en-US"));
+ EXPECT_TRUE(PhoneNumbersMatch(u"14158889999", u"4158889999", "US", "en-US"));
// Same numbers, different formats.
- EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
- ASCIIToUTF16("415-888-9999"), "US", "en-US"));
- EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
- ASCIIToUTF16("(415)888-9999"), "US", "en-US"));
- EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
- ASCIIToUTF16("415 888 9999"), "US", "en-US"));
- EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
- ASCIIToUTF16("415 TUV WXYZ"), "US", "en-US"));
- EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("1(415)888-99-99"),
- ASCIIToUTF16("+14158889999"), "US", "en-US"));
+ EXPECT_TRUE(PhoneNumbersMatch(u"4158889999", u"415-888-9999", "US", "en-US"));
+ EXPECT_TRUE(
+ PhoneNumbersMatch(u"4158889999", u"(415)888-9999", "US", "en-US"));
+ EXPECT_TRUE(PhoneNumbersMatch(u"4158889999", u"415 888 9999", "US", "en-US"));
+ EXPECT_TRUE(PhoneNumbersMatch(u"4158889999", u"415 TUV WXYZ", "US", "en-US"));
+ EXPECT_TRUE(
+ PhoneNumbersMatch(u"1(415)888-99-99", u"+14158889999", "US", "en-US"));
// Partial matches don't count.
- EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"),
- ASCIIToUTF16("8889999"), "US", "en-US"));
+ EXPECT_FALSE(PhoneNumbersMatch(u"14158889999", u"8889999", "US", "en-US"));
// Different numbers don't match.
- EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"),
- ASCIIToUTF16("1415888"), "US", "en-US"));
+ EXPECT_FALSE(PhoneNumbersMatch(u"14158889999", u"1415888", "US", "en-US"));
// Two empty numbers match.
EXPECT_TRUE(
- PhoneNumbersMatch(base::string16(), base::string16(), "US", "en-US"));
+ PhoneNumbersMatch(std::u16string(), std::u16string(), "US", "en-US"));
// An empty and a non-empty number do not match.
- EXPECT_FALSE(PhoneNumbersMatch(base::string16(), ASCIIToUTF16("5088585123"),
- "US", "en-US"));
+ EXPECT_FALSE(
+ PhoneNumbersMatch(std::u16string(), u"5088585123", "US", "en-US"));
}
// Tests that the phone numbers are correctly formatted for the Payment
diff --git a/chromium/components/autofill/core/browser/geo/state_names.cc b/chromium/components/autofill/core/browser/geo/state_names.cc
index 1d4a0e0f1da..deecc9ae400 100644
--- a/chromium/components/autofill/core/browser/geo/state_names.cc
+++ b/chromium/components/autofill/core/browser/geo/state_names.cc
@@ -79,27 +79,27 @@ const StateData kStateData[] = {
} // namespace
-base::string16 GetAbbreviationForName(const base::string16& name) {
+std::u16string GetAbbreviationForName(const std::u16string& name) {
for (const StateData& state : kStateData) {
if (base::LowerCaseEqualsASCII(name, state.name))
return base::ASCIIToUTF16(state.abbreviation);
}
- return base::string16();
+ return std::u16string();
}
-base::string16 GetNameForAbbreviation(const base::string16& abbreviation) {
+std::u16string GetNameForAbbreviation(const std::u16string& abbreviation) {
for (const StateData& state : kStateData) {
if (base::LowerCaseEqualsASCII(abbreviation, state.abbreviation))
return base::ASCIIToUTF16(state.name);
}
- return base::string16();
+ return std::u16string();
}
-void GetNameAndAbbreviation(const base::string16& value,
- base::string16* name,
- base::string16* abbreviation) {
- base::string16 full = GetNameForAbbreviation(value);
- base::string16 abbr = value;
+void GetNameAndAbbreviation(const std::u16string& value,
+ std::u16string* name,
+ std::u16string* abbreviation) {
+ std::u16string full = GetNameForAbbreviation(value);
+ std::u16string abbr = value;
if (full.empty()) {
abbr = GetAbbreviationForName(value);
full = value;
diff --git a/chromium/components/autofill/core/browser/geo/state_names.h b/chromium/components/autofill/core/browser/geo/state_names.h
index 0524f1f080c..621c8fd6086 100644
--- a/chromium/components/autofill/core/browser/geo/state_names.h
+++ b/chromium/components/autofill/core/browser/geo/state_names.h
@@ -5,25 +5,26 @@
#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_STATE_NAMES_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_STATE_NAMES_H_
-#include "base/strings/string16.h"
+#include <string>
+
namespace autofill {
namespace state_names {
// Returns the abbreviation corresponding to the state |name|, or the
// empty string if there is no such state.
-base::string16 GetAbbreviationForName(const base::string16& name);
+std::u16string GetAbbreviationForName(const std::u16string& name);
// Returns the full state name corresponding to the |abbrevation|, or the empty
// string if there is no such state.
-base::string16 GetNameForAbbreviation(const base::string16& abbreviation);
+std::u16string GetNameForAbbreviation(const std::u16string& abbreviation);
// |value| is either a state name or abbreviation. Detects which it is, and
// outputs both |name| and |abbreviation|. If it's neither, then |name| is
// set to |value| and |abbreviation| will be empty.
-void GetNameAndAbbreviation(const base::string16& value,
- base::string16* name,
- base::string16* abbreviation);
+void GetNameAndAbbreviation(const std::u16string& value,
+ std::u16string* name,
+ std::u16string* abbreviation);
} // namespace state_names
} // namespace autofill