summaryrefslogtreecommitdiff
path: root/chromium/components/autofill/core/browser/data_model
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/autofill/core/browser/data_model')
-rw-r--r--chromium/components/autofill/core/browser/data_model/address.cc46
-rw-r--r--chromium/components/autofill/core/browser/data_model/address.h33
-rw-r--r--chromium/components/autofill/core/browser/data_model/address_unittest.cc464
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_data_model.h1
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_data_model_unittest.cc6
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_profile.cc64
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_profile.h21
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_profile_comparator.cc226
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_profile_comparator.h35
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_profile_comparator_unittest.cc630
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_profile_unittest.cc461
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_structured_address.cc47
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_structured_address.h16
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_structured_address_component.cc127
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_structured_address_component.h48
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_structured_address_component_unittest.cc459
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_structured_address_name.cc19
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_structured_address_name.h6
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_structured_address_name_unittest.cc183
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils.cc26
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils.h26
-rw-r--r--chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils_unittest.cc30
-rw-r--r--chromium/components/autofill/core/browser/data_model/borrowed_transliterator.cc2
-rw-r--r--chromium/components/autofill/core/browser/data_model/borrowed_transliterator.h2
-rw-r--r--chromium/components/autofill/core/browser/data_model/borrowed_transliterator_unittest.cc4
-rw-r--r--chromium/components/autofill/core/browser/data_model/contact_info.cc36
-rw-r--r--chromium/components/autofill/core/browser/data_model/contact_info.h39
-rw-r--r--chromium/components/autofill/core/browser/data_model/contact_info_unittest.cc188
-rw-r--r--chromium/components/autofill/core/browser/data_model/credit_card.cc227
-rw-r--r--chromium/components/autofill/core/browser/data_model/credit_card.h89
-rw-r--r--chromium/components/autofill/core/browser/data_model/credit_card_cloud_token_data.cc10
-rw-r--r--chromium/components/autofill/core/browser/data_model/credit_card_cloud_token_data.h13
-rw-r--r--chromium/components/autofill/core/browser/data_model/credit_card_unittest.cc385
-rw-r--r--chromium/components/autofill/core/browser/data_model/data_model_utils.cc50
-rw-r--r--chromium/components/autofill/core/browser/data_model/data_model_utils.h19
-rw-r--r--chromium/components/autofill/core/browser/data_model/form_group.cc24
-rw-r--r--chromium/components/autofill/core/browser/data_model/form_group.h27
-rw-r--r--chromium/components/autofill/core/browser/data_model/phone_number.cc46
-rw-r--r--chromium/components/autofill/core/browser/data_model/phone_number.h25
-rw-r--r--chromium/components/autofill/core/browser/data_model/phone_number_unittest.cc212
-rw-r--r--chromium/components/autofill/core/browser/data_model/test_data_creator.cc87
41 files changed, 2206 insertions, 2253 deletions
diff --git a/chromium/components/autofill/core/browser/data_model/address.cc b/chromium/components/autofill/core/browser/data_model/address.cc
index 9fe03c9a1c1..9e68a112868 100644
--- a/chromium/components/autofill/core/browser/data_model/address.cc
+++ b/chromium/components/autofill/core/browser/data_model/address.cc
@@ -118,7 +118,7 @@ const structured_address::Address& Address::GetStructuredAddress() const {
return structured_address_;
}
-base::string16 Address::GetRawInfo(ServerFieldType type) const {
+std::u16string Address::GetRawInfo(ServerFieldType type) const {
DCHECK_EQ(FieldTypeGroup::kAddressHome, AutofillType(type).group());
// For structured addresses, the value can be directly retrieved.
@@ -127,13 +127,13 @@ base::string16 Address::GetRawInfo(ServerFieldType type) const {
switch (type) {
case ADDRESS_HOME_LINE1:
- return street_address_.size() > 0 ? street_address_[0] : base::string16();
+ return street_address_.size() > 0 ? street_address_[0] : std::u16string();
case ADDRESS_HOME_LINE2:
- return street_address_.size() > 1 ? street_address_[1] : base::string16();
+ return street_address_.size() > 1 ? street_address_[1] : std::u16string();
case ADDRESS_HOME_LINE3:
- return street_address_.size() > 2 ? street_address_[2] : base::string16();
+ return street_address_.size() > 2 ? street_address_[2] : std::u16string();
case ADDRESS_HOME_DEPENDENT_LOCALITY:
return dependent_locality_;
@@ -154,13 +154,13 @@ base::string16 Address::GetRawInfo(ServerFieldType type) const {
return base::ASCIIToUTF16(country_code_);
case ADDRESS_HOME_STREET_ADDRESS:
- return base::JoinString(street_address_, base::ASCIIToUTF16("\n"));
+ return base::JoinString(street_address_, u"\n");
case ADDRESS_HOME_APT_NUM:
- return base::string16();
+ return std::u16string();
case ADDRESS_HOME_FLOOR:
- return base::string16();
+ return std::u16string();
// The following tokens are used for creating new type votes but should not
// be filled into fields.
@@ -181,16 +181,16 @@ base::string16 Address::GetRawInfo(ServerFieldType type) const {
case ADDRESS_HOME_ADDRESS:
case ADDRESS_HOME_ADDRESS_WITH_NAME:
- return base::string16();
+ return std::u16string();
default:
NOTREACHED() << "Unrecognized type: " << type;
- return base::string16();
+ return std::u16string();
}
}
void Address::SetRawInfoWithVerificationStatus(ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
VerificationStatus status) {
DCHECK_EQ(FieldTypeGroup::kAddressHome, AutofillType(type).group());
@@ -202,7 +202,7 @@ void Address::SetRawInfoWithVerificationStatus(ServerFieldType type,
// using the settings dialog. In case the settings dialog was used to change
// the address to contain different tokens, the structure must be reset.
if (type == ADDRESS_HOME_STREET_ADDRESS) {
- const base::string16 current_value =
+ const std::u16string current_value =
structured_address_.GetValueForType(type);
if (!current_value.empty()) {
bool token_equivalent = structured_address::AreStringTokenEquivalent(
@@ -276,13 +276,11 @@ void Address::SetRawInfoWithVerificationStatus(ServerFieldType type,
case ADDRESS_HOME_STREET_ADDRESS:
// If the street address changes, the structured tokens must be reset.
- if (base::SplitString(value, base::ASCIIToUTF16("\n"),
- base::TRIM_WHITESPACE,
+ if (base::SplitString(value, u"\n", base::TRIM_WHITESPACE,
base::SPLIT_WANT_ALL) != street_address_) {
ResetStructuredTokes();
- street_address_ =
- base::SplitString(value, base::ASCIIToUTF16("\n"),
- base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
+ street_address_ = base::SplitString(value, u"\n", base::TRIM_WHITESPACE,
+ base::SPLIT_WANT_ALL);
}
break;
@@ -332,7 +330,7 @@ void Address::ResetStructuredTokes() {
subpremise_.clear();
}
-void Address::GetMatchingTypes(const base::string16& text,
+void Address::GetMatchingTypes(const std::u16string& text,
const std::string& app_locale,
ServerFieldTypeSet* matching_types) const {
FormGroup::GetMatchingTypes(text, app_locale, matching_types);
@@ -358,14 +356,14 @@ void Address::GetMatchingTypes(const base::string16& text,
AutofillProfileComparator comparator(app_locale);
// Check to see if the |text| could be the full name or abbreviation of a
// state.
- base::string16 canon_text = comparator.NormalizeForComparison(text);
- base::string16 state_name;
- base::string16 state_abbreviation;
+ std::u16string canon_text = comparator.NormalizeForComparison(text);
+ std::u16string state_name;
+ std::u16string state_abbreviation;
state_names::GetNameAndAbbreviation(canon_text, &state_name,
&state_abbreviation);
if (!state_name.empty() || !state_abbreviation.empty()) {
- base::string16 canon_profile_state = comparator.NormalizeForComparison(
+ std::u16string canon_profile_state = comparator.NormalizeForComparison(
GetInfo(AutofillType(ADDRESS_HOME_STATE), app_locale));
if ((!state_name.empty() &&
compare.StringsEqual(state_name, canon_profile_state)) ||
@@ -399,7 +397,7 @@ void Address::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
}
}
-base::string16 Address::GetInfoImpl(const AutofillType& type,
+std::u16string Address::GetInfoImpl(const AutofillType& type,
const std::string& locale) const {
// Get the country code stored in the profile either from the structured
// address if enabled or from the legacy field.
@@ -423,7 +421,7 @@ base::string16 Address::GetInfoImpl(const AutofillType& type,
}
bool Address::SetInfoWithVerificationStatusImpl(const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& locale,
VerificationStatus status) {
// TODO(crbug.com/1130194): Clean legacy implementation once structured
@@ -490,7 +488,7 @@ bool Address::SetInfoWithVerificationStatusImpl(const AutofillType& type,
if (structured_address::StructuredAddressesEnabled()) {
return structured_address_.IsValueForTypeValid(
ADDRESS_HOME_STREET_ADDRESS, /*wipe_if_not=*/true);
- } else if (base::Contains(street_address_, base::string16())) {
+ } else if (base::Contains(street_address_, std::u16string())) {
street_address_.clear();
return false;
}
diff --git a/chromium/components/autofill/core/browser/data_model/address.h b/chromium/components/autofill/core/browser/data_model/address.h
index beb2f9d1600..83348474381 100644
--- a/chromium/components/autofill/core/browser/data_model/address.h
+++ b/chromium/components/autofill/core/browser/data_model/address.h
@@ -9,7 +9,6 @@
#include <vector>
#include "base/compiler_specific.h"
-#include "base/strings/string16.h"
#include "components/autofill/core/browser/data_model/autofill_structured_address.h"
#include "components/autofill/core/browser/data_model/form_group.h"
#include "components/autofill/core/browser/geo/alternative_state_name_map.h"
@@ -28,12 +27,12 @@ class Address : public FormGroup {
bool operator!=(const Address& other) const { return !operator==(other); }
// FormGroup:
- base::string16 GetRawInfo(ServerFieldType type) const override;
+ std::u16string GetRawInfo(ServerFieldType type) const override;
void SetRawInfoWithVerificationStatus(
ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
structured_address::VerificationStatus status) override;
- void GetMatchingTypes(const base::string16& text,
+ void GetMatchingTypes(const std::u16string& text,
const std::string& locale,
ServerFieldTypeSet* matching_types) const override;
@@ -68,11 +67,11 @@ class Address : public FormGroup {
private:
// FormGroup:
void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override;
- base::string16 GetInfoImpl(const AutofillType& type,
+ std::u16string GetInfoImpl(const AutofillType& type,
const std::string& locale) const override;
bool SetInfoWithVerificationStatusImpl(
const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& locale,
structured_address::VerificationStatus status) override;
@@ -86,23 +85,23 @@ class Address : public FormGroup {
// TODO(crbug.com/1130194): Clean legacy implementation once structured
// addresses are fully launched.
// The lines of the street address.
- std::vector<base::string16> street_address_;
+ std::vector<std::u16string> street_address_;
// A subdivision of city, e.g. inner-city district or suburb.
- base::string16 dependent_locality_;
- base::string16 city_;
- base::string16 state_;
- base::string16 zip_code_;
+ std::u16string dependent_locality_;
+ std::u16string city_;
+ std::u16string state_;
+ std::u16string zip_code_;
// Similar to a ZIP code, but used by entities that might not be
// geographically contiguous. The canonical example is CEDEX in France.
- base::string16 sorting_code_;
+ std::u16string sorting_code_;
// The following entries are only popluated by Sync and
// used to create type votes, but are not used for filling fields.
- base::string16 street_name_;
- base::string16 dependent_street_name_;
- base::string16 house_number_;
- base::string16 premise_name_;
- base::string16 subpremise_;
+ std::u16string street_name_;
+ std::u16string dependent_street_name_;
+ std::u16string house_number_;
+ std::u16string premise_name_;
+ std::u16string subpremise_;
// The ISO 3166 2-letter country code, or an empty string if there is no
// country data specified for this address.
diff --git a/chromium/components/autofill/core/browser/data_model/address_unittest.cc b/chromium/components/autofill/core/browser/data_model/address_unittest.cc
index 248ccdbe097..b81c20a03bd 100644
--- a/chromium/components/autofill/core/browser/data_model/address_unittest.cc
+++ b/chromium/components/autofill/core/browser/data_model/address_unittest.cc
@@ -7,7 +7,6 @@
#include <string>
#include "base/macros.h"
-#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill/core/browser/autofill_type.h"
@@ -51,145 +50,140 @@ class AddressTest : public testing::Test,
// localized country name.
TEST_P(AddressTest, GetCountry) {
Address address;
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
// Make sure that nothing breaks when the country code is missing.
- base::string16 country =
+ std::u16string country =
address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
- EXPECT_EQ(base::string16(), country);
+ EXPECT_EQ(std::u16string(), country);
- address.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("US"),
- "en-US");
+ address.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), u"US", "en-US");
country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
- EXPECT_EQ(ASCIIToUTF16("United States"), country);
+ EXPECT_EQ(u"United States", country);
country = address.GetInfo(
AutofillType(HTML_TYPE_COUNTRY_NAME, HTML_MODE_NONE), "en-US");
- EXPECT_EQ(ASCIIToUTF16("United States"), country);
+ EXPECT_EQ(u"United States", country);
country = address.GetInfo(
AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE), "en-US");
- EXPECT_EQ(ASCIIToUTF16("US"), country);
+ EXPECT_EQ(u"US", country);
- address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA"));
+ address.SetRawInfo(ADDRESS_HOME_COUNTRY, u"CA");
country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
- EXPECT_EQ(ASCIIToUTF16("Canada"), country);
+ EXPECT_EQ(u"Canada", country);
country = address.GetInfo(
AutofillType(HTML_TYPE_COUNTRY_NAME, HTML_MODE_NONE), "en-US");
- EXPECT_EQ(ASCIIToUTF16("Canada"), country);
+ EXPECT_EQ(u"Canada", country);
country = address.GetInfo(
AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE), "en-US");
- EXPECT_EQ(ASCIIToUTF16("CA"), country);
+ EXPECT_EQ(u"CA", country);
}
// Test that country data can be properly returned as either a country code or a
// full country name that can even be localized.
TEST_P(AddressTest, SetHtmlCountryCodeTypeWithFullCountryName) {
Address address;
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
// Create an autofill type from HTML_TYPE_COUNTRY_CODE.
AutofillType autofill_type(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE);
// Test that the country value can be set and retrieved if it is not
// a country code but a full country name.
- address.SetInfo(autofill_type, ASCIIToUTF16("Germany"), "en-US");
- base::string16 actual_country =
+ address.SetInfo(autofill_type, u"Germany", "en-US");
+ std::u16string actual_country =
address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
- base::string16 actual_country_code = address.GetInfo(
+ std::u16string actual_country_code = address.GetInfo(
AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE), "en-US");
- EXPECT_EQ(ASCIIToUTF16("Germany"), actual_country);
- EXPECT_EQ(ASCIIToUTF16("DE"), actual_country_code);
+ EXPECT_EQ(u"Germany", actual_country);
+ EXPECT_EQ(u"DE", actual_country_code);
// Reset the country and verify that the reset works as expected.
- address.SetInfo(autofill_type, ASCIIToUTF16(""), "en-US");
+ address.SetInfo(autofill_type, u"", "en-US");
actual_country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
actual_country_code = address.GetInfo(
AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE), "en-US");
- EXPECT_EQ(ASCIIToUTF16(""), actual_country);
- EXPECT_EQ(ASCIIToUTF16(""), actual_country_code);
+ EXPECT_EQ(u"", actual_country);
+ EXPECT_EQ(u"", actual_country_code);
// Test that the country value can be set and retrieved if it is not
// a country code but a full country name with a non-standard locale.
- address.SetInfo(autofill_type, ASCIIToUTF16("deutschland"), "de");
+ address.SetInfo(autofill_type, u"deutschland", "de");
actual_country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
actual_country_code = address.GetInfo(
AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE), "en-US");
- EXPECT_EQ(ASCIIToUTF16("Germany"), actual_country);
- EXPECT_EQ(ASCIIToUTF16("DE"), actual_country_code);
+ EXPECT_EQ(u"Germany", actual_country);
+ EXPECT_EQ(u"DE", actual_country_code);
// Reset the country.
- address.SetInfo(autofill_type, ASCIIToUTF16(""), "en-US");
+ address.SetInfo(autofill_type, u"", "en-US");
// Test that the country is still stored correctly with a supplied
// country code.
- address.SetInfo(autofill_type, ASCIIToUTF16("DE"), "en-US");
+ address.SetInfo(autofill_type, u"DE", "en-US");
actual_country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
actual_country_code = address.GetInfo(
AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE), "en-US");
- EXPECT_EQ(ASCIIToUTF16("DE"), actual_country_code);
- EXPECT_EQ(ASCIIToUTF16("Germany"), actual_country);
+ EXPECT_EQ(u"DE", actual_country_code);
+ EXPECT_EQ(u"Germany", actual_country);
}
// Test that we properly detect country codes appropriate for each country.
TEST_P(AddressTest, SetCountry) {
Address address;
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
// Test basic conversion.
- address.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY),
- ASCIIToUTF16("United States"), "en-US");
- base::string16 country =
+ address.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), u"United States",
+ "en-US");
+ std::u16string country =
address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
- EXPECT_EQ(ASCIIToUTF16("US"), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
- EXPECT_EQ(ASCIIToUTF16("United States"), country);
+ EXPECT_EQ(u"US", address.GetRawInfo(ADDRESS_HOME_COUNTRY));
+ EXPECT_EQ(u"United States", country);
// Test basic synonym detection.
- address.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("USA"),
- "en-US");
+ address.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), u"USA", "en-US");
country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
- EXPECT_EQ(ASCIIToUTF16("US"), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
- EXPECT_EQ(ASCIIToUTF16("United States"), country);
+ EXPECT_EQ(u"US", address.GetRawInfo(ADDRESS_HOME_COUNTRY));
+ EXPECT_EQ(u"United States", country);
// Test case-insensitivity.
- address.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("canADA"),
- "en-US");
+ address.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), u"canADA", "en-US");
country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
- EXPECT_EQ(ASCIIToUTF16("CA"), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
- EXPECT_EQ(ASCIIToUTF16("Canada"), country);
+ EXPECT_EQ(u"CA", address.GetRawInfo(ADDRESS_HOME_COUNTRY));
+ EXPECT_EQ(u"Canada", country);
// Test country code detection.
- address.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("JP"),
- "en-US");
+ address.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), u"JP", "en-US");
country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
- EXPECT_EQ(ASCIIToUTF16("JP"), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
- EXPECT_EQ(ASCIIToUTF16("Japan"), country);
+ EXPECT_EQ(u"JP", address.GetRawInfo(ADDRESS_HOME_COUNTRY));
+ EXPECT_EQ(u"Japan", country);
// Test that we ignore unknown countries.
- address.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("Unknown"),
- "en-US");
+ address.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), u"Unknown", "en-US");
country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
- EXPECT_EQ(base::string16(), country);
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
+ EXPECT_EQ(std::u16string(), country);
// Test setting the country based on an HTML field type.
AutofillType html_type_country_code =
AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE);
- address.SetInfo(html_type_country_code, ASCIIToUTF16("US"), "en-US");
+ address.SetInfo(html_type_country_code, u"US", "en-US");
country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
- EXPECT_EQ(ASCIIToUTF16("US"), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
- EXPECT_EQ(ASCIIToUTF16("United States"), country);
+ EXPECT_EQ(u"US", address.GetRawInfo(ADDRESS_HOME_COUNTRY));
+ EXPECT_EQ(u"United States", country);
// Test case-insensitivity when setting the country based on an HTML field
// type.
- address.SetInfo(html_type_country_code, ASCIIToUTF16("cA"), "en-US");
+ address.SetInfo(html_type_country_code, u"cA", "en-US");
country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
- EXPECT_EQ(ASCIIToUTF16("CA"), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
- EXPECT_EQ(ASCIIToUTF16("Canada"), country);
+ EXPECT_EQ(u"CA", address.GetRawInfo(ADDRESS_HOME_COUNTRY));
+ EXPECT_EQ(u"Canada", country);
// Test setting the country based on invalid data with an HTML field type.
- address.SetInfo(html_type_country_code, ASCIIToUTF16("unknown"), "en-US");
+ address.SetInfo(html_type_country_code, u"unknown", "en-US");
country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
- EXPECT_EQ(base::string16(), country);
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
+ EXPECT_EQ(std::u16string(), country);
}
// Test setting and getting the new structured address tokens
@@ -201,27 +195,20 @@ TEST_P(AddressTest, StructuredAddressTokens) {
Address address;
// Set the address tokens.
- address.SetRawInfo(ADDRESS_HOME_STREET_NAME,
- base::ASCIIToUTF16("StreetName"));
- address.SetRawInfo(ADDRESS_HOME_HOUSE_NUMBER,
- base::ASCIIToUTF16("HouseNumber"));
+ address.SetRawInfo(ADDRESS_HOME_STREET_NAME, u"StreetName");
+ address.SetRawInfo(ADDRESS_HOME_HOUSE_NUMBER, u"HouseNumber");
address.SetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME,
- base::ASCIIToUTF16("DependentStreetName"));
- address.SetRawInfo(ADDRESS_HOME_PREMISE_NAME,
- base::ASCIIToUTF16("PremiseNmae"));
- address.SetRawInfo(ADDRESS_HOME_SUBPREMISE, base::ASCIIToUTF16("SubPremise"));
+ u"DependentStreetName");
+ address.SetRawInfo(ADDRESS_HOME_PREMISE_NAME, u"PremiseNmae");
+ address.SetRawInfo(ADDRESS_HOME_SUBPREMISE, u"SubPremise");
// Retrieve the tokens and verify that they are correct.
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME),
- base::ASCIIToUTF16("StreetName"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER),
- base::ASCIIToUTF16("HouseNumber"));
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME), u"StreetName");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), u"HouseNumber");
EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME),
- base::ASCIIToUTF16("DependentStreetName"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_PREMISE_NAME),
- base::ASCIIToUTF16("PremiseNmae"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_SUBPREMISE),
- base::ASCIIToUTF16("SubPremise"));
+ u"DependentStreetName");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_PREMISE_NAME), u"PremiseNmae");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_SUBPREMISE), u"SubPremise");
}
// Test setting and getting the new structured address tokens
@@ -237,134 +224,103 @@ TEST_P(AddressTest,
Address address;
// Set the address tokens.
- address.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS,
- base::ASCIIToUTF16("Line1\nLine2"));
- address.SetRawInfo(ADDRESS_HOME_STREET_NAME,
- base::ASCIIToUTF16("StreetName"));
- address.SetRawInfo(ADDRESS_HOME_HOUSE_NUMBER,
- base::ASCIIToUTF16("HouseNumber"));
+ address.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"Line1\nLine2");
+ address.SetRawInfo(ADDRESS_HOME_STREET_NAME, u"StreetName");
+ address.SetRawInfo(ADDRESS_HOME_HOUSE_NUMBER, u"HouseNumber");
address.SetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME,
- base::ASCIIToUTF16("DependentStreetName"));
- address.SetRawInfo(ADDRESS_HOME_PREMISE_NAME,
- base::ASCIIToUTF16("PremiseNmae"));
- address.SetRawInfo(ADDRESS_HOME_SUBPREMISE, base::ASCIIToUTF16("SubPremise"));
+ u"DependentStreetName");
+ address.SetRawInfo(ADDRESS_HOME_PREMISE_NAME, u"PremiseNmae");
+ address.SetRawInfo(ADDRESS_HOME_SUBPREMISE, u"SubPremise");
// Retrieve the tokens and verify that they are correct.
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE1),
- base::ASCIIToUTF16("Line1"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE2),
- base::ASCIIToUTF16("Line2"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS),
- base::ASCIIToUTF16("Line1\nLine2"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME),
- base::ASCIIToUTF16("StreetName"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER),
- base::ASCIIToUTF16("HouseNumber"));
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE1), u"Line1");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE2), u"Line2");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS), u"Line1\nLine2");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME), u"StreetName");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), u"HouseNumber");
EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME),
- base::ASCIIToUTF16("DependentStreetName"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_PREMISE_NAME),
- base::ASCIIToUTF16("PremiseNmae"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_SUBPREMISE),
- base::ASCIIToUTF16("SubPremise"));
+ u"DependentStreetName");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_PREMISE_NAME), u"PremiseNmae");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_SUBPREMISE), u"SubPremise");
// Set the unstructured address information to the same values as they already
// are.
- address.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS,
- base::ASCIIToUTF16("Line1\nLine2"));
- address.SetRawInfo(ADDRESS_HOME_LINE1, base::ASCIIToUTF16("Line1"));
- address.SetRawInfo(ADDRESS_HOME_LINE2, base::ASCIIToUTF16("Line2"));
+ address.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"Line1\nLine2");
+ address.SetRawInfo(ADDRESS_HOME_LINE1, u"Line1");
+ address.SetRawInfo(ADDRESS_HOME_LINE2, u"Line2");
// Verify that the structured tokens are still set.
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME),
- base::ASCIIToUTF16("StreetName"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER),
- base::ASCIIToUTF16("HouseNumber"));
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME), u"StreetName");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), u"HouseNumber");
EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME),
- base::ASCIIToUTF16("DependentStreetName"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_PREMISE_NAME),
- base::ASCIIToUTF16("PremiseNmae"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_SUBPREMISE),
- base::ASCIIToUTF16("SubPremise"));
+ u"DependentStreetName");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_PREMISE_NAME), u"PremiseNmae");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_SUBPREMISE), u"SubPremise");
// Now, change the address by changing HOME_ADDRESS_LINE1 and verify that the
// structured tokens are reset.
- address.SetRawInfo(ADDRESS_HOME_LINE1, base::ASCIIToUTF16("NewLine1"));
+ address.SetRawInfo(ADDRESS_HOME_LINE1, u"NewLine1");
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE1),
- base::ASCIIToUTF16("NewLine1"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE2),
- base::ASCIIToUTF16("Line2"));
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE1), u"NewLine1");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE2), u"Line2");
EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS),
- base::ASCIIToUTF16("NewLine1\nLine2"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME), base::string16());
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), base::string16());
+ u"NewLine1\nLine2");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME), std::u16string());
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), std::u16string());
EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME),
- base::string16());
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_PREMISE_NAME), base::string16());
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_SUBPREMISE), base::string16());
+ std::u16string());
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_PREMISE_NAME), std::u16string());
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_SUBPREMISE), std::u16string());
// Reset the structured tokens and perform the same step for
// HOME_ADDRESS_LINE2.
- address.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS,
- base::ASCIIToUTF16("Line1\nLine2"));
- address.SetRawInfo(ADDRESS_HOME_STREET_NAME,
- base::ASCIIToUTF16("StreetName"));
- address.SetRawInfo(ADDRESS_HOME_HOUSE_NUMBER,
- base::ASCIIToUTF16("HouseNumber"));
+ address.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"Line1\nLine2");
+ address.SetRawInfo(ADDRESS_HOME_STREET_NAME, u"StreetName");
+ address.SetRawInfo(ADDRESS_HOME_HOUSE_NUMBER, u"HouseNumber");
address.SetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME,
- base::ASCIIToUTF16("DependentStreetName"));
- address.SetRawInfo(ADDRESS_HOME_PREMISE_NAME,
- base::ASCIIToUTF16("PremiseNmae"));
- address.SetRawInfo(ADDRESS_HOME_SUBPREMISE, base::ASCIIToUTF16("SubPremise"));
+ u"DependentStreetName");
+ address.SetRawInfo(ADDRESS_HOME_PREMISE_NAME, u"PremiseNmae");
+ address.SetRawInfo(ADDRESS_HOME_SUBPREMISE, u"SubPremise");
- address.SetRawInfo(ADDRESS_HOME_LINE2, base::ASCIIToUTF16("NewLine2"));
+ address.SetRawInfo(ADDRESS_HOME_LINE2, u"NewLine2");
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE1),
- base::ASCIIToUTF16("Line1"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE2),
- base::ASCIIToUTF16("NewLine2"));
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE1), u"Line1");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE2), u"NewLine2");
EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS),
- base::ASCIIToUTF16("Line1\nNewLine2"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME), base::string16());
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), base::string16());
+ u"Line1\nNewLine2");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME), std::u16string());
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), std::u16string());
EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME),
- base::string16());
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_PREMISE_NAME), base::string16());
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_SUBPREMISE), base::string16());
+ std::u16string());
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_PREMISE_NAME), std::u16string());
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_SUBPREMISE), std::u16string());
// And once again for ADDRESS_HOME_STREET_ADDRESS.
- address.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS,
- base::ASCIIToUTF16("Line1\nLine2"));
- address.SetRawInfo(ADDRESS_HOME_STREET_NAME,
- base::ASCIIToUTF16("StreetName"));
- address.SetRawInfo(ADDRESS_HOME_HOUSE_NUMBER,
- base::ASCIIToUTF16("HouseNumber"));
+ address.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"Line1\nLine2");
+ address.SetRawInfo(ADDRESS_HOME_STREET_NAME, u"StreetName");
+ address.SetRawInfo(ADDRESS_HOME_HOUSE_NUMBER, u"HouseNumber");
address.SetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME,
- base::ASCIIToUTF16("DependentStreetName"));
- address.SetRawInfo(ADDRESS_HOME_PREMISE_NAME,
- base::ASCIIToUTF16("PremiseNmae"));
- address.SetRawInfo(ADDRESS_HOME_SUBPREMISE, base::ASCIIToUTF16("SubPremise"));
-
- address.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS,
- base::ASCIIToUTF16("NewLine1\nNewLine2"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE1),
- base::ASCIIToUTF16("NewLine1"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE2),
- base::ASCIIToUTF16("NewLine2"));
+ u"DependentStreetName");
+ address.SetRawInfo(ADDRESS_HOME_PREMISE_NAME, u"PremiseNmae");
+ address.SetRawInfo(ADDRESS_HOME_SUBPREMISE, u"SubPremise");
+
+ address.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"NewLine1\nNewLine2");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE1), u"NewLine1");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_LINE2), u"NewLine2");
EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS),
- base::ASCIIToUTF16("NewLine1\nNewLine2"));
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME), base::string16());
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), base::string16());
+ u"NewLine1\nNewLine2");
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME), std::u16string());
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), std::u16string());
EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME),
- base::string16());
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_PREMISE_NAME), base::string16());
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_SUBPREMISE), base::string16());
+ std::u16string());
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_PREMISE_NAME), std::u16string());
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_SUBPREMISE), std::u16string());
}
// Test that we properly match typed values to stored country data.
TEST_P(AddressTest, IsCountry) {
Address address;
- address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
+ address.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US");
const char* const kValidMatches[] = {"United States", "USA", "US",
"United states", "us"};
@@ -385,10 +341,10 @@ TEST_P(AddressTest, IsCountry) {
}
// Make sure that garbage values don't match when the country code is empty.
- address.SetRawInfo(ADDRESS_HOME_COUNTRY, base::string16());
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
+ address.SetRawInfo(ADDRESS_HOME_COUNTRY, std::u16string());
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
ServerFieldTypeSet matching_types;
- address.GetMatchingTypes(ASCIIToUTF16("Garbage"), "US", &matching_types);
+ address.GetMatchingTypes(u"Garbage", "US", &matching_types);
EXPECT_EQ(0U, matching_types.size());
}
@@ -450,26 +406,26 @@ TEST_P(AddressTest, GetStreetAddress) {
EXPECT_TRUE(address.GetRawInfo(ADDRESS_HOME_LINE1).empty());
EXPECT_TRUE(address.GetRawInfo(ADDRESS_HOME_LINE2).empty());
EXPECT_TRUE(address.GetRawInfo(ADDRESS_HOME_LINE3).empty());
- EXPECT_EQ(base::string16(), address.GetInfo(type, "en-US"));
+ EXPECT_EQ(std::u16string(), address.GetInfo(type, "en-US"));
// Address has only line 1.
- address.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Example Ave."));
+ address.SetRawInfo(ADDRESS_HOME_LINE1, u"123 Example Ave.");
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE1).empty());
EXPECT_TRUE(address.GetRawInfo(ADDRESS_HOME_LINE2).empty());
EXPECT_TRUE(address.GetRawInfo(ADDRESS_HOME_LINE3).empty());
- EXPECT_EQ(ASCIIToUTF16("123 Example Ave."), address.GetInfo(type, "en-US"));
+ EXPECT_EQ(u"123 Example Ave.", address.GetInfo(type, "en-US"));
// Address has only line 2.
- address.SetRawInfo(ADDRESS_HOME_LINE1, base::string16());
- address.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("Apt 42."));
+ address.SetRawInfo(ADDRESS_HOME_LINE1, std::u16string());
+ address.SetRawInfo(ADDRESS_HOME_LINE2, u"Apt 42.");
EXPECT_TRUE(address.GetRawInfo(ADDRESS_HOME_LINE1).empty());
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE2).empty());
EXPECT_TRUE(address.GetRawInfo(ADDRESS_HOME_LINE3).empty());
- EXPECT_EQ(ASCIIToUTF16("\nApt 42."), address.GetInfo(type, "en-US"));
+ EXPECT_EQ(u"\nApt 42.", address.GetInfo(type, "en-US"));
// Address has lines 1 and 2.
- address.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Example Ave."));
- address.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("Apt. 42"));
+ address.SetRawInfo(ADDRESS_HOME_LINE1, u"123 Example Ave.");
+ address.SetRawInfo(ADDRESS_HOME_LINE2, u"Apt. 42");
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE1).empty());
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE2).empty());
EXPECT_TRUE(address.GetRawInfo(ADDRESS_HOME_LINE3).empty());
@@ -481,16 +437,15 @@ TEST_P(AddressTest, GetStreetAddress) {
address.GetInfo(type, "en-US"));
// A wild third line appears.
- address.SetRawInfo(ADDRESS_HOME_LINE3, ASCIIToUTF16("Living room couch"));
- EXPECT_EQ(ASCIIToUTF16("Living room couch"),
- address.GetRawInfo(ADDRESS_HOME_LINE3));
+ address.SetRawInfo(ADDRESS_HOME_LINE3, u"Living room couch");
+ EXPECT_EQ(u"Living room couch", address.GetRawInfo(ADDRESS_HOME_LINE3));
EXPECT_EQ(ASCIIToUTF16("123 Example Ave.\n"
"Apt. 42\n"
"Living room couch"),
address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS));
// The second line vanishes.
- address.SetRawInfo(ADDRESS_HOME_LINE2, base::string16());
+ address.SetRawInfo(ADDRESS_HOME_LINE2, std::u16string());
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE1).empty());
EXPECT_TRUE(address.GetRawInfo(ADDRESS_HOME_LINE2).empty());
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE3).empty());
@@ -505,84 +460,80 @@ TEST_P(AddressTest, GetStreetAddress) {
TEST_P(AddressTest, GetStreetAddressAfterOverwritingLongAddressWithShorterOne) {
// Start with an address that has two lines.
Address address;
- address.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Example Ave."));
- address.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("Apt. 42"));
+ address.SetRawInfo(ADDRESS_HOME_LINE1, u"123 Example Ave.");
+ address.SetRawInfo(ADDRESS_HOME_LINE2, u"Apt. 42");
// Now clear out the second address line.
- address.SetRawInfo(ADDRESS_HOME_LINE2, base::string16());
- EXPECT_EQ(ASCIIToUTF16("123 Example Ave."),
+ address.SetRawInfo(ADDRESS_HOME_LINE2, std::u16string());
+ EXPECT_EQ(u"123 Example Ave.",
address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS));
// Now clear out the first address line as well.
- address.SetRawInfo(ADDRESS_HOME_LINE1, base::string16());
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS));
+ address.SetRawInfo(ADDRESS_HOME_LINE1, std::u16string());
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS));
}
// Verifies that Address::SetRawInfo() is able to split address lines correctly.
TEST_P(AddressTest, SetRawStreetAddress) {
- const base::string16 empty_street_address;
- const base::string16 short_street_address = ASCIIToUTF16("456 Nowhere Ln.");
- const base::string16 long_street_address = ASCIIToUTF16(
+ const std::u16string empty_street_address;
+ const std::u16string short_street_address = u"456 Nowhere Ln.";
+ const std::u16string long_street_address = ASCIIToUTF16(
"123 Example Ave.\n"
"Apt. 42\n"
"(The one with the blue door)");
Address address;
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE1));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE1));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE2));
address.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, long_street_address);
- EXPECT_EQ(ASCIIToUTF16("123 Example Ave."),
- address.GetRawInfo(ADDRESS_HOME_LINE1));
- EXPECT_EQ(ASCIIToUTF16("Apt. 42"), address.GetRawInfo(ADDRESS_HOME_LINE2));
+ EXPECT_EQ(u"123 Example Ave.", address.GetRawInfo(ADDRESS_HOME_LINE1));
+ EXPECT_EQ(u"Apt. 42", address.GetRawInfo(ADDRESS_HOME_LINE2));
EXPECT_EQ(long_street_address,
address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS));
// A short address should clear out unused address lines.
address.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, short_street_address);
- EXPECT_EQ(ASCIIToUTF16("456 Nowhere Ln."),
- address.GetRawInfo(ADDRESS_HOME_LINE1));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2));
+ EXPECT_EQ(u"456 Nowhere Ln.", address.GetRawInfo(ADDRESS_HOME_LINE1));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE2));
// An empty address should clear out all address lines.
address.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, long_street_address);
address.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, empty_street_address);
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE1));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE1));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE2));
}
// Street addresses should be set properly.
TEST_P(AddressTest, SetStreetAddress) {
- const base::string16 empty_street_address;
- const base::string16 multi_line_street_address = ASCIIToUTF16(
+ const std::u16string empty_street_address;
+ const std::u16string multi_line_street_address = ASCIIToUTF16(
"789 Fancy Pkwy.\n"
"Unit 3.14\n"
"Box 9");
- const base::string16 single_line_street_address =
- ASCIIToUTF16("123 Main, Apt 7");
+ const std::u16string single_line_street_address = u"123 Main, Apt 7";
const AutofillType type = AutofillType(ADDRESS_HOME_STREET_ADDRESS);
// Start with a non-empty address.
Address address;
- address.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Example Ave."));
- address.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("Apt. 42"));
- address.SetRawInfo(ADDRESS_HOME_LINE3, ASCIIToUTF16("and a half"));
+ address.SetRawInfo(ADDRESS_HOME_LINE1, u"123 Example Ave.");
+ address.SetRawInfo(ADDRESS_HOME_LINE2, u"Apt. 42");
+ address.SetRawInfo(ADDRESS_HOME_LINE3, u"and a half");
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE1).empty());
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE2).empty());
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE3).empty());
// Attempting to set a multi-line address should succeed.
EXPECT_TRUE(address.SetInfo(type, multi_line_street_address, "en-US"));
- EXPECT_EQ(ASCIIToUTF16("789 Fancy Pkwy."),
- address.GetRawInfo(ADDRESS_HOME_LINE1));
- EXPECT_EQ(ASCIIToUTF16("Unit 3.14"), address.GetRawInfo(ADDRESS_HOME_LINE2));
- EXPECT_EQ(ASCIIToUTF16("Box 9"), address.GetRawInfo(ADDRESS_HOME_LINE3));
+ EXPECT_EQ(u"789 Fancy Pkwy.", address.GetRawInfo(ADDRESS_HOME_LINE1));
+ EXPECT_EQ(u"Unit 3.14", address.GetRawInfo(ADDRESS_HOME_LINE2));
+ EXPECT_EQ(u"Box 9", address.GetRawInfo(ADDRESS_HOME_LINE3));
// Setting a single line street address should clear out subsequent lines.
EXPECT_TRUE(address.SetInfo(type, single_line_street_address, "en-US"));
EXPECT_EQ(single_line_street_address, address.GetRawInfo(ADDRESS_HOME_LINE1));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE3));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE2));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE3));
// Attempting to set an empty address should also succeed, and clear out the
// previously stored data.
@@ -591,9 +542,9 @@ TEST_P(AddressTest, SetStreetAddress) {
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE2).empty());
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE3).empty());
EXPECT_TRUE(address.SetInfo(type, empty_street_address, "en-US"));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE1));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE3));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE1));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE2));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE3));
}
// Verifies that Address::SetInfio() rejects setting data for
@@ -601,8 +552,8 @@ TEST_P(AddressTest, SetStreetAddress) {
TEST_P(AddressTest, SetStreetAddressRejectsAddressesWithInteriorBlankLines) {
// Start with a non-empty address.
Address address;
- address.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Example Ave."));
- address.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("Apt. 42"));
+ address.SetRawInfo(ADDRESS_HOME_LINE1, u"123 Example Ave.");
+ address.SetRawInfo(ADDRESS_HOME_LINE2, u"Apt. 42");
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE1).empty());
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE2).empty());
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS).empty());
@@ -614,9 +565,9 @@ TEST_P(AddressTest, SetStreetAddressRejectsAddressesWithInteriorBlankLines) {
"\n"
"Address line 3"),
"en-US"));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE1));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE1));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE2));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS));
}
// Verifies that Address::SetInfio() rejects setting data for
@@ -624,8 +575,8 @@ TEST_P(AddressTest, SetStreetAddressRejectsAddressesWithInteriorBlankLines) {
TEST_P(AddressTest, SetStreetAddressRejectsAddressesWithLeadingBlankLines) {
// Start with a non-empty address.
Address address;
- address.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Example Ave."));
- address.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("Apt. 42"));
+ address.SetRawInfo(ADDRESS_HOME_LINE1, u"123 Example Ave.");
+ address.SetRawInfo(ADDRESS_HOME_LINE2, u"Apt. 42");
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE1).empty());
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE2).empty());
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS).empty());
@@ -637,9 +588,9 @@ TEST_P(AddressTest, SetStreetAddressRejectsAddressesWithLeadingBlankLines) {
"Address line 2"
"Address line 3"),
"en-US"));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE1));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE1));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE2));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS));
}
// Verifies that Address::SetInfio() rejects setting data for
@@ -647,8 +598,8 @@ TEST_P(AddressTest, SetStreetAddressRejectsAddressesWithLeadingBlankLines) {
TEST_P(AddressTest, SetStreetAddressRejectsAddressesWithTrailingBlankLines) {
// Start with a non-empty address.
Address address;
- address.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Example Ave."));
- address.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("Apt. 42"));
+ address.SetRawInfo(ADDRESS_HOME_LINE1, u"123 Example Ave.");
+ address.SetRawInfo(ADDRESS_HOME_LINE2, u"Apt. 42");
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE1).empty());
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_LINE2).empty());
EXPECT_FALSE(address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS).empty());
@@ -660,9 +611,9 @@ TEST_P(AddressTest, SetStreetAddressRejectsAddressesWithTrailingBlankLines) {
"Address line 2"
"\n"),
"en-US"));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE1));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2));
- EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE1));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_LINE2));
+ EXPECT_EQ(std::u16string(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS));
}
// Verifies that the merging-related methods for structured addresses are
@@ -679,8 +630,8 @@ TEST_P(AddressTest, TestMergeStructuredAddresses) {
EXPECT_TRUE(address1.IsStructuredAddressMergeable(address2));
// The two zip codes have a is-substring relation and are mergeable.
- address1.SetRawInfo(ADDRESS_HOME_ZIP, base::UTF8ToUTF16("12345"));
- address2.SetRawInfo(ADDRESS_HOME_ZIP, base::UTF8ToUTF16("1234"));
+ address1.SetRawInfo(ADDRESS_HOME_ZIP, u"12345");
+ address2.SetRawInfo(ADDRESS_HOME_ZIP, u"1234");
EXPECT_TRUE(address2.IsStructuredAddressMergeable(address1));
EXPECT_TRUE(address1.IsStructuredAddressMergeable(address2));
@@ -688,18 +639,18 @@ TEST_P(AddressTest, TestMergeStructuredAddresses) {
// recently used.
address1.MergeStructuredAddress(address2,
/*newer_use_more_recently_used=*/false);
- EXPECT_EQ(address1.GetRawInfo(ADDRESS_HOME_ZIP), base::UTF8ToUTF16("12345"));
+ EXPECT_EQ(address1.GetRawInfo(ADDRESS_HOME_ZIP), u"12345");
// Once it is more recently used, the value from address2 should be copied
// into address1.
address1.MergeStructuredAddress(address2,
/*newer_use_more_recently_used=*/true);
- EXPECT_EQ(address1.GetRawInfo(ADDRESS_HOME_ZIP), base::UTF8ToUTF16("1234"));
+ EXPECT_EQ(address1.GetRawInfo(ADDRESS_HOME_ZIP), u"1234");
// With a second incompatible ZIP code the addresses are not mergeable
// anymore.
Address address3;
- address3.SetRawInfo(ADDRESS_HOME_ZIP, base::UTF8ToUTF16("67890"));
+ address3.SetRawInfo(ADDRESS_HOME_ZIP, u"67890");
EXPECT_FALSE(address1.IsStructuredAddressMergeable(address3));
}
@@ -711,13 +662,12 @@ TEST_P(AddressTest, TestGettingTheStructuredAddress) {
// Create the address and set a test value.
Address address1;
- address1.SetRawInfo(ADDRESS_HOME_ZIP, base::UTF8ToUTF16("12345"));
+ address1.SetRawInfo(ADDRESS_HOME_ZIP, u"12345");
// Get the structured address and verify that it has the same test value set.
structured_address::Address structured_address =
address1.GetStructuredAddress();
- EXPECT_EQ(structured_address.GetValueForType(ADDRESS_HOME_ZIP),
- base::UTF8ToUTF16("12345"));
+ EXPECT_EQ(structured_address.GetValueForType(ADDRESS_HOME_ZIP), u"12345");
}
// For structured address, test that the structured information is wiped
@@ -730,23 +680,21 @@ TEST_P(AddressTest, ResetStructuredTokens) {
Address address;
// Set a structured address line and call the finalization routine.
address.SetRawInfoWithVerificationStatus(
- ADDRESS_HOME_STREET_ADDRESS, base::ASCIIToUTF16("Erika-Mann-Str 12"),
+ ADDRESS_HOME_STREET_ADDRESS, u"Erika-Mann-Str 12",
structured_address::VerificationStatus::kUserVerified);
address.FinalizeAfterImport();
// Verify that structured tokens have been assigned correctly.
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME),
- base::ASCIIToUTF16("Erika-Mann-Str"));
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME), u"Erika-Mann-Str");
EXPECT_EQ(address.GetVerificationStatus(ADDRESS_HOME_STREET_NAME),
structured_address::VerificationStatus::kParsed);
- ASSERT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER),
- base::ASCIIToUTF16("12"));
+ ASSERT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), u"12");
EXPECT_EQ(address.GetVerificationStatus(ADDRESS_HOME_HOUSE_NUMBER),
structured_address::VerificationStatus::kParsed);
// Lift the verification status of the house number to be |kObserved|.
address.SetRawInfoWithVerificationStatus(
- ADDRESS_HOME_HOUSE_NUMBER, base::ASCIIToUTF16("12"),
+ ADDRESS_HOME_HOUSE_NUMBER, u"12",
structured_address::VerificationStatus::kObserved);
EXPECT_EQ(address.GetVerificationStatus(ADDRESS_HOME_HOUSE_NUMBER),
structured_address::VerificationStatus::kObserved);
@@ -754,33 +702,29 @@ TEST_P(AddressTest, ResetStructuredTokens) {
// Now, set a new unstructured street address that has the same tokens in a
// different order.
address.SetRawInfoWithVerificationStatus(
- ADDRESS_HOME_STREET_ADDRESS, base::ASCIIToUTF16("12 Erika-Mann-Str"),
+ ADDRESS_HOME_STREET_ADDRESS, u"12 Erika-Mann-Str",
structured_address::VerificationStatus::kUserVerified);
// After this operation, the structure should be maintained including the
// observed status of the house number.
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME),
- base::ASCIIToUTF16("Erika-Mann-Str"));
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME), u"Erika-Mann-Str");
EXPECT_EQ(address.GetVerificationStatus(ADDRESS_HOME_STREET_NAME),
structured_address::VerificationStatus::kParsed);
- ASSERT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER),
- base::ASCIIToUTF16("12"));
+ ASSERT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), u"12");
EXPECT_EQ(address.GetVerificationStatus(ADDRESS_HOME_HOUSE_NUMBER),
structured_address::VerificationStatus::kObserved);
// Now set a different street address.
address.SetRawInfoWithVerificationStatus(
- ADDRESS_HOME_STREET_ADDRESS, base::ASCIIToUTF16("Marienplatz"),
+ ADDRESS_HOME_STREET_ADDRESS, u"Marienplatz",
structured_address::VerificationStatus::kUserVerified);
// The set address is not parsable and the this should unset both the street
// name and the house number.
- EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME),
- base::ASCIIToUTF16(""));
+ EXPECT_EQ(address.GetRawInfo(ADDRESS_HOME_STREET_NAME), u"");
EXPECT_EQ(address.GetVerificationStatus(ADDRESS_HOME_STREET_NAME),
structured_address::VerificationStatus::kNoStatus);
- ASSERT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER),
- base::ASCIIToUTF16(""));
+ ASSERT_EQ(address.GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), u"");
EXPECT_EQ(address.GetVerificationStatus(ADDRESS_HOME_HOUSE_NUMBER),
structured_address::VerificationStatus::kNoStatus);
}
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_data_model.h b/chromium/components/autofill/core/browser/data_model/autofill_data_model.h
index e67afcda8dc..0d85ae3fccb 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_data_model.h
+++ b/chromium/components/autofill/core/browser/data_model/autofill_data_model.h
@@ -9,7 +9,6 @@
#include <string>
-#include "base/strings/string16.h"
#include "base/time/time.h"
#include "components/autofill/core/browser/data_model/form_group.h"
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_data_model_unittest.cc b/chromium/components/autofill/core/browser/data_model/autofill_data_model_unittest.cc
index 75d3117902e..e878bfdcf61 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_data_model_unittest.cc
+++ b/chromium/components/autofill/core/browser/data_model/autofill_data_model_unittest.cc
@@ -38,12 +38,12 @@ class TestAutofillDataModel : public AutofillDataModel {
~TestAutofillDataModel() override {}
private:
- base::string16 GetRawInfo(ServerFieldType type) const override {
- return base::string16();
+ std::u16string GetRawInfo(ServerFieldType type) const override {
+ return std::u16string();
}
void SetRawInfoWithVerificationStatus(
ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
structured_address::VerificationStatus status) override {}
void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override {}
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_profile.cc b/chromium/components/autofill/core/browser/data_model/autofill_profile.cc
index 10eee8a3ffe..abe400343a8 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_profile.cc
+++ b/chromium/components/autofill/core/browser/data_model/autofill_profile.cc
@@ -323,7 +323,7 @@ bool AutofillProfile::IsDeletable() const {
}
void AutofillProfile::GetMatchingTypes(
- const base::string16& text,
+ const std::u16string& text,
const std::string& app_locale,
ServerFieldTypeSet* matching_types) const {
ServerFieldTypeSet matching_types_in_this_profile;
@@ -338,7 +338,7 @@ void AutofillProfile::GetMatchingTypes(
}
void AutofillProfile::GetMatchingTypesAndValidities(
- const base::string16& text,
+ const std::u16string& text,
const std::string& app_locale,
ServerFieldTypeSet* matching_types,
ServerFieldTypeValidityStateMap* matching_types_validities) const {
@@ -362,17 +362,17 @@ void AutofillProfile::GetMatchingTypesAndValidities(
}
}
-base::string16 AutofillProfile::GetRawInfo(ServerFieldType type) const {
+std::u16string AutofillProfile::GetRawInfo(ServerFieldType type) const {
const FormGroup* form_group = FormGroupForType(AutofillType(type));
if (!form_group)
- return base::string16();
+ return std::u16string();
return form_group->GetRawInfo(type);
}
void AutofillProfile::SetRawInfoWithVerificationStatus(
ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
VerificationStatus status) {
FormGroup* form_group = MutableFormGroupForType(AutofillType(type));
if (form_group) {
@@ -397,7 +397,7 @@ bool AutofillProfile::IsEmpty(const std::string& app_locale) const {
bool AutofillProfile::IsPresentButInvalid(ServerFieldType type) const {
std::string country = UTF16ToUTF8(GetRawInfo(ADDRESS_HOME_COUNTRY));
- base::string16 data = GetRawInfo(type);
+ std::u16string data = GetRawInfo(type);
if (data.empty())
return false;
@@ -547,7 +547,7 @@ bool AutofillProfile::IsSubsetOfForFieldSet(
// profile's first and last names are set but its full name is not set.
// GetInfo for the NAME_FULL type returns the constituent name parts;
// however, GetRawInfo returns an empty string.
- const base::string16 value = GetInfo(type, app_locale);
+ const std::u16string value = GetInfo(type, app_locale);
if (value.empty() || type == ADDRESS_HOME_STREET_ADDRESS ||
type == ADDRESS_HOME_LINE1 || type == ADDRESS_HOME_LINE2 ||
@@ -810,7 +810,7 @@ bool AutofillProfile::SaveAdditionalInfo(const AutofillProfile& profile,
void AutofillProfile::CreateDifferentiatingLabels(
const std::vector<AutofillProfile*>& profiles,
const std::string& app_locale,
- std::vector<base::string16>* labels) {
+ std::vector<std::u16string>* labels) {
const size_t kMinimalFieldsShown = 2;
CreateInferredLabels(profiles, nullptr, UNKNOWN_TYPE, kMinimalFieldsShown,
app_locale, labels);
@@ -824,7 +824,7 @@ void AutofillProfile::CreateInferredLabels(
ServerFieldType excluded_field,
size_t minimal_fields_shown,
const std::string& app_locale,
- std::vector<base::string16>* labels) {
+ std::vector<std::u16string>* labels) {
std::vector<ServerFieldType> fields_to_use;
GetFieldsForDistinguishingProfiles(suggested_fields, excluded_field,
&fields_to_use);
@@ -832,9 +832,9 @@ void AutofillProfile::CreateInferredLabels(
// Construct the default label for each profile. Also construct a map that
// associates each label with the profiles that have this label. This map is
// then used to detect which labels need further differentiating fields.
- std::map<base::string16, std::list<size_t>> labels_to_profiles;
+ std::map<std::u16string, std::list<size_t>> labels_to_profiles;
for (size_t i = 0; i < profiles.size(); ++i) {
- base::string16 label = profiles[i]->ConstructInferredLabel(
+ std::u16string label = profiles[i]->ConstructInferredLabel(
fields_to_use.data(), fields_to_use.size(), minimal_fields_shown,
app_locale);
labels_to_profiles[label].push_back(i);
@@ -844,7 +844,7 @@ void AutofillProfile::CreateInferredLabels(
for (auto& it : labels_to_profiles) {
if (it.second.size() == 1) {
// This label is unique, so use it without any further ado.
- base::string16 label = it.first;
+ std::u16string label = it.first;
size_t profile_index = it.second.front();
(*labels)[profile_index] = label;
} else {
@@ -856,17 +856,17 @@ void AutofillProfile::CreateInferredLabels(
}
}
-base::string16 AutofillProfile::ConstructInferredLabel(
+std::u16string AutofillProfile::ConstructInferredLabel(
const ServerFieldType* included_fields,
const size_t included_fields_size,
size_t num_fields_to_use,
const std::string& app_locale) const {
// TODO(estade): use libaddressinput?
- base::string16 separator =
+ std::u16string separator =
l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_SUMMARY_SEPARATOR);
AutofillType region_code_type(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE);
- const base::string16& profile_region_code =
+ const std::u16string& profile_region_code =
GetInfo(region_code_type, app_locale);
std::string address_region_code = UTF16ToUTF8(profile_region_code);
@@ -888,7 +888,7 @@ base::string16 AutofillProfile::ConstructInferredLabel(
}
AutofillType autofill_type(included_fields[i]);
- base::string16 field_value = GetInfo(autofill_type, app_locale);
+ std::u16string field_value = GetInfo(autofill_type, app_locale);
if (field_value.empty())
continue;
@@ -901,12 +901,12 @@ base::string16 AutofillProfile::ConstructInferredLabel(
std::string address_line;
::i18n::addressinput::GetFormattedNationalAddressLine(*address_data,
&address_line);
- base::string16 label = base::UTF8ToUTF16(address_line);
+ std::u16string label = base::UTF8ToUTF16(address_line);
for (std::vector<ServerFieldType>::const_iterator it =
remaining_fields.begin();
it != remaining_fields.end() && num_fields_to_use > 0; ++it) {
- base::string16 field_value;
+ std::u16string field_value;
// Special case whole numbers: we want the user-formatted (raw) version, not
// the canonicalized version we'll fill into the page.
if (*it == PHONE_HOME_WHOLE_NUMBER)
@@ -926,14 +926,14 @@ base::string16 AutofillProfile::ConstructInferredLabel(
// If country code is missing, libaddressinput won't be used to format the
// address. In this case the suggestion might include a multi-line street
// address which needs to be flattened.
- base::ReplaceChars(label, base::ASCIIToUTF16("\n"), separator, &label);
+ base::ReplaceChars(label, u"\n", separator, &label);
return label;
}
void AutofillProfile::GenerateServerProfileIdentifier() {
DCHECK_EQ(SERVER_PROFILE, record_type());
- base::string16 contents = GetRawInfo(NAME_FIRST);
+ std::u16string contents = GetRawInfo(NAME_FIRST);
contents.append(GetRawInfo(NAME_MIDDLE));
contents.append(GetRawInfo(NAME_LAST));
contents.append(GetRawInfo(EMAIL_ADDRESS));
@@ -1158,14 +1158,14 @@ VerificationStatus AutofillProfile::GetVerificationStatusImpl(
return form_group->GetVerificationStatus(type);
}
-base::string16 AutofillProfile::GetInfoImpl(
+std::u16string AutofillProfile::GetInfoImpl(
const AutofillType& type,
const std::string& app_locale) const {
if (type.html_type() == HTML_TYPE_FULL_ADDRESS) {
std::unique_ptr<AddressData> address_data =
i18n::CreateAddressDataFromAutofillProfile(*this, app_locale);
if (!addressinput::HasAllRequiredFields(*address_data))
- return base::string16();
+ return std::u16string();
std::vector<std::string> lines;
::i18n::addressinput::GetFormattedNationalAddress(*address_data, &lines);
@@ -1174,14 +1174,14 @@ base::string16 AutofillProfile::GetInfoImpl(
const FormGroup* form_group = FormGroupForType(type);
if (!form_group)
- return base::string16();
+ return std::u16string();
return form_group->GetInfoImpl(type, app_locale);
}
bool AutofillProfile::SetInfoWithVerificationStatusImpl(
const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale,
VerificationStatus status) {
FormGroup* form_group = MutableFormGroupForType(type);
@@ -1191,7 +1191,7 @@ bool AutofillProfile::SetInfoWithVerificationStatusImpl(
is_client_validity_states_updated_ &=
!IsClientValidationSupportedForType(type.GetStorableType());
- base::string16 trimmed_value;
+ std::u16string trimmed_value;
base::TrimWhitespace(value, base::TRIM_ALL, &trimmed_value);
return form_group->SetInfoWithVerificationStatusImpl(type, trimmed_value,
@@ -1205,18 +1205,18 @@ void AutofillProfile::CreateInferredLabelsHelper(
const std::vector<ServerFieldType>& fields,
size_t num_fields_to_include,
const std::string& app_locale,
- std::vector<base::string16>* labels) {
+ std::vector<std::u16string>* labels) {
// For efficiency, we first construct a map of fields to their text values and
// each value's frequency.
- std::map<ServerFieldType, std::map<base::string16, size_t>>
+ std::map<ServerFieldType, std::map<std::u16string, size_t>>
field_text_frequencies_by_field;
for (const ServerFieldType& field : fields) {
- std::map<base::string16, size_t>& field_text_frequencies =
+ std::map<std::u16string, size_t>& field_text_frequencies =
field_text_frequencies_by_field[field];
for (const auto& it : indices) {
const AutofillProfile* profile = profiles[it];
- base::string16 field_text =
+ std::u16string field_text =
profile->GetInfo(AutofillType(field), app_locale);
// If this label is not already in the map, add it with frequency 0.
@@ -1242,15 +1242,15 @@ void AutofillProfile::CreateInferredLabelsHelper(
bool found_differentiating_field = false;
for (auto field = fields.begin(); field != fields.end(); ++field) {
// Skip over empty fields.
- base::string16 field_text =
+ std::u16string field_text =
profile->GetInfo(AutofillType(*field), app_locale);
if (field_text.empty())
continue;
- std::map<base::string16, size_t>& field_text_frequencies =
+ std::map<std::u16string, size_t>& field_text_frequencies =
field_text_frequencies_by_field[*field];
found_differentiating_field |=
- !field_text_frequencies.count(base::string16()) &&
+ !field_text_frequencies.count(std::u16string()) &&
(field_text_frequencies[field_text] == 1);
// Once we've found enough non-empty fields, skip over any remaining
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_profile.h b/chromium/components/autofill/core/browser/data_model/autofill_profile.h
index d11ce432c8c..cb82d28b473 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_profile.h
+++ b/chromium/components/autofill/core/browser/data_model/autofill_profile.h
@@ -16,7 +16,6 @@
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
-#include "base/strings/string16.h"
#include "base/time/time.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/data_model/address.h"
@@ -66,21 +65,21 @@ class AutofillProfile : public AutofillDataModel {
bool IsDeletable() const override;
// FormGroup:
- void GetMatchingTypes(const base::string16& text,
+ void GetMatchingTypes(const std::u16string& text,
const std::string& app_locale,
ServerFieldTypeSet* matching_types) const override;
void GetMatchingTypesAndValidities(
- const base::string16& text,
+ const std::u16string& text,
const std::string& app_locale,
ServerFieldTypeSet* matching_types,
std::map<ServerFieldType, AutofillProfile::ValidityState>*
matching_types_validities) const;
- base::string16 GetRawInfo(ServerFieldType type) const override;
+ std::u16string GetRawInfo(ServerFieldType type) const override;
void SetRawInfoWithVerificationStatus(
ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
structured_address::VerificationStatus status) override;
void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override;
@@ -167,7 +166,7 @@ class AutofillProfile : public AutofillDataModel {
static void CreateDifferentiatingLabels(
const std::vector<AutofillProfile*>& profiles,
const std::string& app_locale,
- std::vector<base::string16>* labels);
+ std::vector<std::u16string>* labels);
// Creates inferred labels for |profiles|, according to the rules above and
// stores them in |created_labels|. If |suggested_fields| is not NULL, the
@@ -182,12 +181,12 @@ class AutofillProfile : public AutofillDataModel {
ServerFieldType excluded_field,
size_t minimal_fields_shown,
const std::string& app_locale,
- std::vector<base::string16>* labels);
+ std::vector<std::u16string>* labels);
// Builds inferred label from the first |num_fields_to_include| non-empty
// fields in |label_fields|. Uses as many fields as possible if there are not
// enough non-empty fields.
- base::string16 ConstructInferredLabel(const ServerFieldType* label_fields,
+ std::u16string ConstructInferredLabel(const ServerFieldType* label_fields,
const size_t label_fields_size,
size_t num_fields_to_include,
const std::string& app_locale) const;
@@ -302,7 +301,7 @@ class AutofillProfile : public AutofillDataModel {
private:
// FormGroup:
- base::string16 GetInfoImpl(const AutofillType& type,
+ std::u16string GetInfoImpl(const AutofillType& type,
const std::string& app_locale) const override;
structured_address::VerificationStatus GetVerificationStatusImpl(
@@ -310,7 +309,7 @@ class AutofillProfile : public AutofillDataModel {
bool SetInfoWithVerificationStatusImpl(
const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale,
structured_address::VerificationStatus status) override;
@@ -325,7 +324,7 @@ class AutofillProfile : public AutofillDataModel {
const std::vector<ServerFieldType>& fields,
size_t num_fields_to_include,
const std::string& app_locale,
- std::vector<base::string16>* labels);
+ std::vector<std::u16string>* labels);
// Utilities for listing and lookup of the data members that constitute
// user-visible profile information.
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_profile_comparator.cc b/chromium/components/autofill/core/browser/data_model/autofill_profile_comparator.cc
index 978ba958b27..de6ffefc991 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_profile_comparator.cc
+++ b/chromium/components/autofill/core/browser/data_model/autofill_profile_comparator.cc
@@ -32,7 +32,7 @@ using i18n::phonenumbers::PhoneNumberUtil;
namespace autofill {
namespace {
-const base::char16 kSpace[] = {L' ', L'\0'};
+constexpr char16_t kSpace[] = u" ";
bool ContainsNewline(base::StringPiece16 text) {
return text.find('\n') != base::StringPiece16::npos;
@@ -208,6 +208,16 @@ void CopyAddressLineInformationFromProfile(const AutofillProfile& source,
target->SetRawInfo(type, source.GetRawInfo(type));
}
+// Sorts |profiles| by frecency.
+void SortProfilesByFrecency(std::vector<AutofillProfile*>* profiles) {
+ base::Time comparison_time = AutofillClock::Now();
+ std::sort(
+ profiles->begin(), profiles->end(),
+ [comparison_time](const AutofillProfile* a, const AutofillProfile* b) {
+ return a->HasGreaterFrecencyThan(b, comparison_time);
+ });
+}
+
} // namespace
AutofillProfileComparator::AutofillProfileComparator(
@@ -261,7 +271,7 @@ bool AutofillProfileComparator::HasOnlySkippableCharacters(
.End();
}
-base::string16 AutofillProfileComparator::NormalizeForComparison(
+std::u16string AutofillProfileComparator::NormalizeForComparison(
base::StringPiece16 text,
AutofillProfileComparator::WhitespaceSpec whitespace_spec) {
// This algorithm is not designed to be perfect, we could get arbitrarily
@@ -280,7 +290,7 @@ base::string16 AutofillProfileComparator::NormalizeForComparison(
//
// 3. Remove diacritics (accents and other non-spacing marks) and perform
// case folding to lower-case.
- base::string16 result;
+ std::u16string result;
result.reserve(text.length());
bool previous_was_whitespace = (whitespace_spec == RETAIN_WHITESPACE);
for (base::i18n::UTF16CharIterator iter(text); !iter.end(); iter.Advance()) {
@@ -343,8 +353,8 @@ bool AutofillProfileComparator::MergeNames(const AutofillProfile& p1,
DCHECK(HaveMergeableNames(p1, p2));
const AutofillType kFullName(NAME_FULL);
- const base::string16 full_name_1 = p1.GetInfo(kFullName, app_locale_);
- const base::string16 full_name_2 = p2.GetInfo(kFullName, app_locale_);
+ const std::u16string full_name_1 = p1.GetInfo(kFullName, app_locale_);
+ const std::u16string full_name_2 = p2.GetInfo(kFullName, app_locale_);
// At this state it is already determined that the two names are mergeable.
// This can mean of of the following things:
@@ -378,7 +388,7 @@ bool AutofillProfileComparator::MergeNames(const AutofillProfile& p1,
NormalizeForComparison(full_name_1)));
return true;
}
- const base::string16* best_name = nullptr;
+ const std::u16string* best_name = nullptr;
if (HasOnlySkippableCharacters(full_name_1)) {
// p1 has no name, so use the name from p2.
best_name = &full_name_2;
@@ -410,9 +420,9 @@ bool AutofillProfileComparator::MergeCJKNames(const AutofillProfile& p1,
DCHECK(data_util::IsCJKName(p2.GetInfo(NAME_FULL, app_locale_)));
struct Name {
- base::string16 given;
- base::string16 surname;
- base::string16 full;
+ std::u16string given;
+ std::u16string surname;
+ std::u16string full;
};
Name name1 = {p1.GetRawInfo(NAME_FIRST), p1.GetRawInfo(NAME_LAST),
@@ -467,17 +477,17 @@ bool AutofillProfileComparator::MergeCJKNames(const AutofillProfile& p1,
}
bool AutofillProfileComparator::IsNameVariantOf(
- const base::string16& full_name_1,
- const base::string16& full_name_2) const {
+ const std::u16string& full_name_1,
+ const std::u16string& full_name_2) const {
data_util::NameParts name_1_parts = data_util::SplitName(full_name_1);
// Build the variants of full_name_1`s given, middle and family names.
//
// TODO(rogerm): Figure out whether or not we should break apart a compound
// family name into variants (crbug/619051)
- const std::set<base::string16> given_name_variants =
+ const std::set<std::u16string> given_name_variants =
GetNamePartVariants(name_1_parts.given);
- const std::set<base::string16> middle_name_variants =
+ const std::set<std::u16string> middle_name_variants =
GetNamePartVariants(name_1_parts.middle);
base::StringPiece16 family_name = name_1_parts.family;
@@ -485,7 +495,7 @@ bool AutofillProfileComparator::IsNameVariantOf(
// match the full name from profile 1.
for (const auto& given_name : given_name_variants) {
for (const auto& middle_name : middle_name_variants) {
- base::string16 candidate = base::CollapseWhitespace(
+ std::u16string candidate = base::CollapseWhitespace(
base::JoinString({given_name, middle_name, family_name}, kSpace),
true);
if (candidate == full_name_2)
@@ -496,10 +506,10 @@ bool AutofillProfileComparator::IsNameVariantOf(
// Also check if the name is just composed of the user's initials. For
// example, "thomas jefferson miller" could be composed as "tj miller".
if (!name_1_parts.given.empty() && !name_1_parts.middle.empty()) {
- base::string16 initials;
+ std::u16string initials;
initials.push_back(name_1_parts.given[0]);
initials.push_back(name_1_parts.middle[0]);
- base::string16 candidate = base::CollapseWhitespace(
+ std::u16string candidate = base::CollapseWhitespace(
base::JoinString({initials, family_name}, kSpace), true);
if (candidate == full_name_2)
return true;
@@ -516,9 +526,9 @@ bool AutofillProfileComparator::MergeEmailAddresses(
DCHECK(HaveMergeableEmailAddresses(p1, p2));
const AutofillType kEmailAddress(EMAIL_ADDRESS);
- const base::string16& e1 = p1.GetInfo(kEmailAddress, app_locale_);
- const base::string16& e2 = p2.GetInfo(kEmailAddress, app_locale_);
- const base::string16* best = nullptr;
+ const std::u16string& e1 = p1.GetInfo(kEmailAddress, app_locale_);
+ const std::u16string& e2 = p2.GetInfo(kEmailAddress, app_locale_);
+ const std::u16string* best = nullptr;
if (e1.empty()) {
best = &e2;
@@ -537,9 +547,9 @@ bool AutofillProfileComparator::MergeCompanyNames(
const AutofillProfile& p2,
CompanyInfo* company_info) const {
const AutofillType kCompanyName(COMPANY_NAME);
- const base::string16& c1 = p1.GetInfo(kCompanyName, app_locale_);
- const base::string16& c2 = p2.GetInfo(kCompanyName, app_locale_);
- const base::string16* best = nullptr;
+ const std::u16string& c1 = p1.GetInfo(kCompanyName, app_locale_);
+ const std::u16string& c2 = p2.GetInfo(kCompanyName, app_locale_);
+ const std::u16string* best = nullptr;
DCHECK(HaveMergeableCompanyNames(p1, p2))
<< "Company names are not mergeable: '" << c1 << "' vs '" << c2 << "'";
@@ -571,14 +581,14 @@ bool AutofillProfileComparator::MergePhoneNumbers(
const AutofillProfile& p2,
PhoneNumber* phone_number) const {
const ServerFieldType kWholePhoneNumber = PHONE_HOME_WHOLE_NUMBER;
- const base::string16& s1 = p1.GetRawInfo(kWholePhoneNumber);
- const base::string16& s2 = p2.GetRawInfo(kWholePhoneNumber);
+ const std::u16string& s1 = p1.GetRawInfo(kWholePhoneNumber);
+ const std::u16string& s2 = p2.GetRawInfo(kWholePhoneNumber);
DCHECK(HaveMergeablePhoneNumbers(p1, p2))
<< "Phone numbers are not mergeable: '" << s1 << "' vs '" << s2 << "'";
if (HasOnlySkippableCharacters(s1) && HasOnlySkippableCharacters(s2)) {
- phone_number->SetRawInfo(kWholePhoneNumber, base::string16());
+ phone_number->SetRawInfo(kWholePhoneNumber, std::u16string());
}
if (HasOnlySkippableCharacters(s1)) {
@@ -678,15 +688,15 @@ bool AutofillProfileComparator::MergeAddresses(const AutofillProfile& p1,
// One of the countries is empty or they are the same modulo case, so we just
// have to find the non-empty one, if any.
const AutofillType kCountryCode(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE);
- const base::string16& country_code =
+ const std::u16string& country_code =
base::i18n::ToUpper(GetNonEmptyOf(p1, p2, kCountryCode));
address->SetInfo(kCountryCode, country_code, app_locale_);
// One of the zip codes is empty, they are the same, or one is a substring
// of the other. We prefer the most recently used zip code.
const AutofillType kZipCode(ADDRESS_HOME_ZIP);
- const base::string16& zip1 = p1.GetInfo(kZipCode, app_locale_);
- const base::string16& zip2 = p2.GetInfo(kZipCode, app_locale_);
+ const std::u16string& zip1 = p1.GetInfo(kZipCode, app_locale_);
+ const std::u16string& zip2 = p2.GetInfo(kZipCode, app_locale_);
if (zip1.empty()) {
address->SetInfo(kZipCode, zip2, app_locale_);
} else if (zip2.empty()) {
@@ -700,14 +710,14 @@ bool AutofillProfileComparator::MergeAddresses(const AutofillProfile& p1,
// the other. Pick the non-empty state that is shorter. This is usually the
// abbreviated one.
const AutofillType kState(ADDRESS_HOME_STATE);
- const base::string16& state1 = p1.GetInfo(kState, app_locale_);
- const base::string16& state2 = p2.GetInfo(kState, app_locale_);
+ const std::u16string& state1 = p1.GetInfo(kState, app_locale_);
+ const std::u16string& state2 = p2.GetInfo(kState, app_locale_);
if (base::FeatureList::IsEnabled(
features::kAutofillUseAlternativeStateNameMap)) {
// Holds information about the state string that is going to be used as the
// state value in the merged profile.
- base::string16 candidate_state = state1;
+ std::u16string candidate_state = state1;
// Cases where the |state2| is used as the state value in the merged
// profile:
@@ -752,8 +762,8 @@ bool AutofillProfileComparator::MergeAddresses(const AutofillProfile& p1,
// the other. Pick the city name with more tokens; this is usually the most
// explicit one.
const AutofillType kCity(ADDRESS_HOME_CITY);
- const base::string16& city1 = p1.GetInfo(kCity, app_locale_);
- const base::string16& city2 = p2.GetInfo(kCity, app_locale_);
+ const std::u16string& city1 = p1.GetInfo(kCity, app_locale_);
+ const std::u16string& city2 = p2.GetInfo(kCity, app_locale_);
if (city1.empty()) {
address->SetInfo(kCity, city2, app_locale_);
} else if (city2.empty()) {
@@ -793,8 +803,8 @@ bool AutofillProfileComparator::MergeAddresses(const AutofillProfile& p1,
// subset of tokens from the other. Pick the locality name with more tokens;
// this is usually the most explicit one.
const AutofillType kDependentLocality(ADDRESS_HOME_DEPENDENT_LOCALITY);
- const base::string16& locality1 = p1.GetInfo(kDependentLocality, app_locale_);
- const base::string16& locality2 = p2.GetInfo(kDependentLocality, app_locale_);
+ const std::u16string& locality1 = p1.GetInfo(kDependentLocality, app_locale_);
+ const std::u16string& locality2 = p2.GetInfo(kDependentLocality, app_locale_);
if (locality1.empty()) {
address->SetInfo(kDependentLocality, locality2, app_locale_);
} else if (locality2.empty()) {
@@ -835,8 +845,8 @@ bool AutofillProfileComparator::MergeAddresses(const AutofillProfile& p1,
// One of the sorting codes is empty, they are the same, or one is a substring
// of the other. We prefer the most recently used sorting code.
const AutofillType kSortingCode(ADDRESS_HOME_SORTING_CODE);
- const base::string16& sorting1 = p1.GetInfo(kSortingCode, app_locale_);
- const base::string16& sorting2 = p2.GetInfo(kSortingCode, app_locale_);
+ const std::u16string& sorting1 = p1.GetInfo(kSortingCode, app_locale_);
+ const std::u16string& sorting2 = p2.GetInfo(kSortingCode, app_locale_);
if (sorting1.empty()) {
address->SetInfo(kSortingCode, sorting2, app_locale_);
} else if (sorting2.empty()) {
@@ -850,8 +860,8 @@ bool AutofillProfileComparator::MergeAddresses(const AutofillProfile& p1,
// One of the addresses is empty or one of the addresses has a subset of
// tokens from the other. Prefer the more verbosely expressed one.
const AutofillType kStreetAddress(ADDRESS_HOME_STREET_ADDRESS);
- const base::string16& address1 = p1.GetInfo(kStreetAddress, app_locale_);
- const base::string16& address2 = p2.GetInfo(kStreetAddress, app_locale_);
+ const std::u16string& address1 = p1.GetInfo(kStreetAddress, app_locale_);
+ const std::u16string& address2 = p2.GetInfo(kStreetAddress, app_locale_);
// If one of the addresses is empty then use the other.
if (address1.empty()) {
CopyAddressLineInformationFromProfile(p2, address);
@@ -903,6 +913,72 @@ bool AutofillProfileComparator::MergeAddresses(const AutofillProfile& p1,
return true;
}
+bool AutofillProfileComparator::ProfilesHaveDifferentSettingsVisibleValues(
+ const AutofillProfile& p1,
+ const AutofillProfile& p2) {
+ // The values corresponding to those types are visible in the settings.
+ static const ServerFieldTypeSet kUserVisibleTypes = {
+ NAME_FULL, NAME_HONORIFIC_PREFIX, ADDRESS_HOME_STREET_ADDRESS,
+ ADDRESS_HOME_CITY, ADDRESS_HOME_ZIP, ADDRESS_HOME_COUNTRY,
+ EMAIL_ADDRESS, PHONE_HOME_WHOLE_NUMBER};
+
+ // Return true if at least one value corresponding to the settings visible
+ // types is different between the two profiles.
+ return base::ranges::any_of(kUserVisibleTypes, [&](const auto type) {
+ return p1.GetRawInfo(type) != p2.GetRawInfo(type);
+ });
+}
+
+bool AutofillProfileComparator::IsMergeCandidate(
+ const AutofillProfile& existing_profile,
+ const AutofillProfile& new_profile,
+ const std::string& app_locale) {
+ // If the existing profile is not mergeable with the new profile, it is
+ // certainly not a merge candidate.
+ if (!AreMergeable(existing_profile, new_profile)) {
+ return false;
+ }
+
+ // Merge the two profiles. The return value from |MergeDataFrom()| indicates
+ // if the existing profile was modified during the merge.
+ AutofillProfile merged_profile = existing_profile;
+ if (!merged_profile.MergeDataFrom(new_profile, app_locale)) {
+ return false;
+ }
+
+ // If the two profiles have at least one settings-visible value that is
+ // different, |existing_profile| is a merge candidate.
+ return ProfilesHaveDifferentSettingsVisibleValues(merged_profile,
+ existing_profile);
+}
+
+// static
+base::Optional<AutofillProfile>
+AutofillProfileComparator::GetAutofillProfileMergeCandidate(
+ const AutofillProfile& new_profile,
+ const std::vector<AutofillProfile*>& existing_profiles,
+ const std::string& app_locale) {
+ // Make a copy of the existing profiles for this function to have no side
+ // effects.
+ std::vector<AutofillProfile*> existing_profiles_copies = existing_profiles;
+
+ // Sort the profiles by frecency.
+ SortProfilesByFrecency(&existing_profiles_copies);
+
+ // Find and return the first profile that classifies as a merge candidate. If
+ // not profile classifies, return |base::nullopt|.
+ AutofillProfileComparator comparator(app_locale);
+ auto merge_candidate = base::ranges::find_if(
+ existing_profiles_copies, [&](const AutofillProfile* existing_profile) {
+ return comparator.IsMergeCandidate(*existing_profile, new_profile,
+ app_locale);
+ });
+
+ return merge_candidate != existing_profiles_copies.end()
+ ? base::make_optional(**merge_candidate)
+ : base::nullopt;
+}
+
// static
std::string AutofillProfileComparator::MergeProfile(
const AutofillProfile& new_profile,
@@ -1004,19 +1080,19 @@ AutofillProfileComparator::CompareTokens(base::StringPiece16 s1,
return DIFFERENT_TOKENS;
}
-base::string16 AutofillProfileComparator::GetNonEmptyOf(
+std::u16string AutofillProfileComparator::GetNonEmptyOf(
const AutofillProfile& p1,
const AutofillProfile& p2,
AutofillType t) const {
- const base::string16& s1 = p1.GetInfo(t, app_locale_);
+ const std::u16string& s1 = p1.GetInfo(t, app_locale_);
if (!s1.empty())
return s1;
return p2.GetInfo(t, app_locale_);
}
// static
-std::set<base::string16> AutofillProfileComparator::GetNamePartVariants(
- const base::string16& name_part) {
+std::set<std::u16string> AutofillProfileComparator::GetNamePartVariants(
+ const std::u16string& name_part) {
const size_t kMaxSupportedSubNames = 8;
std::vector<base::StringPiece16> sub_names = base::SplitStringPiece(
@@ -1027,7 +1103,7 @@ std::set<base::string16> AutofillProfileComparator::GetNamePartVariants(
return {name_part};
// Start with the empty string as a variant.
- std::set<base::string16> variants = {{}};
+ std::set<std::u16string> variants = {{}};
// For each sub-name, add a variant of all the already existing variants that
// appends this sub-name and one that appends the initial of this sub-name.
@@ -1035,8 +1111,8 @@ std::set<base::string16> AutofillProfileComparator::GetNamePartVariants(
for (const auto& sub_name : sub_names) {
if (sub_name.empty())
continue;
- std::vector<base::string16> new_variants;
- for (const base::string16& variant : variants) {
+ std::vector<std::u16string> new_variants;
+ for (const std::u16string& variant : variants) {
new_variants.push_back(base::CollapseWhitespace(
base::JoinString({variant, sub_name}, kSpace), true));
new_variants.push_back(base::CollapseWhitespace(
@@ -1047,7 +1123,7 @@ std::set<base::string16> AutofillProfileComparator::GetNamePartVariants(
// As a common case, also add the variant that just concatenates all of the
// initials.
- base::string16 initials;
+ std::u16string initials;
for (const auto& sub_name : sub_names) {
if (sub_name.empty())
continue;
@@ -1062,8 +1138,8 @@ std::set<base::string16> AutofillProfileComparator::GetNamePartVariants(
bool AutofillProfileComparator::HaveMergeableNames(
const AutofillProfile& p1,
const AutofillProfile& p2) const {
- base::string16 full_name_1 = p1.GetInfo(NAME_FULL, app_locale_);
- base::string16 full_name_2 = p2.GetInfo(NAME_FULL, app_locale_);
+ std::u16string full_name_1 = p1.GetInfo(NAME_FULL, app_locale_);
+ std::u16string full_name_2 = p2.GetInfo(NAME_FULL, app_locale_);
if (HasOnlySkippableCharacters(full_name_1) ||
HasOnlySkippableCharacters(full_name_2) ||
@@ -1077,8 +1153,8 @@ bool AutofillProfileComparator::HaveMergeableNames(
structured_address::AreStringTokenEquivalent(full_name_1, full_name_2))
return true;
- base::string16 canon_full_name_1 = NormalizeForComparison(full_name_1);
- base::string16 canon_full_name_2 = NormalizeForComparison(full_name_2);
+ std::u16string canon_full_name_1 = NormalizeForComparison(full_name_1);
+ std::u16string canon_full_name_2 = NormalizeForComparison(full_name_2);
// Is it reasonable to merge the names from p1 and p2.
bool result = IsNameVariantOf(canon_full_name_1, canon_full_name_2) ||
@@ -1089,8 +1165,8 @@ bool AutofillProfileComparator::HaveMergeableNames(
bool AutofillProfileComparator::HaveMergeableEmailAddresses(
const AutofillProfile& p1,
const AutofillProfile& p2) const {
- const base::string16& email_1 = p1.GetInfo(EMAIL_ADDRESS, app_locale_);
- const base::string16& email_2 = p2.GetInfo(EMAIL_ADDRESS, app_locale_);
+ const std::u16string& email_1 = p1.GetInfo(EMAIL_ADDRESS, app_locale_);
+ const std::u16string& email_2 = p2.GetInfo(EMAIL_ADDRESS, app_locale_);
return email_1.empty() || email_2.empty() ||
case_insensitive_compare_.StringsEqual(email_1, email_2);
}
@@ -1098,8 +1174,8 @@ bool AutofillProfileComparator::HaveMergeableEmailAddresses(
bool AutofillProfileComparator::HaveMergeableCompanyNames(
const AutofillProfile& p1,
const AutofillProfile& p2) const {
- const base::string16& company_name_1 = p1.GetInfo(COMPANY_NAME, app_locale_);
- const base::string16& company_name_2 = p2.GetInfo(COMPANY_NAME, app_locale_);
+ const std::u16string& company_name_1 = p1.GetInfo(COMPANY_NAME, app_locale_);
+ const std::u16string& company_name_2 = p2.GetInfo(COMPANY_NAME, app_locale_);
return HasOnlySkippableCharacters(company_name_1) ||
HasOnlySkippableCharacters(company_name_2) ||
CompareTokens(NormalizeForComparison(company_name_1),
@@ -1112,8 +1188,8 @@ bool AutofillProfileComparator::HaveMergeablePhoneNumbers(
const AutofillProfile& p2) const {
// We work with the raw phone numbers to avoid losing any helpful information
// as we parse.
- const base::string16& raw_phone_1 = p1.GetRawInfo(PHONE_HOME_WHOLE_NUMBER);
- const base::string16& raw_phone_2 = p2.GetRawInfo(PHONE_HOME_WHOLE_NUMBER);
+ const std::u16string& raw_phone_1 = p1.GetRawInfo(PHONE_HOME_WHOLE_NUMBER);
+ const std::u16string& raw_phone_2 = p2.GetRawInfo(PHONE_HOME_WHOLE_NUMBER);
// Are the two phone numbers trivially mergeable?
if (HasOnlySkippableCharacters(raw_phone_1) ||
@@ -1156,8 +1232,8 @@ bool AutofillProfileComparator::HaveMergeableAddresses(
// If the address are not in the same country, then they're not the same. If
// one of the address countries is unknown/invalid the comparison continues.
const AutofillType kCountryCode(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE);
- const base::string16& country1 = p1.GetInfo(kCountryCode, app_locale_);
- const base::string16& country2 = p2.GetInfo(kCountryCode, app_locale_);
+ const std::u16string& country1 = p1.GetInfo(kCountryCode, app_locale_);
+ const std::u16string& country2 = p2.GetInfo(kCountryCode, app_locale_);
if (!country1.empty() && !country2.empty() &&
!case_insensitive_compare_.StringsEqual(country1, country2)) {
return false;
@@ -1168,13 +1244,13 @@ bool AutofillProfileComparator::HaveMergeableAddresses(
// If the addresses are definitely not in the same zip/area code then we're
// done. Otherwise,the comparison continues.
const AutofillType kZipCode(ADDRESS_HOME_ZIP);
- const base::string16& zip1 = NormalizeForComparison(
+ const std::u16string& zip1 = NormalizeForComparison(
p1.GetInfo(kZipCode, app_locale_), DISCARD_WHITESPACE);
- const base::string16& zip2 = NormalizeForComparison(
+ const std::u16string& zip2 = NormalizeForComparison(
p2.GetInfo(kZipCode, app_locale_), DISCARD_WHITESPACE);
if (!zip1.empty() && !zip2.empty() &&
- zip1.find(zip2) == base::string16::npos &&
- zip2.find(zip1) == base::string16::npos) {
+ zip1.find(zip2) == std::u16string::npos &&
+ zip2.find(zip1) == std::u16string::npos) {
return false;
}
@@ -1217,9 +1293,9 @@ bool AutofillProfileComparator::HaveMergeableAddresses(
}
if (!use_alternative_state_name_map_enabled || !canonical_state_names_match) {
- base::string16 state1 = rewriter.Rewrite(
+ std::u16string state1 = rewriter.Rewrite(
NormalizeForComparison(p1.GetInfo(kState, app_locale_)));
- base::string16 state2 = rewriter.Rewrite(
+ std::u16string state2 = rewriter.Rewrite(
NormalizeForComparison(p2.GetInfo(kState, app_locale_)));
if (CompareTokens(state1, state2) == DIFFERENT_TOKENS) {
return false;
@@ -1235,9 +1311,9 @@ bool AutofillProfileComparator::HaveMergeableAddresses(
// that the two city strings are intended to have the same meaning. This
// handles the cases where we have a city vs one of its suburbs.
const AutofillType kCity(ADDRESS_HOME_CITY);
- const base::string16& city1 =
+ const std::u16string& city1 =
rewriter.Rewrite(NormalizeForComparison(p1.GetInfo(kCity, app_locale_)));
- const base::string16& city2 =
+ const std::u16string& city2 =
rewriter.Rewrite(NormalizeForComparison(p2.GetInfo(kCity, app_locale_)));
if (CompareTokens(city1, city2) == DIFFERENT_TOKENS) {
return false;
@@ -1248,9 +1324,9 @@ bool AutofillProfileComparator::HaveMergeableAddresses(
// Heuristic: Dependent Localities are mergeable if one is a (possibly empty)
// bag of words subset of the other.
const AutofillType kDependentLocality(ADDRESS_HOME_DEPENDENT_LOCALITY);
- const base::string16& locality1 = rewriter.Rewrite(
+ const std::u16string& locality1 = rewriter.Rewrite(
NormalizeForComparison(p1.GetInfo(kDependentLocality, app_locale_)));
- const base::string16& locality2 = rewriter.Rewrite(
+ const std::u16string& locality2 = rewriter.Rewrite(
NormalizeForComparison(p2.GetInfo(kDependentLocality, app_locale_)));
if (CompareTokens(locality1, locality2) == DIFFERENT_TOKENS) {
return false;
@@ -1262,13 +1338,13 @@ bool AutofillProfileComparator::HaveMergeableAddresses(
// substring of the other, post normalization and whitespace removed. This
// is similar to postal/zip codes.
const AutofillType kSortingCode(ADDRESS_HOME_SORTING_CODE);
- const base::string16& sorting1 = NormalizeForComparison(
+ const std::u16string& sorting1 = NormalizeForComparison(
p1.GetInfo(kSortingCode, app_locale_), DISCARD_WHITESPACE);
- const base::string16& sorting2 = NormalizeForComparison(
+ const std::u16string& sorting2 = NormalizeForComparison(
p2.GetInfo(kSortingCode, app_locale_), DISCARD_WHITESPACE);
if (!sorting1.empty() && !sorting2.empty() &&
- sorting1.find(sorting2) == base::string16::npos &&
- sorting2.find(sorting1) == base::string16::npos) {
+ sorting1.find(sorting2) == std::u16string::npos &&
+ sorting2.find(sorting1) == std::u16string::npos) {
return false;
}
@@ -1276,9 +1352,9 @@ bool AutofillProfileComparator::HaveMergeableAddresses(
// --------
// Heuristic: Street addresses are mergeable if one is a (possibly empty) bag
// of words subset of the other.
- const base::string16& address1 = rewriter.Rewrite(NormalizeForComparison(
+ const std::u16string& address1 = rewriter.Rewrite(NormalizeForComparison(
p1.GetInfo(ADDRESS_HOME_STREET_ADDRESS, app_locale_)));
- const base::string16& address2 = rewriter.Rewrite(NormalizeForComparison(
+ const std::u16string& address2 = rewriter.Rewrite(NormalizeForComparison(
p2.GetInfo(ADDRESS_HOME_STREET_ADDRESS, app_locale_)));
if (CompareTokens(address1, address2) == DIFFERENT_TOKENS) {
return false;
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_profile_comparator.h b/chromium/components/autofill/core/browser/data_model/autofill_profile_comparator.h
index e893a9e71e7..2ba6086bb63 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_profile_comparator.h
+++ b/chromium/components/autofill/core/browser/data_model/autofill_profile_comparator.h
@@ -7,8 +7,8 @@
#include <memory>
#include <set>
+#include <string>
-#include "base/strings/string16.h"
#include "base/strings/string_piece.h"
#include "components/autofill/core/browser/data_model/address.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
@@ -44,6 +44,27 @@ class AutofillProfileComparator {
base::StringPiece16 text2,
WhitespaceSpec whitespace_spec = DISCARD_WHITESPACE) const;
+ // Returns the first merge candidate from |existing_profiles| for
+ // |new_profile| as an optional. If no merge candidate exists |base::nullopt|
+ // is returned.
+ static base::Optional<AutofillProfile> GetAutofillProfileMergeCandidate(
+ const AutofillProfile& new_profile,
+ const std::vector<AutofillProfile*>& existing_profiles,
+ const std::string& app_locale);
+
+ // Returns true if |existing_profile| is a merge candidate for |new_profile|.
+ // A profile is a merge candidate if it is mergeable with |new_profile| and if
+ // at least one settings-visible value is changed.
+ bool IsMergeCandidate(const AutofillProfile& existing_profile,
+ const AutofillProfile& new_profile,
+ const std::string& app_locale);
+
+ // Returns true if two AutofillProfiles |p1| and |p2| have at least one
+ // settings-visible value that is different.
+ static bool ProfilesHaveDifferentSettingsVisibleValues(
+ const AutofillProfile& p1,
+ const AutofillProfile& p2);
+
// Returns true if |text| is empty or contains only skippable characters. A
// character is skippable if it is punctuation or white space.
bool HasOnlySkippableCharacters(base::StringPiece16 text) const;
@@ -57,7 +78,7 @@ class AutofillProfileComparator {
//
// If |whitespace_spec| is DISCARD_WHITESPACE, punctuation and whitespace are
// discarded. For example, +1 (234) 567-8900 becomes 12345678900.
- static base::string16 NormalizeForComparison(
+ static std::u16string NormalizeForComparison(
base::StringPiece16 text,
WhitespaceSpec whitespace_spec = RETAIN_WHITESPACE);
@@ -91,8 +112,8 @@ class AutofillProfileComparator {
// true, "john quincy public" is not a name variant of "john q public".
//
// Note: Expects that |full_name| is already normalized for comparison.
- bool IsNameVariantOf(const base::string16& full_name_1,
- const base::string16& full_name_2) const;
+ bool IsNameVariantOf(const std::u16string& full_name_1,
+ const std::u16string& full_name_2) const;
// Populates |email_info| with the result of merging the email addresses in
// |p1| and |p2|. Returns true if successful. Expects that |p1| and |p2| have
@@ -168,7 +189,7 @@ class AutofillProfileComparator {
// Returns the value of |t| from |p1| or |p2| depending on which is non-empty.
// This method expects that the value is either the same in |p1| and |p2| or
// empty in one of them.
- base::string16 GetNonEmptyOf(const AutofillProfile& p1,
+ std::u16string GetNonEmptyOf(const AutofillProfile& p1,
const AutofillProfile& p2,
AutofillType t) const;
@@ -182,8 +203,8 @@ class AutofillProfileComparator {
// "jean", "jean f", "jean francois", "jf" }
//
// Note: Expects that |name| is already normalized for comparison.
- static std::set<base::string16> GetNamePartVariants(
- const base::string16& name_part);
+ static std::set<std::u16string> GetNamePartVariants(
+ const std::u16string& name_part);
// Returns true if |p1| and |p2| have names which are equivalent for the
// purposes of merging the two profiles. This means one of the names is
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_profile_comparator_unittest.cc b/chromium/components/autofill/core/browser/data_model/autofill_profile_comparator_unittest.cc
index 6935d2073eb..6f1614f46b2 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_profile_comparator_unittest.cc
+++ b/chromium/components/autofill/core/browser/data_model/autofill_profile_comparator_unittest.cc
@@ -36,6 +36,7 @@ using autofill::COMPANY_NAME;
using autofill::EMAIL_ADDRESS;
using autofill::NAME_FIRST;
using autofill::NAME_FULL;
+using autofill::NAME_HONORIFIC_PREFIX;
using autofill::NAME_LAST;
using autofill::NAME_MIDDLE;
using autofill::PHONE_HOME_CITY_AND_NUMBER;
@@ -384,18 +385,18 @@ class AutofillProfileComparatorTest
} // namespace
TEST_P(AutofillProfileComparatorTest, UniqueTokens) {
- base::string16 kInput = UTF8ToUTF16("a b a a b");
- std::vector<base::string16> tokens = {UTF8ToUTF16("a"), UTF8ToUTF16("b")};
+ std::u16string kInput = u"a b a a b";
+ std::vector<std::u16string> tokens = {u"a", u"b"};
EXPECT_EQ(std::set<base::StringPiece16>(tokens.begin(), tokens.end()),
comparator_.UniqueTokens(kInput));
}
TEST_P(AutofillProfileComparatorTest, CompareTokens) {
- base::string16 kEmptyStr = UTF8ToUTF16("");
- base::string16 kHello = UTF8ToUTF16("hello");
- base::string16 kHelloThere = UTF8ToUTF16("hello there");
- base::string16 kHelloThereAlice = UTF8ToUTF16("hello there alice");
- base::string16 kHelloThereBob = UTF8ToUTF16("hello there bob");
+ std::u16string kEmptyStr = u"";
+ std::u16string kHello = u"hello";
+ std::u16string kHelloThere = u"hello there";
+ std::u16string kHelloThereAlice = u"hello there alice";
+ std::u16string kHelloThereBob = u"hello there bob";
EXPECT_EQ(AutofillProfileComparator::SAME_TOKENS,
comparator_.CompareTokens(kHelloThereBob, kHelloThereBob));
@@ -416,178 +417,142 @@ TEST_P(AutofillProfileComparatorTest, CompareTokens) {
TEST_P(AutofillProfileComparatorTest, Compare) {
// Checks the empty case.
EXPECT_TRUE(
- comparator_.Compare(base::string16(), base::string16(),
+ comparator_.Compare(std::u16string(), std::u16string(),
AutofillProfileComparator::RETAIN_WHITESPACE));
EXPECT_TRUE(
- comparator_.Compare(base::string16(), base::string16(),
+ comparator_.Compare(std::u16string(), std::u16string(),
AutofillProfileComparator::DISCARD_WHITESPACE));
// Checks that leading punctuation and white space are ignored.
- EXPECT_TRUE(
- comparator_.Compare(UTF8ToUTF16("., -()."), UTF8ToUTF16(""),
- AutofillProfileComparator::RETAIN_WHITESPACE));
- EXPECT_TRUE(
- comparator_.Compare(UTF8ToUTF16("., -()."), UTF8ToUTF16(""),
- AutofillProfileComparator::DISCARD_WHITESPACE));
+ EXPECT_TRUE(comparator_.Compare(
+ u"., -().", u"", AutofillProfileComparator::RETAIN_WHITESPACE));
+ EXPECT_TRUE(comparator_.Compare(
+ u"., -().", u"", AutofillProfileComparator::DISCARD_WHITESPACE));
// Checks that trailing punctuation and white space are ignored.
- EXPECT_TRUE(
- comparator_.Compare(UTF8ToUTF16("a ., "), UTF8ToUTF16("a"),
- AutofillProfileComparator::RETAIN_WHITESPACE));
- EXPECT_TRUE(
- comparator_.Compare(UTF8ToUTF16("a ., "), UTF8ToUTF16("a"),
- AutofillProfileComparator::DISCARD_WHITESPACE));
+ EXPECT_TRUE(comparator_.Compare(
+ u"a ., ", u"a", AutofillProfileComparator::RETAIN_WHITESPACE));
+ EXPECT_TRUE(comparator_.Compare(
+ u"a ., ", u"a", AutofillProfileComparator::DISCARD_WHITESPACE));
// Checks that embedded punctuation and white space is collapsed to a single
// white space with RETAIN_WHITESPACE and is ignored with DISCARD_WHITESPACE.
- EXPECT_TRUE(
- comparator_.Compare(UTF8ToUTF16("a() - a"), UTF8ToUTF16("a a"),
- AutofillProfileComparator::RETAIN_WHITESPACE));
- EXPECT_TRUE(
- comparator_.Compare(UTF8ToUTF16("a() - a"), UTF8ToUTF16("aa"),
- AutofillProfileComparator::DISCARD_WHITESPACE));
+ EXPECT_TRUE(comparator_.Compare(
+ u"a() - a", u"a a", AutofillProfileComparator::RETAIN_WHITESPACE));
+ EXPECT_TRUE(comparator_.Compare(
+ u"a() - a", u"aa", AutofillProfileComparator::DISCARD_WHITESPACE));
// Checks that characters such as 'œ' respect the status quo established by
// NormalizeForComparison.
- EXPECT_FALSE(comparator_.Compare(UTF8ToUTF16("œil"), UTF8ToUTF16("oeil")));
+ EXPECT_FALSE(comparator_.Compare(u"œil", u"oeil"));
// Checks that a substring of the string is not considered equal.
- EXPECT_FALSE(comparator_.Compare(UTF8ToUTF16("A"), UTF8ToUTF16("Anna")));
+ EXPECT_FALSE(comparator_.Compare(u"A", u"Anna"));
- EXPECT_FALSE(comparator_.Compare(UTF8ToUTF16("Anna"), UTF8ToUTF16("A")));
+ EXPECT_FALSE(comparator_.Compare(u"Anna", u"A"));
// Checks that Compare behaves like NormalizeForComparison. Also, checks that
// diacritics are removed.
+ EXPECT_TRUE(comparator_.Compare(
+ u"Timothé", u"timothe", AutofillProfileComparator::RETAIN_WHITESPACE));
EXPECT_TRUE(
- comparator_.Compare(UTF8ToUTF16("Timothé"), UTF8ToUTF16("timothe"),
- AutofillProfileComparator::RETAIN_WHITESPACE));
- EXPECT_TRUE(
- comparator_.Compare(UTF8ToUTF16(" sven-åke "), UTF8ToUTF16("sven ake"),
- AutofillProfileComparator::RETAIN_WHITESPACE));
- EXPECT_TRUE(
- comparator_.Compare(UTF8ToUTF16("Ç 㸐"), UTF8ToUTF16("c 㸐"),
+ comparator_.Compare(u" sven-åke ", u"sven ake",
AutofillProfileComparator::RETAIN_WHITESPACE));
+ EXPECT_TRUE(comparator_.Compare(
+ u"Ç 㸐", u"c 㸐", AutofillProfileComparator::RETAIN_WHITESPACE));
EXPECT_TRUE(
- comparator_.Compare(UTF8ToUTF16("902103214"), UTF8ToUTF16("90210-3214"),
+ comparator_.Compare(u"902103214", u"90210-3214",
AutofillProfileComparator::DISCARD_WHITESPACE));
+ EXPECT_TRUE(comparator_.Compare(
+ u"Timothé-Noël Étienne Périer", u"timothe noel etienne perier",
+ AutofillProfileComparator::RETAIN_WHITESPACE));
+ EXPECT_TRUE(comparator_.Compare(
+ u"1600 Amphitheatre, Pkwy.", u"1600 amphitheatre pkwy",
+ AutofillProfileComparator::RETAIN_WHITESPACE));
EXPECT_TRUE(
- comparator_.Compare(UTF8ToUTF16("Timothé-Noël Étienne Périer"),
- UTF8ToUTF16("timothe noel etienne perier"),
- AutofillProfileComparator::RETAIN_WHITESPACE));
- EXPECT_TRUE(
- comparator_.Compare(UTF8ToUTF16("1600 Amphitheatre, Pkwy."),
- UTF8ToUTF16("1600 amphitheatre pkwy"),
- AutofillProfileComparator::RETAIN_WHITESPACE));
- EXPECT_TRUE(
- comparator_.Compare(base::WideToUTF16(L"Mid\x2013Island\x2003 Plaza"),
- UTF8ToUTF16("mid island plaza"),
+ comparator_.Compare(u"Mid\x2013Island\x2003 Plaza", u"mid island plaza",
AutofillProfileComparator::RETAIN_WHITESPACE));
EXPECT_TRUE(
comparator_.Compare(UTF8ToUTF16("1600 amphitheatre pkwy \n App. 2"),
- UTF8ToUTF16("1600 amphitheatre pkwy app 2"),
- AutofillProfileComparator::RETAIN_WHITESPACE));
- EXPECT_TRUE(
- comparator_.Compare(UTF8ToUTF16("まéÖä정"), UTF8ToUTF16("まeoa정"),
+ u"1600 amphitheatre pkwy app 2",
AutofillProfileComparator::RETAIN_WHITESPACE));
+ EXPECT_TRUE(comparator_.Compare(
+ u"まéÖä정", u"まeoa정", AutofillProfileComparator::RETAIN_WHITESPACE));
+ EXPECT_TRUE(comparator_.Compare(
+ u"유재석", u"유 재석", AutofillProfileComparator::DISCARD_WHITESPACE));
EXPECT_TRUE(
- comparator_.Compare(UTF8ToUTF16("유재석"), UTF8ToUTF16("유 재석"),
+ comparator_.Compare(u"ビルゲイツ", u"ヒル・ケイツ",
AutofillProfileComparator::DISCARD_WHITESPACE));
- EXPECT_TRUE(comparator_.Compare(
- UTF8ToUTF16("ビルゲイツ"), UTF8ToUTF16("ヒル・ケイツ"),
- AutofillProfileComparator::DISCARD_WHITESPACE));
}
TEST_P(AutofillProfileComparatorTest, NormalizeForComparison) {
- EXPECT_EQ(UTF8ToUTF16("timothe"),
- comparator_.NormalizeForComparison(UTF8ToUTF16("Timothé")));
- EXPECT_EQ(UTF8ToUTF16("sven ake"),
- comparator_.NormalizeForComparison(UTF8ToUTF16(" sven-åke ")));
- EXPECT_EQ(UTF8ToUTF16("c 㸐"),
- comparator_.NormalizeForComparison(UTF8ToUTF16("Ç 㸐")));
- EXPECT_EQ(UTF8ToUTF16("902103214"),
+ EXPECT_EQ(u"timothe", comparator_.NormalizeForComparison(u"Timothé"));
+ EXPECT_EQ(u"sven ake", comparator_.NormalizeForComparison(u" sven-åke "));
+ EXPECT_EQ(u"c 㸐", comparator_.NormalizeForComparison(u"Ç 㸐"));
+ EXPECT_EQ(u"902103214",
comparator_.NormalizeForComparison(
- base::UTF8ToUTF16("90210-3214"),
- AutofillProfileComparator::DISCARD_WHITESPACE));
- EXPECT_EQ(UTF8ToUTF16("timothe noel etienne perier"),
- comparator_.NormalizeForComparison(
- UTF8ToUTF16("Timothé-Noël Étienne Périer")));
+ u"90210-3214", AutofillProfileComparator::DISCARD_WHITESPACE));
+ EXPECT_EQ(u"timothe noel etienne perier",
+ comparator_.NormalizeForComparison(u"Timothé-Noël Étienne Périer"));
// NOP.
- EXPECT_EQ(base::string16(),
- comparator_.NormalizeForComparison(base::string16()));
+ EXPECT_EQ(std::u16string(),
+ comparator_.NormalizeForComparison(std::u16string()));
// Simple punctuation removed.
- EXPECT_EQ(UTF8ToUTF16("1600 amphitheatre pkwy"),
- comparator_.NormalizeForComparison(
- UTF8ToUTF16("1600 Amphitheatre, Pkwy.")));
+ EXPECT_EQ(u"1600 amphitheatre pkwy",
+ comparator_.NormalizeForComparison(u"1600 Amphitheatre, Pkwy."));
// Unicode punctuation (hyphen and space), multiple spaces collapsed.
- EXPECT_EQ(UTF8ToUTF16("mid island plaza"),
- comparator_.NormalizeForComparison(
- base::WideToUTF16(L"Mid\x2013Island\x2003 Plaza")));
+ EXPECT_EQ(u"mid island plaza",
+ comparator_.NormalizeForComparison(u"Mid\x2013Island\x2003 Plaza"));
// Newline character removed.
- EXPECT_EQ(UTF8ToUTF16("1600 amphitheatre pkwy app 2"),
+ EXPECT_EQ(u"1600 amphitheatre pkwy app 2",
comparator_.NormalizeForComparison(
UTF8ToUTF16("1600 amphitheatre pkwy \n App. 2")));
// Diacritics removed.
- EXPECT_EQ(UTF8ToUTF16("まeoa정"),
- comparator_.NormalizeForComparison(UTF8ToUTF16("まéÖä정")));
+ EXPECT_EQ(u"まeoa정", comparator_.NormalizeForComparison(u"まéÖä정"));
// Spaces removed.
- EXPECT_EQ(UTF8ToUTF16("유재석"),
+ EXPECT_EQ(u"유재석",
comparator_.NormalizeForComparison(
- UTF8ToUTF16("유 재석"),
- AutofillProfileComparator::DISCARD_WHITESPACE));
+ u"유 재석", AutofillProfileComparator::DISCARD_WHITESPACE));
// Punctuation removed, Japanese kana normalized.
- EXPECT_EQ(UTF8ToUTF16("ヒルケイツ"),
- comparator_.NormalizeForComparison(
- UTF8ToUTF16("ビル・ゲイツ"),
- AutofillProfileComparator::DISCARD_WHITESPACE));
+ EXPECT_EQ(u"ヒルケイツ", comparator_.NormalizeForComparison(
+ u"ビル・ゲイツ",
+ AutofillProfileComparator::DISCARD_WHITESPACE));
}
TEST_P(AutofillProfileComparatorTest, GetNamePartVariants) {
- std::set<base::string16> expected_variants = {
- UTF8ToUTF16("timothe noel"),
- UTF8ToUTF16("timothe n"),
- UTF8ToUTF16("timothe"),
- UTF8ToUTF16("t noel"),
- UTF8ToUTF16("t n"),
- UTF8ToUTF16("t"),
- UTF8ToUTF16("noel"),
- UTF8ToUTF16("n"),
- UTF8ToUTF16(""),
- UTF8ToUTF16("tn"),
+ std::set<std::u16string> expected_variants = {
+ u"timothe noel", u"timothe n", u"timothe", u"t noel", u"t n", u"t",
+ u"noel", u"n", u"", u"tn",
};
EXPECT_EQ(expected_variants,
- comparator_.GetNamePartVariants(UTF8ToUTF16("timothe noel")));
+ comparator_.GetNamePartVariants(u"timothe noel"));
}
TEST_P(AutofillProfileComparatorTest, IsNameVariantOf) {
- const base::string16 kNormalizedFullName =
- UTF8ToUTF16("timothe noel etienne perier");
+ const std::u16string kNormalizedFullName = u"timothe noel etienne perier";
EXPECT_TRUE(
comparator_.IsNameVariantOf(kNormalizedFullName, kNormalizedFullName));
- EXPECT_TRUE(comparator_.IsNameVariantOf(
- kNormalizedFullName, UTF8ToUTF16("t noel etienne perier")));
- EXPECT_TRUE(comparator_.IsNameVariantOf(kNormalizedFullName,
- UTF8ToUTF16("timothe perier")));
- EXPECT_TRUE(comparator_.IsNameVariantOf(kNormalizedFullName,
- UTF8ToUTF16("t perier")));
- EXPECT_TRUE(comparator_.IsNameVariantOf(kNormalizedFullName,
- UTF8ToUTF16("noel perier")));
- EXPECT_TRUE(comparator_.IsNameVariantOf(kNormalizedFullName,
- UTF8ToUTF16("t n etienne perier")));
- EXPECT_TRUE(comparator_.IsNameVariantOf(kNormalizedFullName,
- UTF8ToUTF16("tn perier")));
EXPECT_TRUE(comparator_.IsNameVariantOf(kNormalizedFullName,
- UTF8ToUTF16("te perier")));
+ u"t noel etienne perier"));
+ EXPECT_TRUE(
+ comparator_.IsNameVariantOf(kNormalizedFullName, u"timothe perier"));
+ EXPECT_TRUE(comparator_.IsNameVariantOf(kNormalizedFullName, u"t perier"));
+ EXPECT_TRUE(comparator_.IsNameVariantOf(kNormalizedFullName, u"noel perier"));
+ EXPECT_TRUE(
+ comparator_.IsNameVariantOf(kNormalizedFullName, u"t n etienne perier"));
+ EXPECT_TRUE(comparator_.IsNameVariantOf(kNormalizedFullName, u"tn perier"));
+ EXPECT_TRUE(comparator_.IsNameVariantOf(kNormalizedFullName, u"te perier"));
- EXPECT_FALSE(comparator_.IsNameVariantOf(kNormalizedFullName,
- UTF8ToUTF16("etienne noel perier")));
+ EXPECT_FALSE(
+ comparator_.IsNameVariantOf(kNormalizedFullName, u"etienne noel perier"));
}
TEST_P(AutofillProfileComparatorTest, HaveMergeableNames) {
@@ -730,8 +695,8 @@ TEST_P(AutofillProfileComparatorTest, HaveMergeableAddresses) {
AutofillProfile empty = CreateProfileWithAddress("", "", "", "", "", "");
AutofillProfile p1 = CreateProfileWithAddress(
"1 Some Street", "Unit 3", "Carver", "CA - California", "90210", "US");
- p1.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, UTF8ToUTF16("Some String"));
- p1.SetRawInfo(ADDRESS_HOME_SORTING_CODE, UTF8ToUTF16("64205 Biarritz CEDEX"));
+ p1.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u"Some String");
+ p1.SetRawInfo(ADDRESS_HOME_SORTING_CODE, u"64205 Biarritz CEDEX");
AutofillProfile p2 = CreateProfileWithAddress(
"Unit 3", "1 Some Street", "Suburb", "california", "90 210-3214", "");
@@ -827,25 +792,25 @@ TEST_P(AutofillProfileComparatorTest, MergeStructuredNames_WithPermutation) {
// The first name has an observed structure.
NameInfo name1;
name1.SetRawInfoWithVerificationStatus(
- NAME_FIRST, UTF8ToUTF16("Thomas"),
+ NAME_FIRST, u"Thomas",
autofill::structured_address::VerificationStatus::kObserved);
name1.SetRawInfoWithVerificationStatus(
- NAME_MIDDLE, UTF8ToUTF16("A."),
+ NAME_MIDDLE, u"A.",
autofill::structured_address::VerificationStatus::kObserved);
name1.SetRawInfoWithVerificationStatus(
- NAME_LAST, UTF8ToUTF16("Anderson"),
+ NAME_LAST, u"Anderson",
autofill::structured_address::VerificationStatus::kObserved);
AutofillProfile profile1 = CreateProfileWithName(name1);
profile1.FinalizeAfterImport();
- EXPECT_EQ(profile1.GetRawInfo(NAME_FULL), UTF8ToUTF16("Thomas A. Anderson"));
+ EXPECT_EQ(profile1.GetRawInfo(NAME_FULL), u"Thomas A. Anderson");
EXPECT_EQ(profile1.GetVerificationStatus(NAME_FULL),
autofill::structured_address::VerificationStatus::kFormatted);
// The second name has an observed full name that uses a custom formatting.
NameInfo name2;
name2.SetRawInfoWithVerificationStatus(
- NAME_FULL, UTF8ToUTF16("Anderson, Thomas A."),
+ NAME_FULL, u"Anderson, Thomas A.",
autofill::structured_address::VerificationStatus::kObserved);
AutofillProfile profile2 = CreateProfileWithName(name2);
profile2.FinalizeAfterImport();
@@ -855,57 +820,56 @@ TEST_P(AutofillProfileComparatorTest, MergeStructuredNames_WithPermutation) {
// The merged name should maintain the structure but use the observation of
// the custom-formatted full name.
- EXPECT_EQ(merged_name.GetRawInfo(NAME_FULL),
- UTF8ToUTF16("Anderson, Thomas A."));
+ EXPECT_EQ(merged_name.GetRawInfo(NAME_FULL), u"Anderson, Thomas A.");
EXPECT_EQ(merged_name.GetVerificationStatus(NAME_FULL),
autofill::structured_address::VerificationStatus::kObserved);
- EXPECT_EQ(merged_name.GetRawInfo(NAME_FIRST), UTF8ToUTF16("Thomas"));
+ EXPECT_EQ(merged_name.GetRawInfo(NAME_FIRST), u"Thomas");
EXPECT_EQ(merged_name.GetVerificationStatus(NAME_FIRST),
autofill::structured_address::VerificationStatus::kObserved);
- EXPECT_EQ(merged_name.GetRawInfo(NAME_MIDDLE), UTF8ToUTF16("A."));
+ EXPECT_EQ(merged_name.GetRawInfo(NAME_MIDDLE), u"A.");
EXPECT_EQ(merged_name.GetVerificationStatus(NAME_MIDDLE),
autofill::structured_address::VerificationStatus::kObserved);
- EXPECT_EQ(merged_name.GetRawInfo(NAME_LAST), UTF8ToUTF16("Anderson"));
+ EXPECT_EQ(merged_name.GetRawInfo(NAME_LAST), u"Anderson");
EXPECT_EQ(merged_name.GetVerificationStatus(NAME_LAST),
autofill::structured_address::VerificationStatus::kObserved);
}
TEST_P(AutofillProfileComparatorTest, MergeNames) {
NameInfo name1;
- name1.SetRawInfo(NAME_FULL, UTF8ToUTF16("John Quincy Public"));
- name1.SetRawInfo(NAME_FIRST, UTF8ToUTF16("John"));
- name1.SetRawInfo(NAME_MIDDLE, UTF8ToUTF16("Quincy"));
- name1.SetRawInfo(NAME_LAST, UTF8ToUTF16("Public"));
+ name1.SetRawInfo(NAME_FULL, u"John Quincy Public");
+ name1.SetRawInfo(NAME_FIRST, u"John");
+ name1.SetRawInfo(NAME_MIDDLE, u"Quincy");
+ name1.SetRawInfo(NAME_LAST, u"Public");
name1.FinalizeAfterImport();
NameInfo name2;
- name2.SetRawInfo(NAME_FULL, UTF8ToUTF16("John Q. Public"));
- name2.SetRawInfo(NAME_FIRST, UTF8ToUTF16("John"));
- name2.SetRawInfo(NAME_MIDDLE, UTF8ToUTF16("Q."));
- name2.SetRawInfo(NAME_LAST, UTF8ToUTF16("Public"));
+ name2.SetRawInfo(NAME_FULL, u"John Q. Public");
+ name2.SetRawInfo(NAME_FIRST, u"John");
+ name2.SetRawInfo(NAME_MIDDLE, u"Q.");
+ name2.SetRawInfo(NAME_LAST, u"Public");
name2.FinalizeAfterImport();
NameInfo name3;
- name3.SetRawInfo(NAME_FULL, UTF8ToUTF16("J Public"));
- name3.SetRawInfo(NAME_FIRST, UTF8ToUTF16("J"));
- name3.SetRawInfo(NAME_MIDDLE, UTF8ToUTF16(""));
- name3.SetRawInfo(NAME_LAST, UTF8ToUTF16("Public"));
+ name3.SetRawInfo(NAME_FULL, u"J Public");
+ name3.SetRawInfo(NAME_FIRST, u"J");
+ name3.SetRawInfo(NAME_MIDDLE, u"");
+ name3.SetRawInfo(NAME_LAST, u"Public");
name3.FinalizeAfterImport();
NameInfo name4;
- name4.SetRawInfo(NAME_FULL, UTF8ToUTF16("John Quincy Public"));
+ name4.SetRawInfo(NAME_FULL, u"John Quincy Public");
name4.FinalizeAfterImport();
NameInfo name5;
- name5.SetRawInfo(NAME_FIRST, UTF8ToUTF16("John"));
- name5.SetRawInfo(NAME_LAST, UTF8ToUTF16("Public"));
+ name5.SetRawInfo(NAME_FIRST, u"John");
+ name5.SetRawInfo(NAME_LAST, u"Public");
name5.FinalizeAfterImport();
NameInfo synthesized;
- synthesized.SetRawInfo(NAME_FULL, UTF8ToUTF16("John Public"));
- synthesized.SetRawInfo(NAME_FIRST, UTF8ToUTF16("John"));
- synthesized.SetRawInfo(NAME_MIDDLE, UTF8ToUTF16(""));
- synthesized.SetRawInfo(NAME_LAST, UTF8ToUTF16("Public"));
+ synthesized.SetRawInfo(NAME_FULL, u"John Public");
+ synthesized.SetRawInfo(NAME_FIRST, u"John");
+ synthesized.SetRawInfo(NAME_MIDDLE, u"");
+ synthesized.SetRawInfo(NAME_LAST, u"Public");
synthesized.FinalizeAfterImport();
AutofillProfile p1 = CreateProfileWithName(name1);
@@ -1166,7 +1130,7 @@ TEST_P(AutofillProfileComparatorTest, MergePhoneNumbers_NA) {
}
TEST_P(AutofillProfileComparatorTest, MergePhoneNumbers_Intl) {
- const base::string16 kGermany = UTF8ToUTF16("DE");
+ const std::u16string kGermany = u"DE";
const AutofillType kCountry(ADDRESS_HOME_COUNTRY);
static const char kPhoneA[] = "+49492180185611";
@@ -1215,17 +1179,16 @@ TEST_P(AutofillProfileComparatorTest, MergeAddresses) {
"1 Some Street #3", "", "Carver City", "ca", "90210-1234", "us");
Address expected;
- expected.SetRawInfo(ADDRESS_HOME_LINE1, UTF8ToUTF16("1 Some Street"));
- expected.SetRawInfo(ADDRESS_HOME_LINE2, UTF8ToUTF16("Unit 3"));
- expected.SetRawInfo(ADDRESS_HOME_CITY, UTF8ToUTF16("Carver City"));
- expected.SetRawInfo(ADDRESS_HOME_STATE, UTF8ToUTF16("ca"));
- expected.SetRawInfo(ADDRESS_HOME_ZIP, UTF8ToUTF16("90210-1234"));
- expected.SetRawInfo(ADDRESS_HOME_COUNTRY, UTF8ToUTF16("US"));
+ expected.SetRawInfo(ADDRESS_HOME_LINE1, u"1 Some Street");
+ expected.SetRawInfo(ADDRESS_HOME_LINE2, u"Unit 3");
+ expected.SetRawInfo(ADDRESS_HOME_CITY, u"Carver City");
+ expected.SetRawInfo(ADDRESS_HOME_STATE, u"ca");
+ expected.SetRawInfo(ADDRESS_HOME_ZIP, u"90210-1234");
+ expected.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US");
if (autofill::structured_address::StructuredAddressesEnabled()) {
- expected.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER, UTF8ToUTF16("1"));
- expected.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME,
- UTF8ToUTF16("Some Street"));
+ expected.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER, u"1");
+ expected.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME, u"Some Street");
}
MergeAddressesAndExpect(p1, p2, expected,
@@ -1236,51 +1199,41 @@ TEST_P(AutofillProfileComparatorTest, MergeAddressesMostUniqueTokens) {
AutofillProfile p1 = CreateProfileWithAddress(
"1 Some Street", "Unit 3", "Carver", "CA - California", "90210", "US");
- p1.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME,
- base::UTF8ToUTF16("Some Street"));
- p1.SetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_STREET_NAME,
- base::UTF8ToUTF16(""));
- p1.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER, base::UTF8ToUTF16(""));
- p1.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME, base::UTF8ToUTF16(""));
- p1.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE, base::UTF8ToUTF16("Unit 3"));
+ p1.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME, u"Some Street");
+ p1.SetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_STREET_NAME, u"");
+ p1.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER, u"");
+ p1.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME, u"");
+ p1.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE, u"Unit 3");
AutofillProfile p2 = CreateProfileWithAddress(
"1 Some Other Street", "Unit 3", "Carver City", "ca", "90210-1234", "us");
p2.set_use_date(p1.use_date() + base::TimeDelta::FromMinutes(1));
- p2.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME,
- base::UTF8ToUTF16("Some Other Street"));
+ p2.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME, u"Some Other Street");
p2.SetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_STREET_NAME,
- base::UTF8ToUTF16("DependentStreetName2"));
- p2.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER,
- base::UTF8ToUTF16("HouseNumber2"));
- p2.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME,
- base::UTF8ToUTF16("PremiseName2"));
- p2.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE,
- base::UTF8ToUTF16("Subpremise2"));
+ u"DependentStreetName2");
+ p2.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER, u"HouseNumber2");
+ p2.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME, u"PremiseName2");
+ p2.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE, u"Subpremise2");
Address expected;
- expected.SetRawInfo(ADDRESS_HOME_LINE1, UTF8ToUTF16("1 Some Other Street"));
- expected.SetRawInfo(ADDRESS_HOME_LINE2, UTF8ToUTF16("Unit 3"));
- expected.SetRawInfo(ADDRESS_HOME_CITY, UTF8ToUTF16("Carver City"));
- expected.SetRawInfo(ADDRESS_HOME_STATE, UTF8ToUTF16("ca"));
- expected.SetRawInfo(ADDRESS_HOME_ZIP, UTF8ToUTF16("90210-1234"));
- expected.SetRawInfo(ADDRESS_HOME_COUNTRY, UTF8ToUTF16("US"));
+ expected.SetRawInfo(ADDRESS_HOME_LINE1, u"1 Some Other Street");
+ expected.SetRawInfo(ADDRESS_HOME_LINE2, u"Unit 3");
+ expected.SetRawInfo(ADDRESS_HOME_CITY, u"Carver City");
+ expected.SetRawInfo(ADDRESS_HOME_STATE, u"ca");
+ expected.SetRawInfo(ADDRESS_HOME_ZIP, u"90210-1234");
+ expected.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US");
// If address enhancement votes are enabled, it is expecfted that the
// substructure from p2 since it is a superset of p1.
// Otherwise the fields are expected to be empty after the merge process.
if (AddressEnhancementVotes()) {
- expected.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME,
- base::UTF8ToUTF16("StreetName2"));
+ expected.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME, u"StreetName2");
expected.SetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_STREET_NAME,
- base::UTF8ToUTF16("DependentStreetName2"));
- expected.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER,
- base::UTF8ToUTF16("HouseNumber2"));
- expected.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME,
- base::UTF8ToUTF16("PremiseName2"));
- expected.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE,
- base::UTF8ToUTF16("Subpremise2"));
+ u"DependentStreetName2");
+ expected.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER, u"HouseNumber2");
+ expected.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME, u"PremiseName2");
+ expected.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE, u"Subpremise2");
}
MergeAddressesAndExpect(p1, p2, expected);
MergeAddressesAndExpect(p2, p1, expected);
@@ -1290,53 +1243,41 @@ TEST_P(AutofillProfileComparatorTest, MergeAddressesWithStructure) {
AutofillProfile p1 = CreateProfileWithAddress(
"6543 CH BACON", "APP 3", "MONTRÉAL", "QUÉBEC", "HHH999", "ca");
- p1.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME,
- base::UTF8ToUTF16("StreetName"));
+ p1.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME, u"StreetName");
p1.SetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_STREET_NAME,
- base::UTF8ToUTF16("DependentStreetName"));
- p1.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER,
- base::UTF8ToUTF16("HouseNumber"));
- p1.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME,
- base::UTF8ToUTF16("PremiseName"));
- p1.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE,
- base::UTF8ToUTF16("Subpremise"));
+ u"DependentStreetName");
+ p1.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER, u"HouseNumber");
+ p1.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME, u"PremiseName");
+ p1.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE, u"Subpremise");
AutofillProfile p2 = CreateProfileWithAddress(
"6543, Bacon Rd", "", "Montreal", "QC", "hhh 999", "CA");
p2.set_use_date(p1.use_date() + base::TimeDelta::FromMinutes(1));
- p2.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME,
- base::UTF8ToUTF16("StreetName2"));
+ p2.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME, u"StreetName2");
p2.SetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_STREET_NAME,
- base::UTF8ToUTF16("DependentStreetName2"));
- p2.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER,
- base::UTF8ToUTF16("HouseNumber2"));
- p2.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME,
- base::UTF8ToUTF16("PremiseName2"));
- p2.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE,
- base::UTF8ToUTF16("Subpremise2"));
+ u"DependentStreetName2");
+ p2.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER, u"HouseNumber2");
+ p2.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME, u"PremiseName2");
+ p2.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE, u"Subpremise2");
Address expected;
- expected.SetRawInfo(ADDRESS_HOME_LINE1, UTF8ToUTF16("6543 CH BACON"));
- expected.SetRawInfo(ADDRESS_HOME_LINE2, UTF8ToUTF16("APP 3"));
- expected.SetRawInfo(ADDRESS_HOME_CITY, UTF8ToUTF16("Montreal"));
- expected.SetRawInfo(ADDRESS_HOME_STATE, UTF8ToUTF16("QC"));
- expected.SetRawInfo(ADDRESS_HOME_ZIP, UTF8ToUTF16("hhh 999"));
- expected.SetRawInfo(ADDRESS_HOME_COUNTRY, UTF8ToUTF16("CA"));
+ expected.SetRawInfo(ADDRESS_HOME_LINE1, u"6543 CH BACON");
+ expected.SetRawInfo(ADDRESS_HOME_LINE2, u"APP 3");
+ expected.SetRawInfo(ADDRESS_HOME_CITY, u"Montreal");
+ expected.SetRawInfo(ADDRESS_HOME_STATE, u"QC");
+ expected.SetRawInfo(ADDRESS_HOME_ZIP, u"hhh 999");
+ expected.SetRawInfo(ADDRESS_HOME_COUNTRY, u"CA");
// If address enhancement votes are enabled, it is expecfted that the
// substructure from p1 is used since it is most recent.
// Otherwise the fields are expected to be empty after the merge process.
if (AddressEnhancementVotes()) {
- expected.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME,
- base::UTF8ToUTF16("StreetName"));
+ expected.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME, u"StreetName");
expected.SetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_STREET_NAME,
- base::UTF8ToUTF16("DependentStreetName"));
- expected.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER,
- base::UTF8ToUTF16("HouseNumber"));
- expected.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME,
- base::UTF8ToUTF16("PremiseName"));
- expected.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE,
- base::UTF8ToUTF16("Subpremise"));
+ u"DependentStreetName");
+ expected.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER, u"HouseNumber");
+ expected.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME, u"PremiseName");
+ expected.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE, u"Subpremise");
}
MergeAddressesAndExpect(p1, p2, expected);
@@ -1347,53 +1288,41 @@ TEST_P(AutofillProfileComparatorTest, MergeAddressesWithRewrite) {
AutofillProfile p1 = CreateProfileWithAddress(
"6543 CH BACON", "APP 3", "MONTRÉAL", "QUÉBEC", "HHH999", "ca");
- p1.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME,
- base::UTF8ToUTF16("StreetName"));
+ p1.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME, u"StreetName");
p1.SetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_STREET_NAME,
- base::UTF8ToUTF16("DependentStreetName"));
- p1.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER,
- base::UTF8ToUTF16("HouseNumber"));
- p1.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME,
- base::UTF8ToUTF16("PremiseName"));
- p1.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE,
- base::UTF8ToUTF16("Subpremise"));
+ u"DependentStreetName");
+ p1.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER, u"HouseNumber");
+ p1.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME, u"PremiseName");
+ p1.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE, u"Subpremise");
AutofillProfile p2 = CreateProfileWithAddress(
"6543, Bacon Rd", "", "Montreal", "QC", "hhh 999", "CA");
- p2.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME,
- base::UTF8ToUTF16("StreetName2"));
+ p2.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME, u"StreetName2");
p2.SetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_STREET_NAME,
- base::UTF8ToUTF16("DependentStreetName2"));
- p2.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER,
- base::UTF8ToUTF16("HouseNumber2"));
- p2.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME,
- base::UTF8ToUTF16("PremiseName2"));
- p2.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE,
- base::UTF8ToUTF16("Subpremise2"));
+ u"DependentStreetName2");
+ p2.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER, u"HouseNumber2");
+ p2.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME, u"PremiseName2");
+ p2.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE, u"Subpremise2");
p2.set_use_date(p1.use_date() + base::TimeDelta::FromMinutes(1));
Address expected;
- expected.SetRawInfo(ADDRESS_HOME_LINE1, UTF8ToUTF16("6543 CH BACON"));
- expected.SetRawInfo(ADDRESS_HOME_LINE2, UTF8ToUTF16("APP 3"));
- expected.SetRawInfo(ADDRESS_HOME_CITY, UTF8ToUTF16("Montreal"));
- expected.SetRawInfo(ADDRESS_HOME_STATE, UTF8ToUTF16("QC"));
- expected.SetRawInfo(ADDRESS_HOME_ZIP, UTF8ToUTF16("hhh 999"));
- expected.SetRawInfo(ADDRESS_HOME_COUNTRY, UTF8ToUTF16("CA"));
+ expected.SetRawInfo(ADDRESS_HOME_LINE1, u"6543 CH BACON");
+ expected.SetRawInfo(ADDRESS_HOME_LINE2, u"APP 3");
+ expected.SetRawInfo(ADDRESS_HOME_CITY, u"Montreal");
+ expected.SetRawInfo(ADDRESS_HOME_STATE, u"QC");
+ expected.SetRawInfo(ADDRESS_HOME_ZIP, u"hhh 999");
+ expected.SetRawInfo(ADDRESS_HOME_COUNTRY, u"CA");
// If address enhancement votes are enabled, it is expecfted that the
// substructure from p1 is used since it has more tokens.
if (AddressEnhancementVotes()) {
- expected.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME,
- base::UTF8ToUTF16("StreetName"));
+ expected.SetRawInfo(autofill::ADDRESS_HOME_STREET_NAME, u"StreetName");
expected.SetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_STREET_NAME,
- base::UTF8ToUTF16("DependentStreetName"));
- expected.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER,
- base::UTF8ToUTF16("HouseNumber"));
- expected.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME,
- base::UTF8ToUTF16("PremiseName"));
- expected.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE,
- base::UTF8ToUTF16("Subpremise"));
+ u"DependentStreetName");
+ expected.SetRawInfo(autofill::ADDRESS_HOME_HOUSE_NUMBER, u"HouseNumber");
+ expected.SetRawInfo(autofill::ADDRESS_HOME_PREMISE_NAME, u"PremiseName");
+ expected.SetRawInfo(autofill::ADDRESS_HOME_SUBPREMISE, u"Subpremise");
}
MergeAddressesAndExpect(p1, p2, expected);
@@ -1404,26 +1333,24 @@ TEST_P(AutofillProfileComparatorTest,
MergeAddressesDependendLocalityAndSortingCode) {
AutofillProfile p1 = CreateProfileWithAddress(
"6543 CH BACON", "APP 3", "MONTRÉAL", "QUÉBEC", "HHH999", "ca");
- p1.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, UTF8ToUTF16("Some String"));
- p1.SetRawInfo(ADDRESS_HOME_SORTING_CODE, UTF8ToUTF16("64205 Biarritz CEDEX"));
+ p1.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u"Some String");
+ p1.SetRawInfo(ADDRESS_HOME_SORTING_CODE, u"64205 Biarritz CEDEX");
AutofillProfile p2 = CreateProfileWithAddress(
"6543, Bacon Rd", "", "Montreal", "QC", "hhh 999", "CA");
- p2.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY,
- UTF8ToUTF16("Some Other String"));
- p2.SetRawInfo(ADDRESS_HOME_SORTING_CODE, UTF8ToUTF16("64205 Biarritz"));
+ p2.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u"Some Other String");
+ p2.SetRawInfo(ADDRESS_HOME_SORTING_CODE, u"64205 Biarritz");
p2.set_use_date(p1.use_date() + base::TimeDelta::FromMinutes(1));
Address expected;
- expected.SetRawInfo(ADDRESS_HOME_LINE1, UTF8ToUTF16("6543 CH BACON"));
- expected.SetRawInfo(ADDRESS_HOME_LINE2, UTF8ToUTF16("APP 3"));
- expected.SetRawInfo(ADDRESS_HOME_CITY, UTF8ToUTF16("Montreal"));
- expected.SetRawInfo(ADDRESS_HOME_STATE, UTF8ToUTF16("QC"));
- expected.SetRawInfo(ADDRESS_HOME_ZIP, UTF8ToUTF16("hhh 999"));
- expected.SetRawInfo(ADDRESS_HOME_COUNTRY, UTF8ToUTF16("CA"));
- expected.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY,
- UTF8ToUTF16("Some Other String"));
+ expected.SetRawInfo(ADDRESS_HOME_LINE1, u"6543 CH BACON");
+ expected.SetRawInfo(ADDRESS_HOME_LINE2, u"APP 3");
+ expected.SetRawInfo(ADDRESS_HOME_CITY, u"Montreal");
+ expected.SetRawInfo(ADDRESS_HOME_STATE, u"QC");
+ expected.SetRawInfo(ADDRESS_HOME_ZIP, u"hhh 999");
+ expected.SetRawInfo(ADDRESS_HOME_COUNTRY, u"CA");
+ expected.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u"Some Other String");
expected.SetRawInfo(ADDRESS_HOME_SORTING_CODE,
- UTF8ToUTF16("64205 Biarritz")); // Preferred by use date.
+ u"64205 Biarritz"); // Preferred by use date.
MergeAddressesAndExpect(p1, p2, expected);
MergeAddressesAndExpect(p2, p1, expected);
@@ -1456,6 +1383,167 @@ TEST_P(AutofillProfileComparatorTest, CheckStatesMergeability) {
EXPECT_FALSE(comparator_.HaveMergeableAddresses(p2, p4));
}
+// Tests if determining if two profiles have at least one different settings
+// visible value works.
+TEST_P(AutofillProfileComparatorTest,
+ ProfilesHaveDifferentSettingsVisibleValues) {
+ AutofillProfile existing_profile(base::GenerateGUID(),
+ "http://www.example.com/");
+ autofill::test::SetProfileInfo(
+ &existing_profile, "firstName", "middleName", "lastName", "mail@mail.com",
+ "company", "line1", "line2", "city", "state", "zip", "US", "phone");
+
+ // A profile compared with itself cannot have different settings visible
+ // values.
+ EXPECT_FALSE(
+ AutofillProfileComparator::ProfilesHaveDifferentSettingsVisibleValues(
+ existing_profile, existing_profile));
+
+ // Test for most settings visible types that a change is correctly recognized.
+ for (ServerFieldType changed_type :
+ {NAME_FULL, ADDRESS_HOME_STREET_ADDRESS, ADDRESS_HOME_CITY,
+ ADDRESS_HOME_ZIP, EMAIL_ADDRESS, PHONE_HOME_WHOLE_NUMBER}) {
+ // Make a fresh copy and test that the function returns false.
+ AutofillProfile new_profile = existing_profile;
+ EXPECT_FALSE(
+ AutofillProfileComparator::ProfilesHaveDifferentSettingsVisibleValues(
+ existing_profile, new_profile));
+
+ // Change one of the settings visible values and test that the function
+ // returns true.
+ SCOPED_TRACE(changed_type);
+ new_profile.SetRawInfo(
+ changed_type, existing_profile.GetRawInfo(changed_type) + u"_edited");
+ EXPECT_TRUE(
+ AutofillProfileComparator::ProfilesHaveDifferentSettingsVisibleValues(
+ existing_profile, new_profile));
+ }
+
+ // The rest of the test is only applicable for structured names.
+ if (!StructuredNames())
+ return;
+
+ AutofillProfile new_profile = existing_profile;
+ // Now change the first name which is not visible in the settings to upper
+ // case. Note, the value was converted to upper case to maintain the name
+ // structure in a correct state.
+ new_profile.SetRawInfo(
+ NAME_FIRST, base::ToUpperASCII(existing_profile.GetRawInfo(NAME_FIRST)));
+ EXPECT_FALSE(
+ AutofillProfileComparator::ProfilesHaveDifferentSettingsVisibleValues(
+ existing_profile, new_profile));
+}
+
+TEST_P(AutofillProfileComparatorTest, IsMergeCandidate) {
+ AutofillProfile existing_profile(base::GenerateGUID(),
+ "http://www.example.com/");
+ autofill::test::SetProfileInfo(
+ &existing_profile, "firstName", "middleName", "lastName", "mail@mail.com",
+ "company", "line1", "line2", "the city", "state", "zip", "US", "phone");
+
+ // Explicitly set the full name if the structured name feature is not enabled.
+ if (!StructuredNames()) {
+ existing_profile.SetRawInfo(NAME_FULL, u"fistName middleName lastName");
+ }
+
+ AutofillProfileComparator comparator("en_US");
+
+ // A profile is not a merge candidate to itself.
+ EXPECT_FALSE(
+ comparator.IsMergeCandidate(existing_profile, existing_profile, "en_US"));
+
+ // A profile that is mergeable but only by changing a value is a merge
+ // candidate.
+ AutofillProfile mergeable_profile = existing_profile;
+ // This is a superset of the existing city name and should result in a merge
+ // and change of the stored value.
+ mergeable_profile.SetRawInfoWithVerificationStatus(
+ ADDRESS_HOME_CITY, u"the real City",
+ autofill::structured_address::VerificationStatus::kObserved);
+ EXPECT_TRUE(comparator.IsMergeCandidate(existing_profile, mergeable_profile,
+ "en_US"));
+
+ // A profile that is mergeable but without changing a value is not a merge
+ // candidate.
+ AutofillProfile updateable_profile = existing_profile;
+ // This is a subset of the existing city name and should result in a merge but
+ // without changing the stored value.
+ mergeable_profile.SetRawInfoWithVerificationStatus(
+ ADDRESS_HOME_CITY, u"City",
+ autofill::structured_address::VerificationStatus::kObserved);
+ EXPECT_FALSE(comparator.IsMergeCandidate(existing_profile, updateable_profile,
+ "en_US"));
+
+ // A profile that is not mergeable is not a merge candidate.
+ AutofillProfile unmergeable_profile = existing_profile;
+ // This is a different city name and therefore should not result in a merge.
+ mergeable_profile.SetRawInfoWithVerificationStatus(
+ ADDRESS_HOME_CITY, u"Village",
+ autofill::structured_address::VerificationStatus::kObserved);
+ EXPECT_FALSE(comparator.IsMergeCandidate(existing_profile,
+ unmergeable_profile, "en_US"));
+}
+
+// Test the correct determination of a merge candidate.
+TEST_P(AutofillProfileComparatorTest, GetMergeCandidate) {
+ AutofillProfile existing_profile(base::GenerateGUID(),
+ "http://www.example.com/");
+ autofill::test::SetProfileInfo(
+ &existing_profile, "firstName", "middleName", "lastName", "mail@mail.com",
+ "company", "line1", "line2", "city", "state", "zip", "US", "phone");
+
+ // Explicitly set the full name if the structured name feature is not enabled.
+ if (!StructuredNames()) {
+ existing_profile.SetRawInfo(NAME_FULL, u"fistName middleName lastName");
+ }
+
+ // A profile should never be a merge candidate to itself because all values
+ // are the same.
+ EXPECT_EQ(AutofillProfileComparator::GetAutofillProfileMergeCandidate(
+ existing_profile, {&existing_profile}, "en_US"),
+ base::nullopt);
+
+ // Create a new profile that is not mergeable because it has a completely
+ // different name.
+ AutofillProfile new_profile = existing_profile;
+ new_profile.SetRawInfo(NAME_FULL, u"JustAnotherName");
+ EXPECT_EQ(AutofillProfileComparator::GetAutofillProfileMergeCandidate(
+ new_profile, {&existing_profile}, "en_US"),
+ base::nullopt);
+
+ // Use a city name that is a superset of the existing city name. It should be
+ // mergeable and the profile should be updated to the new value.
+ new_profile = existing_profile;
+ new_profile.SetRawInfoWithVerificationStatus(
+ ADDRESS_HOME_CITY, u"the City",
+ autofill::structured_address::VerificationStatus::kObserved);
+ base::Optional<AutofillProfile> optional_merge_candidate =
+ AutofillProfileComparator::GetAutofillProfileMergeCandidate(
+ new_profile, {&existing_profile}, "en_US");
+ ASSERT_TRUE(optional_merge_candidate.has_value());
+ EXPECT_EQ(optional_merge_candidate.value(), existing_profile);
+
+ // Now create a second existing profile that is the same as the first one, but
+ // was used more often. By this, this profile should become the merge
+ // candidate.
+ AutofillProfile second_existing_profile = existing_profile;
+ second_existing_profile.set_use_count(second_existing_profile.use_count() +
+ 10);
+ optional_merge_candidate =
+ AutofillProfileComparator::GetAutofillProfileMergeCandidate(
+ new_profile, {&existing_profile, &second_existing_profile}, "en_US");
+ ASSERT_TRUE(optional_merge_candidate.has_value());
+ EXPECT_EQ(optional_merge_candidate.value(), second_existing_profile);
+
+ // Make sure the result is independent of the initial ordering of the
+ // profiles.
+ optional_merge_candidate =
+ AutofillProfileComparator::GetAutofillProfileMergeCandidate(
+ new_profile, {&second_existing_profile, &existing_profile}, "en_US");
+ ASSERT_TRUE(optional_merge_candidate.has_value());
+ EXPECT_EQ(optional_merge_candidate.value(), second_existing_profile);
+}
+
// Tests that the profiles are merged when they have common states.
TEST_P(AutofillProfileComparatorTest, MergeProfilesBasedOnState) {
base::test::ScopedFeatureList feature;
@@ -1481,8 +1569,8 @@ TEST_P(AutofillProfileComparatorTest, MergeProfilesBasedOnState) {
CreateProfileWithAddress("", "", "", "Bayern - BY - Bavaria", "", "DE");
Address expected;
- expected.SetRawInfo(ADDRESS_HOME_COUNTRY, UTF8ToUTF16("DE"));
- expected.SetRawInfo(ADDRESS_HOME_STATE, UTF8ToUTF16("Bayern"));
+ expected.SetRawInfo(ADDRESS_HOME_COUNTRY, u"DE");
+ expected.SetRawInfo(ADDRESS_HOME_STATE, u"Bayern");
MergeAddressesAndExpect(empty, p1, expected);
MergeAddressesAndExpect(p1, empty, expected);
MergeAddressesAndExpect(p1, p2, expected);
@@ -1492,8 +1580,8 @@ TEST_P(AutofillProfileComparatorTest, MergeProfilesBasedOnState) {
CreateProfileWithAddress("", "", "", "Pradesh", "", "IN");
AutofillProfile p4 =
CreateProfileWithAddress("", "", "", "Uttar Pradesh", "", "IN");
- expected.SetRawInfo(ADDRESS_HOME_COUNTRY, UTF8ToUTF16("IN"));
- expected.SetRawInfo(ADDRESS_HOME_STATE, UTF8ToUTF16("Uttar Pradesh"));
+ expected.SetRawInfo(ADDRESS_HOME_COUNTRY, u"IN");
+ expected.SetRawInfo(ADDRESS_HOME_STATE, u"Uttar Pradesh");
MergeAddressesAndExpect(p3, p4, expected);
MergeAddressesAndExpect(p4, p3, expected);
}
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_profile_unittest.cc b/chromium/components/autofill/core/browser/data_model/autofill_profile_unittest.cc
index 2e47d29e0b9..7a8b029f5e9 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_profile_unittest.cc
+++ b/chromium/components/autofill/core/browser/data_model/autofill_profile_unittest.cc
@@ -7,12 +7,12 @@
#include <stddef.h>
#include <memory>
+#include <string>
#include <vector>
#include "base/format_macros.h"
#include "base/guid.h"
#include "base/stl_util.h"
-#include "base/strings/string16.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
@@ -38,10 +38,10 @@ constexpr VerificationStatus kObserved = VerificationStatus::kObserved;
namespace {
-base::string16 GetLabel(AutofillProfile* profile) {
+std::u16string GetLabel(AutofillProfile* profile) {
std::vector<AutofillProfile*> profiles;
profiles.push_back(profile);
- std::vector<base::string16> labels;
+ std::vector<std::u16string> labels;
AutofillProfile::CreateDifferentiatingLabels(profiles, "en-US", &labels);
return labels[0];
}
@@ -95,81 +95,81 @@ TEST_P(AutofillProfileTest, PreviewSummaryString) {
// Case 0/null: ""
AutofillProfile profile0(base::GenerateGUID(), test::kEmptyOrigin);
// Empty profile - nothing to update.
- base::string16 summary0 = GetLabel(&profile0);
- EXPECT_EQ(base::string16(), summary0);
+ std::u16string summary0 = GetLabel(&profile0);
+ EXPECT_EQ(std::u16string(), summary0);
// Case 0a/empty name and address, so the first two fields of the rest of the
// data is used: "Hollywood, CA"
AutofillProfile profile00(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile00, "", "", "", "johnwayne@me.xyz", "Fox", "",
"", "Hollywood", "CA", "91601", "US", "16505678910");
- base::string16 summary00 = GetLabel(&profile00);
- EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary00);
+ std::u16string summary00 = GetLabel(&profile00);
+ EXPECT_EQ(u"Hollywood, CA", summary00);
// Case 1: "<address>" without line 2.
AutofillProfile profile1(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile1, "", "", "", "johnwayne@me.xyz", "Fox",
"123 Zoo St.", "", "Hollywood", "CA", "91601", "US",
"16505678910");
- base::string16 summary1 = GetLabel(&profile1);
- EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary1);
+ std::u16string summary1 = GetLabel(&profile1);
+ EXPECT_EQ(u"123 Zoo St., Hollywood", summary1);
// Case 1a: "<address>" with line 2.
AutofillProfile profile1a(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile1a, "", "", "", "johnwayne@me.xyz", "Fox",
"123 Zoo St.", "unit 5", "Hollywood", "CA", "91601",
"US", "16505678910");
- base::string16 summary1a = GetLabel(&profile1a);
- EXPECT_EQ(ASCIIToUTF16("123 Zoo St., unit 5"), summary1a);
+ std::u16string summary1a = GetLabel(&profile1a);
+ EXPECT_EQ(u"123 Zoo St., unit 5", summary1a);
// Case 2: "<lastname>"
AutofillProfile profile2(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile2, "", "Mitchell", "Morrison",
"johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA",
"91601", "US", "16505678910");
- base::string16 summary2 = GetLabel(&profile2);
+ std::u16string summary2 = GetLabel(&profile2);
// Summary includes full name, to the maximal extent available.
- EXPECT_EQ(ASCIIToUTF16("Mitchell Morrison, Hollywood"), summary2);
+ EXPECT_EQ(u"Mitchell Morrison, Hollywood", summary2);
// Case 3: "<lastname>, <address>"
AutofillProfile profile3(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile3, "", "Mitchell", "Morrison",
"johnwayne@me.xyz", "Fox", "123 Zoo St.", "",
"Hollywood", "CA", "91601", "US", "16505678910");
- base::string16 summary3 = GetLabel(&profile3);
- EXPECT_EQ(ASCIIToUTF16("Mitchell Morrison, 123 Zoo St."), summary3);
+ std::u16string summary3 = GetLabel(&profile3);
+ EXPECT_EQ(u"Mitchell Morrison, 123 Zoo St.", summary3);
// Case 4: "<firstname>"
AutofillProfile profile4(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile4, "Marion", "Mitchell", "", "johnwayne@me.xyz",
"Fox", "", "", "Hollywood", "CA", "91601", "US",
"16505678910");
- base::string16 summary4 = GetLabel(&profile4);
- EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, Hollywood"), summary4);
+ std::u16string summary4 = GetLabel(&profile4);
+ EXPECT_EQ(u"Marion Mitchell, Hollywood", summary4);
// Case 5: "<firstname>, <address>"
AutofillProfile profile5(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile5, "Marion", "Mitchell", "", "johnwayne@me.xyz",
"Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA",
"91601", "US", "16505678910");
- base::string16 summary5 = GetLabel(&profile5);
- EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, 123 Zoo St."), summary5);
+ std::u16string summary5 = GetLabel(&profile5);
+ EXPECT_EQ(u"Marion Mitchell, 123 Zoo St.", summary5);
// Case 6: "<firstname> <lastname>"
AutofillProfile profile6(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile6, "Marion", "Mitchell", "Morrison",
"johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA",
"91601", "US", "16505678910");
- base::string16 summary6 = GetLabel(&profile6);
- EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, Hollywood"), summary6);
+ std::u16string summary6 = GetLabel(&profile6);
+ EXPECT_EQ(u"Marion Mitchell Morrison, Hollywood", summary6);
// Case 7: "<firstname> <lastname>, <address>"
AutofillProfile profile7(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile7, "Marion", "Mitchell", "Morrison",
"johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5",
"Hollywood", "CA", "91601", "US", "16505678910");
- base::string16 summary7 = GetLabel(&profile7);
- EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, 123 Zoo St."), summary7);
+ std::u16string summary7 = GetLabel(&profile7);
+ EXPECT_EQ(u"Marion Mitchell Morrison, 123 Zoo St.", summary7);
// Case 7a: "<firstname> <lastname>, <address>" - same as #7, except for
// e-mail.
@@ -180,17 +180,14 @@ TEST_P(AutofillProfileTest, PreviewSummaryString) {
std::vector<AutofillProfile*> profiles;
profiles.push_back(&profile7);
profiles.push_back(&profile7a);
- std::vector<base::string16> labels;
+ std::vector<std::u16string> labels;
AutofillProfile::CreateDifferentiatingLabels(profiles, "en-US", &labels);
ASSERT_EQ(profiles.size(), labels.size());
summary7 = labels[0];
- base::string16 summary7a = labels[1];
- EXPECT_EQ(
- ASCIIToUTF16("Marion Mitchell Morrison, 123 Zoo St., johnwayne@me.xyz"),
- summary7);
- EXPECT_EQ(
- ASCIIToUTF16("Marion Mitchell Morrison, 123 Zoo St., marion@me.xyz"),
- summary7a);
+ std::u16string summary7a = labels[1];
+ EXPECT_EQ(u"Marion Mitchell Morrison, 123 Zoo St., johnwayne@me.xyz",
+ summary7);
+ EXPECT_EQ(u"Marion Mitchell Morrison, 123 Zoo St., marion@me.xyz", summary7a);
}
TEST_P(AutofillProfileTest, AdjustInferredLabels) {
@@ -205,12 +202,12 @@ TEST_P(AutofillProfileTest, AdjustInferredLabels) {
test::SetProfileInfo(profiles[1].get(), "Jane", "", "Doe",
"janedoe@tertium.com", "Pluto Inc.", "123 Letha Shore.",
"", "Dis", "CA", "91222", "US", "12345678910");
- std::vector<base::string16> labels;
+ std::vector<std::u16string> labels;
AutofillProfile::CreateDifferentiatingLabels(ToRawPointerVector(profiles),
"en-US", &labels);
ASSERT_EQ(2U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St."), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), labels[1]);
+ EXPECT_EQ(u"John Doe, 666 Erebus St.", labels[0]);
+ EXPECT_EQ(u"Jane Doe, 123 Letha Shore.", labels[1]);
profiles.push_back(
std::make_unique<AutofillProfile>(base::GenerateGUID(), kSettingsOrigin));
@@ -223,11 +220,9 @@ TEST_P(AutofillProfileTest, AdjustInferredLabels) {
// Profile 0 and 2 inferred label now includes an e-mail.
ASSERT_EQ(3U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@hades.com"),
- labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), labels[1]);
- EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@tertium.com"),
- labels[2]);
+ EXPECT_EQ(u"John Doe, 666 Erebus St., johndoe@hades.com", labels[0]);
+ EXPECT_EQ(u"Jane Doe, 123 Letha Shore.", labels[1]);
+ EXPECT_EQ(u"John Doe, 666 Erebus St., johndoe@tertium.com", labels[2]);
profiles.resize(2);
@@ -244,9 +239,9 @@ TEST_P(AutofillProfileTest, AdjustInferredLabels) {
// Profile 0 and 2 inferred label now includes a state.
ASSERT_EQ(3U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CA"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), labels[1]);
- EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CO"), labels[2]);
+ EXPECT_EQ(u"John Doe, 666 Erebus St., CA", labels[0]);
+ EXPECT_EQ(u"Jane Doe, 123 Letha Shore.", labels[1]);
+ EXPECT_EQ(u"John Doe, 666 Erebus St., CO", labels[2]);
profiles.push_back(std::make_unique<AutofillProfile>(base::GenerateGUID(),
test::kEmptyOrigin));
@@ -260,14 +255,12 @@ TEST_P(AutofillProfileTest, AdjustInferredLabels) {
AutofillProfile::CreateDifferentiatingLabels(ToRawPointerVector(profiles),
"en-US", &labels);
ASSERT_EQ(4U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CA"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), labels[1]);
- EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CO, 16502111111"),
- labels[2]);
+ EXPECT_EQ(u"John Doe, 666 Erebus St., CA", labels[0]);
+ EXPECT_EQ(u"Jane Doe, 123 Letha Shore.", labels[1]);
+ EXPECT_EQ(u"John Doe, 666 Erebus St., CO, 16502111111", labels[2]);
// This one differs from other ones by unique phone, so no need for extra
// information.
- EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CO, 16504444444"),
- labels[3]);
+ EXPECT_EQ(u"John Doe, 666 Erebus St., CO, 16504444444", labels[3]);
profiles.push_back(std::make_unique<AutofillProfile>(base::GenerateGUID(),
test::kEmptyOrigin));
@@ -282,8 +275,8 @@ TEST_P(AutofillProfileTest, AdjustInferredLabels) {
AutofillProfile::CreateDifferentiatingLabels(ToRawPointerVector(profiles),
"en-US", &labels);
ASSERT_EQ(5U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CA"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), labels[1]);
+ EXPECT_EQ(u"John Doe, 666 Erebus St., CA", labels[0]);
+ EXPECT_EQ(u"Jane Doe, 123 Letha Shore.", labels[1]);
EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CO, johndoe@hades.com,"
" 16502111111"),
labels[2]);
@@ -292,8 +285,7 @@ TEST_P(AutofillProfileTest, AdjustInferredLabels) {
labels[3]);
// This one differs from other ones by unique e-mail, so no need for extra
// information.
- EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CO, johndoe@styx.com"),
- labels[4]);
+ EXPECT_EQ(u"John Doe, 666 Erebus St., CO, johndoe@styx.com", labels[4]);
}
TEST_P(AutofillProfileTest, CreateInferredLabelsI18n_CH) {
@@ -320,7 +312,7 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsI18n_CH) {
"Switzerland, hrgiger@beispiel.com, +41 44-668-1800",
};
- std::vector<base::string16> labels;
+ std::vector<std::u16string> labels;
for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
UNKNOWN_TYPE, i, "en-US", &labels);
@@ -354,7 +346,7 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsI18n_FR) {
"France, antoine@exemple.com, +33 (0) 1 42 68 53 00",
};
- std::vector<base::string16> labels;
+ std::vector<std::u16string> labels;
for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
UNKNOWN_TYPE, i, "en-US", &labels);
@@ -372,8 +364,8 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsI18n_KR) {
"Gangnam Finance Center", "152 Teheran-ro", "Gangnam-Gu",
"Seoul", "135-984", "KR", "+82-2-531-9000");
profiles.back()->set_language_code("ko_Latn");
- profiles.back()->SetInfo(ADDRESS_HOME_DEPENDENT_LOCALITY,
- UTF8ToUTF16("Yeoksam-Dong"), "en-US");
+ profiles.back()->SetInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u"Yeoksam-Dong",
+ "en-US");
static const char* kExpectedLabels[] = {
"",
"Park Jae-sang",
@@ -398,7 +390,7 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsI18n_KR) {
"park@yeleul.com, +82-2-531-9000",
};
- std::vector<base::string16> labels;
+ std::vector<std::u16string> labels;
for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
UNKNOWN_TYPE, i, "en-US", &labels);
@@ -435,7 +427,7 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsI18n_JP_Latn) {
"Minato-ku, Tokyo, 106-6126, Japan, miku@rei.com, +81-3-6384-9000",
};
- std::vector<base::string16> labels;
+ std::vector<std::u16string> labels;
for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
UNKNOWN_TYPE, i, "en-US", &labels);
@@ -468,7 +460,7 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsI18n_JP_ja) {
"miku@rei.com, 03-6384-9000",
};
- std::vector<base::string16> labels;
+ std::vector<std::u16string> labels;
for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
UNKNOWN_TYPE, i, "en-US", &labels);
@@ -489,18 +481,18 @@ TEST_P(AutofillProfileTest, CreateInferredLabels) {
test::SetProfileInfo(profiles[1].get(), "Jane", "", "Doe",
"janedoe@tertium.com", "Pluto Inc.", "123 Letha Shore.",
"", "Dis", "CA", "91222", "US", "12345678910");
- std::vector<base::string16> labels;
+ std::vector<std::u16string> labels;
// Two fields at least - no filter.
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
UNKNOWN_TYPE, 2, "en-US", &labels);
- EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St."), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), labels[1]);
+ EXPECT_EQ(u"John Doe, 666 Erebus St.", labels[0]);
+ EXPECT_EQ(u"Jane Doe, 123 Letha Shore.", labels[1]);
// Three fields at least - no filter.
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
UNKNOWN_TYPE, 3, "en-US", &labels);
- EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., Elysium"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore., Dis"), labels[1]);
+ EXPECT_EQ(u"John Doe, 666 Erebus St., Elysium", labels[0]);
+ EXPECT_EQ(u"Jane Doe, 123 Letha Shore., Dis", labels[1]);
std::vector<ServerFieldType> suggested_fields;
suggested_fields.push_back(ADDRESS_HOME_CITY);
@@ -511,23 +503,23 @@ TEST_P(AutofillProfileTest, CreateInferredLabels) {
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles),
&suggested_fields, UNKNOWN_TYPE, 2,
"en-US", &labels);
- EXPECT_EQ(ASCIIToUTF16("Elysium 91111"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Dis 91222"), labels[1]);
+ EXPECT_EQ(u"Elysium 91111", labels[0]);
+ EXPECT_EQ(u"Dis 91222", labels[1]);
// Three fields at least, from suggested fields - no filter.
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles),
&suggested_fields, UNKNOWN_TYPE, 3,
"en-US", &labels);
- EXPECT_EQ(ASCIIToUTF16("Elysium, CA 91111"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Dis, CA 91222"), labels[1]);
+ EXPECT_EQ(u"Elysium, CA 91111", labels[0]);
+ EXPECT_EQ(u"Dis, CA 91222", labels[1]);
// Three fields at least, from suggested fields - but filter reduces available
// fields to two.
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles),
&suggested_fields, ADDRESS_HOME_ZIP, 3,
"en-US", &labels);
- EXPECT_EQ(ASCIIToUTF16("Elysium, CA"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Dis, CA"), labels[1]);
+ EXPECT_EQ(u"Elysium, CA", labels[0]);
+ EXPECT_EQ(u"Dis, CA", labels[1]);
suggested_fields.clear();
// In our implementation we always display NAME_FULL for all NAME* fields...
@@ -536,16 +528,16 @@ TEST_P(AutofillProfileTest, CreateInferredLabels) {
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles),
&suggested_fields, UNKNOWN_TYPE, 1,
"en-US", &labels);
- EXPECT_EQ(ASCIIToUTF16("John Doe"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Jane Doe"), labels[1]);
+ EXPECT_EQ(u"John Doe", labels[0]);
+ EXPECT_EQ(u"Jane Doe", labels[1]);
// One field at least, from suggested fields - filter the same as suggested
// field.
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles),
&suggested_fields, NAME_MIDDLE, 1,
"en-US", &labels);
- EXPECT_EQ(base::string16(), labels[0]);
- EXPECT_EQ(base::string16(), labels[1]);
+ EXPECT_EQ(std::u16string(), labels[0]);
+ EXPECT_EQ(std::u16string(), labels[1]);
suggested_fields.clear();
// In our implementation we always display NAME_FULL for NAME_MIDDLE_INITIAL
@@ -554,8 +546,8 @@ TEST_P(AutofillProfileTest, CreateInferredLabels) {
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles),
&suggested_fields, UNKNOWN_TYPE, 1,
"en-US", &labels);
- EXPECT_EQ(ASCIIToUTF16("John Doe"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Jane Doe"), labels[1]);
+ EXPECT_EQ(u"John Doe", labels[0]);
+ EXPECT_EQ(u"Jane Doe", labels[1]);
// One field at least, from suggested fields - filter same as the first non-
// unknown suggested field.
@@ -566,14 +558,14 @@ TEST_P(AutofillProfileTest, CreateInferredLabels) {
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles),
&suggested_fields, NAME_FULL, 1,
"en-US", &labels);
- EXPECT_EQ(base::string16(ASCIIToUTF16("666 Erebus St.")), labels[0]);
- EXPECT_EQ(base::string16(ASCIIToUTF16("123 Letha Shore.")), labels[1]);
+ EXPECT_EQ(std::u16string(u"666 Erebus St."), labels[0]);
+ EXPECT_EQ(std::u16string(u"123 Letha Shore."), labels[1]);
// No suggested fields, but non-unknown excluded field.
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
NAME_FULL, 1, "en-US", &labels);
- EXPECT_EQ(base::string16(ASCIIToUTF16("666 Erebus St.")), labels[0]);
- EXPECT_EQ(base::string16(ASCIIToUTF16("123 Letha Shore.")), labels[1]);
+ EXPECT_EQ(std::u16string(u"666 Erebus St."), labels[0]);
+ EXPECT_EQ(std::u16string(u"123 Letha Shore."), labels[1]);
}
// Test that we fall back to using the full name if there are no other
@@ -596,13 +588,13 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsFallsBackToFullName) {
suggested_fields.push_back(NAME_LAST);
suggested_fields.push_back(ADDRESS_HOME_LINE1);
suggested_fields.push_back(EMAIL_ADDRESS);
- std::vector<base::string16> labels;
+ std::vector<std::u16string> labels;
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles),
&suggested_fields, NAME_LAST, 1,
"en-US", &labels);
ASSERT_EQ(2U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave."), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave."), labels[1]);
+ EXPECT_EQ(u"88 Nowhere Ave.", labels[0]);
+ EXPECT_EQ(u"88 Nowhere Ave.", labels[1]);
// Otherwise, we should.
suggested_fields.push_back(NAME_FIRST);
@@ -610,8 +602,8 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsFallsBackToFullName) {
&suggested_fields, NAME_LAST, 1,
"en-US", &labels);
ASSERT_EQ(2U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave., John Doe"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave., Johnny K Doe"), labels[1]);
+ EXPECT_EQ(u"88 Nowhere Ave., John Doe", labels[0]);
+ EXPECT_EQ(u"88 Nowhere Ave., Johnny K Doe", labels[1]);
}
// Test that we do not show duplicate fields in the labels.
@@ -632,13 +624,13 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsNoDuplicatedFields) {
suggested_fields.push_back(ADDRESS_HOME_LINE1);
suggested_fields.push_back(ADDRESS_BILLING_LINE1);
suggested_fields.push_back(EMAIL_ADDRESS);
- std::vector<base::string16> labels;
+ std::vector<std::u16string> labels;
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles),
&suggested_fields, UNKNOWN_TYPE, 2,
"en-US", &labels);
ASSERT_EQ(2U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave., doe@example.com"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave., dojo@example.com"), labels[1]);
+ EXPECT_EQ(u"88 Nowhere Ave., doe@example.com", labels[0]);
+ EXPECT_EQ(u"88 Nowhere Ave., dojo@example.com", labels[1]);
}
// Make sure that empty fields are not treated as distinguishing fields.
@@ -658,25 +650,24 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsSkipsEmptyFields) {
"john.doe@example.com", "Goolge", "", "", "", "", "", "",
"");
- std::vector<base::string16> labels;
+ std::vector<std::u16string> labels;
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
UNKNOWN_TYPE, 3, "en-US", &labels);
ASSERT_EQ(3U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Gogole"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Ggoole"), labels[1]);
- EXPECT_EQ(ASCIIToUTF16("John Doe, john.doe@example.com, Goolge"), labels[2]);
+ EXPECT_EQ(u"John Doe, doe@example.com, Gogole", labels[0]);
+ EXPECT_EQ(u"John Doe, doe@example.com, Ggoole", labels[1]);
+ EXPECT_EQ(u"John Doe, john.doe@example.com, Goolge", labels[2]);
// A field must have a non-empty value for each profile to be considered a
// distinguishing field.
- profiles[1]->SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("88 Nowhere Ave."));
+ profiles[1]->SetRawInfo(ADDRESS_HOME_LINE1, u"88 Nowhere Ave.");
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
UNKNOWN_TYPE, 1, "en-US", &labels);
ASSERT_EQ(3U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Gogole"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("John Doe, 88 Nowhere Ave., doe@example.com, Ggoole"),
- labels[1])
+ EXPECT_EQ(u"John Doe, doe@example.com, Gogole", labels[0]);
+ EXPECT_EQ(u"John Doe, 88 Nowhere Ave., doe@example.com, Ggoole", labels[1])
<< labels[1];
- EXPECT_EQ(ASCIIToUTF16("John Doe, john.doe@example.com"), labels[2]);
+ EXPECT_EQ(u"John Doe, john.doe@example.com", labels[2]);
}
// Test that labels that would otherwise have multiline values are flattened.
@@ -692,12 +683,12 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsFlattensMultiLineValues) {
std::vector<ServerFieldType> suggested_fields;
suggested_fields.push_back(NAME_FULL);
suggested_fields.push_back(ADDRESS_HOME_STREET_ADDRESS);
- std::vector<base::string16> labels;
+ std::vector<std::u16string> labels;
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles),
&suggested_fields, NAME_FULL, 1,
"en-US", &labels);
ASSERT_EQ(1U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave., Apt. 42"), labels[0]);
+ EXPECT_EQ(u"88 Nowhere Ave., Apt. 42", labels[0]);
}
TEST_P(AutofillProfileTest, IsSubsetOfForFieldSet_DifferentMiddleNames) {
@@ -988,14 +979,13 @@ TEST_P(AutofillProfileTest, TestFinalizeAfterImport) {
// A profile with just a full name should be finalizeable.
{
AutofillProfile profile;
- profile.SetRawInfoWithVerificationStatus(NAME_FULL,
- base::ASCIIToUTF16("Peter Pan"),
+ profile.SetRawInfoWithVerificationStatus(NAME_FULL, u"Peter Pan",
VerificationStatus::kObserved);
EXPECT_TRUE(profile.FinalizeAfterImport());
- EXPECT_EQ(profile.GetRawInfo(NAME_FIRST), base::ASCIIToUTF16("Peter"));
+ EXPECT_EQ(profile.GetRawInfo(NAME_FIRST), u"Peter");
EXPECT_EQ(profile.GetVerificationStatus(NAME_FIRST),
VerificationStatus::kParsed);
- EXPECT_EQ(profile.GetRawInfo(NAME_LAST), base::ASCIIToUTF16("Pan"));
+ EXPECT_EQ(profile.GetRawInfo(NAME_LAST), u"Pan");
EXPECT_EQ(profile.GetVerificationStatus(NAME_LAST),
VerificationStatus::kParsed);
}
@@ -1006,11 +996,9 @@ TEST_P(AutofillProfileTest, TestFinalizeAfterImport) {
// and would not yield a correctly imported name.
{
AutofillProfile profile;
- profile.SetRawInfoWithVerificationStatus(NAME_FULL,
- base::ASCIIToUTF16("Peter Pan"),
+ profile.SetRawInfoWithVerificationStatus(NAME_FULL, u"Peter Pan",
VerificationStatus::kObserved);
- profile.SetRawInfoWithVerificationStatus(NAME_FIRST,
- base::ASCIIToUTF16("Michael"),
+ profile.SetRawInfoWithVerificationStatus(NAME_FIRST, u"Michael",
VerificationStatus::kObserved);
EXPECT_FALSE(profile.FinalizeAfterImport());
}
@@ -1033,17 +1021,15 @@ TEST_P(AutofillProfileTest, SetAndGetRawInfoWithValidationStatus) {
VerificationStatus::kNoStatus);
// Set a value with verification status and verify the results.
- profile.SetRawInfoWithVerificationStatus(NAME_FULL,
- base::ASCIIToUTF16("full name"),
+ profile.SetRawInfoWithVerificationStatus(NAME_FULL, u"full name",
VerificationStatus::kFormatted);
EXPECT_EQ(profile.GetVerificationStatusInt(NAME_FULL), 2);
EXPECT_EQ(profile.GetVerificationStatus(NAME_FULL),
VerificationStatus::kFormatted);
- EXPECT_EQ(profile.GetRawInfo(NAME_FULL), base::ASCIIToUTF16("full name"));
+ EXPECT_EQ(profile.GetRawInfo(NAME_FULL), u"full name");
// Test the working of the wrapper to pass the value by int.
- profile.SetRawInfoWithVerificationStatusInt(
- NAME_FULL, base::ASCIIToUTF16("full name"), 2);
+ profile.SetRawInfoWithVerificationStatusInt(NAME_FULL, u"full name", 2);
EXPECT_EQ(profile.GetVerificationStatusInt(NAME_FULL), 2);
}
@@ -1064,34 +1050,33 @@ TEST_P(AutofillProfileTest, SetAndGetInfoWithValidationStatus) {
VerificationStatus::kNoStatus);
// Set a value with verification status and verify the results.
- profile.SetInfoWithVerificationStatus(
- AutofillType(NAME_FULL), base::ASCIIToUTF16("full name"), "en-US",
- VerificationStatus::kFormatted);
+ profile.SetInfoWithVerificationStatus(AutofillType(NAME_FULL), u"full name",
+ "en-US",
+ VerificationStatus::kFormatted);
EXPECT_EQ(profile.GetVerificationStatus(NAME_FULL),
VerificationStatus::kFormatted);
- EXPECT_EQ(profile.GetRawInfo(NAME_FULL), base::ASCIIToUTF16("full name"));
+ EXPECT_EQ(profile.GetRawInfo(NAME_FULL), u"full name");
// Settings an unknown type should result in false.
EXPECT_FALSE(profile.SetInfoWithVerificationStatus(
- UNKNOWN_TYPE, base::ASCIIToUTF16("DM"), "en-US",
- VerificationStatus::kFormatted));
+ UNKNOWN_TYPE, u"DM", "en-US", VerificationStatus::kFormatted));
// Set a value with verification status using and AutofillType and verify the
// results.
EXPECT_TRUE(profile.SetInfoWithVerificationStatus(
- AutofillType(NAME_MIDDLE_INITIAL), base::ASCIIToUTF16("MK"), "en-US",
+ AutofillType(NAME_MIDDLE_INITIAL), u"MK", "en-US",
VerificationStatus::kFormatted));
EXPECT_EQ(profile.GetVerificationStatus(NAME_MIDDLE_INITIAL),
VerificationStatus::kFormatted);
- EXPECT_EQ(profile.GetRawInfo(NAME_MIDDLE_INITIAL), base::ASCIIToUTF16("MK"));
+ EXPECT_EQ(profile.GetRawInfo(NAME_MIDDLE_INITIAL), u"MK");
// Set a value with verification status and verify the results.
EXPECT_TRUE(profile.SetInfoWithVerificationStatus(
- AutofillType(NAME_MIDDLE_INITIAL), base::ASCIIToUTF16("CS"), "en-US",
+ AutofillType(NAME_MIDDLE_INITIAL), u"CS", "en-US",
VerificationStatus::kFormatted));
EXPECT_EQ(profile.GetVerificationStatus(NAME_MIDDLE_INITIAL),
VerificationStatus::kFormatted);
- EXPECT_EQ(profile.GetRawInfo(NAME_MIDDLE_INITIAL), base::ASCIIToUTF16("CS"));
+ EXPECT_EQ(profile.GetRawInfo(NAME_MIDDLE_INITIAL), u"CS");
}
TEST_P(AutofillProfileTest, SetRawInfo_UpdateValidityFlag) {
@@ -1099,12 +1084,12 @@ TEST_P(AutofillProfileTest, SetRawInfo_UpdateValidityFlag) {
SetupValidatedTestProfile(a);
EXPECT_TRUE(a.is_client_validity_states_updated());
- a.SetRawInfo(NAME_FULL, ASCIIToUTF16("Alice Munro"));
+ a.SetRawInfo(NAME_FULL, u"Alice Munro");
// NAME_FULL is NOT validated through the client API (not supported),
// therefore it should not change the validity flag.
EXPECT_TRUE(a.is_client_validity_states_updated());
- a.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Ooz"));
+ a.SetRawInfo(ADDRESS_HOME_CITY, u"Ooz");
// ADDRESS_HOME_CITY IS validated through the client API, therefore it should
// change the flag to false.
EXPECT_FALSE(a.is_client_validity_states_updated());
@@ -1124,14 +1109,14 @@ TEST_P(AutofillProfileTest, MergeDataFrom_DifferentProfile) {
b.set_guid(base::GenerateGUID());
b.set_origin(kSettingsOrigin);
b.SetRawInfoWithVerificationStatus(
- ADDRESS_HOME_LINE2, ASCIIToUTF16("Unit 5, area 51"),
+ ADDRESS_HOME_LINE2, u"Unit 5, area 51",
structured_address::VerificationStatus::kObserved);
b.SetRawInfoWithVerificationStatus(
- COMPANY_NAME, base::string16(),
+ COMPANY_NAME, std::u16string(),
structured_address::VerificationStatus::kObserved);
- b.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("M."));
- b.SetRawInfo(NAME_FULL, ASCIIToUTF16("Marion M. Morrison"));
+ b.SetRawInfo(NAME_MIDDLE, u"M.");
+ b.SetRawInfo(NAME_FULL, u"Marion M. Morrison");
b.set_language_code("en");
b.FinalizeAfterImport();
a.FinalizeAfterImport();
@@ -1142,9 +1127,9 @@ TEST_P(AutofillProfileTest, MergeDataFrom_DifferentProfile) {
EXPECT_EQ(kSettingsOrigin, a.origin());
EXPECT_EQ("Unit 5, area 51",
base::UTF16ToUTF8(a.GetRawInfo(ADDRESS_HOME_LINE2)));
- EXPECT_EQ(ASCIIToUTF16("Fox"), a.GetRawInfo(COMPANY_NAME));
- base::string16 name = a.GetInfo(NAME_FULL, "en-US");
- EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison"), name);
+ EXPECT_EQ(u"Fox", a.GetRawInfo(COMPANY_NAME));
+ std::u16string name = a.GetInfo(NAME_FULL, "en-US");
+ EXPECT_EQ(u"Marion Mitchell Morrison", name);
EXPECT_EQ("en", a.language_code());
}
@@ -1184,24 +1169,23 @@ TEST_P(AutofillProfileTest, MergeDataFrom_SameProfile) {
TEST_P(AutofillProfileTest, OverwriteName_AddNameFull) {
AutofillProfile a;
- a.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("Marion"));
- a.SetRawInfo(NAME_MIDDLE, base::ASCIIToUTF16("Mitchell"));
- a.SetRawInfo(NAME_LAST, base::ASCIIToUTF16("Morrison"));
+ a.SetRawInfo(NAME_FIRST, u"Marion");
+ a.SetRawInfo(NAME_MIDDLE, u"Mitchell");
+ a.SetRawInfo(NAME_LAST, u"Morrison");
AutofillProfile b = a;
a.FinalizeAfterImport();
b.SetRawInfoWithVerificationStatus(
- NAME_FULL, base::ASCIIToUTF16("Marion Mitchell Morrison"),
+ NAME_FULL, u"Marion Mitchell Morrison",
structured_address::VerificationStatus::kUserVerified);
b.FinalizeAfterImport();
EXPECT_TRUE(a.MergeDataFrom(b, "en-US"));
- EXPECT_EQ(base::ASCIIToUTF16("Marion"), a.GetRawInfo(NAME_FIRST));
- EXPECT_EQ(base::ASCIIToUTF16("Mitchell"), a.GetRawInfo(NAME_MIDDLE));
- EXPECT_EQ(base::ASCIIToUTF16("Morrison"), a.GetRawInfo(NAME_LAST));
- EXPECT_EQ(base::ASCIIToUTF16("Marion Mitchell Morrison"),
- a.GetRawInfo(NAME_FULL));
+ EXPECT_EQ(u"Marion", a.GetRawInfo(NAME_FIRST));
+ EXPECT_EQ(u"Mitchell", a.GetRawInfo(NAME_MIDDLE));
+ EXPECT_EQ(u"Morrison", a.GetRawInfo(NAME_LAST));
+ EXPECT_EQ(u"Marion Mitchell Morrison", a.GetRawInfo(NAME_FULL));
}
// Tests that OverwriteName overwrites the name parts if they have different
@@ -1210,29 +1194,27 @@ TEST_P(AutofillProfileTest, OverwriteName_DifferentCase) {
AutofillProfile a;
AutofillProfile b = a;
- a.SetRawInfoWithVerificationStatus(NAME_FIRST, base::ASCIIToUTF16("marion"),
+ a.SetRawInfoWithVerificationStatus(NAME_FIRST, u"marion",
VerificationStatus::kObserved);
- a.SetRawInfoWithVerificationStatus(NAME_MIDDLE,
- base::ASCIIToUTF16("mitchell"),
+ a.SetRawInfoWithVerificationStatus(NAME_MIDDLE, u"mitchell",
VerificationStatus::kObserved);
- a.SetRawInfoWithVerificationStatus(NAME_LAST, base::ASCIIToUTF16("morrison"),
+ a.SetRawInfoWithVerificationStatus(NAME_LAST, u"morrison",
VerificationStatus::kObserved);
- b.SetRawInfoWithVerificationStatus(NAME_FIRST, base::ASCIIToUTF16("Marion"),
+ b.SetRawInfoWithVerificationStatus(NAME_FIRST, u"Marion",
VerificationStatus::kObserved);
- b.SetRawInfoWithVerificationStatus(NAME_MIDDLE,
- base::ASCIIToUTF16("Mitchell"),
+ b.SetRawInfoWithVerificationStatus(NAME_MIDDLE, u"Mitchell",
VerificationStatus::kObserved);
- b.SetRawInfoWithVerificationStatus(NAME_LAST, base::ASCIIToUTF16("Morrison"),
+ b.SetRawInfoWithVerificationStatus(NAME_LAST, u"Morrison",
VerificationStatus::kObserved);
a.FinalizeAfterImport();
b.FinalizeAfterImport();
EXPECT_TRUE(a.MergeDataFrom(b, "en-US"));
- EXPECT_EQ(base::ASCIIToUTF16("Marion"), a.GetRawInfo(NAME_FIRST));
- EXPECT_EQ(base::ASCIIToUTF16("Mitchell"), a.GetRawInfo(NAME_MIDDLE));
- EXPECT_EQ(base::ASCIIToUTF16("Morrison"), a.GetRawInfo(NAME_LAST));
+ EXPECT_EQ(u"Marion", a.GetRawInfo(NAME_FIRST));
+ EXPECT_EQ(u"Mitchell", a.GetRawInfo(NAME_MIDDLE));
+ EXPECT_EQ(u"Morrison", a.GetRawInfo(NAME_LAST));
}
TEST_P(AutofillProfileTest, AssignmentOperator) {
@@ -1302,11 +1284,10 @@ TEST_P(AutofillProfileTest, Compare) {
// Addresses are compared in full. Regression test for http://crbug.com/375545
test::SetProfileInfo(&a, "John", nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
- a.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("line one\nline two"));
+ a.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"line one\nline two");
test::SetProfileInfo(&b, "John", nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
- b.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS,
- ASCIIToUTF16("line one\nline two\nline three"));
+ b.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"line one\nline two\nline three");
EXPECT_GT(0, a.Compare(b));
EXPECT_LT(0, b.Compare(a));
}
@@ -1317,27 +1298,27 @@ TEST_P(AutofillProfileTest, IsPresentButInvalid) {
EXPECT_FALSE(profile.IsPresentButInvalid(ADDRESS_HOME_ZIP));
EXPECT_FALSE(profile.IsPresentButInvalid(PHONE_HOME_WHOLE_NUMBER));
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US");
EXPECT_FALSE(profile.IsPresentButInvalid(ADDRESS_HOME_STATE));
EXPECT_FALSE(profile.IsPresentButInvalid(ADDRESS_HOME_ZIP));
EXPECT_FALSE(profile.IsPresentButInvalid(PHONE_HOME_WHOLE_NUMBER));
- profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("C"));
+ profile.SetRawInfo(ADDRESS_HOME_STATE, u"C");
EXPECT_TRUE(profile.IsPresentButInvalid(ADDRESS_HOME_STATE));
- profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA"));
+ profile.SetRawInfo(ADDRESS_HOME_STATE, u"CA");
EXPECT_FALSE(profile.IsPresentButInvalid(ADDRESS_HOME_STATE));
- profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90"));
+ profile.SetRawInfo(ADDRESS_HOME_ZIP, u"90");
EXPECT_TRUE(profile.IsPresentButInvalid(ADDRESS_HOME_ZIP));
- profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90210"));
+ profile.SetRawInfo(ADDRESS_HOME_ZIP, u"90210");
EXPECT_FALSE(profile.IsPresentButInvalid(ADDRESS_HOME_ZIP));
- profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("310"));
+ profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"310");
EXPECT_TRUE(profile.IsPresentButInvalid(PHONE_HOME_WHOLE_NUMBER));
- profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("(310) 310-6000"));
+ profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"(310) 310-6000");
EXPECT_FALSE(profile.IsPresentButInvalid(PHONE_HOME_WHOLE_NUMBER));
}
@@ -1366,18 +1347,15 @@ TEST_P(AutofillProfileTest, SetInfoPreservesLineBreaks) {
TEST_P(AutofillProfileTest, SetRawInfoDoesntTrimWhitespace) {
AutofillProfile profile(base::GenerateGUID(), test::kEmptyOrigin);
- profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("\tuser@example.com "));
- EXPECT_EQ(ASCIIToUTF16("\tuser@example.com "),
- profile.GetRawInfo(EMAIL_ADDRESS));
+ profile.SetRawInfo(EMAIL_ADDRESS, u"\tuser@example.com ");
+ EXPECT_EQ(u"\tuser@example.com ", profile.GetRawInfo(EMAIL_ADDRESS));
}
TEST_P(AutofillProfileTest, SetInfoTrimsWhitespace) {
AutofillProfile profile(base::GenerateGUID(), test::kEmptyOrigin);
- profile.SetInfo(EMAIL_ADDRESS, ASCIIToUTF16("\tuser@example.com "),
- "en-US");
- EXPECT_EQ(ASCIIToUTF16("user@example.com"),
- profile.GetRawInfo(EMAIL_ADDRESS));
+ profile.SetInfo(EMAIL_ADDRESS, u"\tuser@example.com ", "en-US");
+ EXPECT_EQ(u"user@example.com", profile.GetRawInfo(EMAIL_ADDRESS));
}
TEST_P(AutofillProfileTest, FullAddress) {
@@ -1387,7 +1365,7 @@ TEST_P(AutofillProfileTest, FullAddress) {
"Hollywood", "CA", "91601", "US", "12345678910");
AutofillType full_address(HTML_TYPE_FULL_ADDRESS, HTML_MODE_NONE);
- base::string16 formatted_address(
+ std::u16string formatted_address(
ASCIIToUTF16("Marion Mitchell Morrison\n"
"Fox\n"
"123 Zoo St.\n"
@@ -1395,12 +1373,12 @@ TEST_P(AutofillProfileTest, FullAddress) {
"Hollywood, CA 91601"));
EXPECT_EQ(formatted_address, profile.GetInfo(full_address, "en-US"));
// This should fail and leave the profile unchanged.
- EXPECT_FALSE(profile.SetInfo(full_address, ASCIIToUTF16("foobar"), "en-US"));
+ EXPECT_FALSE(profile.SetInfo(full_address, u"foobar", "en-US"));
EXPECT_EQ(formatted_address, profile.GetInfo(full_address, "en-US"));
// Some things can be missing...
- profile.SetInfo(ADDRESS_HOME_LINE2, base::string16(), "en-US");
- profile.SetInfo(EMAIL_ADDRESS, base::string16(), "en-US");
+ profile.SetInfo(ADDRESS_HOME_LINE2, std::u16string(), "en-US");
+ profile.SetInfo(EMAIL_ADDRESS, std::u16string(), "en-US");
EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison\n"
"Fox\n"
"123 Zoo St.\n"
@@ -1408,13 +1386,13 @@ TEST_P(AutofillProfileTest, FullAddress) {
profile.GetInfo(full_address, "en-US"));
// ...but nothing comes out if a required field is missing.
- profile.SetInfo(ADDRESS_HOME_STATE, base::string16(), "en-US");
+ profile.SetInfo(ADDRESS_HOME_STATE, std::u16string(), "en-US");
EXPECT_TRUE(profile.GetInfo(full_address, "en-US").empty());
// Restore the state but remove country. This should also fail.
- profile.SetInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA"), "en-US");
+ profile.SetInfo(ADDRESS_HOME_STATE, u"CA", "en-US");
EXPECT_FALSE(profile.GetInfo(full_address, "en-US").empty());
- profile.SetInfo(ADDRESS_HOME_COUNTRY, base::string16(), "en-US");
+ profile.SetInfo(ADDRESS_HOME_COUNTRY, std::u16string(), "en-US");
EXPECT_TRUE(profile.GetInfo(full_address, "en-US").empty());
}
@@ -1424,9 +1402,8 @@ TEST_P(AutofillProfileTest, SaveAdditionalInfo_Verified_MergeStructure) {
return;
AutofillProfile a;
- a.SetRawInfoWithVerificationStatus(
- NAME_FULL, base::ASCIIToUTF16("Marion Mitchell Morrison"),
- VerificationStatus::kUserVerified);
+ a.SetRawInfoWithVerificationStatus(NAME_FULL, u"Marion Mitchell Morrison",
+ VerificationStatus::kUserVerified);
a.FinalizeAfterImport();
ASSERT_FALSE(a.IsVerified());
a.set_origin(autofill::kSettingsOrigin);
@@ -1437,16 +1414,16 @@ TEST_P(AutofillProfileTest, SaveAdditionalInfo_Verified_MergeStructure) {
EXPECT_EQ(a.GetVerificationStatus(NAME_FIRST), VerificationStatus::kParsed);
EXPECT_EQ(a.GetVerificationStatus(NAME_MIDDLE), VerificationStatus::kParsed);
EXPECT_EQ(a.GetVerificationStatus(NAME_LAST), VerificationStatus::kParsed);
- EXPECT_EQ(a.GetRawInfo(NAME_FIRST), base::ASCIIToUTF16("Marion"));
- EXPECT_EQ(a.GetRawInfo(NAME_MIDDLE), base::ASCIIToUTF16("Mitchell"));
- EXPECT_EQ(a.GetRawInfo(NAME_LAST), base::ASCIIToUTF16("Morrison"));
+ EXPECT_EQ(a.GetRawInfo(NAME_FIRST), u"Marion");
+ EXPECT_EQ(a.GetRawInfo(NAME_MIDDLE), u"Mitchell");
+ EXPECT_EQ(a.GetRawInfo(NAME_LAST), u"Morrison");
AutofillProfile b;
- b.SetRawInfoWithVerificationStatus(NAME_FIRST, base::ASCIIToUTF16("Mitchell"),
+ b.SetRawInfoWithVerificationStatus(NAME_FIRST, u"Mitchell",
VerificationStatus::kObserved);
- b.SetRawInfoWithVerificationStatus(NAME_MIDDLE, base::ASCIIToUTF16("Marion"),
+ b.SetRawInfoWithVerificationStatus(NAME_MIDDLE, u"Marion",
VerificationStatus::kObserved);
- b.SetRawInfoWithVerificationStatus(NAME_LAST, base::ASCIIToUTF16("Morrison"),
+ b.SetRawInfoWithVerificationStatus(NAME_LAST, u"Morrison",
VerificationStatus::kObserved);
b.FinalizeAfterImport();
ASSERT_FALSE(b.IsVerified());
@@ -1460,53 +1437,50 @@ TEST_P(AutofillProfileTest, SaveAdditionalInfo_Verified_MergeStructure) {
EXPECT_EQ(a.GetVerificationStatus(NAME_MIDDLE),
VerificationStatus::kObserved);
EXPECT_EQ(a.GetVerificationStatus(NAME_LAST), VerificationStatus::kObserved);
- EXPECT_EQ(a.GetRawInfo(NAME_FULL),
- base::ASCIIToUTF16("Marion Mitchell Morrison"));
- EXPECT_EQ(a.GetRawInfo(NAME_FIRST), base::ASCIIToUTF16("Mitchell"));
- EXPECT_EQ(a.GetRawInfo(NAME_MIDDLE), base::ASCIIToUTF16("Marion"));
- EXPECT_EQ(a.GetRawInfo(NAME_LAST), base::ASCIIToUTF16("Morrison"));
+ EXPECT_EQ(a.GetRawInfo(NAME_FULL), u"Marion Mitchell Morrison");
+ EXPECT_EQ(a.GetRawInfo(NAME_FIRST), u"Mitchell");
+ EXPECT_EQ(a.GetRawInfo(NAME_MIDDLE), u"Marion");
+ EXPECT_EQ(a.GetRawInfo(NAME_LAST), u"Morrison");
}
TEST_P(AutofillProfileTest, SaveAdditionalInfo_Name_AddingNameFull) {
AutofillProfile a;
- a.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("Marion"));
- a.SetRawInfo(NAME_MIDDLE, base::ASCIIToUTF16("Mitchell"));
- a.SetRawInfo(NAME_LAST, base::ASCIIToUTF16("Morrison"));
+ a.SetRawInfo(NAME_FIRST, u"Marion");
+ a.SetRawInfo(NAME_MIDDLE, u"Mitchell");
+ a.SetRawInfo(NAME_LAST, u"Morrison");
a.FinalizeAfterImport();
AutofillProfile b = a;
- b.SetRawInfo(NAME_FULL, base::ASCIIToUTF16("Marion Mitchell Morrison"));
+ b.SetRawInfo(NAME_FULL, u"Marion Mitchell Morrison");
b.FinalizeAfterImport();
EXPECT_TRUE(a.SaveAdditionalInfo(b, "en-US"));
- EXPECT_EQ(base::ASCIIToUTF16("Marion"), a.GetRawInfo(NAME_FIRST));
- EXPECT_EQ(base::ASCIIToUTF16("Mitchell"), a.GetRawInfo(NAME_MIDDLE));
- EXPECT_EQ(base::ASCIIToUTF16("Morrison"), a.GetRawInfo(NAME_LAST));
- EXPECT_EQ(base::ASCIIToUTF16("Marion Mitchell Morrison"),
- a.GetRawInfo(NAME_FULL));
+ EXPECT_EQ(u"Marion", a.GetRawInfo(NAME_FIRST));
+ EXPECT_EQ(u"Mitchell", a.GetRawInfo(NAME_MIDDLE));
+ EXPECT_EQ(u"Morrison", a.GetRawInfo(NAME_LAST));
+ EXPECT_EQ(u"Marion Mitchell Morrison", a.GetRawInfo(NAME_FULL));
}
TEST_P(AutofillProfileTest, SaveAdditionalInfo_Name_KeepNameFull) {
AutofillProfile a;
- a.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("Marion"));
- a.SetRawInfo(NAME_MIDDLE, base::ASCIIToUTF16("Mitchell"));
- a.SetRawInfo(NAME_LAST, base::ASCIIToUTF16("Morrison"));
- a.SetRawInfo(NAME_FULL, base::ASCIIToUTF16("Marion Mitchell Morrison"));
+ a.SetRawInfo(NAME_FIRST, u"Marion");
+ a.SetRawInfo(NAME_MIDDLE, u"Mitchell");
+ a.SetRawInfo(NAME_LAST, u"Morrison");
+ a.SetRawInfo(NAME_FULL, u"Marion Mitchell Morrison");
AutofillProfile b = a;
- b.SetRawInfo(NAME_FULL, base::ASCIIToUTF16(""));
+ b.SetRawInfo(NAME_FULL, u"");
EXPECT_TRUE(a.SaveAdditionalInfo(b, "en-US"));
- EXPECT_EQ(base::ASCIIToUTF16("Marion"), a.GetRawInfo(NAME_FIRST));
- EXPECT_EQ(base::ASCIIToUTF16("Mitchell"), a.GetRawInfo(NAME_MIDDLE));
- EXPECT_EQ(base::ASCIIToUTF16("Morrison"), a.GetRawInfo(NAME_LAST));
- EXPECT_EQ(base::ASCIIToUTF16("Marion Mitchell Morrison"),
- a.GetRawInfo(NAME_FULL));
+ EXPECT_EQ(u"Marion", a.GetRawInfo(NAME_FIRST));
+ EXPECT_EQ(u"Mitchell", a.GetRawInfo(NAME_MIDDLE));
+ EXPECT_EQ(u"Morrison", a.GetRawInfo(NAME_LAST));
+ EXPECT_EQ(u"Marion Mitchell Morrison", a.GetRawInfo(NAME_FULL));
}
// Tests the merging of two similar profiles results in the second profile's
@@ -1515,40 +1489,34 @@ TEST_P(AutofillProfileTest,
SaveAdditionalInfo_Name_DifferentCaseAndDiacriticsNoNameFull) {
AutofillProfile a;
- a.SetRawInfoWithVerificationStatus(NAME_FIRST, base::ASCIIToUTF16("marion"),
- kObserved);
- a.SetRawInfoWithVerificationStatus(NAME_MIDDLE,
- base::ASCIIToUTF16("mitchell"), kObserved);
- a.SetRawInfoWithVerificationStatus(NAME_LAST, base::ASCIIToUTF16("morrison"),
+ a.SetRawInfoWithVerificationStatus(NAME_FIRST, u"marion", kObserved);
+ a.SetRawInfoWithVerificationStatus(NAME_MIDDLE, u"mitchell", kObserved);
+ a.SetRawInfoWithVerificationStatus(NAME_LAST, u"morrison", kObserved);
+ a.SetRawInfoWithVerificationStatus(NAME_FULL, u"marion mitchell morrison",
kObserved);
- a.SetRawInfoWithVerificationStatus(
- NAME_FULL, base::ASCIIToUTF16("marion mitchell morrison"), kObserved);
AutofillProfile b = a;
a.FinalizeAfterImport();
- b.SetRawInfoWithVerificationStatus(NAME_FIRST, UTF8ToUTF16("Märion"),
- kObserved);
- b.SetRawInfoWithVerificationStatus(NAME_MIDDLE, UTF8ToUTF16("Mitchéll"),
- kObserved);
- b.SetRawInfoWithVerificationStatus(NAME_LAST, UTF8ToUTF16("Morrison"),
- kObserved);
- b.SetRawInfoWithVerificationStatus(NAME_FULL, UTF8ToUTF16(""), kObserved);
+ b.SetRawInfoWithVerificationStatus(NAME_FIRST, u"Märion", kObserved);
+ b.SetRawInfoWithVerificationStatus(NAME_MIDDLE, u"Mitchéll", kObserved);
+ b.SetRawInfoWithVerificationStatus(NAME_LAST, u"Morrison", kObserved);
+ b.SetRawInfoWithVerificationStatus(NAME_FULL, u"", kObserved);
b.FinalizeAfterImport();
EXPECT_TRUE(a.SaveAdditionalInfo(b, "en-US"));
// The first, middle and last names should have their first letter in
// uppercase and have acquired diacritics.
- EXPECT_EQ(UTF8ToUTF16("Märion"), a.GetRawInfo(NAME_FIRST));
- EXPECT_EQ(UTF8ToUTF16("Mitchéll"), a.GetRawInfo(NAME_MIDDLE));
- EXPECT_EQ(UTF8ToUTF16("Morrison"), a.GetRawInfo(NAME_LAST));
+ EXPECT_EQ(u"Märion", a.GetRawInfo(NAME_FIRST));
+ EXPECT_EQ(u"Mitchéll", a.GetRawInfo(NAME_MIDDLE));
+ EXPECT_EQ(u"Morrison", a.GetRawInfo(NAME_LAST));
if (!StructuredNames()) {
- EXPECT_EQ(UTF8ToUTF16("Märion Mitchéll Morrison"), a.GetRawInfo(NAME_FULL));
+ EXPECT_EQ(u"Märion Mitchéll Morrison", a.GetRawInfo(NAME_FULL));
} else {
// In the new merging logic the observed lower-case value should remain
// because the upper-case-diacritic version is only formatted.
- EXPECT_EQ(UTF8ToUTF16("marion mitchell morrison"), a.GetRawInfo(NAME_FULL));
+ EXPECT_EQ(u"marion mitchell morrison", a.GetRawInfo(NAME_FULL));
}
}
@@ -1557,18 +1525,18 @@ TEST_P(AutofillProfileTest,
TEST_P(AutofillProfileTest, SaveAdditionalInfo_Name_LossOfInformation) {
AutofillProfile a;
- a.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("Marion"));
- a.SetRawInfo(NAME_MIDDLE, base::ASCIIToUTF16("Mitchell"));
- a.SetRawInfo(NAME_LAST, base::ASCIIToUTF16("Morrison"));
+ a.SetRawInfo(NAME_FIRST, u"Marion");
+ a.SetRawInfo(NAME_MIDDLE, u"Mitchell");
+ a.SetRawInfo(NAME_LAST, u"Morrison");
a.FinalizeAfterImport();
AutofillProfile b = a;
- b.SetRawInfo(NAME_MIDDLE, base::ASCIIToUTF16(""));
+ b.SetRawInfo(NAME_MIDDLE, u"");
EXPECT_TRUE(a.SaveAdditionalInfo(b, "en-US"));
- EXPECT_EQ(base::ASCIIToUTF16("Marion"), a.GetRawInfo(NAME_FIRST));
- EXPECT_EQ(base::ASCIIToUTF16("Mitchell"), a.GetRawInfo(NAME_MIDDLE));
- EXPECT_EQ(base::ASCIIToUTF16("Morrison"), a.GetRawInfo(NAME_LAST));
+ EXPECT_EQ(u"Marion", a.GetRawInfo(NAME_FIRST));
+ EXPECT_EQ(u"Mitchell", a.GetRawInfo(NAME_MIDDLE));
+ EXPECT_EQ(u"Morrison", a.GetRawInfo(NAME_LAST));
}
// Tests that merging two complementary profiles for names results in a profile
@@ -1576,24 +1544,23 @@ TEST_P(AutofillProfileTest, SaveAdditionalInfo_Name_LossOfInformation) {
TEST_P(AutofillProfileTest, SaveAdditionalInfo_Name_ComplementaryInformation) {
AutofillProfile a;
- a.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("Marion"));
- a.SetRawInfo(NAME_MIDDLE, base::ASCIIToUTF16("Mitchell"));
- a.SetRawInfo(NAME_LAST, base::ASCIIToUTF16("Morrison"));
+ a.SetRawInfo(NAME_FIRST, u"Marion");
+ a.SetRawInfo(NAME_MIDDLE, u"Mitchell");
+ a.SetRawInfo(NAME_LAST, u"Morrison");
a.FinalizeAfterImport();
AutofillProfile b;
- b.SetRawInfo(NAME_FULL, base::ASCIIToUTF16("Marion Mitchell Morrison"));
+ b.SetRawInfo(NAME_FULL, u"Marion Mitchell Morrison");
b.FinalizeAfterImport();
EXPECT_TRUE(a.SaveAdditionalInfo(b, "en-US"));
// The first, middle and last names should be kept and name full should be
// added.
- EXPECT_EQ(base::ASCIIToUTF16("Marion"), a.GetRawInfo(NAME_FIRST));
- EXPECT_EQ(base::ASCIIToUTF16("Mitchell"), a.GetRawInfo(NAME_MIDDLE));
- EXPECT_EQ(base::ASCIIToUTF16("Morrison"), a.GetRawInfo(NAME_LAST));
- EXPECT_EQ(base::ASCIIToUTF16("Marion Mitchell Morrison"),
- a.GetRawInfo(NAME_FULL));
+ EXPECT_EQ(u"Marion", a.GetRawInfo(NAME_FIRST));
+ EXPECT_EQ(u"Mitchell", a.GetRawInfo(NAME_MIDDLE));
+ EXPECT_EQ(u"Morrison", a.GetRawInfo(NAME_LAST));
+ EXPECT_EQ(u"Marion Mitchell Morrison", a.GetRawInfo(NAME_FULL));
}
TEST_P(AutofillProfileTest, IsAnInvalidPhoneNumber) {
@@ -2335,10 +2302,10 @@ TEST_P(AutofillProfileTest, EqualsForClientValidationPurpose) {
AutofillProfile profile = test::GetFullProfile();
AutofillProfile profile2(profile);
- profile2.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("different@email.com"));
+ profile2.SetRawInfo(EMAIL_ADDRESS, u"different@email.com");
AutofillProfile profile3(profile);
- profile3.SetRawInfo(NAME_FULL, base::ASCIIToUTF16("Alice Munro"));
+ profile3.SetRawInfo(NAME_FULL, u"Alice Munro");
// For client validation purposes,
// profile2 != profile, because they differ in the email, which is validated
@@ -2378,14 +2345,14 @@ TEST_P(AutofillProfileTest, ShouldSkipFillingOrSuggesting) {
profile.SetValidityState(ADDRESS_HOME_CITY, AutofillProfile::INVALID,
AutofillProfile::CLIENT);
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, base::ASCIIToUTF16(""));
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"");
EXPECT_FALSE(profile.ShouldSkipFillingOrSuggesting(ADDRESS_HOME_CITY));
EXPECT_TRUE(profile.ShouldSkipFillingOrSuggesting(ADDRESS_HOME_STATE));
EXPECT_FALSE(profile.ShouldSkipFillingOrSuggesting(ADDRESS_HOME_COUNTRY));
EXPECT_FALSE(profile.ShouldSkipFillingOrSuggesting(ADDRESS_HOME_LINE1));
EXPECT_TRUE(profile.ShouldSkipFillingOrSuggesting(EMAIL_ADDRESS));
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, base::ASCIIToUTF16("CA"));
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"CA");
EXPECT_TRUE(profile.ShouldSkipFillingOrSuggesting(ADDRESS_HOME_CITY));
EXPECT_TRUE(profile.ShouldSkipFillingOrSuggesting(ADDRESS_HOME_STATE));
EXPECT_FALSE(profile.ShouldSkipFillingOrSuggesting(ADDRESS_HOME_COUNTRY));
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_structured_address.cc b/chromium/components/autofill/core/browser/data_model/autofill_structured_address.cc
index 80aabc5ac36..863e605ce3a 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_structured_address.cc
+++ b/chromium/components/autofill/core/browser/data_model/autofill_structured_address.cc
@@ -21,17 +21,16 @@ namespace autofill {
namespace structured_address {
-base::string16 AddressComponentWithRewriter::RewriteValue(
- const base::string16& value) const {
+std::u16string AddressComponentWithRewriter::RewriteValue(
+ const std::u16string& value) const {
// Retrieve the country name from the structured tree the node resides in.
- base::string16 country = GetRootNode().GetValueForType(ADDRESS_HOME_COUNTRY);
+ std::u16string country = GetRootNode().GetValueForType(ADDRESS_HOME_COUNTRY);
// If no country is available (this should not be the case for a valid
// importable profile), use the US as a fallback country for the rewriter.
- return RewriterCache::Rewrite(
- !country.empty() ? country : base::ASCIIToUTF16("US"), value);
+ return RewriterCache::Rewrite(!country.empty() ? country : u"US", value);
}
-base::string16 AddressComponentWithRewriter::ValueForComparison() const {
+std::u16string AddressComponentWithRewriter::ValueForComparison() const {
return RewriteValue(NormalizedValue());
}
@@ -137,8 +136,8 @@ bool StreetAddress::HasNewerValuePrecendenceInMerging(
// If the verification statuses are the same, do not use the newer component
// if the older one has new lines but the newer one doesn't.
if (GetVerificationStatus() == newer_component.GetVerificationStatus()) {
- if (GetValue().find('\n') != base::string16::npos &&
- newer_component.GetValue().find('\n') == base::string16::npos) {
+ if (GetValue().find('\n') != std::u16string::npos &&
+ newer_component.GetValue().find('\n') == std::u16string::npos) {
return false;
}
return true;
@@ -146,7 +145,7 @@ bool StreetAddress::HasNewerValuePrecendenceInMerging(
return false;
}
-base::string16 StreetAddress::GetBestFormatString() const {
+std::u16string StreetAddress::GetBestFormatString() const {
std::string country_code =
base::UTF16ToUTF8(GetRootNode().GetValueForType(ADDRESS_HOME_COUNTRY));
@@ -183,24 +182,23 @@ void StreetAddress::UnsetValue() {
address_lines_.clear();
}
-void StreetAddress::SetValue(base::string16 value, VerificationStatus status) {
+void StreetAddress::SetValue(std::u16string value, VerificationStatus status) {
AddressComponent::SetValue(value, status);
CalculateAddressLines();
}
void StreetAddress::CalculateAddressLines() {
// Recalculate |address_lines_| after changing the street address.
- address_lines_ =
- base::SplitString(GetValue(), base::ASCIIToUTF16("\n"),
- base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
+ address_lines_ = base::SplitString(GetValue(), u"\n", base::TRIM_WHITESPACE,
+ base::SPLIT_WANT_ALL);
// If splitting of the address line results in more than 3 entries, join the
// additional entries into the third line.
if (address_lines_.size() > 3) {
address_lines_[2] =
- base::JoinString(std::vector<base::string16>(address_lines_.begin() + 2,
+ base::JoinString(std::vector<std::u16string>(address_lines_.begin() + 2,
address_lines_.end()),
- base::ASCIIToUTF16(" "));
+ u" ");
// Drop the addition address lines.
while (address_lines_.size() > 3)
address_lines_.pop_back();
@@ -208,30 +206,30 @@ void StreetAddress::CalculateAddressLines() {
}
bool StreetAddress::IsValueValid() const {
- return !base::Contains(address_lines_, base::string16());
+ return !base::Contains(address_lines_, std::u16string());
}
bool StreetAddress::ConvertAndGetTheValueForAdditionalFieldTypeName(
const std::string& type_name,
- base::string16* value) const {
+ std::u16string* value) const {
if (type_name == AutofillType::ServerFieldTypeToString(ADDRESS_HOME_LINE1)) {
if (value) {
*value =
- address_lines_.size() > 0 ? address_lines_.at(0) : base::string16();
+ address_lines_.size() > 0 ? address_lines_.at(0) : std::u16string();
}
return true;
}
if (type_name == AutofillType::ServerFieldTypeToString(ADDRESS_HOME_LINE2)) {
if (value) {
*value =
- address_lines_.size() > 1 ? address_lines_.at(1) : base::string16();
+ address_lines_.size() > 1 ? address_lines_.at(1) : std::u16string();
}
return true;
}
if (type_name == AutofillType::ServerFieldTypeToString(ADDRESS_HOME_LINE3)) {
if (value) {
*value =
- address_lines_.size() > 2 ? address_lines_.at(2) : base::string16();
+ address_lines_.size() > 2 ? address_lines_.at(2) : std::u16string();
}
return true;
}
@@ -242,7 +240,7 @@ bool StreetAddress::ConvertAndGetTheValueForAdditionalFieldTypeName(
// Implements support for setting the value of the individual address lines.
bool StreetAddress::ConvertAndSetValueForAdditionalFieldTypeName(
const std::string& type_name,
- const base::string16& value,
+ const std::u16string& value,
const VerificationStatus& status) {
size_t index = 0;
if (type_name == AutofillType::ServerFieldTypeToString(ADDRESS_HOME_LINE1)) {
@@ -259,7 +257,7 @@ bool StreetAddress::ConvertAndSetValueForAdditionalFieldTypeName(
// Make sure that there are three address lines stored.
if (index >= address_lines_.size())
- address_lines_.resize(index + 1, base::string16());
+ address_lines_.resize(index + 1, std::u16string());
bool change = address_lines_[index] != value;
if (change)
@@ -271,8 +269,7 @@ bool StreetAddress::ConvertAndSetValueForAdditionalFieldTypeName(
// By calling the base class implementation, the recreation of the address
// lines from the street address is omitted.
if (change) {
- AddressComponent::SetValue(
- base::JoinString(address_lines_, base::ASCIIToUTF16("\n")), status);
+ AddressComponent::SetValue(base::JoinString(address_lines_, u"\n"), status);
}
return true;
@@ -337,7 +334,7 @@ PostalCode::PostalCode(AddressComponent* parent)
PostalCode::~PostalCode() = default;
-base::string16 PostalCode::NormalizedValue() const {
+std::u16string PostalCode::NormalizedValue() const {
return NormalizeValue(GetValue(), /*keep_white_space=*/false);
}
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_structured_address.h b/chromium/components/autofill/core/browser/data_model/autofill_structured_address.h
index 87ac1fdc8e8..3b8fd509e57 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_structured_address.h
+++ b/chromium/components/autofill/core/browser/data_model/autofill_structured_address.h
@@ -23,13 +23,13 @@ class AddressComponentWithRewriter : public AddressComponent {
protected:
// Apply a country-specific rewriter to the normalized value.
- base::string16 ValueForComparison() const override;
+ std::u16string ValueForComparison() const override;
// Tries to retrieve the |ADDRESS_HOME_COUNTRY| node from the structure tree
// to apply a country-specific rewriter to the normalized value.
// If the country value cannot be retrieved or is empty, the method returns
// the normalized values without further processing.
- base::string16 RewriteValue(const base::string16&) const;
+ std::u16string RewriteValue(const std::u16string&) const;
};
// The name of the street.
@@ -110,7 +110,7 @@ class StreetAddress : public AddressComponentWithRewriter {
void GetAdditionalSupportedFieldTypes(
ServerFieldTypeSet* supported_types) const override;
- void SetValue(base::string16 value, VerificationStatus status) override;
+ void SetValue(std::u16string value, VerificationStatus status) override;
void UnsetValue() override;
@@ -125,7 +125,7 @@ class StreetAddress : public AddressComponentWithRewriter {
const override;
// Returns the format string to create the full name from its subcomponents.
- base::string16 GetBestFormatString() const override;
+ std::u16string GetBestFormatString() const override;
// Recalculates the address line after an assignment.
void PostAssignSanitization() override;
@@ -137,12 +137,12 @@ class StreetAddress : public AddressComponentWithRewriter {
// Implements support for getting the value of the individual address lines.
bool ConvertAndGetTheValueForAdditionalFieldTypeName(
const std::string& type_name,
- base::string16* value) const override;
+ std::u16string* value) const override;
// Implements support for setting the value of the individual address lines.
bool ConvertAndSetValueForAdditionalFieldTypeName(
const std::string& type_name,
- const base::string16& value,
+ const std::u16string& value,
const VerificationStatus& status) override;
// Returns true of the address lines do not contain an empty line.
@@ -159,7 +159,7 @@ class StreetAddress : public AddressComponentWithRewriter {
// Holds the values of the individual address lines.
// Must be recalculated if the value of the component changes.
- std::vector<base::string16> address_lines_;
+ std::vector<std::u16string> address_lines_;
};
// Stores the country code of an address profile.
@@ -203,7 +203,7 @@ class PostalCode : public AddressComponentWithRewriter {
protected:
// In contrast to the base class, the normalization removes all white spaces
// from the value.
- base::string16 NormalizedValue() const override;
+ std::u16string NormalizedValue() const override;
};
// Stores the sorting code.
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_component.cc b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_component.cc
index a2a1c831c31..d7389ded48a 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_component.cc
+++ b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_component.cc
@@ -12,7 +12,6 @@
#include "base/feature_list.h"
#include "base/notreached.h"
#include "base/strings/strcat.h"
-#include "base/strings/string16.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -196,7 +195,7 @@ VerificationStatus AddressComponent::GetVerificationStatus() const {
return value_verification_status_;
}
-const base::string16& AddressComponent::GetValue() const {
+const std::u16string& AddressComponent::GetValue() const {
if (value_.has_value())
return value_.value();
return base::EmptyString16();
@@ -206,7 +205,7 @@ bool AddressComponent::IsValueAssigned() const {
return value_.has_value();
}
-void AddressComponent::SetValue(base::string16 value,
+void AddressComponent::SetValue(std::u16string value,
VerificationStatus status) {
value_ = std::move(value);
value_verification_status_ = status;
@@ -234,18 +233,18 @@ void AddressComponent::GetSupportedTypes(
bool AddressComponent::ConvertAndSetValueForAdditionalFieldTypeName(
const std::string& field_type_name,
- const base::string16& value,
+ const std::u16string& value,
const VerificationStatus& status) {
return false;
}
bool AddressComponent::ConvertAndGetTheValueForAdditionalFieldTypeName(
const std::string& field_type_name,
- base::string16* value) const {
+ std::u16string* value) const {
return false;
}
-base::string16 AddressComponent::GetBestFormatString() const {
+std::u16string AddressComponent::GetBestFormatString() const {
// If the component is atomic, the format string is just the value.
if (IsAtomic())
return base::ASCIIToUTF16(GetPlaceholderToken(GetStorageTypeName()));
@@ -272,7 +271,7 @@ std::vector<ServerFieldType> AddressComponent::GetSubcomponentTypes() const {
bool AddressComponent::SetValueForTypeIfPossible(
const ServerFieldType& type,
- const base::string16& value,
+ const std::u16string& value,
const VerificationStatus& verification_status,
bool invalidate_child_nodes,
bool invalidate_parent_nodes) {
@@ -294,7 +293,7 @@ bool AddressComponent::SetValueForTypeIfPossible(
bool AddressComponent::SetValueForTypeIfPossible(
const std::string& type_name,
- const base::string16& value,
+ const std::u16string& value,
const VerificationStatus& verification_status,
bool invalidate_child_nodes,
bool invalidate_parent_nodes) {
@@ -353,7 +352,7 @@ void AddressComponent::UnsetSubcomponents() {
bool AddressComponent::GetValueAndStatusForTypeIfPossible(
const ServerFieldType& type,
- base::string16* value,
+ std::u16string* value,
VerificationStatus* status) const {
return GetValueAndStatusForTypeIfPossible(
AutofillType::ServerFieldTypeToString(type), value, status);
@@ -361,12 +360,12 @@ bool AddressComponent::GetValueAndStatusForTypeIfPossible(
bool AddressComponent::GetValueAndStatusForTypeIfPossible(
const std::string& type_name,
- base::string16* value,
+ std::u16string* value,
VerificationStatus* status) const {
// If the value is the storage type, it can be simply returned.
if (type_name == GetStorageTypeName()) {
if (value)
- *value = value_.value_or(base::string16());
+ *value = value_.value_or(std::u16string());
if (status)
*status = GetVerificationStatus();
return true;
@@ -388,14 +387,14 @@ bool AddressComponent::GetValueAndStatusForTypeIfPossible(
return false;
}
-base::string16 AddressComponent::GetValueForType(
+std::u16string AddressComponent::GetValueForType(
const ServerFieldType& type) const {
return GetValueForType(AutofillType::ServerFieldTypeToString(type));
}
-base::string16 AddressComponent::GetValueForType(
+std::u16string AddressComponent::GetValueForType(
const std::string& type_name) const {
- base::string16 value;
+ std::u16string value;
bool success = GetValueAndStatusForTypeIfPossible(type_name, &value, nullptr);
DCHECK(success) << type_name;
return value;
@@ -444,7 +443,7 @@ void AddressComponent::ParseValueAndAssignSubcomponents() {
// Set the values of all subcomponents to the empty string and set the
// verification status to kParsed.
for (auto* subcomponent : subcomponents_)
- subcomponent->SetValue(base::string16(), VerificationStatus::kParsed);
+ subcomponent->SetValue(std::u16string(), VerificationStatus::kParsed);
// First attempt, try to parse by method.
if (ParseValueAndAssignSubcomponentsByMethod())
@@ -470,7 +469,7 @@ bool AddressComponent::ParseValueAndAssignSubcomponentsByRegularExpressions() {
}
bool AddressComponent::ParseValueAndAssignSubcomponentsByRegularExpression(
- const base::string16& value,
+ const std::u16string& value,
const RE2* parse_expression) {
std::map<std::string, std::string> result_map;
if (ParseValueByRegularExpression(base::UTF16ToUTF8(value), parse_expression,
@@ -479,7 +478,7 @@ bool AddressComponent::ParseValueAndAssignSubcomponentsByRegularExpression(
// to the structure.
for (const auto& result_entry : result_map) {
const std::string& field_type = result_entry.first;
- base::string16 field_value = base::UTF8ToUTF16(result_entry.second);
+ std::u16string field_value = base::UTF8ToUTF16(result_entry.second);
// Do not reassign the value of this node.
if (field_type == GetStorageTypeName()) {
continue;
@@ -505,9 +504,8 @@ void AddressComponent::ParseValueAndAssignSubcomponentsByFallbackMethod() {
return;
// Split the string by spaces.
- std::vector<base::string16> space_separated_tokens =
- base::SplitString(GetValue(), base::UTF8ToUTF16(" "),
- base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
+ std::vector<std::u16string> space_separated_tokens = base::SplitString(
+ GetValue(), u" ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
auto token_iterator = space_separated_tokens.begin();
auto subcomponent_types = GetSubcomponentTypes();
@@ -526,9 +524,9 @@ void AddressComponent::ParseValueAndAssignSubcomponentsByFallbackMethod() {
}
// Collect all remaining tokens in the last subcomponent.
- base::string16 remaining_tokens = base::JoinString(
- std::vector<base::string16>(token_iterator, space_separated_tokens.end()),
- base::ASCIIToUTF16(" "));
+ std::u16string remaining_tokens = base::JoinString(
+ std::vector<std::u16string>(token_iterator, space_separated_tokens.end()),
+ u" ");
// By design, it should be possible to assign the value unless the regular
// expression is wrong.
bool success = SetValueForTypeIfPossible(
@@ -552,7 +550,7 @@ bool AddressComponent::IsStructureValid() const {
// information in the components is contained in the unstructured
// representation.
return base::ranges::all_of(Subcomponents(), [this](const auto* c) {
- return GetValue().find(c->GetValue()) != base::string16::npos;
+ return GetValue().find(c->GetValue()) != std::u16string::npos;
});
}
@@ -564,9 +562,9 @@ bool AddressComponent::WipeInvalidStructure() {
return false;
}
-base::string16 AddressComponent::GetFormattedValueFromSubcomponents() {
+std::u16string AddressComponent::GetFormattedValueFromSubcomponents() {
// Get the most suited format string.
- base::string16 format_string = GetBestFormatString();
+ std::u16string format_string = GetBestFormatString();
// Perform the following steps on a copy of the format string.
// * Replace all the placeholders of the form ${TYPE_NAME} with the
@@ -574,7 +572,7 @@ base::string16 AddressComponent::GetFormattedValueFromSubcomponents() {
// * Strip away double spaces as they may occur after replacing a placeholder
// with an empty value.
- base::string16 result = ReplacePlaceholderTypesWithValues(format_string);
+ std::u16string result = ReplacePlaceholderTypesWithValues(format_string);
return base::CollapseWhitespace(result,
/*trim_sequences_with_line_breaks=*/false);
}
@@ -584,8 +582,8 @@ void AddressComponent::FormatValueFromSubcomponents() {
VerificationStatus::kFormatted);
}
-base::string16 AddressComponent::ReplacePlaceholderTypesWithValues(
- const base::string16& format) const {
+std::u16string AddressComponent::ReplacePlaceholderTypesWithValues(
+ const std::u16string& format) const {
// Replaces placeholders using the following rules.
// Assumptions: Placeholder values are not nested.
//
@@ -601,15 +599,11 @@ base::string16 AddressComponent::ReplacePlaceholderTypesWithValues(
//
// * If the corresponding value is empty, return false.
- auto control_parmater = base::ASCIIToUTF16("$").at(0);
- auto control_parmater_open_delimitor = base::ASCIIToUTF16("{").at(0);
- auto control_parmater_close_delimitor = base::ASCIIToUTF16("}").at(0);
-
// Create a result vector for the tokens that are joined in the end.
std::vector<base::StringPiece16> result_pieces;
// Store the token pieces that are joined in the end.
- std::vector<base::string16> inserted_values;
+ std::vector<std::u16string> inserted_values;
inserted_values.reserve(20);
// Use a StringPiece rather than the string since this allows for getting
@@ -622,8 +616,8 @@ base::string16 AddressComponent::ReplacePlaceholderTypesWithValues(
for (size_t i = 0; i < format_piece.size(); ++i) {
// Check if a control sequence is started by '${'
- if (format_piece[i] == control_parmater && i < format_piece.size() - 1 &&
- format_piece[i + 1] == control_parmater_open_delimitor) {
+ if (format_piece[i] == u'$' && i < format_piece.size() - 1 &&
+ format_piece[i + 1] == u'{') {
// A control sequence is started.
started_control_sequence = true;
// Append the preceding string since it can't be a valid placeholder.
@@ -633,31 +627,29 @@ base::string16 AddressComponent::ReplacePlaceholderTypesWithValues(
}
processed_until_index = i;
++i;
- } else if (started_control_sequence &&
- format_piece[i] == control_parmater_close_delimitor) {
+ } else if (started_control_sequence && format_piece[i] == u'}') {
// The control sequence came to an end.
started_control_sequence = false;
size_t placeholder_start = processed_until_index + 2;
- base::string16 placeholder(
+ std::u16string placeholder(
format_piece.substr(placeholder_start, i - placeholder_start));
- std::vector<base::string16> placeholder_tokens =
- base::SplitString(placeholder, base::ASCIIToUTF16(";"),
- base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
+ std::vector<std::u16string> placeholder_tokens = base::SplitString(
+ placeholder, u";", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
DCHECK(placeholder_tokens.size() > 0);
// By convention, the first token is the type of the placeholder.
- base::string16 type_name = placeholder_tokens.at(0);
+ std::u16string type_name = placeholder_tokens.at(0);
// If present, the second token is the prefix.
- base::string16 prefix = placeholder_tokens.size() > 1
+ std::u16string prefix = placeholder_tokens.size() > 1
? placeholder_tokens.at(1)
- : base::string16();
+ : std::u16string();
// And the third token the suffix.
- base::string16 suffix = placeholder_tokens.size() > 2
+ std::u16string suffix = placeholder_tokens.size() > 2
? placeholder_tokens.at(2)
- : base::string16();
+ : std::u16string();
- base::string16 value;
+ std::u16string value;
if (GetValueAndStatusForTypeIfPossible(base::UTF16ToASCII(type_name),
&value, nullptr)) {
// The type is valid and should be substituted.
@@ -683,10 +675,10 @@ base::string16 AddressComponent::ReplacePlaceholderTypesWithValues(
}
// Append the rest of the string.
inserted_values.emplace_back(
- format_piece.substr(processed_until_index, base::string16::npos));
+ format_piece.substr(processed_until_index, std::u16string::npos));
// Build the final result.
- return base::JoinString(inserted_values, base::ASCIIToUTF16(""));
+ return base::JoinString(inserted_values, u"");
}
bool AddressComponent::CompleteFullTree() {
@@ -801,8 +793,8 @@ const std::vector<AddressToken> AddressComponent::GetSortedTokens() const {
bool AddressComponent::IsMergeableWithComponent(
const AddressComponent& newer_component) const {
- const base::string16 value = ValueForComparison();
- const base::string16 value_newer = newer_component.ValueForComparison();
+ const std::u16string value = ValueForComparison();
+ const std::u16string value_newer = newer_component.ValueForComparison();
// If both components are the same, there is nothing to do.
if (SameAs(newer_component))
@@ -852,8 +844,8 @@ bool AddressComponent::IsMergeableWithComponent(
// If the one value is a substring of the other, use the substring of the
// corresponding mode is active.
if ((merge_mode_ & kUseMostRecentSubstring) &&
- (value.find(value_newer) != base::string16::npos ||
- value_newer.find(value) != base::string16::npos)) {
+ (value.find(value_newer) != std::u16string::npos ||
+ value_newer.find(value) != std::u16string::npos)) {
return true;
}
@@ -884,8 +876,8 @@ bool AddressComponent::MergeWithComponent(
bool newer_was_more_recently_used) {
// If both components are the same, there is nothing to do.
- const base::string16 value = ValueForComparison();
- const base::string16 value_newer = newer_component.ValueForComparison();
+ const std::u16string value = ValueForComparison();
+ const std::u16string value_newer = newer_component.ValueForComparison();
if (SameAs(newer_component))
return true;
@@ -978,8 +970,8 @@ bool AddressComponent::MergeWithComponent(
// If the one value is a substring of the other, use the substring of the
// corresponding mode is active.
if ((merge_mode_ & kUseMostRecentSubstring) &&
- (value.find(value_newer) != base::string16::npos ||
- value_newer.find(value) != base::string16::npos)) {
+ (value.find(value_newer) != std::u16string::npos ||
+ value_newer.find(value) != std::u16string::npos)) {
if (newer_was_more_recently_used &&
!IsLessSignificantVerificationStatus(
newer_component.GetVerificationStatus(), GetVerificationStatus()))
@@ -1025,7 +1017,7 @@ bool AddressComponent::MergeWithComponent(
}
} else {
// Otherwise do a reformat from the subcomponents.
- base::string16 formatted_value = GetFormattedValueFromSubcomponents();
+ std::u16string formatted_value = GetFormattedValueFromSubcomponents();
// If the current value is maintained, keep the more significant
// verification status.
if (formatted_value == GetValue()) {
@@ -1163,12 +1155,12 @@ bool AddressComponent::MergeTokenEquivalentComponent(
}
void AddressComponent::ConsumeAdditionalToken(
- const base::string16& token_value) {
+ const std::u16string& token_value) {
if (IsAtomic()) {
if (GetValue().empty()) {
SetValue(token_value, VerificationStatus::kParsed);
} else {
- SetValue(base::StrCat({GetValue(), base::ASCIIToUTF16(" "), token_value}),
+ SetValue(base::StrCat({GetValue(), u" ", token_value}),
VerificationStatus::kParsed);
}
return;
@@ -1183,9 +1175,8 @@ void AddressComponent::ConsumeAdditionalToken(
}
// Otherwise append the value to the first component.
- subcomponents_[0]->SetValue(
- base::StrCat({GetValue(), base::ASCIIToUTF16(" "), token_value}),
- VerificationStatus::kParsed);
+ subcomponents_[0]->SetValue(base::StrCat({GetValue(), u" ", token_value}),
+ VerificationStatus::kParsed);
}
bool AddressComponent::MergeSubsetComponent(
@@ -1194,7 +1185,7 @@ bool AddressComponent::MergeSubsetComponent(
DCHECK(token_comparison_result.IsSingleTokenSuperset());
DCHECK(token_comparison_result.additional_tokens.size() == 1);
- base::string16 token_to_consume =
+ std::u16string token_to_consume =
token_comparison_result.additional_tokens.back().value;
int this_component_verification_score = 0;
@@ -1216,7 +1207,7 @@ bool AddressComponent::MergeSubsetComponent(
AddressComponent* subcomponent = subcomponents_[i];
const AddressComponent* subset_subcomponent = subset_subcomponents.at(i);
- base::string16 additional_token;
+ std::u16string additional_token;
// If the additional token is the value of this token. Just leave it in.
if (!found_subset_component &&
@@ -1292,11 +1283,11 @@ int AddressComponent::GetStructureVerificationScore() const {
return result;
}
-base::string16 AddressComponent::NormalizedValue() const {
+std::u16string AddressComponent::NormalizedValue() const {
return NormalizeValue(GetValue());
}
-base::string16 AddressComponent::ValueForComparison() const {
+std::u16string AddressComponent::ValueForComparison() const {
return NormalizedValue();
}
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_component.h b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_component.h
index 8b7f5345471..f1e1f256088 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_component.h
+++ b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_component.h
@@ -177,13 +177,13 @@ class AddressComponent {
// Returns a constant reference to |value_.value()|. If the value is not
// assigned, an empty string is returned.
- const base::string16& GetValue() const;
+ const std::u16string& GetValue() const;
// Returns true if the value of this AddressComponent is assigned.
bool IsValueAssigned() const;
// Sets the value corresponding to the storage type of this AddressComponent.
- virtual void SetValue(base::string16 value, VerificationStatus status);
+ virtual void SetValue(std::u16string value, VerificationStatus status);
// Sets the value to an empty string, marks it unassigned and sets the
// verification status to |kNoStatus|.
@@ -199,7 +199,7 @@ class AddressComponent {
// unassigned. If |invalidate_parent_nodes|, all ancestor nodes of the
// assigned node as unassigned.
bool SetValueForTypeIfPossible(const ServerFieldType& type,
- const base::string16& value,
+ const std::u16string& value,
const VerificationStatus& verification_status,
bool invalidate_child_nodes = false,
bool invalidate_parent_nodes = false);
@@ -207,7 +207,7 @@ class AddressComponent {
// Same as |SetValueForTypeIfPossible()| but the type is supplied in the
// corresponding string representation.
bool SetValueForTypeIfPossible(const std::string& type_name,
- const base::string16& value,
+ const std::u16string& value,
const VerificationStatus& verification_status,
bool invalidate_child_nodes = false,
bool invalidate_parent_nodes = false);
@@ -228,11 +228,11 @@ class AddressComponent {
// Convenience method to get the value of |type|.
// Returns an empty string if |type| is not supported.
- base::string16 GetValueForType(const ServerFieldType& type) const;
+ std::u16string GetValueForType(const ServerFieldType& type) const;
// Convenience method to get the value of |type| identified by its string
// representation name. Returns an empty string if |type| is not supported.
- base::string16 GetValueForType(const std::string& type) const;
+ std::u16string GetValueForType(const std::string& type) const;
// Convenience method to get the verification status of |type|.
// Returns |VerificationStatus::kNoStatus| if |type| is not supported.
@@ -254,13 +254,13 @@ class AddressComponent {
// children. Returns false if the neither the node or one of its ancestors
// supports |type|.
bool GetValueAndStatusForTypeIfPossible(const ServerFieldType& type,
- base::string16* value,
+ std::u16string* value,
VerificationStatus* status) const;
// Get the value and status of a |type| identified by its name.
// Returns false if the |type| is not supported by the structure.
bool GetValueAndStatusForTypeIfPossible(const std::string& type_name,
- base::string16* value,
+ std::u16string* value,
VerificationStatus* status) const;
// Returns true if the |value| and |verification_status| were successfully
@@ -384,7 +384,7 @@ class AddressComponent {
}
// Returns the best format string for testing.
- base::string16 GetBestFormatStringForTesting() {
+ std::u16string GetBestFormatStringForTesting() {
return GetBestFormatString();
}
@@ -399,7 +399,7 @@ class AddressComponent {
// Replaces placeholder values in the best format string with the
// corresponding values.
- base::string16 GetReplacedPlaceholderTypesWithValuesForTesting() const {
+ std::u16string GetReplacedPlaceholderTypesWithValuesForTesting() const {
return ReplacePlaceholderTypesWithValues(GetBestFormatString());
}
@@ -413,7 +413,7 @@ class AddressComponent {
void SetMergeModeForTesting(int merge_mode) { merge_mode_ = merge_mode; }
// Returns the value used for comparison for testing purposes.
- base::string16 ValueForComparisonForTesting() const {
+ std::u16string ValueForComparisonForTesting() const {
return ValueForComparison();
}
#endif
@@ -429,7 +429,7 @@ class AddressComponent {
// Heuristic method to get the best suited format string.
// This method is virtual and can be reimplemented for each type.
- virtual base::string16 GetBestFormatString() const;
+ virtual std::u16string GetBestFormatString() const;
// Returns pointers to regular expressions sorted by their relevance.
// This method is virtual and can be reimplemented for each type.
@@ -452,7 +452,7 @@ class AddressComponent {
// It returns true if conversion logic exists and the type can be set.
virtual bool ConvertAndSetValueForAdditionalFieldTypeName(
const std::string& field_type_name,
- const base::string16& value,
+ const std::u16string& value,
const VerificationStatus& status);
// This method is used to retrieve the value for a supported field type
@@ -462,7 +462,7 @@ class AddressComponent {
// The method must handle |nullptr|s for both the value and status.
virtual bool ConvertAndGetTheValueForAdditionalFieldTypeName(
const std::string& field_type_name,
- base::string16* value) const;
+ std::u16string* value) const;
// Clears all parsed and formatted values.
void ClearAllParsedAndFormattedValues();
@@ -476,7 +476,7 @@ class AddressComponent {
// Can be implemented by the specific node types.
// The fall-back solution uses the first empty node.
// If no empty node is available, it appends the value to the first node.
- virtual void ConsumeAdditionalToken(const base::string16& token_value);
+ virtual void ConsumeAdditionalToken(const std::u16string& token_value);
// Returns a reference to the root node of the tree.
AddressComponent& GetRootNode();
@@ -495,13 +495,13 @@ class AddressComponent {
// In the default implementation, this converts the value to lower case and
// removes white spaces. This function may be reimplemented to perform
// different normalization operations.
- virtual base::string16 NormalizedValue() const;
+ virtual std::u16string NormalizedValue() const;
// Returns a value used for comparison.
// In the default implementation this is just the normalized value but this
// function can be overridden in subclasses to apply further operations on
// the normalized value.
- virtual base::string16 ValueForComparison() const;
+ virtual std::u16string ValueForComparison() const;
// Returns true if the merging of two token identical values should give
// precedence to the newer value. By default, the newer component gets
@@ -512,7 +512,7 @@ class AddressComponent {
// Parses |value| by using |parse_expressions| and assigns the values.
// Returns true on success.
bool ParseValueAndAssignSubcomponentsByRegularExpression(
- const base::string16& value,
+ const std::u16string& value,
const re2::RE2* parse_expression);
// Determines and sets a formatted value using
@@ -536,15 +536,15 @@ class AddressComponent {
// Determines a value from the subcomponents by using the
// most suitable format string determined by |GetBestFormatString()|.
- base::string16 GetFormattedValueFromSubcomponents();
+ std::u16string GetFormattedValueFromSubcomponents();
// Replaces placeholder values with the corresponding values.
- base::string16 ReplacePlaceholderTypesWithValues(
- const base::string16& format) const;
+ std::u16string ReplacePlaceholderTypesWithValues(
+ const std::u16string& format) const;
// Replaces placeholder values with the corresponding values.
- base::string16 ReplacePlaceholderTypesWithValuesRegexVersion(
- const base::string16& format) const;
+ std::u16string ReplacePlaceholderTypesWithValuesRegexVersion(
+ const std::u16string& format) const;
// This method uses regular expressions acquired by
// |GetParseRegularExpressionsByRelevance| to parse |value_| into the values
@@ -552,7 +552,7 @@ class AddressComponent {
bool ParseValueAndAssignSubcomponentsByRegularExpressions();
// The unstructured value of this component.
- base::Optional<base::string16> value_;
+ base::Optional<std::u16string> value_;
// The verification status of |value_| indicates the certainty of the value
// to be correct.
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_component_unittest.cc b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_component_unittest.cc
index 029c510ea41..ec0fbf78877 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_component_unittest.cc
+++ b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_component_unittest.cc
@@ -49,7 +49,7 @@ class TestAtomicMiddleNameAddressComponent : public AddressComponent {
bool ConvertAndSetValueForAdditionalFieldTypeName(
const std::string& field_type_name,
- const base::string16& value,
+ const std::u16string& value,
const VerificationStatus& status) override {
if (field_type_name ==
AutofillType::ServerFieldTypeToString(NAME_MIDDLE_INITIAL)) {
@@ -61,7 +61,7 @@ class TestAtomicMiddleNameAddressComponent : public AddressComponent {
bool ConvertAndGetTheValueForAdditionalFieldTypeName(
const std::string& field_type_name,
- base::string16* value) const override {
+ std::u16string* value) const override {
if (field_type_name ==
AutofillType::ServerFieldTypeToString(NAME_MIDDLE_INITIAL)) {
if (value) {
@@ -166,8 +166,8 @@ class TestCompoundNameCustomFormatAddressComponent : public AddressComponent {
MergeMode::kDefault) {}
// Introduces a custom format with a leading last name.
- base::string16 GetBestFormatString() const override {
- return ASCIIToUTF16("${NAME_LAST}, ${NAME_FIRST}");
+ std::u16string GetBestFormatString() const override {
+ return u"${NAME_LAST}, ${NAME_FIRST}";
}
private:
@@ -189,8 +189,8 @@ class TestCompoundNameCustomAffixedFormatAddressComponent
MergeMode::kDefault) {}
// Introduces a custom format with a leading last name.
- base::string16 GetBestFormatString() const override {
- return ASCIIToUTF16("${NAME_LAST;Dr. ; MD}, ${NAME_FIRST}");
+ std::u16string GetBestFormatString() const override {
+ return u"${NAME_LAST;Dr. ; MD}, ${NAME_FIRST}";
}
private:
@@ -213,8 +213,8 @@ class TestCompoundNameCustomFormatWithUnsupportedTokenAddressComponent
MergeMode::kDefault) {}
// Introduce a custom format with a leading last name.
- base::string16 GetBestFormatString() const override {
- return ASCIIToUTF16("${NAME_LAST}, ${NAME_FIRST} ${NOT_SUPPORTED}");
+ std::u16string GetBestFormatString() const override {
+ return u"${NAME_LAST}, ${NAME_FIRST} ${NOT_SUPPORTED}";
}
private:
@@ -354,19 +354,18 @@ TEST(AutofillStructuredAddressAddressComponent, TestGetSupportedFieldType) {
TEST(AutofillStructuredAddressAddressComponent, TestSetFieldTypeValue) {
TestCompoundNameAddressComponent compound_name;
EXPECT_TRUE(compound_name.SetValueForTypeIfPossible(
- NAME_MIDDLE_INITIAL, UTF8ToUTF16("M"), VerificationStatus::kObserved));
+ NAME_MIDDLE_INITIAL, u"M", VerificationStatus::kObserved));
- EXPECT_EQ(compound_name.GetValueForType(NAME_MIDDLE), UTF8ToUTF16("M"));
+ EXPECT_EQ(compound_name.GetValueForType(NAME_MIDDLE), u"M");
}
// Tests retrieving an additional field type.
TEST(AutofillStructuredAddressAddressComponent, TestGetFieldTypeValue) {
TestCompoundNameAddressComponent compound_name;
EXPECT_TRUE(compound_name.SetValueForTypeIfPossible(
- NAME_MIDDLE, UTF8ToUTF16("Middle"), VerificationStatus::kObserved));
+ NAME_MIDDLE, u"Middle", VerificationStatus::kObserved));
- EXPECT_EQ(compound_name.GetValueForType(NAME_MIDDLE_INITIAL),
- UTF8ToUTF16("M"));
+ EXPECT_EQ(compound_name.GetValueForType(NAME_MIDDLE_INITIAL), u"M");
EXPECT_EQ(compound_name.GetVerificationStatusForType(NAME_MIDDLE_INITIAL),
VerificationStatus::kObserved);
}
@@ -402,15 +401,14 @@ TEST(AutofillStructuredAddressAddressComponent, TestComparison_Atom) {
AddressComponent left(NAME_FIRST, nullptr, MergeMode::kReplaceEmpty);
AddressComponent right(NAME_FIRST, nullptr, MergeMode::kReplaceEmpty);
- left.SetValue(UTF8ToUTF16("some value"), VerificationStatus::kParsed);
- right.SetValue(UTF8ToUTF16("some other value"),
- VerificationStatus::kFormatted);
+ left.SetValue(u"some value", VerificationStatus::kParsed);
+ right.SetValue(u"some other value", VerificationStatus::kFormatted);
EXPECT_NE(left.GetValue(), right.GetValue());
EXPECT_NE(left.GetVerificationStatus(), right.GetVerificationStatus());
EXPECT_FALSE(left.SameAs(right));
- right.SetValue(UTF8ToUTF16("some value"), VerificationStatus::kParsed);
+ right.SetValue(u"some value", VerificationStatus::kParsed);
EXPECT_TRUE(left.SameAs(right));
}
@@ -440,13 +438,13 @@ TEST(AutofillStructuredAddressAddressComponent, TestComparison_Compound) {
TestCompoundNameAddressComponent right;
// Set left to a value and verify its state.
- left.SetValueForTypeIfPossible(NAME_FULL, UTF8ToUTF16("First Middle Last"),
+ left.SetValueForTypeIfPossible(NAME_FULL, u"First Middle Last",
VerificationStatus::kObserved);
EXPECT_TRUE(left.CompleteFullTree());
- EXPECT_EQ(left.GetValueForType(NAME_FULL), UTF8ToUTF16("First Middle Last"));
- EXPECT_EQ(left.GetValueForType(NAME_FIRST), UTF8ToUTF16("First"));
- EXPECT_EQ(left.GetValueForType(NAME_MIDDLE), UTF8ToUTF16("Middle"));
- EXPECT_EQ(left.GetValueForType(NAME_LAST), UTF8ToUTF16("Last"));
+ EXPECT_EQ(left.GetValueForType(NAME_FULL), u"First Middle Last");
+ EXPECT_EQ(left.GetValueForType(NAME_FIRST), u"First");
+ EXPECT_EQ(left.GetValueForType(NAME_MIDDLE), u"Middle");
+ EXPECT_EQ(left.GetValueForType(NAME_LAST), u"Last");
EXPECT_EQ(left.GetVerificationStatusForType(NAME_FULL),
VerificationStatus::kObserved);
EXPECT_EQ(left.GetVerificationStatusForType(NAME_FIRST),
@@ -457,13 +455,13 @@ TEST(AutofillStructuredAddressAddressComponent, TestComparison_Compound) {
VerificationStatus::kParsed);
// Set right to another value and verify its state.
- right.SetValueForTypeIfPossible(NAME_FULL, UTF8ToUTF16("The Dark Knight"),
+ right.SetValueForTypeIfPossible(NAME_FULL, u"The Dark Knight",
VerificationStatus::kUserVerified);
EXPECT_TRUE(right.CompleteFullTree());
- EXPECT_EQ(right.GetValueForType(NAME_FULL), UTF8ToUTF16("The Dark Knight"));
- EXPECT_EQ(right.GetValueForType(NAME_FIRST), UTF8ToUTF16("The"));
- EXPECT_EQ(right.GetValueForType(NAME_MIDDLE), UTF8ToUTF16("Dark"));
- EXPECT_EQ(right.GetValueForType(NAME_LAST), UTF8ToUTF16("Knight"));
+ EXPECT_EQ(right.GetValueForType(NAME_FULL), u"The Dark Knight");
+ EXPECT_EQ(right.GetValueForType(NAME_FIRST), u"The");
+ EXPECT_EQ(right.GetValueForType(NAME_MIDDLE), u"Dark");
+ EXPECT_EQ(right.GetValueForType(NAME_LAST), u"Knight");
EXPECT_EQ(right.GetVerificationStatusForType(NAME_FULL),
VerificationStatus::kUserVerified);
EXPECT_EQ(right.GetVerificationStatusForType(NAME_FIRST),
@@ -477,15 +475,14 @@ TEST(AutofillStructuredAddressAddressComponent, TestComparison_Compound) {
// Set left to the same values as right and verify that it is now equal.
TestCompoundNameAddressComponent same_right;
- same_right.SetValueForTypeIfPossible(NAME_FULL,
- UTF8ToUTF16("The Dark Knight"),
+ same_right.SetValueForTypeIfPossible(NAME_FULL, u"The Dark Knight",
VerificationStatus::kUserVerified);
EXPECT_TRUE(same_right.CompleteFullTree());
EXPECT_TRUE(right.SameAs(same_right));
// Change one subcomponent and verify that it is not equal anymore.
- same_right.SetValueForTypeIfPossible(NAME_LAST, UTF8ToUTF16("Joker"),
+ same_right.SetValueForTypeIfPossible(NAME_LAST, u"Joker",
VerificationStatus::kParsed);
EXPECT_FALSE(right.SameAs(same_right));
}
@@ -495,13 +492,11 @@ TEST(AutofillStructuredAddressAddressComponent, TestAssignmentOperator_Atom) {
AddressComponent left(NAME_FIRST, nullptr, MergeMode::kReplaceEmpty);
AddressComponent right(NAME_FIRST, nullptr, MergeMode::kReplaceEmpty);
- left.SetValue(UTF8ToUTF16("some value"), VerificationStatus::kParsed);
- right.SetValue(UTF8ToUTF16("some other value"),
- VerificationStatus::kFormatted);
+ left.SetValue(u"some value", VerificationStatus::kParsed);
+ right.SetValue(u"some other value", VerificationStatus::kFormatted);
EXPECT_FALSE(left.SameAs(right));
- left.SetValue(UTF8ToUTF16("some other value"),
- VerificationStatus::kFormatted);
+ left.SetValue(u"some other value", VerificationStatus::kFormatted);
EXPECT_TRUE(left.SameAs(right));
}
@@ -511,11 +506,11 @@ TEST(AutofillStructuredAddressAddressComponent,
TestCompoundNameAddressComponent left;
TestCompoundNameAddressComponent right;
- left.SetValueForTypeIfPossible(NAME_FULL, UTF8ToUTF16("First Middle Last"),
+ left.SetValueForTypeIfPossible(NAME_FULL, u"First Middle Last",
VerificationStatus::kObserved);
left.RecursivelyCompleteTree();
- right.SetValueForTypeIfPossible(NAME_FULL, UTF8ToUTF16("The Dark Knight"),
+ right.SetValueForTypeIfPossible(NAME_FULL, u"The Dark Knight",
VerificationStatus::kParsed);
right.RecursivelyCompleteTree();
@@ -535,11 +530,11 @@ TEST(AutofillStructuredAddressAddressComponent,
TestCompoundNameAddressComponent left;
TestCompoundNameAddressComponent right;
- left.SetValueForTypeIfPossible(NAME_FULL, UTF8ToUTF16("First Middle Last"),
+ left.SetValueForTypeIfPossible(NAME_FULL, u"First Middle Last",
VerificationStatus::kObserved);
left.RecursivelyCompleteTree();
- right.SetValueForTypeIfPossible(NAME_FULL, UTF8ToUTF16("The Dark Knight"),
+ right.SetValueForTypeIfPossible(NAME_FULL, u"The Dark Knight",
VerificationStatus::kParsed);
right.RecursivelyCompleteTree();
@@ -553,11 +548,11 @@ TEST(AutofillStructuredAddressAddressComponent,
TEST(AutofillStructuredAddressAddressComponent, SelfAssignment) {
TestCompoundNameAddressComponent left;
- left.SetValueForTypeIfPossible(NAME_FULL, UTF8ToUTF16("First Middle Last"),
+ left.SetValueForTypeIfPossible(NAME_FULL, u"First Middle Last",
VerificationStatus::kObserved);
left.CopyFrom(*(&left));
- EXPECT_EQ(left.GetValueForType(NAME_FULL), UTF8ToUTF16("First Middle Last"));
+ EXPECT_EQ(left.GetValueForType(NAME_FULL), u"First Middle Last");
}
// Tests that the correct storage types are returned.
@@ -591,11 +586,11 @@ TEST(AutofillStructuredAddressAddressComponent, GetAtomicity) {
// Tests directly setting and retrieving values.
TEST(AutofillStructuredAddressAddressComponent, DirectlyGetSetAndUnsetValue) {
- base::string16 test_value = ASCIIToUTF16("test_value");
+ std::u16string test_value = u"test_value";
// Create an atomic structured component and verify its initial unset state
TestAtomicFirstNameAddressComponent first_name_component;
- EXPECT_EQ(first_name_component.GetValue(), base::string16());
+ EXPECT_EQ(first_name_component.GetValue(), std::u16string());
EXPECT_FALSE(first_name_component.IsValueAssigned());
EXPECT_EQ(first_name_component.GetVerificationStatus(),
VerificationStatus::kNoStatus);
@@ -609,7 +604,7 @@ TEST(AutofillStructuredAddressAddressComponent, DirectlyGetSetAndUnsetValue) {
// Unset the value and verify the unset state again.
first_name_component.UnsetValue();
- EXPECT_EQ(first_name_component.GetValue(), base::string16());
+ EXPECT_EQ(first_name_component.GetValue(), std::u16string());
EXPECT_FALSE(first_name_component.IsValueAssigned());
EXPECT_EQ(first_name_component.GetVerificationStatus(),
VerificationStatus::kNoStatus);
@@ -618,7 +613,7 @@ TEST(AutofillStructuredAddressAddressComponent, DirectlyGetSetAndUnsetValue) {
// Tests recursively setting and retrieving values.
TEST(AutofillStructuredAddressAddressComponent,
RecursivelySettingAndGettingValues) {
- base::string16 test_value = ASCIIToUTF16("test_value");
+ std::u16string test_value = u"test_value";
// Create a compound component that has a child of type NAME_FIRST.
TestCompoundNameAddressComponent compound_component;
@@ -636,7 +631,7 @@ TEST(AutofillStructuredAddressAddressComponent,
// Retrieve the value and verification status, verify the success and
// retrieved values.
- base::string16 retrieved_value;
+ std::u16string retrieved_value;
VerificationStatus retrieved_status;
EXPECT_TRUE(compound_component.GetValueAndStatusForTypeIfPossible(
NAME_FIRST, &retrieved_value, &retrieved_status));
@@ -666,7 +661,7 @@ TEST(AutofillStructuredAddressAddressComponent, GetSubcomponentTypes) {
TEST(AutofillStructuredAddressAddressComponent, GetBestFormatString_ForAtom) {
TestAtomicFirstNameAddressComponent first_name_component;
EXPECT_EQ(first_name_component.GetBestFormatStringForTesting(),
- UTF8ToUTF16("${NAME_FIRST}"));
+ u"${NAME_FIRST}");
}
// Tests getting the best format string using the fallback mechanism.
@@ -676,9 +671,8 @@ TEST(AutofillStructuredAddressAddressComponent,
TestCompoundNameAddressComponent compound_component;
// Verify the retrieved default format string against the expectation.
- base::string16 expected_result =
- ASCIIToUTF16("${NAME_FIRST} ${NAME_MIDDLE} ${NAME_LAST}");
- base::string16 actual_result =
+ std::u16string expected_result = u"${NAME_FIRST} ${NAME_MIDDLE} ${NAME_LAST}";
+ std::u16string actual_result =
compound_component.GetBestFormatStringForTesting();
EXPECT_EQ(expected_result, actual_result);
}
@@ -690,8 +684,8 @@ TEST(AutofillStructuredAddressAddressComponent,
TestCompoundNameCustomFormatAddressComponent compound_component;
// Verify the retrieved custom format string against the expectation.
- base::string16 expected_result = ASCIIToUTF16("${NAME_LAST}, ${NAME_FIRST}");
- base::string16 actual_result =
+ std::u16string expected_result = u"${NAME_LAST}, ${NAME_FIRST}";
+ std::u16string actual_result =
compound_component.GetBestFormatStringForTesting();
EXPECT_EQ(expected_result, actual_result);
}
@@ -700,9 +694,9 @@ TEST(AutofillStructuredAddressAddressComponent,
// unsupported token.
TEST(AutofillStructuredAddressAddressComponent,
FormatValueFromSubcomponents_UnsupportedToken) {
- base::string16 first_name = ASCIIToUTF16("Winston");
- base::string16 middle_name = ASCIIToUTF16("O'Brien");
- base::string16 last_name = ASCIIToUTF16("Smith");
+ std::u16string first_name = u"Winston";
+ std::u16string middle_name = u"O'Brien";
+ std::u16string last_name = u"Smith";
// Create a compound component and set the values.
TestCompoundNameCustomFormatWithUnsupportedTokenAddressComponent
@@ -716,18 +710,17 @@ TEST(AutofillStructuredAddressAddressComponent,
compound_component.FormatValueFromSubcomponentsForTesting();
- base::string16 expected_value =
- ASCIIToUTF16("Smith, Winston ${NOT_SUPPORTED}");
- base::string16 actual_value = compound_component.GetValue();
+ std::u16string expected_value = u"Smith, Winston ${NOT_SUPPORTED}";
+ std::u16string actual_value = compound_component.GetValue();
EXPECT_EQ(expected_value, actual_value);
}
// Tests formatting the unstructured value from the subcomponents.
TEST(AutofillStructuredAddressAddressComponent, FormatValueFromSubcomponents) {
- base::string16 first_name = ASCIIToUTF16("Winston");
- base::string16 middle_name = ASCIIToUTF16("O'Brien");
- base::string16 last_name = ASCIIToUTF16("Smith");
+ std::u16string first_name = u"Winston";
+ std::u16string middle_name = u"O'Brien";
+ std::u16string last_name = u"Smith";
// Create a compound component and set the values.
TestCompoundNameAddressComponent compound_component;
@@ -740,8 +733,8 @@ TEST(AutofillStructuredAddressAddressComponent, FormatValueFromSubcomponents) {
compound_component.FormatValueFromSubcomponentsForTesting();
- base::string16 expected_value = ASCIIToUTF16("Winston O'Brien Smith");
- base::string16 actual_value = compound_component.GetValue();
+ std::u16string expected_value = u"Winston O'Brien Smith";
+ std::u16string actual_value = compound_component.GetValue();
EXPECT_EQ(expected_value, actual_value);
}
@@ -749,9 +742,9 @@ TEST(AutofillStructuredAddressAddressComponent, FormatValueFromSubcomponents) {
// Tests that formatted values are correctly trimmed.
TEST(AutofillStructuredAddressAddressComponent,
FormatAndTrimmValueFromSubcomponents) {
- base::string16 first_name = ASCIIToUTF16("");
- base::string16 middle_name = ASCIIToUTF16("O'Brien ");
- base::string16 last_name = ASCIIToUTF16("Smith");
+ std::u16string first_name = u"";
+ std::u16string middle_name = u"O'Brien ";
+ std::u16string last_name = u"Smith";
// Create a compound component.
TestCompoundNameAddressComponent compound_component;
@@ -767,17 +760,17 @@ TEST(AutofillStructuredAddressAddressComponent,
// Expect that the leading whitespace due to the missing first name and the
// double white spaces after the middle name are correctly trimmed.
- base::string16 expected_value = ASCIIToUTF16("O'Brien Smith");
- base::string16 actual_value = compound_component.GetValue();
+ std::u16string expected_value = u"O'Brien Smith";
+ std::u16string actual_value = compound_component.GetValue();
EXPECT_EQ(expected_value, actual_value);
}
TEST(AutofillStructuredAddressAddressComponent,
TestEquivalenceOfReplacePlaceholderImplementations) {
- base::string16 first_name = ASCIIToUTF16("Winston");
- base::string16 middle_name = ASCIIToUTF16("O'Brien");
- base::string16 last_name = ASCIIToUTF16("Smith");
+ std::u16string first_name = u"Winston";
+ std::u16string middle_name = u"O'Brien";
+ std::u16string last_name = u"Smith";
// Create a compound component.
TestCompoundNameCustomFormatAddressComponent compound_component;
@@ -794,9 +787,9 @@ TEST(AutofillStructuredAddressAddressComponent,
// type-specific format string.
TEST(AutofillStructuredAddressAddressComponent,
FormatValueFromSubcomponentsWithTypeSpecificFormat) {
- base::string16 first_name = ASCIIToUTF16("Winston");
- base::string16 middle_name = ASCIIToUTF16("O'Brien");
- base::string16 last_name = ASCIIToUTF16("Smith");
+ std::u16string first_name = u"Winston";
+ std::u16string middle_name = u"O'Brien";
+ std::u16string last_name = u"Smith";
// Create a compound component.
TestCompoundNameCustomFormatAddressComponent compound_component;
@@ -810,8 +803,8 @@ TEST(AutofillStructuredAddressAddressComponent,
// Format the compound and verify the expectation.
compound_component.FormatValueFromSubcomponentsForTesting();
- base::string16 expected_value = ASCIIToUTF16("Smith, Winston");
- base::string16 actual_value = compound_component.GetValue();
+ std::u16string expected_value = u"Smith, Winston";
+ std::u16string actual_value = compound_component.GetValue();
EXPECT_EQ(expected_value, actual_value);
}
@@ -820,9 +813,9 @@ TEST(AutofillStructuredAddressAddressComponent,
// type-specific format string containing a prefix and a suffix.
TEST(AutofillStructuredAddressAddressComponent,
FormatValueFromSubcomponentsWithTypeSpecificAffixedFormat) {
- base::string16 first_name = ASCIIToUTF16("Winston");
- base::string16 middle_name = ASCIIToUTF16("O'Brien");
- base::string16 last_name = ASCIIToUTF16("Smith");
+ std::u16string first_name = u"Winston";
+ std::u16string middle_name = u"O'Brien";
+ std::u16string last_name = u"Smith";
// Create a compound component.
TestCompoundNameCustomAffixedFormatAddressComponent compound_component;
@@ -836,8 +829,8 @@ TEST(AutofillStructuredAddressAddressComponent,
// Format the compound and verify the expectation.
compound_component.FormatValueFromSubcomponentsForTesting();
- base::string16 expected_value = ASCIIToUTF16("Dr. Smith MD, Winston");
- base::string16 actual_value = compound_component.GetValue();
+ std::u16string expected_value = u"Dr. Smith MD, Winston";
+ std::u16string actual_value = compound_component.GetValue();
EXPECT_EQ(expected_value, actual_value);
}
@@ -846,62 +839,59 @@ TEST(AutofillStructuredAddressAddressComponent,
TEST(AutofillStructuredAddressAddressComponent,
TestParseValueAndAssignSubcomponentsByFallbackMethod_EmptyString) {
TestCompoundNameAddressComponent compound_component;
- compound_component.SetValue(base::string16(), VerificationStatus::kObserved);
+ compound_component.SetValue(std::u16string(), VerificationStatus::kObserved);
compound_component.ParseValueAndAssignSubcomponents();
- EXPECT_EQ(compound_component.GetValue(), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), base::string16());
+ EXPECT_EQ(compound_component.GetValue(), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), std::u16string());
}
// Tests parsing using a defined method.
TEST(AutofillStructuredAddressAddressComponent,
TestParseValueAndAssignSubcomponentsByMethod) {
TestCompoundNameMethodParsedAddressComponent compound_component;
- compound_component.SetValue(ASCIIToUTF16("Dr. Strangelove"),
+ compound_component.SetValue(u"Dr. Strangelove",
VerificationStatus::kObserved);
compound_component.ParseValueAndAssignSubcomponents();
- EXPECT_EQ(compound_component.GetValue(), ASCIIToUTF16("Dr. Strangelove"));
- EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST),
- ASCIIToUTF16("Dr. Strangelove"));
- EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), base::string16());
+ EXPECT_EQ(compound_component.GetValue(), u"Dr. Strangelove");
+ EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), u"Dr. Strangelove");
+ EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), std::u16string());
}
// Tests parsing using a defined method.
TEST(AutofillStructuredAddressAddressComponent,
TestParseValueAndAssignSubcomponentsByRegEx) {
TestCompoundNameRegExParsedAddressComponent compound_component;
- compound_component.SetValue(ASCIIToUTF16("Dr. Strangelove"),
+ compound_component.SetValue(u"Dr. Strangelove",
VerificationStatus::kObserved);
compound_component.ParseValueAndAssignSubcomponents();
- EXPECT_EQ(compound_component.GetValue(), ASCIIToUTF16("Dr. Strangelove"));
- EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_LAST),
- ASCIIToUTF16("Dr. Strangelove"));
+ EXPECT_EQ(compound_component.GetValue(), u"Dr. Strangelove");
+ EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), u"Dr. Strangelove");
}
// Go nuclear and parse the value of an atomic component.
TEST(AutofillStructuredAddressAddressComponent,
TestParseValueAndAssignSubcomponentsByFallbackMethod_Atom) {
TestAtomicFirstNameAddressComponent atomic_component;
- atomic_component.SetValue(UTF8ToUTF16("Dangerzone"),
- VerificationStatus::kObserved);
+ atomic_component.SetValue(u"Dangerzone", VerificationStatus::kObserved);
atomic_component.ParseValueAndAssignSubcomponents();
// The parsing should not crash the browser and keep the initial value intact.
- EXPECT_EQ(UTF8ToUTF16("Dangerzone"), atomic_component.GetValue());
+ EXPECT_EQ(u"Dangerzone", atomic_component.GetValue());
}
// Tests the fallback method to parse a value into its components if there are
// more space-separated tokens than components.
TEST(AutofillStructuredAddressAddressComponent,
TestParseValueAndAssignSubcomponentsByFallbackMethod) {
- base::string16 full_name = ASCIIToUTF16("Winston O'Brien Hammer Smith");
+ std::u16string full_name = u"Winston O'Brien Hammer Smith";
// Create a compound component, set the value and parse the value of the
// subcomponents.
@@ -911,9 +901,9 @@ TEST(AutofillStructuredAddressAddressComponent,
compound_component.ParseValueAndAssignSubcomponents();
// Define the expectations, and verify the expectation.
- base::string16 first_name = ASCIIToUTF16("Winston");
- base::string16 middle_name = ASCIIToUTF16("O'Brien");
- base::string16 last_name = ASCIIToUTF16("Hammer Smith");
+ std::u16string first_name = u"Winston";
+ std::u16string middle_name = u"O'Brien";
+ std::u16string last_name = u"Hammer Smith";
EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), first_name);
EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), middle_name);
EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), last_name);
@@ -923,7 +913,7 @@ TEST(AutofillStructuredAddressAddressComponent,
// less space-separated tokens than components.
TEST(AutofillStructuredAddressAddressComponent,
ParseValueAndAssignSubcomponentsByFallbackMethod_WithFewTokens) {
- base::string16 full_name = ASCIIToUTF16("Winston");
+ std::u16string full_name = u"Winston";
// Create a compound component and assign a value.
TestCompoundNameAddressComponent compound_component;
@@ -934,9 +924,9 @@ TEST(AutofillStructuredAddressAddressComponent,
compound_component.ParseValueAndAssignSubcomponents();
// Verify the expectation.
- base::string16 first_name = ASCIIToUTF16("Winston");
- base::string16 middle_name = ASCIIToUTF16("");
- base::string16 last_name = ASCIIToUTF16("");
+ std::u16string first_name = u"Winston";
+ std::u16string middle_name = u"";
+ std::u16string last_name = u"";
EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), first_name);
EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), middle_name);
EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), last_name);
@@ -947,9 +937,9 @@ TEST(AutofillStructuredAddressAddressComponent,
// exactly one.
TEST(AutofillStructuredAddressAddressComponent, IsTreeCompletable) {
// Some values.
- base::string16 first_name = ASCIIToUTF16("Winston");
- base::string16 middle_name = ASCIIToUTF16("O'Brien");
- base::string16 full_name = ASCIIToUTF16("Winston O'Brien Smith");
+ std::u16string first_name = u"Winston";
+ std::u16string middle_name = u"O'Brien";
+ std::u16string full_name = u"Winston O'Brien Smith";
// Create a compound component.
TestCompoundNameAddressComponent compound_component;
@@ -986,10 +976,10 @@ TEST(AutofillStructuredAddressAddressComponent, IsTreeCompletable) {
// leafs.
TEST(AutofillStructuredAddressAddressComponent, TreeCompletion_TopToBottom) {
// Some values.
- base::string16 first_name = ASCIIToUTF16("Winston");
- base::string16 middle_name = ASCIIToUTF16("O'Brien");
- base::string16 last_name = ASCIIToUTF16("Smith");
- base::string16 full_name = ASCIIToUTF16("Winston O'Brien Smith");
+ std::u16string first_name = u"Winston";
+ std::u16string middle_name = u"O'Brien";
+ std::u16string last_name = u"Smith";
+ std::u16string full_name = u"Winston O'Brien Smith";
// Create a compound component and set the value of the root node.
TestCompoundNameAddressComponent compound_component;
@@ -997,9 +987,9 @@ TEST(AutofillStructuredAddressAddressComponent, TreeCompletion_TopToBottom) {
NAME_FULL, full_name, VerificationStatus::kUserVerified);
// Verify that the are subcomponents empty.
- EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), base::string16());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), std::u16string());
// Complete the tree.
EXPECT_TRUE(compound_component.CompleteFullTree());
@@ -1013,10 +1003,10 @@ TEST(AutofillStructuredAddressAddressComponent, TreeCompletion_TopToBottom) {
// Tests that the tree is completed successfully from leaf nodes to the root.
TEST(AutofillStructuredAddressAddressComponent, TreeCompletion_BottomToTop) {
// Some values.
- base::string16 first_name = ASCIIToUTF16("Winston");
- base::string16 middle_name = ASCIIToUTF16("O'Brien");
- base::string16 last_name = ASCIIToUTF16("Smith");
- base::string16 full_name = ASCIIToUTF16("Winston O'Brien Smith");
+ std::u16string first_name = u"Winston";
+ std::u16string middle_name = u"O'Brien";
+ std::u16string last_name = u"Smith";
+ std::u16string full_name = u"Winston O'Brien Smith";
// Create a compound component and set the value of the first, middle and last
// name.
@@ -1029,7 +1019,7 @@ TEST(AutofillStructuredAddressAddressComponent, TreeCompletion_BottomToTop) {
NAME_LAST, last_name, VerificationStatus::kUserVerified);
// Verify that the root node is empty.
- EXPECT_EQ(compound_component.GetValueForType(NAME_FULL), base::string16());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_FULL), std::u16string());
// Complete the tree.
compound_component.CompleteFullTree();
@@ -1042,13 +1032,12 @@ TEST(AutofillStructuredAddressAddressComponent, TreeCompletion_BottomToTop) {
// a node with both subcomponents and a parent is set.
TEST(AutofillStructuredAddressAddressComponent, TreeCompletion_ToTopAndBottom) {
// Define Some values.
- base::string16 title = ASCIIToUTF16("Dr.");
- base::string16 first_name = ASCIIToUTF16("Winston");
- base::string16 middle_name = ASCIIToUTF16("O'Brien");
- base::string16 last_name = ASCIIToUTF16("Smith");
- base::string16 full_name = ASCIIToUTF16("Winston O'Brien Smith");
- base::string16 full_name_with_title =
- ASCIIToUTF16("Dr. Winston O'Brien Smith");
+ std::u16string title = u"Dr.";
+ std::u16string first_name = u"Winston";
+ std::u16string middle_name = u"O'Brien";
+ std::u16string last_name = u"Smith";
+ std::u16string full_name = u"Winston O'Brien Smith";
+ std::u16string full_name_with_title = u"Dr. Winston O'Brien Smith";
// Create a compound component.
TestCompoundNameWithTitleAddressComponent compound_component;
@@ -1062,10 +1051,10 @@ TEST(AutofillStructuredAddressAddressComponent, TreeCompletion_ToTopAndBottom) {
// Verify that the are subcomponents empty.
// CREDIT_CARD_NAME_FULL is a fictive type containing a title and a full name.
EXPECT_EQ(compound_component.GetValueForType(CREDIT_CARD_NAME_FULL),
- base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), base::string16());
+ std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), std::u16string());
// Complete the tree.
compound_component.CompleteFullTree();
@@ -1083,13 +1072,12 @@ TEST(AutofillStructuredAddressAddressComponent, TreeCompletion_ToTopAndBottom) {
TEST(AutofillStructuredAddressAddressComponent,
TestSettingsValuesWithInvalidation) {
// Define Some values.
- base::string16 title = ASCIIToUTF16("Dr.");
- base::string16 first_name = ASCIIToUTF16("Winston");
- base::string16 middle_name = ASCIIToUTF16("O'Brien");
- base::string16 last_name = ASCIIToUTF16("Smith");
- base::string16 full_name = ASCIIToUTF16("Winston O'Brien Smith");
- base::string16 full_name_with_title =
- ASCIIToUTF16("Dr. Winston O'Brien Smith");
+ std::u16string title = u"Dr.";
+ std::u16string first_name = u"Winston";
+ std::u16string middle_name = u"O'Brien";
+ std::u16string last_name = u"Smith";
+ std::u16string full_name = u"Winston O'Brien Smith";
+ std::u16string full_name_with_title = u"Dr. Winston O'Brien Smith";
// Create a compound component.
TestCompoundNameWithTitleAddressComponent compound_component;
@@ -1103,10 +1091,10 @@ TEST(AutofillStructuredAddressAddressComponent,
// Verify that the are subcomponents empty.
// CREDIT_CARD_NAME_FULL is a fictive type containing a title and a full name.
EXPECT_EQ(compound_component.GetValueForType(CREDIT_CARD_NAME_FULL),
- base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), base::string16());
+ std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), std::u16string());
// Complete the tree.
compound_component.CompleteFullTree();
@@ -1121,26 +1109,24 @@ TEST(AutofillStructuredAddressAddressComponent,
// Change the value of FULL_NAME and invalidate all child and ancestor nodes.
compound_component.SetValueForTypeIfPossible(
- NAME_FULL, UTF8ToUTF16("Oh' Brian"), VerificationStatus::kObserved, true,
- true);
+ NAME_FULL, u"Oh' Brian", VerificationStatus::kObserved, true, true);
EXPECT_EQ(compound_component.GetValueForType(CREDIT_CARD_NAME_FULL),
- base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), base::string16());
+ std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), std::u16string());
}
// Test unsetting a value and its subcomponents.
TEST(AutofillStructuredAddressAddressComponent,
TestUnsettingAValueAndItsSubcomponents) {
// Define Some values.
- base::string16 title = ASCIIToUTF16("Dr.");
- base::string16 first_name = ASCIIToUTF16("Winston");
- base::string16 middle_name = ASCIIToUTF16("O'Brien");
- base::string16 last_name = ASCIIToUTF16("Smith");
- base::string16 full_name = ASCIIToUTF16("Winston O'Brien Smith");
- base::string16 full_name_with_title =
- ASCIIToUTF16("Dr. Winston O'Brien Smith");
+ std::u16string title = u"Dr.";
+ std::u16string first_name = u"Winston";
+ std::u16string middle_name = u"O'Brien";
+ std::u16string last_name = u"Smith";
+ std::u16string full_name = u"Winston O'Brien Smith";
+ std::u16string full_name_with_title = u"Dr. Winston O'Brien Smith";
// Create a compound component.
TestCompoundNameWithTitleAddressComponent compound_component;
@@ -1154,10 +1140,10 @@ TEST(AutofillStructuredAddressAddressComponent,
// Verify that the are subcomponents empty.
// CREDIT_CARD_NAME_FULL is a fictive type containing a title and a full name.
EXPECT_EQ(compound_component.GetValueForType(CREDIT_CARD_NAME_FULL),
- base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), base::string16());
+ std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), std::u16string());
// Complete the tree.
compound_component.CompleteFullTree();
@@ -1174,9 +1160,9 @@ TEST(AutofillStructuredAddressAddressComponent,
compound_component.UnsetValueForTypeIfSupported(NAME_FULL);
EXPECT_EQ(compound_component.GetValueForType(CREDIT_CARD_NAME_FULL),
full_name_with_title);
- EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), base::string16());
- EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), base::string16());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_FIRST), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_MIDDLE), std::u16string());
+ EXPECT_EQ(compound_component.GetValueForType(NAME_LAST), std::u16string());
}
// Tests that the tree is completed successfully both upwards and downwards when
@@ -1190,8 +1176,7 @@ TEST(AutofillStructuredAddressAddressComponent,
// Set a value somewhere in the tree, complete and verify that another node is
// assigned.
compound_component.SetValueForTypeIfPossible(
- NAME_FULL, UTF8ToUTF16("Winston Brian Smith"),
- VerificationStatus::kObserved);
+ NAME_FULL, u"Winston Brian Smith", VerificationStatus::kObserved);
EXPECT_EQ(VerificationStatus::kObserved,
compound_component.GetVerificationStatusForType(NAME_FULL));
compound_component.CompleteFullTree();
@@ -1215,30 +1200,30 @@ TEST(AutofillStructuredAddressAddressComponent,
TEST(AutofillStructuredAddressAddressComponent,
MergeAtomicComponentsWithDifferentValues) {
TestAtomicFirstNameAddressComponent one;
- one.SetValue(ASCIIToUTF16("Peter"), VerificationStatus::kFormatted);
+ one.SetValue(u"Peter", VerificationStatus::kFormatted);
TestAtomicFirstNameAddressComponent two;
- two.SetValue(ASCIIToUTF16("Hook"), VerificationStatus::kUserVerified);
+ two.SetValue(u"Hook", VerificationStatus::kUserVerified);
// |one| and |two| are note mergeable because they contain completely
// different values.
EXPECT_FALSE(one.MergeWithComponent(two));
// Since |one| and |two| are not mergeable, it is expected that the value of
// |one| is preserved.
- EXPECT_EQ(one.GetValue(), ASCIIToUTF16("Peter"));
+ EXPECT_EQ(one.GetValue(), u"Peter");
EXPECT_EQ(one.GetVerificationStatus(), VerificationStatus::kFormatted);
}
TEST(AutofillStructuredAddressAddressComponent,
MergeAtomicComponentsWithSameValue) {
TestAtomicFirstNameAddressComponent one;
- one.SetValue(ASCIIToUTF16("Peter"), VerificationStatus::kFormatted);
+ one.SetValue(u"Peter", VerificationStatus::kFormatted);
TestAtomicFirstNameAddressComponent two;
- two.SetValue(ASCIIToUTF16("Peter"), VerificationStatus::kUserVerified);
+ two.SetValue(u"Peter", VerificationStatus::kUserVerified);
EXPECT_TRUE(one.MergeWithComponent(two));
- EXPECT_EQ(one.GetValue(), ASCIIToUTF16("Peter"));
+ EXPECT_EQ(one.GetValue(), u"Peter");
// The actual action is that the higher verification status is picked.
EXPECT_EQ(one.GetVerificationStatus(), VerificationStatus::kUserVerified);
@@ -1247,15 +1232,15 @@ TEST(AutofillStructuredAddressAddressComponent,
TEST(AutofillStructuredAddressAddressComponent,
MergeAtomicComponentsSimilarValueThatContainsSameNormalizedValue) {
TestAtomicFirstNameAddressComponent one;
- one.SetValue(UTF8ToUTF16("müller"), VerificationStatus::kFormatted);
+ one.SetValue(u"müller", VerificationStatus::kFormatted);
TestAtomicFirstNameAddressComponent two;
- two.SetValue(UTF8ToUTF16("Muller"), VerificationStatus::kUserVerified);
+ two.SetValue(u"Muller", VerificationStatus::kUserVerified);
// Should be mergeable because the values are the same after normalization.
EXPECT_TRUE(one.MergeWithComponent(two));
// The value should be Muller bebause of its higher validation status.
- EXPECT_EQ(one.GetValue(), ASCIIToUTF16("Muller"));
+ EXPECT_EQ(one.GetValue(), u"Muller");
// The actual action is that the higher verification status is picked.
EXPECT_EQ(one.GetVerificationStatus(), VerificationStatus::kUserVerified);
@@ -1264,20 +1249,20 @@ TEST(AutofillStructuredAddressAddressComponent,
TEST(AutofillStructuredAddressAddressComponent,
MergeAtomicComponentsWithPermutatedValue) {
TestAtomicFirstNameAddressComponent one;
- one.SetValue(ASCIIToUTF16("Peter Pan"), VerificationStatus::kFormatted);
+ one.SetValue(u"Peter Pan", VerificationStatus::kFormatted);
TestAtomicFirstNameAddressComponent two;
- two.SetValue(ASCIIToUTF16("Pan Peter"), VerificationStatus::kUserVerified);
+ two.SetValue(u"Pan Peter", VerificationStatus::kUserVerified);
EXPECT_TRUE(one.MergeWithComponent(two));
- EXPECT_EQ(one.GetValue(), ASCIIToUTF16("Pan Peter"));
+ EXPECT_EQ(one.GetValue(), u"Pan Peter");
EXPECT_EQ(one.GetVerificationStatus(), VerificationStatus::kUserVerified);
// If the merging is applied the other way round, the value of two is not
// altered because |two| has the higher validation status.
- one.SetValue(ASCIIToUTF16("Peter Pan"), VerificationStatus::kFormatted);
+ one.SetValue(u"Peter Pan", VerificationStatus::kFormatted);
EXPECT_TRUE(two.MergeWithComponent(one));
- EXPECT_EQ(two.GetValue(), ASCIIToUTF16("Pan Peter"));
+ EXPECT_EQ(two.GetValue(), u"Pan Peter");
EXPECT_EQ(two.GetVerificationStatus(), VerificationStatus::kUserVerified);
}
@@ -1287,30 +1272,29 @@ TEST(AutofillStructuredAddressAddressComponent, MergeVerificationStatuses) {
TestCompoundNameAddressComponent one;
TestCompoundNameAddressComponent two;
- one.SetValueForTypeIfPossible(NAME_FULL, ASCIIToUTF16("A B C"),
+ one.SetValueForTypeIfPossible(NAME_FULL, u"A B C",
VerificationStatus::kObserved);
- one.SetValueForTypeIfPossible(NAME_FIRST, ASCIIToUTF16("A"),
+ one.SetValueForTypeIfPossible(NAME_FIRST, u"A",
VerificationStatus::kObserved);
- one.SetValueForTypeIfPossible(NAME_MIDDLE, ASCIIToUTF16("B"),
- VerificationStatus::kObserved);
- one.SetValueForTypeIfPossible(NAME_LAST, ASCIIToUTF16("C"),
+ one.SetValueForTypeIfPossible(NAME_MIDDLE, u"B",
VerificationStatus::kObserved);
+ one.SetValueForTypeIfPossible(NAME_LAST, u"C", VerificationStatus::kObserved);
- two.SetValueForTypeIfPossible(NAME_FULL, ASCIIToUTF16("A D C"),
+ two.SetValueForTypeIfPossible(NAME_FULL, u"A D C",
VerificationStatus::kUserVerified);
- two.SetValueForTypeIfPossible(NAME_FIRST, ASCIIToUTF16("A"),
+ two.SetValueForTypeIfPossible(NAME_FIRST, u"A",
VerificationStatus::kUserVerified);
- two.SetValueForTypeIfPossible(NAME_MIDDLE, ASCIIToUTF16("D"),
+ two.SetValueForTypeIfPossible(NAME_MIDDLE, u"D",
VerificationStatus::kUserVerified);
- two.SetValueForTypeIfPossible(NAME_LAST, ASCIIToUTF16("C"),
+ two.SetValueForTypeIfPossible(NAME_LAST, u"C",
VerificationStatus::kUserVerified);
one.MergeVerificationStatuses(two);
- EXPECT_EQ(one.GetValueForType(NAME_FULL), ASCIIToUTF16("A B C"));
- EXPECT_EQ(one.GetValueForType(NAME_FIRST), ASCIIToUTF16("A"));
- EXPECT_EQ(one.GetValueForType(NAME_MIDDLE), ASCIIToUTF16("B"));
- EXPECT_EQ(one.GetValueForType(NAME_LAST), ASCIIToUTF16("C"));
+ EXPECT_EQ(one.GetValueForType(NAME_FULL), u"A B C");
+ EXPECT_EQ(one.GetValueForType(NAME_FIRST), u"A");
+ EXPECT_EQ(one.GetValueForType(NAME_MIDDLE), u"B");
+ EXPECT_EQ(one.GetValueForType(NAME_LAST), u"C");
EXPECT_EQ(one.GetVerificationStatusForType(NAME_FULL),
VerificationStatus::kObserved);
@@ -1328,20 +1312,19 @@ TEST(AutofillStructuredAddressAddressComponent, ClearParsedAndFormattedValues) {
TestCompoundNameAddressComponent one;
TestCompoundNameAddressComponent two;
- one.SetValueForTypeIfPossible(NAME_FULL, ASCIIToUTF16("A B C"),
+ one.SetValueForTypeIfPossible(NAME_FULL, u"A B C",
VerificationStatus::kFormatted);
- one.SetValueForTypeIfPossible(NAME_FIRST, ASCIIToUTF16("A"),
+ one.SetValueForTypeIfPossible(NAME_FIRST, u"A",
VerificationStatus::kObserved);
- one.SetValueForTypeIfPossible(NAME_MIDDLE, ASCIIToUTF16("B"),
- VerificationStatus::kParsed);
- one.SetValueForTypeIfPossible(NAME_LAST, ASCIIToUTF16("C"),
+ one.SetValueForTypeIfPossible(NAME_MIDDLE, u"B", VerificationStatus::kParsed);
+ one.SetValueForTypeIfPossible(NAME_LAST, u"C",
VerificationStatus::kUserVerified);
one.RecursivelyUnsetParsedAndFormattedValues();
- EXPECT_EQ(one.GetValueForType(NAME_FULL), ASCIIToUTF16(""));
- EXPECT_EQ(one.GetValueForType(NAME_FIRST), ASCIIToUTF16("A"));
- EXPECT_EQ(one.GetValueForType(NAME_MIDDLE), ASCIIToUTF16(""));
- EXPECT_EQ(one.GetValueForType(NAME_LAST), ASCIIToUTF16("C"));
+ EXPECT_EQ(one.GetValueForType(NAME_FULL), u"");
+ EXPECT_EQ(one.GetValueForType(NAME_FIRST), u"A");
+ EXPECT_EQ(one.GetValueForType(NAME_MIDDLE), u"");
+ EXPECT_EQ(one.GetValueForType(NAME_LAST), u"C");
EXPECT_EQ(one.GetVerificationStatusForType(NAME_FULL),
VerificationStatus::kNoStatus);
@@ -1360,14 +1343,14 @@ TEST(AutofillStructuredAddressAddressComponent,
TestCompoundNameAddressComponent one;
TestCompoundNameAddressComponent two;
- EXPECT_TRUE(one.SetValueForTypeIfPossible(
- NAME_FULL, ASCIIToUTF16("First LastFirst LastSecond"),
- VerificationStatus::kUserVerified));
+ EXPECT_TRUE(one.SetValueForTypeIfPossible(NAME_FULL,
+ u"First LastFirst LastSecond",
+ VerificationStatus::kUserVerified));
one.CompleteFullTree();
- EXPECT_EQ(one.GetValueForType(NAME_FIRST), ASCIIToUTF16("First"));
- EXPECT_EQ(one.GetValueForType(NAME_MIDDLE), ASCIIToUTF16("LastFirst"));
- EXPECT_EQ(one.GetValueForType(NAME_LAST), ASCIIToUTF16("LastSecond"));
+ EXPECT_EQ(one.GetValueForType(NAME_FIRST), u"First");
+ EXPECT_EQ(one.GetValueForType(NAME_MIDDLE), u"LastFirst");
+ EXPECT_EQ(one.GetValueForType(NAME_LAST), u"LastSecond");
EXPECT_EQ(one.GetVerificationStatusForType(NAME_FIRST),
VerificationStatus::kParsed);
EXPECT_EQ(one.GetVerificationStatusForType(NAME_MIDDLE),
@@ -1375,27 +1358,23 @@ TEST(AutofillStructuredAddressAddressComponent,
EXPECT_EQ(one.GetVerificationStatusForType(NAME_LAST),
VerificationStatus::kParsed);
- EXPECT_TRUE(two.SetValueForTypeIfPossible(NAME_FIRST, ASCIIToUTF16("First"),
+ EXPECT_TRUE(two.SetValueForTypeIfPossible(NAME_FIRST, u"First",
+ VerificationStatus::kObserved));
+ EXPECT_TRUE(two.SetValueForTypeIfPossible(NAME_LAST, u"LastFirst LastSecond",
VerificationStatus::kObserved));
- EXPECT_TRUE(two.SetValueForTypeIfPossible(
- NAME_LAST, ASCIIToUTF16("LastFirst LastSecond"),
- VerificationStatus::kObserved));
two.CompleteFullTree();
- EXPECT_EQ(two.GetValueForType(NAME_FULL),
- ASCIIToUTF16("First LastFirst LastSecond"));
- EXPECT_EQ(two.GetValueForType(NAME_MIDDLE), ASCIIToUTF16(""));
+ EXPECT_EQ(two.GetValueForType(NAME_FULL), u"First LastFirst LastSecond");
+ EXPECT_EQ(two.GetValueForType(NAME_MIDDLE), u"");
EXPECT_TRUE(one.MergeWithComponent(two));
- EXPECT_EQ(one.GetValueForType(NAME_FULL),
- ASCIIToUTF16("First LastFirst LastSecond"));
+ EXPECT_EQ(one.GetValueForType(NAME_FULL), u"First LastFirst LastSecond");
EXPECT_EQ(one.GetVerificationStatusForType(NAME_FULL),
VerificationStatus::kUserVerified);
- EXPECT_EQ(one.GetValueForType(NAME_FIRST), ASCIIToUTF16("First"));
+ EXPECT_EQ(one.GetValueForType(NAME_FIRST), u"First");
EXPECT_EQ(one.GetVerificationStatusForType(NAME_FIRST),
VerificationStatus::kObserved);
- EXPECT_EQ(one.GetValueForType(NAME_MIDDLE), ASCIIToUTF16(""));
- EXPECT_EQ(one.GetValueForType(NAME_LAST),
- ASCIIToUTF16("LastFirst LastSecond"));
+ EXPECT_EQ(one.GetValueForType(NAME_MIDDLE), u"");
+ EXPECT_EQ(one.GetValueForType(NAME_LAST), u"LastFirst LastSecond");
EXPECT_EQ(one.GetVerificationStatusForType(NAME_LAST),
VerificationStatus::kObserved);
}
@@ -1408,26 +1387,24 @@ TEST(AutofillStructuredAddressAddressComponent, MergePermutatedComponent) {
// The first component has the unstructured representation as the user
// verified it, but a wrong componentization.
- EXPECT_TRUE(one.SetValueForTypeIfPossible(NAME_FULL,
- ASCIIToUTF16("Last First Middle"),
+ EXPECT_TRUE(one.SetValueForTypeIfPossible(NAME_FULL, u"Last First Middle",
VerificationStatus::kUserVerified));
- EXPECT_TRUE(one.SetValueForTypeIfPossible(NAME_FIRST, ASCIIToUTF16("Last"),
+ EXPECT_TRUE(one.SetValueForTypeIfPossible(NAME_FIRST, u"Last",
VerificationStatus::kParsed));
- EXPECT_TRUE(one.SetValueForTypeIfPossible(NAME_MIDDLE, ASCIIToUTF16("First"),
+ EXPECT_TRUE(one.SetValueForTypeIfPossible(NAME_MIDDLE, u"First",
VerificationStatus::kParsed));
- EXPECT_TRUE(one.SetValueForTypeIfPossible(NAME_LAST, ASCIIToUTF16("Middle"),
+ EXPECT_TRUE(one.SetValueForTypeIfPossible(NAME_LAST, u"Middle",
VerificationStatus::kParsed));
// The second component has a correct componentization but not the
// unstructured representation the user prefers.
- EXPECT_TRUE(two.SetValueForTypeIfPossible(NAME_FULL,
- ASCIIToUTF16("First Last Middle"),
+ EXPECT_TRUE(two.SetValueForTypeIfPossible(NAME_FULL, u"First Last Middle",
VerificationStatus::kFormatted));
- EXPECT_TRUE(two.SetValueForTypeIfPossible(NAME_FIRST, ASCIIToUTF16("First"),
+ EXPECT_TRUE(two.SetValueForTypeIfPossible(NAME_FIRST, u"First",
VerificationStatus::kObserved));
- EXPECT_TRUE(two.SetValueForTypeIfPossible(NAME_MIDDLE, ASCIIToUTF16("Middle"),
+ EXPECT_TRUE(two.SetValueForTypeIfPossible(NAME_MIDDLE, u"Middle",
VerificationStatus::kObserved));
- EXPECT_TRUE(two.SetValueForTypeIfPossible(NAME_LAST, ASCIIToUTF16("Last"),
+ EXPECT_TRUE(two.SetValueForTypeIfPossible(NAME_LAST, u"Last",
VerificationStatus::kObserved));
TestCompoundNameAddressComponent copy_of_one;
@@ -1436,31 +1413,31 @@ TEST(AutofillStructuredAddressAddressComponent, MergePermutatedComponent) {
// As a result of the merging, the unstructured representation should be
// maintained, but the substructure should be corrected
- EXPECT_EQ(one.GetValueForType(NAME_FULL), ASCIIToUTF16("Last First Middle"));
+ EXPECT_EQ(one.GetValueForType(NAME_FULL), u"Last First Middle");
EXPECT_EQ(one.GetVerificationStatusForType(NAME_FULL),
VerificationStatus::kUserVerified);
- EXPECT_EQ(one.GetValueForType(NAME_FIRST), ASCIIToUTF16("First"));
+ EXPECT_EQ(one.GetValueForType(NAME_FIRST), u"First");
EXPECT_EQ(one.GetVerificationStatusForType(NAME_FIRST),
VerificationStatus::kObserved);
- EXPECT_EQ(one.GetValueForType(NAME_MIDDLE), ASCIIToUTF16("Middle"));
+ EXPECT_EQ(one.GetValueForType(NAME_MIDDLE), u"Middle");
EXPECT_EQ(one.GetVerificationStatusForType(NAME_MIDDLE),
VerificationStatus::kObserved);
- EXPECT_EQ(one.GetValueForType(NAME_LAST), ASCIIToUTF16("Last"));
+ EXPECT_EQ(one.GetValueForType(NAME_LAST), u"Last");
EXPECT_EQ(one.GetVerificationStatusForType(NAME_LAST),
VerificationStatus::kObserved);
// The merging should work in both directions the same way.
EXPECT_TRUE(two.MergeWithComponent(copy_of_one));
- EXPECT_EQ(two.GetValueForType(NAME_FULL), ASCIIToUTF16("Last First Middle"));
+ EXPECT_EQ(two.GetValueForType(NAME_FULL), u"Last First Middle");
EXPECT_EQ(two.GetVerificationStatusForType(NAME_FULL),
VerificationStatus::kUserVerified);
- EXPECT_EQ(two.GetValueForType(NAME_FIRST), ASCIIToUTF16("First"));
+ EXPECT_EQ(two.GetValueForType(NAME_FIRST), u"First");
EXPECT_EQ(two.GetVerificationStatusForType(NAME_FIRST),
VerificationStatus::kObserved);
- EXPECT_EQ(two.GetValueForType(NAME_MIDDLE), ASCIIToUTF16("Middle"));
+ EXPECT_EQ(two.GetValueForType(NAME_MIDDLE), u"Middle");
EXPECT_EQ(two.GetVerificationStatusForType(NAME_MIDDLE),
VerificationStatus::kObserved);
- EXPECT_EQ(two.GetValueForType(NAME_LAST), ASCIIToUTF16("Last"));
+ EXPECT_EQ(two.GetValueForType(NAME_LAST), u"Last");
EXPECT_EQ(two.GetVerificationStatusForType(NAME_LAST),
VerificationStatus::kObserved);
}
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_name.cc b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_name.cc
index dfc86617acc..4cd66a50ffa 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_name.cc
+++ b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_name.cc
@@ -21,16 +21,16 @@ namespace autofill {
namespace structured_address {
-base::string16 ReduceToInitials(const base::string16& value) {
+std::u16string ReduceToInitials(const std::u16string& value) {
if (value.empty())
- return base::string16();
+ return std::u16string();
- std::vector<base::string16> middle_name_tokens =
+ std::vector<std::u16string> middle_name_tokens =
base::SplitString(value, base::ASCIIToUTF16(kNameSeparators),
base::WhitespaceHandling::TRIM_WHITESPACE,
base::SplitResult::SPLIT_WANT_NONEMPTY);
- base::string16 result;
+ std::u16string result;
result.reserve(middle_name_tokens.size());
for (const auto& token : middle_name_tokens) {
DCHECK(!token.empty());
@@ -61,7 +61,7 @@ void NameMiddle::GetAdditionalSupportedFieldTypes(
bool NameMiddle::ConvertAndGetTheValueForAdditionalFieldTypeName(
const std::string& type_name,
- base::string16* value) const {
+ std::u16string* value) const {
if (type_name == AutofillType::ServerFieldTypeToString(NAME_MIDDLE_INITIAL)) {
if (value) {
// If the stored value has the characteristics of containing only
@@ -81,7 +81,7 @@ bool NameMiddle::ConvertAndGetTheValueForAdditionalFieldTypeName(
bool NameMiddle::ConvertAndSetValueForAdditionalFieldTypeName(
const std::string& type_name,
- const base::string16& value,
+ const std::u16string& value,
const VerificationStatus& status) {
if (type_name == AutofillType::ServerFieldTypeToString(NAME_MIDDLE_INITIAL)) {
SetValue(value, status);
@@ -235,13 +235,12 @@ std::vector<const re2::RE2*> NameFull::GetParseRegularExpressionsByRelevance()
pattern_provider->GetRegEx(RegEx::kParseLastCommaFirstMiddleName),
pattern_provider->GetRegEx(RegEx::kParseFirstMiddleLastName)};
}
-base::string16 NameFull::GetBestFormatString() const {
+std::u16string NameFull::GetBestFormatString() const {
if (HasCjkNameCharacteristics(base::UTF16ToUTF8(name_first_.GetValue())) &&
HasCjkNameCharacteristics(base::UTF16ToUTF8(name_last_.GetValue()))) {
- return base::ASCIIToUTF16("${NAME_LAST}${NAME_FIRST}");
+ return u"${NAME_LAST}${NAME_FIRST}";
}
- return
- base::ASCIIToUTF16("${NAME_FIRST} ${NAME_MIDDLE} ${NAME_LAST}");
+ return u"${NAME_FIRST} ${NAME_MIDDLE} ${NAME_LAST}";
}
NameFull::~NameFull() = default;
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_name.h b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_name.h
index db4e70137d6..108c024cb7f 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_name.h
+++ b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_name.h
@@ -47,12 +47,12 @@ class NameMiddle : public AddressComponent {
// type.
bool ConvertAndGetTheValueForAdditionalFieldTypeName(
const std::string& type_name,
- base::string16* value) const override;
+ std::u16string* value) const override;
// Implements support for setting the |MIDDLE_NAME_INITIAL| type.
bool ConvertAndSetValueForAdditionalFieldTypeName(
const std::string& type_name,
- const base::string16& value,
+ const std::u16string& value,
const VerificationStatus& status) override;
};
@@ -145,7 +145,7 @@ class NameFull : public AddressComponent {
const override;
// Returns the format string to create the full name from its subcomponents.
- base::string16 GetBestFormatString() const override;
+ std::u16string GetBestFormatString() const override;
private:
NameFirst name_first_{this};
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_name_unittest.cc b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_name_unittest.cc
index 7be3e48495e..44a4d0752e3 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_name_unittest.cc
+++ b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_name_unittest.cc
@@ -48,14 +48,14 @@ struct LastNameParserTestRecord {
// Function to test the parsing of a name from the full (unstructured)
// representation into its subcomponents.
-void TestNameParsing(const base::string16& full_with_prefix,
- const base::string16& honorific,
- const base::string16& first,
- const base::string16& middle,
- const base::string16& last,
- const base::string16& last_first,
- const base::string16& last_conjunction,
- const base::string16& last_second) {
+void TestNameParsing(const std::u16string& full_with_prefix,
+ const std::u16string& honorific,
+ const std::u16string& first,
+ const std::u16string& middle,
+ const std::u16string& last,
+ const std::u16string& last_first,
+ const std::u16string& last_conjunction,
+ const std::u16string& last_second) {
SCOPED_TRACE(full_with_prefix);
NameFullWithPrefix name;
name.SetValueForTypeIfPossible(NAME_FULL_WITH_HONORIFIC_PREFIX,
@@ -84,10 +84,10 @@ void TestNameParsing(const base::string16& full_with_prefix,
}
// Testing function for parsing a |NAME_LAST| into its subcomponents.
-void TestLastNameParsing(const base::string16& last_name,
- const base::string16& target_first,
- const base::string16& target_conjunction,
- const base::string16& target_second) {
+void TestLastNameParsing(const std::u16string& last_name,
+ const std::u16string& target_first,
+ const std::u16string& target_conjunction,
+ const std::u16string& target_second) {
SCOPED_TRACE(last_name);
NameLast last_name_component(nullptr);
@@ -303,57 +303,44 @@ TEST(AutofillStructuredName, HasMiddleNameInitialsCharacteristics) {
// Test the reduction of a name to its initials.
TEST(AutofillStructuredName, ReduceToInitials) {
- EXPECT_EQ(ReduceToInitials(base::ASCIIToUTF16("")), base::ASCIIToUTF16(""));
- EXPECT_EQ(ReduceToInitials(base::ASCIIToUTF16("George")),
- base::ASCIIToUTF16("G"));
- EXPECT_EQ(ReduceToInitials(base::ASCIIToUTF16("George Walker")),
- base::ASCIIToUTF16("GW"));
- EXPECT_EQ(ReduceToInitials(base::ASCIIToUTF16("michael myers")),
- base::ASCIIToUTF16("MM"));
- EXPECT_EQ(ReduceToInitials(base::ASCIIToUTF16("Hans-Peter")),
- base::ASCIIToUTF16("HP"));
+ EXPECT_EQ(ReduceToInitials(u""), u"");
+ EXPECT_EQ(ReduceToInitials(u"George"), u"G");
+ EXPECT_EQ(ReduceToInitials(u"George Walker"), u"GW");
+ EXPECT_EQ(ReduceToInitials(u"michael myers"), u"MM");
+ EXPECT_EQ(ReduceToInitials(u"Hans-Peter"), u"HP");
}
// Test getting the field type |NAME_MIDDLE_INITIAL|.
TEST(AutofillStructuredName, GetNameMiddleInitial) {
NameFull full_name;
- full_name.SetValueForTypeIfPossible(NAME_MIDDLE,
- base::ASCIIToUTF16("Michael"),
+ full_name.SetValueForTypeIfPossible(NAME_MIDDLE, u"Michael",
VerificationStatus::kObserved);
- EXPECT_EQ(full_name.GetValueForType(NAME_MIDDLE_INITIAL),
- base::ASCIIToUTF16("M"));
+ EXPECT_EQ(full_name.GetValueForType(NAME_MIDDLE_INITIAL), u"M");
- full_name.SetValueForTypeIfPossible(NAME_MIDDLE,
- base::ASCIIToUTF16("Michael Myers"),
+ full_name.SetValueForTypeIfPossible(NAME_MIDDLE, u"Michael Myers",
VerificationStatus::kObserved);
- EXPECT_EQ(full_name.GetValueForType(NAME_MIDDLE_INITIAL),
- base::ASCIIToUTF16("MM"));
+ EXPECT_EQ(full_name.GetValueForType(NAME_MIDDLE_INITIAL), u"MM");
- full_name.SetValueForTypeIfPossible(NAME_MIDDLE,
- base::ASCIIToUTF16("george walker"),
+ full_name.SetValueForTypeIfPossible(NAME_MIDDLE, u"george walker",
VerificationStatus::kObserved);
- EXPECT_EQ(full_name.GetValueForType(NAME_MIDDLE_INITIAL),
- base::ASCIIToUTF16("GW"));
+ EXPECT_EQ(full_name.GetValueForType(NAME_MIDDLE_INITIAL), u"GW");
// The the set value already has the characteristics of initials, the value
// should be returned as it is.
- full_name.SetValueForTypeIfPossible(NAME_MIDDLE, base::ASCIIToUTF16("GW"),
+ full_name.SetValueForTypeIfPossible(NAME_MIDDLE, u"GW",
VerificationStatus::kObserved);
- EXPECT_EQ(full_name.GetValueForType(NAME_MIDDLE_INITIAL),
- base::ASCIIToUTF16("GW"));
+ EXPECT_EQ(full_name.GetValueForType(NAME_MIDDLE_INITIAL), u"GW");
- full_name.SetValueForTypeIfPossible(NAME_MIDDLE, base::ASCIIToUTF16("G. W."),
+ full_name.SetValueForTypeIfPossible(NAME_MIDDLE, u"G. W.",
VerificationStatus::kObserved);
- EXPECT_EQ(full_name.GetValueForType(NAME_MIDDLE_INITIAL),
- base::ASCIIToUTF16("G. W."));
+ EXPECT_EQ(full_name.GetValueForType(NAME_MIDDLE_INITIAL), u"G. W.");
- full_name.SetValueForTypeIfPossible(NAME_MIDDLE, base::ASCIIToUTF16("G.-W."),
+ full_name.SetValueForTypeIfPossible(NAME_MIDDLE, u"G.-W.",
VerificationStatus::kObserved);
- EXPECT_EQ(full_name.GetValueForType(NAME_MIDDLE_INITIAL),
- base::ASCIIToUTF16("G.-W."));
+ EXPECT_EQ(full_name.GetValueForType(NAME_MIDDLE_INITIAL), u"G.-W.");
}
TEST(AutofillStructuredName, TestGetSupportedTypes_FullNameWithPrefix) {
@@ -380,15 +367,12 @@ TEST(AutofillStructuredName, TestGetSupportedTypes_FullName) {
TEST(AutofillStructuredName, TestSettingMiddleNameInitial) {
NameFullWithPrefix full_name_with_prefix;
EXPECT_EQ(full_name_with_prefix.GetValueForType(NAME_MIDDLE),
- base::string16());
+ std::u16string());
EXPECT_TRUE(full_name_with_prefix.SetValueForTypeIfPossible(
- NAME_MIDDLE_INITIAL, base::UTF8ToUTF16("M"),
- VerificationStatus::kObserved));
- EXPECT_EQ(full_name_with_prefix.GetValueForType(NAME_MIDDLE_INITIAL),
- base::UTF8ToUTF16("M"));
- EXPECT_EQ(full_name_with_prefix.GetValueForType(NAME_MIDDLE),
- base::UTF8ToUTF16("M"));
+ NAME_MIDDLE_INITIAL, u"M", VerificationStatus::kObserved));
+ EXPECT_EQ(full_name_with_prefix.GetValueForType(NAME_MIDDLE_INITIAL), u"M");
+ EXPECT_EQ(full_name_with_prefix.GetValueForType(NAME_MIDDLE), u"M");
}
TEST(AutofillStructuredName, MergePermutatedNames) {
@@ -396,21 +380,20 @@ TEST(AutofillStructuredName, MergePermutatedNames) {
NameFull two;
// The first component has an observed substructure of the full name.
- EXPECT_TRUE(one.SetValueForTypeIfPossible(
- NAME_FIRST, base::ASCIIToUTF16("First"), VerificationStatus::kObserved));
- EXPECT_TRUE(one.SetValueForTypeIfPossible(
- NAME_LAST, base::ASCIIToUTF16("Last"), VerificationStatus::kObserved));
+ EXPECT_TRUE(one.SetValueForTypeIfPossible(NAME_FIRST, u"First",
+ VerificationStatus::kObserved));
+ EXPECT_TRUE(one.SetValueForTypeIfPossible(NAME_LAST, u"Last",
+ VerificationStatus::kObserved));
one.CompleteFullTree();
// The formatted full name has the canonical representation "FIRST LAST".
- EXPECT_EQ(one.GetValueForType(NAME_FULL), base::ASCIIToUTF16("First Last"));
+ EXPECT_EQ(one.GetValueForType(NAME_FULL), u"First Last");
EXPECT_EQ(one.GetVerificationStatusForType(NAME_FULL),
VerificationStatus::kFormatted);
// In contrast, the second component has a verified name in an alternative
// representation "LAST, FIRST"
- EXPECT_TRUE(two.SetValueForTypeIfPossible(NAME_FULL,
- base::ASCIIToUTF16("Last, First"),
+ EXPECT_TRUE(two.SetValueForTypeIfPossible(NAME_FULL, u"Last, First",
VerificationStatus::kUserVerified));
EXPECT_EQ(two.GetVerificationStatusForType(NAME_FULL),
VerificationStatus::kUserVerified);
@@ -418,20 +401,20 @@ TEST(AutofillStructuredName, MergePermutatedNames) {
EXPECT_EQ(two.GetVerificationStatusForType(NAME_FULL),
VerificationStatus::kUserVerified);
- EXPECT_EQ(two.GetValueForType(NAME_FIRST), base::ASCIIToUTF16("First"));
- EXPECT_EQ(two.GetValueForType(NAME_LAST), base::ASCIIToUTF16("Last"));
+ EXPECT_EQ(two.GetValueForType(NAME_FIRST), u"First");
+ EXPECT_EQ(two.GetValueForType(NAME_LAST), u"Last");
EXPECT_TRUE(one.MergeWithComponent(two));
// It is expected that the alternative representation of the second component
// is merged into the first one, while maintaining the observed substructure.
- EXPECT_EQ(one.GetValueForType(NAME_FULL), base::ASCIIToUTF16("Last, First"));
+ EXPECT_EQ(one.GetValueForType(NAME_FULL), u"Last, First");
EXPECT_EQ(one.GetVerificationStatusForType(NAME_FULL),
VerificationStatus::kUserVerified);
- EXPECT_EQ(one.GetValueForType(NAME_FIRST), base::ASCIIToUTF16("First"));
+ EXPECT_EQ(one.GetValueForType(NAME_FIRST), u"First");
EXPECT_EQ(one.GetVerificationStatusForType(NAME_FIRST),
VerificationStatus::kObserved);
- EXPECT_EQ(one.GetValueForType(NAME_LAST), base::ASCIIToUTF16("Last"));
+ EXPECT_EQ(one.GetValueForType(NAME_LAST), u"Last");
EXPECT_EQ(one.GetVerificationStatusForType(NAME_LAST),
VerificationStatus::kObserved);
}
@@ -812,22 +795,17 @@ TEST(AutofillStructuredName, TestCopyConstructuror) {
NameFull orginal;
// The first name has an incorrect componentization of the last name, but
// a correctly observed structure of title, first, middle, last.
- orginal.SetValueForTypeIfPossible(
- NAME_FULL, base::ASCIIToUTF16("Mr Pablo Diego Ruiz y Picasso"),
- VerificationStatus::kUserVerified);
- orginal.SetValueForTypeIfPossible(NAME_HONORIFIC_PREFIX,
- base::ASCIIToUTF16("Mr"),
+ orginal.SetValueForTypeIfPossible(NAME_FULL, u"Mr Pablo Diego Ruiz y Picasso",
+ VerificationStatus::kUserVerified);
+ orginal.SetValueForTypeIfPossible(NAME_HONORIFIC_PREFIX, u"Mr",
VerificationStatus::kObserved);
- orginal.SetValueForTypeIfPossible(NAME_FIRST,
- base::ASCIIToUTF16("Pablo Diego"),
+ orginal.SetValueForTypeIfPossible(NAME_FIRST, u"Pablo Diego",
VerificationStatus::kObserved);
- orginal.SetValueForTypeIfPossible(NAME_MIDDLE, base::ASCIIToUTF16(""),
+ orginal.SetValueForTypeIfPossible(NAME_MIDDLE, u"",
VerificationStatus::kObserved);
- orginal.SetValueForTypeIfPossible(NAME_LAST,
- base::ASCIIToUTF16("Ruiz y Picasso"),
+ orginal.SetValueForTypeIfPossible(NAME_LAST, u"Ruiz y Picasso",
VerificationStatus::kObserved);
- orginal.SetValueForTypeIfPossible(NAME_LAST_SECOND,
- base::ASCIIToUTF16("Ruiz y Picasso"),
+ orginal.SetValueForTypeIfPossible(NAME_LAST_SECOND, u"Ruiz y Picasso",
VerificationStatus::kParsed);
NameFull copy = orginal;
@@ -837,27 +815,24 @@ TEST(AutofillStructuredName, TestCopyConstructuror) {
TEST(AutofillStructuredName,
MigrationFromLegacyStructure_WithFullName_Unverified) {
NameFull name;
- name.SetValueForTypeIfPossible(NAME_FULL,
- base::ASCIIToUTF16("Thomas Neo Anderson"),
+ name.SetValueForTypeIfPossible(NAME_FULL, u"Thomas Neo Anderson",
VerificationStatus::kNoStatus);
- name.SetValueForTypeIfPossible(NAME_FIRST, base::ASCIIToUTF16("Thomas"),
+ name.SetValueForTypeIfPossible(NAME_FIRST, u"Thomas",
VerificationStatus::kNoStatus);
- name.SetValueForTypeIfPossible(NAME_MIDDLE, base::ASCIIToUTF16("Neo"),
+ name.SetValueForTypeIfPossible(NAME_MIDDLE, u"Neo",
VerificationStatus::kNoStatus);
- name.SetValueForTypeIfPossible(NAME_LAST, base::ASCIIToUTF16("Anderson"),
+ name.SetValueForTypeIfPossible(NAME_LAST, u"Anderson",
VerificationStatus::kNoStatus);
name.MigrateLegacyStructure(false);
// Since the full name is set and the profile is not verified it is promoted
// to observed. All other tokens are reset.
- EXPECT_EQ(name.GetValueForType(NAME_FULL),
- base::ASCIIToUTF16("Thomas Neo Anderson"));
- EXPECT_EQ(name.GetValueForType(NAME_FIRST), base::ASCIIToUTF16("Thomas"));
- EXPECT_EQ(name.GetValueForType(NAME_MIDDLE), base::ASCIIToUTF16("Neo"));
- EXPECT_EQ(name.GetValueForType(NAME_LAST), base::ASCIIToUTF16("Anderson"));
- EXPECT_EQ(name.GetValueForType(NAME_LAST_SECOND),
- base::ASCIIToUTF16("Anderson"));
+ EXPECT_EQ(name.GetValueForType(NAME_FULL), u"Thomas Neo Anderson");
+ EXPECT_EQ(name.GetValueForType(NAME_FIRST), u"Thomas");
+ EXPECT_EQ(name.GetValueForType(NAME_MIDDLE), u"Neo");
+ EXPECT_EQ(name.GetValueForType(NAME_LAST), u"Anderson");
+ EXPECT_EQ(name.GetValueForType(NAME_LAST_SECOND), u"Anderson");
EXPECT_EQ(name.GetVerificationStatusForType(NAME_FULL),
VerificationStatus::kObserved);
@@ -874,27 +849,24 @@ TEST(AutofillStructuredName,
TEST(AutofillStructuredName,
MigrationFromLegacyStructure_WithFullName_Verified) {
NameFull name;
- name.SetValueForTypeIfPossible(NAME_FULL,
- base::ASCIIToUTF16("Thomas Neo Anderson"),
+ name.SetValueForTypeIfPossible(NAME_FULL, u"Thomas Neo Anderson",
VerificationStatus::kNoStatus);
- name.SetValueForTypeIfPossible(NAME_FIRST, base::ASCIIToUTF16("Thomas"),
+ name.SetValueForTypeIfPossible(NAME_FIRST, u"Thomas",
VerificationStatus::kNoStatus);
- name.SetValueForTypeIfPossible(NAME_MIDDLE, base::ASCIIToUTF16("Neo"),
+ name.SetValueForTypeIfPossible(NAME_MIDDLE, u"Neo",
VerificationStatus::kNoStatus);
- name.SetValueForTypeIfPossible(NAME_LAST, base::ASCIIToUTF16("Anderson"),
+ name.SetValueForTypeIfPossible(NAME_LAST, u"Anderson",
VerificationStatus::kNoStatus);
name.MigrateLegacyStructure(true);
// Since the full name is set and the profile is verified, it is promoted to
// kUserVerified. All other tokens are reset.
- EXPECT_EQ(name.GetValueForType(NAME_FULL),
- base::ASCIIToUTF16("Thomas Neo Anderson"));
- EXPECT_EQ(name.GetValueForType(NAME_FIRST), base::ASCIIToUTF16("Thomas"));
- EXPECT_EQ(name.GetValueForType(NAME_MIDDLE), base::ASCIIToUTF16("Neo"));
- EXPECT_EQ(name.GetValueForType(NAME_LAST), base::ASCIIToUTF16("Anderson"));
- EXPECT_EQ(name.GetValueForType(NAME_LAST_SECOND),
- base::ASCIIToUTF16("Anderson"));
+ EXPECT_EQ(name.GetValueForType(NAME_FULL), u"Thomas Neo Anderson");
+ EXPECT_EQ(name.GetValueForType(NAME_FIRST), u"Thomas");
+ EXPECT_EQ(name.GetValueForType(NAME_MIDDLE), u"Neo");
+ EXPECT_EQ(name.GetValueForType(NAME_LAST), u"Anderson");
+ EXPECT_EQ(name.GetValueForType(NAME_LAST_SECOND), u"Anderson");
EXPECT_EQ(name.GetVerificationStatusForType(NAME_FULL),
VerificationStatus::kUserVerified);
@@ -912,13 +884,12 @@ TEST(AutofillStructuredName, MigrationFromLegacyStructure_WithoutFullName) {
NameFull name;
// The first name has an incorrect componentization of the last name, but
// a correctly observed structure of title, first, middle, last.
- name.SetValueForTypeIfPossible(NAME_FULL, base::ASCIIToUTF16(""),
- VerificationStatus::kNoStatus);
- name.SetValueForTypeIfPossible(NAME_FIRST, base::ASCIIToUTF16("Thomas"),
+ name.SetValueForTypeIfPossible(NAME_FULL, u"", VerificationStatus::kNoStatus);
+ name.SetValueForTypeIfPossible(NAME_FIRST, u"Thomas",
VerificationStatus::kNoStatus);
- name.SetValueForTypeIfPossible(NAME_MIDDLE, base::ASCIIToUTF16("Neo"),
+ name.SetValueForTypeIfPossible(NAME_MIDDLE, u"Neo",
VerificationStatus::kNoStatus);
- name.SetValueForTypeIfPossible(NAME_LAST, base::ASCIIToUTF16("Anderson"),
+ name.SetValueForTypeIfPossible(NAME_LAST, u"Anderson",
VerificationStatus::kNoStatus);
name.MigrateLegacyStructure(false);
@@ -927,10 +898,10 @@ TEST(AutofillStructuredName, MigrationFromLegacyStructure_WithoutFullName) {
// This is an edge case that normally should not happen.
// Also, it is ignored that the profile might be verified because a verified
// profile should contain a full name (or potentially no name).
- EXPECT_EQ(name.GetValueForType(NAME_FULL), base::ASCIIToUTF16(""));
- EXPECT_EQ(name.GetValueForType(NAME_FIRST), base::ASCIIToUTF16("Thomas"));
- EXPECT_EQ(name.GetValueForType(NAME_MIDDLE), base::ASCIIToUTF16("Neo"));
- EXPECT_EQ(name.GetValueForType(NAME_LAST), base::ASCIIToUTF16("Anderson"));
+ EXPECT_EQ(name.GetValueForType(NAME_FULL), u"");
+ EXPECT_EQ(name.GetValueForType(NAME_FIRST), u"Thomas");
+ EXPECT_EQ(name.GetValueForType(NAME_MIDDLE), u"Neo");
+ EXPECT_EQ(name.GetValueForType(NAME_LAST), u"Anderson");
EXPECT_EQ(name.GetVerificationStatusForType(NAME_FULL),
VerificationStatus::kNoStatus);
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils.cc b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils.cc
index 0dc7769247a..3fe9d8eaec5 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils.cc
+++ b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils.cc
@@ -113,13 +113,13 @@ RewriterCache* RewriterCache::GetInstance() {
}
// static
-base::string16 RewriterCache::Rewrite(const base::string16& country_code,
- const base::string16& text) {
+std::u16string RewriterCache::Rewrite(const std::u16string& country_code,
+ const std::u16string& text) {
return GetInstance()->GetRewriter(country_code).Rewrite(NormalizeValue(text));
}
const AddressRewriter& RewriterCache::GetRewriter(
- const base::string16& country_code) {
+ const std::u16string& country_code) {
// For thread safety, acquire a lock to prevent concurrent access.
base::AutoLock lock(lock_);
@@ -353,15 +353,15 @@ std::string CaptureTypeWithPattern(const ServerFieldType& type,
std::string(), options);
}
-base::string16 NormalizeValue(base::StringPiece16 value,
+std::u16string NormalizeValue(base::StringPiece16 value,
bool keep_white_space) {
return AutofillProfileComparator::NormalizeForComparison(
value, keep_white_space ? AutofillProfileComparator::RETAIN_WHITESPACE
: AutofillProfileComparator::DISCARD_WHITESPACE);
}
-bool AreStringTokenEquivalent(const base::string16& one,
- const base::string16& other) {
+bool AreStringTokenEquivalent(const std::u16string& one,
+ const std::u16string& other) {
return AreSortedTokensEqual(TokenizeValue(one), TokenizeValue(other));
}
@@ -405,8 +405,8 @@ SortedTokenComparisonResult CompareSortedTokens(
return SortedTokenComparisonResult(SUBSET, additional_tokens);
}
-SortedTokenComparisonResult CompareSortedTokens(const base::string16& first,
- const base::string16& second) {
+SortedTokenComparisonResult CompareSortedTokens(const std::u16string& first,
+ const std::u16string& second) {
return CompareSortedTokens(TokenizeValue(first), TokenizeValue(second));
}
@@ -415,7 +415,7 @@ bool AreSortedTokensEqual(const std::vector<AddressToken>& first,
return CompareSortedTokens(first, second).status == MATCH;
}
-std::vector<AddressToken> TokenizeValue(const base::string16 value) {
+std::vector<AddressToken> TokenizeValue(const std::u16string value) {
std::vector<AddressToken> tokens;
int index = 0;
@@ -424,8 +424,8 @@ std::vector<AddressToken> TokenizeValue(const base::string16 value) {
if (HasCjkNameCharacteristics(base::UTF16ToUTF8(value))) {
tokens.reserve(value.size());
for (size_t i = 0; i < value.size(); i++) {
- base::string16 cjk_separators = base::UTF8ToUTF16("・·  ");
- if (cjk_separators.find(value.substr(i, 1)) == base::string16::npos) {
+ std::u16string cjk_separators = u"・·  ";
+ if (cjk_separators.find(value.substr(i, 1)) == std::u16string::npos) {
tokens.emplace_back(AddressToken{.value = value.substr(i, 1),
.normalized_value = value.substr(i, 1),
.position = index++});
@@ -434,8 +434,8 @@ std::vector<AddressToken> TokenizeValue(const base::string16 value) {
} else {
// Split it by white spaces and commas into non-empty values.
for (const auto& token :
- base::SplitString(value, base::ASCIIToUTF16(", \n"),
- base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) {
+ base::SplitString(value, u", \n", base::TRIM_WHITESPACE,
+ base::SPLIT_WANT_NONEMPTY)) {
tokens.emplace_back(
AddressToken{.value = token,
.normalized_value = NormalizeValue(token),
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils.h b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils.h
index f01c89aa50c..2853c2b19bd 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils.h
+++ b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils.h
@@ -25,9 +25,9 @@ namespace structured_address {
struct AddressToken {
// The original value.
- base::string16 value;
+ std::u16string value;
// The normalized value.
- base::string16 normalized_value;
+ std::u16string normalized_value;
// The token position in the original string.
int position;
};
@@ -150,21 +150,21 @@ class RewriterCache {
// Applies the rewriter to |text| for a specific county given by
// |country_code|.
- static base::string16 Rewrite(const base::string16& country_code,
- const base::string16& text);
+ static std::u16string Rewrite(const std::u16string& country_code,
+ const std::u16string& text);
private:
RewriterCache();
// Returns the Rewriter for |country_code|.
- const AddressRewriter& GetRewriter(const base::string16& country_code);
+ const AddressRewriter& GetRewriter(const std::u16string& country_code);
// Since the constructor is private, |base::NoDestructor| must be friend to be
// allowed to construct the cache.
friend class base::NoDestructor<RewriterCache>;
// Stores a country-specific Rewriter keyed by its corresponding |pattern|.
- std::map<base::string16, const AddressRewriter> rewriter_map_;
+ std::map<std::u16string, const AddressRewriter> rewriter_map_;
// A lock to prevent concurrent access to the map.
base::Lock lock_;
@@ -190,7 +190,7 @@ bool HasMiddleNameInitialsCharacteristics(const std::string& middle_name);
// Reduces a name to the initials in upper case.
// Example: George walker -> GW, Hans-Peter -> HP
-base::string16 ReduceToInitials(const base::string16& value);
+std::u16string ReduceToInitials(const std::u16string& value);
// Parses |value| with an regular expression defined by |pattern|.
// Returns true on success meaning that the expressions is fully matched.
@@ -287,7 +287,7 @@ std::string CaptureTypeWithPattern(
// removes diacritics.
// If |keep_white_spaces| is true, white spaces are collapsed. Otherwise,
// white spaces are completely removed.
-base::string16 NormalizeValue(const base::StringPiece16 value,
+std::u16string NormalizeValue(const base::StringPiece16 value,
bool keep_white_space = true);
// Returns true of both vectors contain the same tokens in the same order.
@@ -295,13 +295,13 @@ bool AreSortedTokensEqual(const std::vector<AddressToken>& first,
const std::vector<AddressToken>& second);
// Returns true if both strings contain the same tokens after normalization.
-bool AreStringTokenEquivalent(const base::string16& one,
- const base::string16& other);
+bool AreStringTokenEquivalent(const std::u16string& one,
+ const std::u16string& other);
// Returns a sorted vector containing the tokens of |value| after |value| was
// canonicalized. |value| is tokenized by splitting it by white spaces and
// commas.
-std::vector<AddressToken> TokenizeValue(const base::string16 value);
+std::vector<AddressToken> TokenizeValue(const std::u16string value);
// Compares two vectors of sorted AddressTokens and returns the
// SortedTokenComparisonResult;
@@ -310,8 +310,8 @@ SortedTokenComparisonResult CompareSortedTokens(
const std::vector<AddressToken>& second);
// Convenience wrapper to supply untokenized strings.
-SortedTokenComparisonResult CompareSortedTokens(const base::string16& first,
- const base::string16& second);
+SortedTokenComparisonResult CompareSortedTokens(const std::u16string& first,
+ const std::u16string& second);
} // namespace structured_address
diff --git a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils_unittest.cc b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils_unittest.cc
index 01fd13bc3ad..3f0f56c89f6 100644
--- a/chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils_unittest.cc
+++ b/chromium/components/autofill/core/browser/data_model/autofill_structured_address_utils_unittest.cc
@@ -230,35 +230,27 @@ TEST(AutofillStructuredAddressUtils, NoCaptureTypeWithPattern) {
TEST(AutofillStructuredAddressUtils, TokenizeValue) {
std::vector<AddressToken> expected_tokens = {
- {base::ASCIIToUTF16("AnD"), base::ASCIIToUTF16("and"), 1},
- {base::ASCIIToUTF16("anotherOne"), base::ASCIIToUTF16("anotherone"), 2},
- {base::ASCIIToUTF16("valUe"), base::ASCIIToUTF16("value"), 0}};
+ {u"AnD", u"and", 1},
+ {u"anotherOne", u"anotherone", 2},
+ {u"valUe", u"value", 0}};
- EXPECT_EQ(TokenizeValue(base::ASCIIToUTF16(" valUe AnD anotherOne")),
- expected_tokens);
+ EXPECT_EQ(TokenizeValue(u" valUe AnD anotherOne"), expected_tokens);
std::vector<AddressToken> expected_cjk_tokens = {
- {base::UTF8ToUTF16("영"), base::UTF8ToUTF16("영"), 1},
- {base::UTF8ToUTF16("이"), base::UTF8ToUTF16("이"), 0},
- {base::UTF8ToUTF16("호"), base::UTF8ToUTF16("호"), 2}};
+ {u"영", u"영", 1}, {u"이", u"이", 0}, {u"호", u"호", 2}};
- EXPECT_EQ(TokenizeValue(base::UTF8ToUTF16("이영 호")), expected_cjk_tokens);
- EXPECT_EQ(TokenizeValue(base::UTF8ToUTF16("이・영호")), expected_cjk_tokens);
- EXPECT_EQ(TokenizeValue(base::UTF8ToUTF16("이영 호")), expected_cjk_tokens);
+ EXPECT_EQ(TokenizeValue(u"이영 호"), expected_cjk_tokens);
+ EXPECT_EQ(TokenizeValue(u"이・영호"), expected_cjk_tokens);
+ EXPECT_EQ(TokenizeValue(u"이영 호"), expected_cjk_tokens);
}
TEST(AutofillStructuredAddressUtils, NormalizeValue) {
- EXPECT_EQ(NormalizeValue(base::UTF8ToUTF16(" MÜLLeR Örber")),
- base::UTF8ToUTF16("muller orber"));
+ EXPECT_EQ(NormalizeValue(u" MÜLLeR Örber"), u"muller orber");
}
TEST(AutofillStructuredAddressUtils, TestGetRewriter) {
- EXPECT_EQ(RewriterCache::Rewrite(base::UTF8ToUTF16("us"),
- base::UTF8ToUTF16("unit #3")),
- base::UTF8ToUTF16("unit 3"));
- EXPECT_EQ(RewriterCache::Rewrite(base::UTF8ToUTF16("us"),
- base::UTF8ToUTF16("california")),
- base::UTF8ToUTF16("ca"));
+ EXPECT_EQ(RewriterCache::Rewrite(u"us", u"unit #3"), u"unit 3");
+ EXPECT_EQ(RewriterCache::Rewrite(u"us", u"california"), u"ca");
}
} // namespace structured_address
diff --git a/chromium/components/autofill/core/browser/data_model/borrowed_transliterator.cc b/chromium/components/autofill/core/browser/data_model/borrowed_transliterator.cc
index 5d59f3278b0..df72ad74494 100644
--- a/chromium/components/autofill/core/browser/data_model/borrowed_transliterator.cc
+++ b/chromium/components/autofill/core/browser/data_model/borrowed_transliterator.cc
@@ -50,7 +50,7 @@ BorrowedTransliterator::GetTransliterator() {
return *instance;
}
-base::string16 RemoveDiacriticsAndConvertToLowerCase(
+std::u16string RemoveDiacriticsAndConvertToLowerCase(
base::StringPiece16 value) {
icu::UnicodeString result = icu::UnicodeString(value.data(), value.length());
BorrowedTransliterator().Transliterate(&result);
diff --git a/chromium/components/autofill/core/browser/data_model/borrowed_transliterator.h b/chromium/components/autofill/core/browser/data_model/borrowed_transliterator.h
index 247edf5b613..110c7d437f5 100644
--- a/chromium/components/autofill/core/browser/data_model/borrowed_transliterator.h
+++ b/chromium/components/autofill/core/browser/data_model/borrowed_transliterator.h
@@ -37,7 +37,7 @@ class BorrowedTransliterator {
// Apply the transliteration to a full string to convert it to lower case and to
// remove the diacritics.
// and remove the diacritics.
-base::string16 RemoveDiacriticsAndConvertToLowerCase(base::StringPiece16 value);
+std::u16string RemoveDiacriticsAndConvertToLowerCase(base::StringPiece16 value);
} // namespace autofill
diff --git a/chromium/components/autofill/core/browser/data_model/borrowed_transliterator_unittest.cc b/chromium/components/autofill/core/browser/data_model/borrowed_transliterator_unittest.cc
index f972854a3c6..d694f941f9a 100644
--- a/chromium/components/autofill/core/browser/data_model/borrowed_transliterator_unittest.cc
+++ b/chromium/components/autofill/core/browser/data_model/borrowed_transliterator_unittest.cc
@@ -14,8 +14,8 @@ namespace autofill {
TEST(BorrowedTransliterator, RemoveDiacriticsAndConvertToLowerCase) {
EXPECT_EQ(RemoveDiacriticsAndConvertToLowerCase(
- base::UTF8ToUTF16("āēaa11.īūčģķļņšžKāäǟḑēīļņōȯȱõȭŗšțūž")),
- base::ASCIIToUTF16("aeaa11.iucgklnszkaaadeilnooooorstuz"));
+ u"āēaa11.īūčģķļņšžKāäǟḑēīļņōȯȱõȭŗšțūž"),
+ u"aeaa11.iucgklnszkaaadeilnooooorstuz");
}
} // namespace autofill
diff --git a/chromium/components/autofill/core/browser/data_model/contact_info.cc b/chromium/components/autofill/core/browser/data_model/contact_info.cc
index a42f4a78f59..8155e9fe99b 100644
--- a/chromium/components/autofill/core/browser/data_model/contact_info.cc
+++ b/chromium/components/autofill/core/browser/data_model/contact_info.cc
@@ -98,7 +98,7 @@ bool NameInfo::operator==(const NameInfo& other) const {
family_ == other.family_ && full_ == other.full_;
}
-base::string16 NameInfo::GetRawInfo(ServerFieldType type) const {
+std::u16string NameInfo::GetRawInfo(ServerFieldType type) const {
DCHECK_EQ(FieldTypeGroup::kName, AutofillType(type).group());
// TODO(crbug.com/1103421): Clean legacy implementation once structured names
@@ -109,7 +109,7 @@ base::string16 NameInfo::GetRawInfo(ServerFieldType type) const {
if ((type == NAME_HONORIFIC_PREFIX ||
type == NAME_FULL_WITH_HONORIFIC_PREFIX) &&
!structured_address::HonorificPrefixEnabled()) {
- return base::string16();
+ return std::u16string();
}
return name_->GetValueForType(type);
}
@@ -130,12 +130,12 @@ base::string16 NameInfo::GetRawInfo(ServerFieldType type) const {
return full_;
default:
- return base::string16();
+ return std::u16string();
}
}
void NameInfo::SetRawInfoWithVerificationStatus(ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
VerificationStatus status) {
DCHECK_EQ(FieldTypeGroup::kName, AutofillType(type).group());
// TODO(crbug.com/1103421): Clean legacy implementation once structured names
@@ -196,7 +196,7 @@ void NameInfo::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
}
}
-base::string16 NameInfo::GetInfoImpl(const AutofillType& type,
+std::u16string NameInfo::GetInfoImpl(const AutofillType& type,
const std::string& app_locale) const {
// TODO(crbug.com/1103421): Clean legacy implementation once structured names
// are fully launched.
@@ -208,7 +208,7 @@ base::string16 NameInfo::GetInfoImpl(const AutofillType& type,
}
bool NameInfo::SetInfoWithVerificationStatusImpl(const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale,
VerificationStatus status) {
// TODO(crbug.com/1103421): Clean legacy implementation once structured names
@@ -240,7 +240,7 @@ bool NameInfo::SetInfoWithVerificationStatusImpl(const AutofillType& type,
status);
}
-void NameInfo::GetMatchingTypes(const base::string16& text,
+void NameInfo::GetMatchingTypes(const std::u16string& text,
const std::string& app_locale,
ServerFieldTypeSet* matching_types) const {
FormGroup::GetMatchingTypes(text, app_locale, matching_types);
@@ -268,7 +268,7 @@ VerificationStatus NameInfo::GetVerificationStatusImpl(
return VerificationStatus::kNoStatus;
}
-base::string16 NameInfo::FullName() const {
+std::u16string NameInfo::FullName() const {
// TODO(crbug.com/1103421): Clean legacy implementation once structured
// names are fully launched.
if (structured_address::StructuredNamesEnabled())
@@ -279,15 +279,15 @@ base::string16 NameInfo::FullName() const {
return data_util::JoinNameParts(given_, middle_, family_);
}
-base::string16 NameInfo::MiddleInitial() const {
+std::u16string NameInfo::MiddleInitial() const {
// TODO(crbug.com/1103421): Clean legacy implementation once structured
// names are fully launched.
if (structured_address::StructuredNamesEnabled())
NOTREACHED();
- return middle_.empty() ? base::string16() : middle_.substr(0U, 1U);
+ return middle_.empty() ? std::u16string() : middle_.substr(0U, 1U);
}
-void NameInfo::SetFullName(const base::string16& full) {
+void NameInfo::SetFullName(const std::u16string& full) {
// TODO(crbug.com/1103421): Clean legacy implementation once structured
// names are fully launched.
if (structured_address::StructuredNamesEnabled())
@@ -323,15 +323,15 @@ void EmailInfo::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
supported_types->insert(EMAIL_ADDRESS);
}
-base::string16 EmailInfo::GetRawInfo(ServerFieldType type) const {
+std::u16string EmailInfo::GetRawInfo(ServerFieldType type) const {
if (type == EMAIL_ADDRESS)
return email_;
- return base::string16();
+ return std::u16string();
}
void EmailInfo::SetRawInfoWithVerificationStatus(ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
VerificationStatus status) {
DCHECK_EQ(EMAIL_ADDRESS, type);
email_ = value;
@@ -364,18 +364,18 @@ void CompanyInfo::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
supported_types->insert(COMPANY_NAME);
}
-base::string16 CompanyInfo::GetRawInfo(ServerFieldType type) const {
- return IsValidOrVerified(company_name_) ? company_name_ : base::string16();
+std::u16string CompanyInfo::GetRawInfo(ServerFieldType type) const {
+ return IsValidOrVerified(company_name_) ? company_name_ : std::u16string();
}
void CompanyInfo::SetRawInfoWithVerificationStatus(ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
VerificationStatus status) {
DCHECK_EQ(COMPANY_NAME, type);
company_name_ = value;
}
-bool CompanyInfo::IsValidOrVerified(const base::string16& value) const {
+bool CompanyInfo::IsValidOrVerified(const std::u16string& value) const {
// TODO(crbug/1117296): retrieve regular expressions dynamically.
static const char* kBirthyearRe = "^(19|20)\\d{2}$";
static const char* kSocialTitleRe =
diff --git a/chromium/components/autofill/core/browser/data_model/contact_info.h b/chromium/components/autofill/core/browser/data_model/contact_info.h
index 818dbed3b7e..9e75f1a6f3d 100644
--- a/chromium/components/autofill/core/browser/data_model/contact_info.h
+++ b/chromium/components/autofill/core/browser/data_model/contact_info.h
@@ -10,7 +10,6 @@
#include <vector>
#include "base/compiler_specific.h"
-#include "base/strings/string16.h"
#include "components/autofill/core/browser/data_model/autofill_structured_address_name.h"
#include "components/autofill/core/browser/data_model/form_group.h"
@@ -30,15 +29,15 @@ class NameInfo : public FormGroup {
bool operator!=(const NameInfo& other) const { return !operator==(other); }
// FormGroup:
- base::string16 GetRawInfo(ServerFieldType type) const override;
+ std::u16string GetRawInfo(ServerFieldType type) const override;
- void GetMatchingTypes(const base::string16& text,
+ void GetMatchingTypes(const std::u16string& text,
const std::string& app_locale,
ServerFieldTypeSet* matching_types) const override;
void SetRawInfoWithVerificationStatus(
ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
structured_address::VerificationStatus status) override;
// Derives all missing tokens in the structured representation of the name by
@@ -77,12 +76,12 @@ class NameInfo : public FormGroup {
private:
// FormGroup:
void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override;
- base::string16 GetInfoImpl(const AutofillType& type,
+ std::u16string GetInfoImpl(const AutofillType& type,
const std::string& app_locale) const override;
bool SetInfoWithVerificationStatusImpl(
const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale,
structured_address::VerificationStatus status) override;
@@ -92,21 +91,21 @@ class NameInfo : public FormGroup {
// Returns the full name, which is either |full_|, or if |full_| is empty,
// is composed of given, middle and family.
- base::string16 FullName() const;
+ std::u16string FullName() const;
// Returns the middle initial if |middle_| is non-empty. Returns an empty
// string otherwise.
- base::string16 MiddleInitial() const;
+ std::u16string MiddleInitial() const;
// Sets |given_|, |middle_|, and |family_| to the tokenized |full|.
- void SetFullName(const base::string16& full);
+ void SetFullName(const std::u16string& full);
// Legacy fields to store the unstructured representation of the name when
// |features::kAutofillEnableSupportForMoreStructureInNames| is not enabled.
- base::string16 given_;
- base::string16 middle_;
- base::string16 family_;
- base::string16 full_;
+ std::u16string given_;
+ std::u16string middle_;
+ std::u16string family_;
+ std::u16string full_;
// This data structure stores the more-structured representation of the name
// when |features::kAutofillEnableSupportForMoreStructureInNames| is enabled.
@@ -124,17 +123,17 @@ class EmailInfo : public FormGroup {
bool operator!=(const EmailInfo& other) const { return !operator==(other); }
// FormGroup:
- base::string16 GetRawInfo(ServerFieldType type) const override;
+ std::u16string GetRawInfo(ServerFieldType type) const override;
void SetRawInfoWithVerificationStatus(
ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
structured_address::VerificationStatus status) override;
private:
// FormGroup:
void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override;
- base::string16 email_;
+ std::u16string email_;
};
class CompanyInfo : public FormGroup {
@@ -149,19 +148,19 @@ class CompanyInfo : public FormGroup {
bool operator!=(const CompanyInfo& other) const { return !operator==(other); }
// FormGroup:
- base::string16 GetRawInfo(ServerFieldType type) const override;
+ std::u16string GetRawInfo(ServerFieldType type) const override;
void SetRawInfoWithVerificationStatus(
ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
structured_address::VerificationStatus status) override;
void set_profile(const AutofillProfile* profile) { profile_ = profile; }
private:
// FormGroup:
void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override;
- bool IsValidOrVerified(const base::string16& value) const;
+ bool IsValidOrVerified(const std::u16string& value) const;
- base::string16 company_name_;
+ std::u16string company_name_;
const AutofillProfile* profile_ = nullptr;
};
diff --git a/chromium/components/autofill/core/browser/data_model/contact_info_unittest.cc b/chromium/components/autofill/core/browser/data_model/contact_info_unittest.cc
index 65385838a4f..97790e6d3df 100644
--- a/chromium/components/autofill/core/browser/data_model/contact_info_unittest.cc
+++ b/chromium/components/autofill/core/browser/data_model/contact_info_unittest.cc
@@ -98,17 +98,17 @@ TEST(NameInfoTest, GetMatchingTypesForStructuredNameWithPrefix) {
test::VerifyFormGroupValues(name, expectation);
ServerFieldTypeSet matching_types;
- name.GetMatchingTypes(base::ASCIIToUTF16("Ruiz"), "US", &matching_types);
+ name.GetMatchingTypes(u"Ruiz", "US", &matching_types);
EXPECT_EQ(matching_types, ServerFieldTypeSet({NAME_LAST_FIRST}));
- name.GetMatchingTypes(base::ASCIIToUTF16("Mr."), "US", &matching_types);
+ name.GetMatchingTypes(u"Mr.", "US", &matching_types);
EXPECT_EQ(matching_types,
ServerFieldTypeSet({NAME_LAST_FIRST, NAME_HONORIFIC_PREFIX}));
// Verify that a field filled with |NAME_FULL_WITH_HONORIFIC_PREFIX| creates a
// |NAME_FULL| vote.
- name.GetMatchingTypes(base::ASCIIToUTF16("Mr. Pablo Diego Ruiz y Picasso"),
- "US", &matching_types);
+ name.GetMatchingTypes(u"Mr. Pablo Diego Ruiz y Picasso", "US",
+ &matching_types);
EXPECT_EQ(matching_types, ServerFieldTypeSet({NAME_FULL, NAME_LAST_FIRST,
NAME_HONORIFIC_PREFIX}));
}
@@ -154,11 +154,11 @@ TEST(NameInfoTest, GetMatchingTypesForStructuredName) {
test::VerifyFormGroupValues(name, expectation);
ServerFieldTypeSet matching_types;
- name.GetMatchingTypes(base::ASCIIToUTF16("Ruiz"), "US", &matching_types);
+ name.GetMatchingTypes(u"Ruiz", "US", &matching_types);
EXPECT_EQ(matching_types, ServerFieldTypeSet({NAME_LAST_FIRST}));
// The honorific prefix is ignored.
- name.GetMatchingTypes(base::ASCIIToUTF16("Mr."), "US", &matching_types);
+ name.GetMatchingTypes(u"Mr.", "US", &matching_types);
EXPECT_EQ(matching_types, ServerFieldTypeSet({NAME_LAST_FIRST}));
}
@@ -203,121 +203,115 @@ TEST(NameInfoTest, GetFullName) {
return;
NameInfo name;
- name.SetRawInfo(NAME_FIRST, ASCIIToUTF16("First"));
- name.SetRawInfo(NAME_MIDDLE, base::string16());
- name.SetRawInfo(NAME_LAST, base::string16());
+ name.SetRawInfo(NAME_FIRST, u"First");
+ name.SetRawInfo(NAME_MIDDLE, std::u16string());
+ name.SetRawInfo(NAME_LAST, std::u16string());
name.FinalizeAfterImport();
- EXPECT_EQ(ASCIIToUTF16("First"), name.GetRawInfo(NAME_FIRST));
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_MIDDLE));
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_LAST));
- EXPECT_EQ(ASCIIToUTF16("First"),
- name.GetInfo(AutofillType(NAME_FULL), "en-US"));
+ EXPECT_EQ(u"First", name.GetRawInfo(NAME_FIRST));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_MIDDLE));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_LAST));
+ EXPECT_EQ(u"First", name.GetInfo(AutofillType(NAME_FULL), "en-US"));
name = NameInfo();
- name.SetRawInfo(NAME_FIRST, base::string16());
- name.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("Middle"));
- name.SetRawInfo(NAME_LAST, base::string16());
+ name.SetRawInfo(NAME_FIRST, std::u16string());
+ name.SetRawInfo(NAME_MIDDLE, u"Middle");
+ name.SetRawInfo(NAME_LAST, std::u16string());
name.FinalizeAfterImport();
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_FIRST));
- EXPECT_EQ(ASCIIToUTF16("Middle"), name.GetRawInfo(NAME_MIDDLE));
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_LAST));
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("Middle"),
- name.GetInfo(AutofillType(NAME_FULL), "en-US"));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_FIRST));
+ EXPECT_EQ(u"Middle", name.GetRawInfo(NAME_MIDDLE));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_LAST));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_FULL));
+ EXPECT_EQ(u"Middle", name.GetInfo(AutofillType(NAME_FULL), "en-US"));
name = NameInfo();
- name.SetRawInfo(NAME_FIRST, base::string16());
- name.SetRawInfo(NAME_MIDDLE, base::string16());
- name.SetRawInfo(NAME_LAST, ASCIIToUTF16("Last"));
+ name.SetRawInfo(NAME_FIRST, std::u16string());
+ name.SetRawInfo(NAME_MIDDLE, std::u16string());
+ name.SetRawInfo(NAME_LAST, u"Last");
name.FinalizeAfterImport();
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_FIRST));
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_MIDDLE));
- EXPECT_EQ(ASCIIToUTF16("Last"), name.GetRawInfo(NAME_LAST));
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("Last"),
- name.GetInfo(AutofillType(NAME_FULL), "en-US"));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_FIRST));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_MIDDLE));
+ EXPECT_EQ(u"Last", name.GetRawInfo(NAME_LAST));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_FULL));
+ EXPECT_EQ(u"Last", name.GetInfo(AutofillType(NAME_FULL), "en-US"));
name = NameInfo();
- name.SetRawInfo(NAME_FIRST, ASCIIToUTF16("First"));
- name.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("Middle"));
- name.SetRawInfo(NAME_LAST, base::string16());
+ name.SetRawInfo(NAME_FIRST, u"First");
+ name.SetRawInfo(NAME_MIDDLE, u"Middle");
+ name.SetRawInfo(NAME_LAST, std::u16string());
name.FinalizeAfterImport();
- EXPECT_EQ(ASCIIToUTF16("First"), name.GetRawInfo(NAME_FIRST));
- EXPECT_EQ(ASCIIToUTF16("Middle"), name.GetRawInfo(NAME_MIDDLE));
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_LAST));
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("First Middle"),
- name.GetInfo(AutofillType(NAME_FULL), "en-US"));
+ EXPECT_EQ(u"First", name.GetRawInfo(NAME_FIRST));
+ EXPECT_EQ(u"Middle", name.GetRawInfo(NAME_MIDDLE));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_LAST));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_FULL));
+ EXPECT_EQ(u"First Middle", name.GetInfo(AutofillType(NAME_FULL), "en-US"));
name = NameInfo();
- name.SetRawInfo(NAME_FIRST, ASCIIToUTF16("First"));
- name.SetRawInfo(NAME_MIDDLE, base::string16());
- name.SetRawInfo(NAME_LAST, ASCIIToUTF16("Last"));
+ name.SetRawInfo(NAME_FIRST, u"First");
+ name.SetRawInfo(NAME_MIDDLE, std::u16string());
+ name.SetRawInfo(NAME_LAST, u"Last");
name.FinalizeAfterImport();
- EXPECT_EQ(ASCIIToUTF16("First"), name.GetRawInfo(NAME_FIRST));
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_MIDDLE));
- EXPECT_EQ(ASCIIToUTF16("Last"), name.GetRawInfo(NAME_LAST));
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("First Last"),
- name.GetInfo(AutofillType(NAME_FULL), "en-US"));
+ EXPECT_EQ(u"First", name.GetRawInfo(NAME_FIRST));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_MIDDLE));
+ EXPECT_EQ(u"Last", name.GetRawInfo(NAME_LAST));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_FULL));
+ EXPECT_EQ(u"First Last", name.GetInfo(AutofillType(NAME_FULL), "en-US"));
name = NameInfo();
- name.SetRawInfo(NAME_FIRST, base::string16());
- name.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("Middle"));
- name.SetRawInfo(NAME_LAST, ASCIIToUTF16("Last"));
+ name.SetRawInfo(NAME_FIRST, std::u16string());
+ name.SetRawInfo(NAME_MIDDLE, u"Middle");
+ name.SetRawInfo(NAME_LAST, u"Last");
name.FinalizeAfterImport();
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_FIRST));
- EXPECT_EQ(ASCIIToUTF16("Middle"), name.GetRawInfo(NAME_MIDDLE));
- EXPECT_EQ(ASCIIToUTF16("Last"), name.GetRawInfo(NAME_LAST));
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("Middle Last"),
- name.GetInfo(AutofillType(NAME_FULL), "en-US"));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_FIRST));
+ EXPECT_EQ(u"Middle", name.GetRawInfo(NAME_MIDDLE));
+ EXPECT_EQ(u"Last", name.GetRawInfo(NAME_LAST));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_FULL));
+ EXPECT_EQ(u"Middle Last", name.GetInfo(AutofillType(NAME_FULL), "en-US"));
name = NameInfo();
- name.SetRawInfo(NAME_FIRST, ASCIIToUTF16("First"));
- name.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("Middle"));
- name.SetRawInfo(NAME_LAST, ASCIIToUTF16("Last"));
+ name.SetRawInfo(NAME_FIRST, u"First");
+ name.SetRawInfo(NAME_MIDDLE, u"Middle");
+ name.SetRawInfo(NAME_LAST, u"Last");
name.FinalizeAfterImport();
- EXPECT_EQ(ASCIIToUTF16("First"), name.GetRawInfo(NAME_FIRST));
- EXPECT_EQ(ASCIIToUTF16("Middle"), name.GetRawInfo(NAME_MIDDLE));
- EXPECT_EQ(ASCIIToUTF16("Last"), name.GetRawInfo(NAME_LAST));
- EXPECT_EQ(base::string16(), name.GetRawInfo(NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("First Middle Last"),
+ EXPECT_EQ(u"First", name.GetRawInfo(NAME_FIRST));
+ EXPECT_EQ(u"Middle", name.GetRawInfo(NAME_MIDDLE));
+ EXPECT_EQ(u"Last", name.GetRawInfo(NAME_LAST));
+ EXPECT_EQ(std::u16string(), name.GetRawInfo(NAME_FULL));
+ EXPECT_EQ(u"First Middle Last",
name.GetInfo(AutofillType(NAME_FULL), "en-US"));
- name.SetRawInfo(NAME_FULL, ASCIIToUTF16("First Middle Last, MD"));
- EXPECT_EQ(name.GetRawInfo(NAME_FIRST), ASCIIToUTF16("First"));
- EXPECT_EQ(name.GetRawInfo(NAME_MIDDLE), ASCIIToUTF16("Middle"));
- EXPECT_EQ(name.GetRawInfo(NAME_LAST), ASCIIToUTF16("Last"));
- EXPECT_EQ(name.GetRawInfo(NAME_FULL), ASCIIToUTF16("First Middle Last, MD"));
- EXPECT_EQ(ASCIIToUTF16("First Middle Last, MD"),
+ name.SetRawInfo(NAME_FULL, u"First Middle Last, MD");
+ EXPECT_EQ(name.GetRawInfo(NAME_FIRST), u"First");
+ EXPECT_EQ(name.GetRawInfo(NAME_MIDDLE), u"Middle");
+ EXPECT_EQ(name.GetRawInfo(NAME_LAST), u"Last");
+ EXPECT_EQ(name.GetRawInfo(NAME_FULL), u"First Middle Last, MD");
+ EXPECT_EQ(u"First Middle Last, MD",
name.GetInfo(AutofillType(NAME_FULL), "en-US"));
// Setting a name to the value it already has: no change.
- name.SetInfo(AutofillType(NAME_FIRST), ASCIIToUTF16("First"), "en-US");
- EXPECT_EQ(name.GetRawInfo(NAME_FIRST), ASCIIToUTF16("First"));
- EXPECT_EQ(name.GetRawInfo(NAME_MIDDLE), ASCIIToUTF16("Middle"));
- EXPECT_EQ(name.GetRawInfo(NAME_LAST), ASCIIToUTF16("Last"));
- EXPECT_EQ(name.GetRawInfo(NAME_FULL), ASCIIToUTF16("First Middle Last, MD"));
- EXPECT_EQ(ASCIIToUTF16("First Middle Last, MD"),
+ name.SetInfo(AutofillType(NAME_FIRST), u"First", "en-US");
+ EXPECT_EQ(name.GetRawInfo(NAME_FIRST), u"First");
+ EXPECT_EQ(name.GetRawInfo(NAME_MIDDLE), u"Middle");
+ EXPECT_EQ(name.GetRawInfo(NAME_LAST), u"Last");
+ EXPECT_EQ(name.GetRawInfo(NAME_FULL), u"First Middle Last, MD");
+ EXPECT_EQ(u"First Middle Last, MD",
name.GetInfo(AutofillType(NAME_FULL), "en-US"));
// Setting raw info: no change. (Even though this leads to a slightly
// inconsistent state.)
- name.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Second"));
- EXPECT_EQ(name.GetRawInfo(NAME_FIRST), ASCIIToUTF16("Second"));
- EXPECT_EQ(name.GetRawInfo(NAME_MIDDLE), ASCIIToUTF16("Middle"));
- EXPECT_EQ(name.GetRawInfo(NAME_LAST), ASCIIToUTF16("Last"));
- EXPECT_EQ(name.GetRawInfo(NAME_FULL), ASCIIToUTF16("First Middle Last, MD"));
- EXPECT_EQ(ASCIIToUTF16("First Middle Last, MD"),
+ name.SetRawInfo(NAME_FIRST, u"Second");
+ EXPECT_EQ(name.GetRawInfo(NAME_FIRST), u"Second");
+ EXPECT_EQ(name.GetRawInfo(NAME_MIDDLE), u"Middle");
+ EXPECT_EQ(name.GetRawInfo(NAME_LAST), u"Last");
+ EXPECT_EQ(name.GetRawInfo(NAME_FULL), u"First Middle Last, MD");
+ EXPECT_EQ(u"First Middle Last, MD",
name.GetInfo(AutofillType(NAME_FULL), "en-US"));
// Changing something (e.g., the first name) clears the stored full name.
- name.SetInfo(AutofillType(NAME_FIRST), ASCIIToUTF16("Third"), "en-US");
- EXPECT_EQ(name.GetRawInfo(NAME_FIRST), ASCIIToUTF16("Third"));
- EXPECT_EQ(name.GetRawInfo(NAME_MIDDLE), ASCIIToUTF16("Middle"));
- EXPECT_EQ(name.GetRawInfo(NAME_LAST), ASCIIToUTF16("Last"));
- EXPECT_EQ(ASCIIToUTF16("Third Middle Last"),
+ name.SetInfo(AutofillType(NAME_FIRST), u"Third", "en-US");
+ EXPECT_EQ(name.GetRawInfo(NAME_FIRST), u"Third");
+ EXPECT_EQ(name.GetRawInfo(NAME_MIDDLE), u"Middle");
+ EXPECT_EQ(name.GetRawInfo(NAME_LAST), u"Last");
+ EXPECT_EQ(u"Third Middle Last",
name.GetInfo(AutofillType(NAME_FULL), "en-US"));
}
@@ -391,14 +385,14 @@ TEST(CompanyTest, CompanyNameSocialTitleCopy) {
CompanyInfo company_year(&profile);
CompanyInfo company_social_title(&profile);
- company_google.SetRawInfo(COMPANY_NAME, UTF8ToUTF16("Google"));
- company_year.SetRawInfo(COMPANY_NAME, UTF8ToUTF16("1987"));
- company_social_title.SetRawInfo(COMPANY_NAME, UTF8ToUTF16("Dr"));
+ company_google.SetRawInfo(COMPANY_NAME, u"Google");
+ company_year.SetRawInfo(COMPANY_NAME, u"1987");
+ company_social_title.SetRawInfo(COMPANY_NAME, u"Dr");
company_google = company_year;
- EXPECT_EQ(UTF8ToUTF16(""), company_google.GetRawInfo(COMPANY_NAME));
+ EXPECT_EQ(u"", company_google.GetRawInfo(COMPANY_NAME));
company_google = company_social_title;
- EXPECT_EQ(UTF8ToUTF16(""), company_google.GetRawInfo(COMPANY_NAME));
+ EXPECT_EQ(u"", company_google.GetRawInfo(COMPANY_NAME));
}
TEST(CompanyTest, CompanyNameYearIsEqual) {
@@ -408,8 +402,8 @@ TEST(CompanyTest, CompanyNameYearIsEqual) {
CompanyInfo company_year(&profile);
CompanyInfo company_social_title(&profile);
- company_year.SetRawInfo(COMPANY_NAME, UTF8ToUTF16("1987"));
- company_social_title.SetRawInfo(COMPANY_NAME, UTF8ToUTF16("Dr"));
+ company_year.SetRawInfo(COMPANY_NAME, u"1987");
+ company_social_title.SetRawInfo(COMPANY_NAME, u"Dr");
EXPECT_EQ(company_year, company_social_title);
}
diff --git a/chromium/components/autofill/core/browser/data_model/credit_card.cc b/chromium/components/autofill/core/browser/data_model/credit_card.cc
index c775eb2c686..e7281177b5a 100644
--- a/chromium/components/autofill/core/browser/data_model/credit_card.cc
+++ b/chromium/components/autofill/core/browser/data_model/credit_card.cc
@@ -18,7 +18,6 @@
#include "base/macros.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
-#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_split.h"
@@ -48,20 +47,22 @@ namespace autofill {
using structured_address::VerificationStatus;
// Unicode characters used in card number obfuscation:
-// - 0x2022 - Bullet.
-// - 0x2006 - SIX-PER-EM SPACE (small space between bullets).
-// - 0x2060 - WORD-JOINER (makes obfuscated string undivisible).
-const base::char16 kMidlineEllipsis[] = {
- 0x2022, 0x2060, 0x2006, 0x2060, 0x2022, 0x2060, 0x2006, 0x2060, 0x2022,
- 0x2060, 0x2006, 0x2060, 0x2022, 0x2060, 0x2006, 0x2060, 0};
+// - \u2022 - Bullet.
+// - \u2006 - SIX-PER-EM SPACE (small space between bullets).
+// - \u2060 - WORD-JOINER (makes obfuscated string undivisible).
+constexpr char16_t kMidlineEllipsis[] =
+ u"\u2022\u2060\u2006\u2060"
+ u"\u2022\u2060\u2006\u2060"
+ u"\u2022\u2060\u2006\u2060"
+ u"\u2022\u2060\u2006\u2060";
namespace {
-const base::char16 kCreditCardObfuscationSymbol = '*';
+const char16_t kCreditCardObfuscationSymbol = '*';
const int kMaxNicknameLength = 25;
-base::string16 NetworkForFill(const std::string& network) {
+std::u16string NetworkForFill(const std::string& network) {
if (network == kAmericanExpressCard)
return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_AMEX);
if (network == kDinersCard)
@@ -86,15 +87,15 @@ base::string16 NetworkForFill(const std::string& network) {
// If you hit this DCHECK, the above list of cases needs to be updated to
// include a new card.
DCHECK_EQ(kGenericCard, network);
- return base::string16();
+ return std::u16string();
}
// Returns the last four digits of the credit card |number| (fewer if there are
// not enough characters in |number|).
-base::string16 GetLastFourDigits(const base::string16& number) {
+std::u16string GetLastFourDigits(const std::u16string& number) {
static const size_t kNumLastDigits = 4;
- base::string16 stripped = CreditCard::StripSeparators(number);
+ std::u16string stripped = CreditCard::StripSeparators(number);
if (stripped.size() <= kNumLastDigits)
return stripped;
@@ -105,8 +106,8 @@ base::string16 GetLastFourDigits(const base::string16& number) {
namespace internal {
-base::string16 GetObfuscatedStringForCardDigits(const base::string16& digits) {
- base::string16 obfuscated_string = base::string16(kMidlineEllipsis) + digits;
+std::u16string GetObfuscatedStringForCardDigits(const std::u16string& digits) {
+ std::u16string obfuscated_string = std::u16string(kMidlineEllipsis) + digits;
base::i18n::WrapStringWithLTRFormatting(&obfuscated_string);
return obfuscated_string;
}
@@ -139,14 +140,14 @@ CreditCard::CreditCard(const CreditCard& credit_card) : CreditCard() {
CreditCard::~CreditCard() {}
// static
-const base::string16 CreditCard::StripSeparators(const base::string16& number) {
- base::string16 stripped;
- base::RemoveChars(number, ASCIIToUTF16("- "), &stripped);
+const std::u16string CreditCard::StripSeparators(const std::u16string& number) {
+ std::u16string stripped;
+ base::RemoveChars(number, u"- ", &stripped);
return stripped;
}
// static
-base::string16 CreditCard::NetworkForDisplay(const std::string& network) {
+std::u16string CreditCard::NetworkForDisplay(const std::string& network) {
if (kGenericCard == network)
return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_GENERIC);
if (kAmericanExpressCard == network)
@@ -185,14 +186,14 @@ int CreditCard::IconResourceId(const std::string& network) {
}
// static
-const char* CreditCard::GetCardNetwork(const base::string16& number) {
+const char* CreditCard::GetCardNetwork(const std::u16string& number) {
// Credit card number specifications taken from:
// https://en.wikipedia.org/wiki/Payment_card_number,
// http://www.regular-expressions.info/creditcard.html,
// https://developer.ean.com/general-info/valid-card-types,
// http://www.bincodes.com/, and
// http://www.fraudpractice.com/FL-binCC.html.
- // (Last updated: February 2020; added Troy)
+ // (Last updated: March 2021; change Troy bin range)
//
// Card Type Prefix(es) Length
// --------------------------------------------------------------------------
@@ -204,12 +205,12 @@ const char* CreditCard::GetCardNetwork(const base::string16& number) {
// JCB 3528-3589 16
// Mastercard 2221-2720, 51-55 16
// MIR 2200-2204 16
- // Troy 2205, 9792 16
+ // Troy 22050-22052, 9792 16
// UnionPay 62 16-19
// Determine the network for the given |number| by going from the longest
// (most specific) prefix to the shortest (most general) prefix.
- base::string16 stripped_number = CreditCard::StripSeparators(number);
+ std::u16string stripped_number = CreditCard::StripSeparators(number);
// Check for prefixes of length 6.
if (stripped_number.size() >= 6) {
@@ -222,6 +223,18 @@ const char* CreditCard::GetCardNetwork(const base::string16& number) {
return kEloCard;
}
+ // Check for prefixes of length 5.
+ if (stripped_number.size() >= 5) {
+ int first_five_digits = 0;
+ if (!base::StringToInt(stripped_number.substr(0, 5), &first_five_digits))
+ return kGenericCard;
+
+ if (first_five_digits == 22050 || first_five_digits == 22051 ||
+ first_five_digits == 22052) {
+ return kTroyCard;
+ }
+ }
+
// Check for prefixes of length 4.
if (stripped_number.size() >= 4) {
int first_four_digits = 0;
@@ -231,7 +244,7 @@ const char* CreditCard::GetCardNetwork(const base::string16& number) {
if (first_four_digits >= 2200 && first_four_digits <= 2204)
return kMirCard;
- if (first_four_digits == 2205 || first_four_digits == 9792)
+ if (first_four_digits == 9792)
return kTroyCard;
if (first_four_digits >= 2221 && first_four_digits <= 2720)
@@ -295,20 +308,20 @@ const char* CreditCard::GetCardNetwork(const base::string16& number) {
}
// static
-bool CreditCard::IsNicknameValid(const base::string16& nickname) {
+bool CreditCard::IsNicknameValid(const std::u16string& nickname) {
// Must not exceed max length.
if (nickname.size() > kMaxNicknameLength)
return false;
// Must not contain newlines, tabs, or carriage returns.
- if (nickname.find('\n') != base::string16::npos ||
- nickname.find('\r') != base::string16::npos ||
- nickname.find('\t') != base::string16::npos) {
+ if (nickname.find('\n') != std::u16string::npos ||
+ nickname.find('\r') != std::u16string::npos ||
+ nickname.find('\t') != std::u16string::npos) {
return false;
}
// Must not contain digits.
- for (base::char16 c : nickname) {
+ for (char16_t c : nickname) {
if (base::IsAsciiDigit(c))
return false;
}
@@ -355,7 +368,7 @@ bool CreditCard::IsDeletable() const {
IsExpired(AutofillClock::Now() - kDisusedDataModelDeletionTimeDelta);
}
-base::string16 CreditCard::GetRawInfo(ServerFieldType type) const {
+std::u16string CreditCard::GetRawInfo(ServerFieldType type) const {
DCHECK_EQ(FieldTypeGroup::kCreditCard, AutofillType(type).group());
switch (type) {
case CREDIT_CARD_NAME_FULL:
@@ -377,19 +390,19 @@ base::string16 CreditCard::GetRawInfo(ServerFieldType type) const {
return Expiration4DigitYearAsString();
case CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR: {
- base::string16 month = Expiration2DigitMonthAsString();
- base::string16 year = Expiration2DigitYearAsString();
+ std::u16string month = Expiration2DigitMonthAsString();
+ std::u16string year = Expiration2DigitYearAsString();
if (!month.empty() && !year.empty())
- return month + ASCIIToUTF16("/") + year;
- return base::string16();
+ return month + u"/" + year;
+ return std::u16string();
}
case CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR: {
- base::string16 month = Expiration2DigitMonthAsString();
- base::string16 year = Expiration4DigitYearAsString();
+ std::u16string month = Expiration2DigitMonthAsString();
+ std::u16string year = Expiration4DigitYearAsString();
if (!month.empty() && !year.empty())
- return month + ASCIIToUTF16("/") + year;
- return base::string16();
+ return month + u"/" + year;
+ return std::u16string();
}
case CREDIT_CARD_TYPE:
@@ -400,16 +413,16 @@ base::string16 CreditCard::GetRawInfo(ServerFieldType type) const {
case CREDIT_CARD_VERIFICATION_CODE:
// Chrome doesn't store credit card verification codes.
- return base::string16();
+ return std::u16string();
default:
// ComputeDataPresentForArray will hit this repeatedly.
- return base::string16();
+ return std::u16string();
}
}
void CreditCard::SetRawInfoWithVerificationStatus(ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
VerificationStatus status) {
DCHECK_EQ(FieldTypeGroup::kCreditCard, AutofillType(type).group());
switch (type) {
@@ -472,12 +485,12 @@ void CreditCard::SetRawInfoWithVerificationStatus(ServerFieldType type,
}
}
-void CreditCard::GetMatchingTypes(const base::string16& text,
+void CreditCard::GetMatchingTypes(const std::u16string& text,
const std::string& app_locale,
ServerFieldTypeSet* matching_types) const {
FormGroup::GetMatchingTypes(text, app_locale, matching_types);
- base::string16 card_number =
+ std::u16string card_number =
GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale);
if (!card_number.empty()) {
// We only have the last four digits for masked cards, so match against
@@ -496,13 +509,13 @@ void CreditCard::GetMatchingTypes(const base::string16& text,
}
}
-void CreditCard::SetInfoForMonthInputType(const base::string16& value) {
+void CreditCard::SetInfoForMonthInputType(const std::u16string& value) {
// Check if |text| is "yyyy-mm" format first, and check normal month format.
- if (!MatchesPattern(value, base::UTF8ToUTF16("^[0-9]{4}-[0-9]{1,2}$")))
+ if (!MatchesPattern(value, u"^[0-9]{4}-[0-9]{1,2}$"))
return;
std::vector<base::StringPiece16> year_month = base::SplitStringPiece(
- value, ASCIIToUTF16("-"), base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
+ value, u"-", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
DCHECK_EQ(2u, year_month.size());
int num = 0;
bool converted = false;
@@ -522,13 +535,12 @@ void CreditCard::SetExpirationYear(int expiration_year) {
data_util::SetExpirationYear(expiration_year, &expiration_year_);
}
-void CreditCard::SetNickname(const base::string16& nickname) {
+void CreditCard::SetNickname(const std::u16string& nickname) {
// First replace all tabs and newlines with whitespaces and store it as
// |nickname_|.
- base::ReplaceChars(nickname, base::ASCIIToUTF16("\t\r\n"),
- base::ASCIIToUTF16(" "), &nickname_);
+ base::ReplaceChars(nickname, u"\t\r\n", u" ", &nickname_);
// Then trim leading/trailing whitespaces from |nickname_|.
- base::TrimString(nickname_, base::ASCIIToUTF16(" "), &nickname_);
+ base::TrimString(nickname_, u" ", &nickname_);
}
bool CreditCard::IsGoogleIssuedCard() const {
@@ -738,38 +750,37 @@ bool CreditCard::HasValidExpirationDate() const {
AutofillClock::Now());
}
-bool CreditCard::SetExpirationMonthFromString(const base::string16& text,
+bool CreditCard::SetExpirationMonthFromString(const std::u16string& text,
const std::string& app_locale) {
return data_util::ParseExpirationMonth(text, app_locale, &expiration_month_);
}
-bool CreditCard::SetExpirationYearFromString(const base::string16& text) {
+bool CreditCard::SetExpirationYearFromString(const std::u16string& text) {
return data_util::ParseExpirationYear(text, &expiration_year_);
}
-void CreditCard::SetExpirationDateFromString(const base::string16& text) {
+void CreditCard::SetExpirationDateFromString(const std::u16string& text) {
// Check that |text| fits the supported patterns: mmyy, mmyyyy, m-yy,
// mm-yy, m-yyyy and mm-yyyy. Note that myy and myyyy matched by this pattern
// but are not supported (ambiguous). Separators: -, / and |.
- if (!MatchesPattern(text, base::UTF8ToUTF16("^[0-9]{1,2}[-/|]?[0-9]{2,4}$")))
+ if (!MatchesPattern(text, u"^[0-9]{1,2}[-/|]?[0-9]{2,4}$"))
return;
- base::string16 month;
- base::string16 year;
+ std::u16string month;
+ std::u16string year;
// Check for a separator.
- base::string16 found_separator;
- const std::vector<base::string16> kSeparators{
- ASCIIToUTF16("-"), ASCIIToUTF16("/"), ASCIIToUTF16("|")};
- for (const base::string16& separator : kSeparators) {
- if (text.find(separator) != base::string16::npos) {
+ std::u16string found_separator;
+ const std::vector<std::u16string> kSeparators{u"-", u"/", u"|"};
+ for (const std::u16string& separator : kSeparators) {
+ if (text.find(separator) != std::u16string::npos) {
found_separator = separator;
break;
}
}
if (!found_separator.empty()) {
- std::vector<base::string16> month_year = base::SplitString(
+ std::vector<std::u16string> month_year = base::SplitString(
text, found_separator, base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
DCHECK_EQ(2u, month_year.size());
month = month_year[0];
@@ -793,45 +804,45 @@ void CreditCard::SetExpirationDateFromString(const base::string16& text) {
SetExpirationYear(num);
}
-const std::pair<base::string16, base::string16> CreditCard::LabelPieces()
+const std::pair<std::u16string, std::u16string> CreditCard::LabelPieces()
const {
- base::string16 label;
+ std::u16string label;
if (number().empty()) {
// No CC number, if valid nickname is present, return nickname only.
// Otherwise, return cardholder name only.
if (HasNonEmptyValidNickname())
- return std::make_pair(nickname_, base::string16());
+ return std::make_pair(nickname_, std::u16string());
- return std::make_pair(name_on_card_, base::string16());
+ return std::make_pair(name_on_card_, std::u16string());
}
- base::string16 obfuscated_cc_number =
+ std::u16string obfuscated_cc_number =
CardIdentifierStringForAutofillDisplay();
// No expiration date set.
if (!expiration_month_ || !expiration_year_)
- return std::make_pair(obfuscated_cc_number, base::string16());
+ return std::make_pair(obfuscated_cc_number, std::u16string());
- base::string16 formatted_date = ExpirationDateForDisplay();
+ std::u16string formatted_date = ExpirationDateForDisplay();
- base::string16 separator =
+ std::u16string separator =
l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_SUMMARY_SEPARATOR);
return std::make_pair(obfuscated_cc_number, separator + formatted_date);
}
-const base::string16 CreditCard::Label() const {
- std::pair<base::string16, base::string16> pieces = LabelPieces();
+const std::u16string CreditCard::Label() const {
+ std::pair<std::u16string, std::u16string> pieces = LabelPieces();
return pieces.first + pieces.second;
}
-base::string16 CreditCard::LastFourDigits() const {
+std::u16string CreditCard::LastFourDigits() const {
return GetLastFourDigits(number_);
}
-base::string16 CreditCard::NetworkForDisplay() const {
+std::u16string CreditCard::NetworkForDisplay() const {
return CreditCard::NetworkForDisplay(network_);
}
-base::string16 CreditCard::ObfuscatedLastFourDigits() const {
+std::u16string CreditCard::ObfuscatedLastFourDigits() const {
return internal::GetObfuscatedStringForCardDigits(LastFourDigits());
}
@@ -843,59 +854,59 @@ std::string CreditCard::CardIconStringForAutofillSuggestion() const {
return network_;
}
-base::string16 CreditCard::NetworkAndLastFourDigits() const {
- const base::string16 network = NetworkForDisplay();
+std::u16string CreditCard::NetworkAndLastFourDigits() const {
+ const std::u16string network = NetworkForDisplay();
// TODO(crbug.com/734197): truncate network.
- const base::string16 digits = LastFourDigits();
+ const std::u16string digits = LastFourDigits();
if (digits.empty())
return network;
// TODO(estade): i18n?
- const base::string16 obfuscated_string =
+ const std::u16string obfuscated_string =
internal::GetObfuscatedStringForCardDigits(digits);
return network.empty() ? obfuscated_string
- : network + ASCIIToUTF16(" ") + obfuscated_string;
+ : network + u" " + obfuscated_string;
}
-base::string16 CreditCard::CardIdentifierStringForAutofillDisplay(
- base::string16 customized_nickname) const {
+std::u16string CreditCard::CardIdentifierStringForAutofillDisplay(
+ std::u16string customized_nickname) const {
if (HasNonEmptyValidNickname() || !customized_nickname.empty()) {
return NicknameAndLastFourDigits(customized_nickname);
}
- base::string16 networkAndLastFourDigits = NetworkAndLastFourDigits();
+ std::u16string networkAndLastFourDigits = NetworkAndLastFourDigits();
// Add Plex before the network and last four digits to identify it as a Google
// Plex card.
if (base::FeatureList::IsEnabled(features::kAutofillEnableGoogleIssuedCard) &&
IsGoogleIssuedCard()) {
- return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_GOOGLE_ISSUED) +
- ASCIIToUTF16(" ") + networkAndLastFourDigits;
+ return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_GOOGLE_ISSUED) + u" " +
+ networkAndLastFourDigits;
}
return networkAndLastFourDigits;
}
-base::string16 CreditCard::CardIdentifierStringAndDescriptiveExpiration(
+std::u16string CreditCard::CardIdentifierStringAndDescriptiveExpiration(
const std::string& app_locale,
- base::string16 customized_nickname) const {
+ std::u16string customized_nickname) const {
return l10n_util::GetStringFUTF16(
IDS_AUTOFILL_CREDIT_CARD_TWO_LINE_LABEL_FROM_NAME,
CardIdentifierStringForAutofillDisplay(customized_nickname),
GetInfo(AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale));
}
-base::string16 CreditCard::DescriptiveExpiration(
+std::u16string CreditCard::DescriptiveExpiration(
const std::string& app_locale) const {
return l10n_util::GetStringFUTF16(
IDS_AUTOFILL_CREDIT_CARD_TWO_LINE_LABEL_FROM_CARD_NUMBER,
GetInfo(AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale));
}
-base::string16 CreditCard::AbbreviatedExpirationDateForDisplay(
+std::u16string CreditCard::AbbreviatedExpirationDateForDisplay(
bool with_prefix) const {
- base::string16 month = Expiration2DigitMonthAsString();
- base::string16 year = Expiration2DigitYearAsString();
+ std::u16string month = Expiration2DigitMonthAsString();
+ std::u16string year = Expiration2DigitYearAsString();
if (month.empty() || year.empty())
- return base::string16();
+ return std::u16string();
return l10n_util::GetStringFUTF16(
with_prefix ? IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_ABBR
@@ -903,18 +914,18 @@ base::string16 CreditCard::AbbreviatedExpirationDateForDisplay(
month, year);
}
-base::string16 CreditCard::ExpirationDateForDisplay() const {
- base::string16 formatted_date(Expiration2DigitMonthAsString());
- formatted_date.append(ASCIIToUTF16("/"));
+std::u16string CreditCard::ExpirationDateForDisplay() const {
+ std::u16string formatted_date(Expiration2DigitMonthAsString());
+ formatted_date.append(u"/");
formatted_date.append(Expiration4DigitYearAsString());
return formatted_date;
}
-base::string16 CreditCard::Expiration2DigitMonthAsString() const {
+std::u16string CreditCard::Expiration2DigitMonthAsString() const {
return data_util::Expiration2DigitMonthAsString(expiration_month_);
}
-base::string16 CreditCard::Expiration4DigitYearAsString() const {
+std::u16string CreditCard::Expiration4DigitYearAsString() const {
return data_util::Expiration4DigitYearAsString(expiration_year_);
}
@@ -935,11 +946,11 @@ bool CreditCard::HasNonEmptyValidNickname() const {
return CreditCard::IsNicknameValid(nickname_);
}
-base::string16 CreditCard::NicknameAndLastFourDigitsForTesting() const {
+std::u16string CreditCard::NicknameAndLastFourDigitsForTesting() const {
return NicknameAndLastFourDigits();
}
-base::string16 CreditCard::Expiration2DigitYearAsString() const {
+std::u16string CreditCard::Expiration2DigitYearAsString() const {
return data_util::Expiration2DigitYearAsString(expiration_year_);
}
@@ -956,7 +967,7 @@ void CreditCard::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
supported_types->insert(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR);
}
-base::string16 CreditCard::GetInfoImpl(const AutofillType& type,
+std::u16string CreditCard::GetInfoImpl(const AutofillType& type,
const std::string& app_locale) const {
ServerFieldType storable_type = type.GetStorableType();
if (storable_type == CREDIT_CARD_NUMBER) {
@@ -973,7 +984,7 @@ base::string16 CreditCard::GetInfoImpl(const AutofillType& type,
bool CreditCard::SetInfoWithVerificationStatusImpl(
const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale,
VerificationStatus status) {
ServerFieldType storable_type = type.GetStorableType();
@@ -989,26 +1000,25 @@ bool CreditCard::SetInfoWithVerificationStatusImpl(
return true;
}
-base::string16 CreditCard::NetworkForFill() const {
+std::u16string CreditCard::NetworkForFill() const {
return ::autofill::NetworkForFill(network_);
}
-base::string16 CreditCard::NicknameAndLastFourDigits(
- base::string16 customized_nickname) const {
+std::u16string CreditCard::NicknameAndLastFourDigits(
+ std::u16string customized_nickname) const {
// Should call HasNonEmptyValidNickname() to check valid nickname before
// calling this.
DCHECK(HasNonEmptyValidNickname() || !customized_nickname.empty());
- const base::string16 digits = LastFourDigits();
+ const std::u16string digits = LastFourDigits();
// If digits are empty, return nickname.
if (digits.empty())
return customized_nickname.empty() ? nickname_ : customized_nickname;
return (customized_nickname.empty() ? nickname_ : customized_nickname) +
- ASCIIToUTF16(" ") +
- internal::GetObfuscatedStringForCardDigits(digits);
+ u" " + internal::GetObfuscatedStringForCardDigits(digits);
}
-void CreditCard::SetNumber(const base::string16& number) {
+void CreditCard::SetNumber(const std::u16string& number) {
number_ = number;
// Set the type based on the card number, but only for full numbers, not
@@ -1063,8 +1073,7 @@ std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card) {
void CreditCard::SetNameOnCardFromSeparateParts() {
DCHECK(name_on_card_.empty() && !temp_card_first_name_.empty() &&
!temp_card_last_name_.empty());
- name_on_card_ =
- temp_card_first_name_ + base::UTF8ToUTF16(" ") + temp_card_last_name_;
+ name_on_card_ = temp_card_first_name_ + u" " + temp_card_last_name_;
}
const char kAmericanExpressCard[] = "americanExpressCC";
diff --git a/chromium/components/autofill/core/browser/data_model/credit_card.h b/chromium/components/autofill/core/browser/data_model/credit_card.h
index ab8d3c91163..ce2d224dfde 100644
--- a/chromium/components/autofill/core/browser/data_model/credit_card.h
+++ b/chromium/components/autofill/core/browser/data_model/credit_card.h
@@ -12,7 +12,6 @@
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
-#include "base/strings/string16.h"
#include "base/strings/string_piece_forward.h"
#include "build/build_config.h"
#include "components/autofill/core/browser/data_model/autofill_data_model.h"
@@ -23,7 +22,7 @@ namespace autofill {
struct AutofillMetadata;
// A midline horizontal ellipsis (U+22EF).
-extern const base::char16 kMidlineEllipsis[];
+extern const char16_t kMidlineEllipsis[];
namespace internal {
@@ -32,7 +31,7 @@ namespace internal {
// digits, even for RTL languages, inserts a Left-To-Right Embedding mark at the
// beginning and a Pop Directional Formatting mark at the end.
// Exposed for testing.
-base::string16 GetObfuscatedStringForCardDigits(const base::string16& digits);
+std::u16string GetObfuscatedStringForCardDigits(const std::u16string& digits);
} // namespace internal
@@ -78,10 +77,10 @@ class CreditCard : public AutofillDataModel {
~CreditCard() override;
// Returns a version of |number| that has any separator characters removed.
- static const base::string16 StripSeparators(const base::string16& number);
+ static const std::u16string StripSeparators(const std::u16string& number);
// The user-visible issuer network of the card, e.g. 'Mastercard'.
- static base::string16 NetworkForDisplay(const std::string& network);
+ static std::u16string NetworkForDisplay(const std::string& network);
// The ResourceBundle ID for the appropriate card issuer network image.
static int IconResourceId(const std::string& network);
@@ -94,11 +93,11 @@ class CreditCard : public AutofillDataModel {
// Hence, the returned issuer network for both the valid card
// "4111-1111-1111-1111" and the invalid card "4garbage" will be Visa, which
// has an IIN of 4.
- static const char* GetCardNetwork(const base::string16& number);
+ static const char* GetCardNetwork(const std::u16string& number);
// Returns whether the nickname is valid. Note that empty nicknames are valid
// because they are not required.
- static bool IsNicknameValid(const base::string16& nickname);
+ static bool IsNicknameValid(const std::u16string& nickname);
// Network issuer strings are defined at the bottom of this file, e.g.
// kVisaCard.
@@ -116,17 +115,17 @@ class CreditCard : public AutofillDataModel {
bool IsDeletable() const override;
// FormGroup:
- void GetMatchingTypes(const base::string16& text,
+ void GetMatchingTypes(const std::u16string& text,
const std::string& app_locale,
ServerFieldTypeSet* matching_types) const override;
- base::string16 GetRawInfo(ServerFieldType type) const override;
+ std::u16string GetRawInfo(ServerFieldType type) const override;
void SetRawInfoWithVerificationStatus(
ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
structured_address::VerificationStatus status) override;
// Special method to set value for HTML5 month input type.
- void SetInfoForMonthInputType(const base::string16& value);
+ void SetInfoForMonthInputType(const std::u16string& value);
const std::string& network() const { return network_; }
@@ -145,7 +144,7 @@ class CreditCard : public AutofillDataModel {
const std::string& server_id() const { return server_id_; }
void set_server_id(const std::string& server_id) { server_id_ = server_id; }
- const base::string16& nickname() const { return nickname_; }
+ const std::u16string& nickname() const { return nickname_; }
int64_t instrument_id() const { return instrument_id_; }
void set_instrument_id(int64_t instrument_id) {
@@ -154,7 +153,7 @@ class CreditCard : public AutofillDataModel {
// Set the nickname with the processed input (replace all tabs and newlines
// with whitespaces, and trim leading/trailing whitespaces).
- void SetNickname(const base::string16& nickname);
+ void SetNickname(const std::u16string& nickname);
Issuer card_issuer() const { return card_issuer_; }
void set_card_issuer(Issuer card_issuer) { card_issuer_ = card_issuer; }
@@ -215,10 +214,10 @@ class CreditCard : public AutofillDataModel {
bool IsValid() const;
// Returns the card number.
- const base::string16& number() const { return number_; }
+ const std::u16string& number() const { return number_; }
// Sets |number_| to |number| and computes the appropriate card issuer
// |network_|.
- void SetNumber(const base::string16& number);
+ void SetNumber(const std::u16string& number);
// Logs the number of days since the card was last used and records its use.
void RecordAndLogUse();
@@ -236,65 +235,65 @@ class CreditCard : public AutofillDataModel {
// Sets |expiration_month_| to the integer conversion of |text| and returns
// whether the operation was successful.
- bool SetExpirationMonthFromString(const base::string16& text,
+ bool SetExpirationMonthFromString(const std::u16string& text,
const std::string& app_locale);
// Sets |expiration_year_| to the integer conversion of |text|. Will handle
// 4-digit year or 2-digit year (eventually converted to 4-digit year).
// Returns whether the operation was successful.
- bool SetExpirationYearFromString(const base::string16& text);
+ bool SetExpirationYearFromString(const std::u16string& text);
// Sets |expiration_year_| and |expiration_month_| to the integer conversion
// of |text|. Will handle mmyy, mmyyyy, mm-yyyy and mm-yy as well as single
// digit months, with various separators.
- void SetExpirationDateFromString(const base::string16& text);
+ void SetExpirationDateFromString(const std::u16string& text);
// Various display functions.
// Card preview summary, for example: "Nickname/Network - ****1234",
// ", 01/2020".
- const std::pair<base::string16, base::string16> LabelPieces() const;
+ const std::pair<std::u16string, std::u16string> LabelPieces() const;
// Like LabelPieces, but appends the two pieces together.
- const base::string16 Label() const;
+ const std::u16string Label() const;
// The last four digits of the card number (or possibly less if there aren't
// enough characters).
- base::string16 LastFourDigits() const;
+ std::u16string LastFourDigits() const;
// The user-visible issuer network of the card, e.g. 'Mastercard'.
- base::string16 NetworkForDisplay() const;
+ std::u16string NetworkForDisplay() const;
// A label for this card formatted as '****2345'.
- base::string16 ObfuscatedLastFourDigits() const;
+ std::u16string ObfuscatedLastFourDigits() const;
// The string used to represent the icon to be used for the autofill
// suggestion. For ex: visaCC, googleIssuedCC, americanExpressCC, etc.
std::string CardIconStringForAutofillSuggestion() const;
// A label for this card formatted as 'IssuerNetwork - ****2345'.
- base::string16 NetworkAndLastFourDigits() const;
+ std::u16string NetworkAndLastFourDigits() const;
// A label for this card formatted as 'Nickname - ****2345' if nickname is
// available and valid; otherwise, formatted as 'IssuerNetwork - ****2345'.
// Google-issued cards have their own specific identifier, instead of
// displaying the issuer network name.
- base::string16 CardIdentifierStringForAutofillDisplay(
- base::string16 customized_nickname = base::string16()) const;
+ std::u16string CardIdentifierStringForAutofillDisplay(
+ std::u16string customized_nickname = std::u16string()) const;
// A label for this card formatted as 'Nickname - ****2345, expires on MM/YY'
// if nickname experiment is turned on and nickname is available; otherwise,
// formatted as 'IssuerNetwork - ****2345, expires on MM/YY'.
// This label is used as a second line label when the cardholder
// name/expiration date field is selected.
- base::string16 CardIdentifierStringAndDescriptiveExpiration(
+ std::u16string CardIdentifierStringAndDescriptiveExpiration(
const std::string& app_locale,
- base::string16 customized_nickname = base::string16()) const;
+ std::u16string customized_nickname = std::u16string()) const;
// A label for this card formatted as 'Expires on MM/YY'.
// This label is used as a second line label when the autofill dropdown
// uses a two line layout and the credit card number is selected.
- base::string16 DescriptiveExpiration(const std::string& app_locale) const;
+ std::u16string DescriptiveExpiration(const std::string& app_locale) const;
// Localized expiration for this card formatted as 'Exp: 06/17' if with_prefix
// is true or as '06/17' otherwise.
- base::string16 AbbreviatedExpirationDateForDisplay(bool with_prefix) const;
+ std::u16string AbbreviatedExpirationDateForDisplay(bool with_prefix) const;
// Formatted expiration date (e.g., 05/2020).
- base::string16 ExpirationDateForDisplay() const;
+ std::u16string ExpirationDateForDisplay() const;
// Expiration functions.
- base::string16 Expiration2DigitMonthAsString() const;
- base::string16 Expiration4DigitYearAsString() const;
+ std::u16string Expiration2DigitMonthAsString() const;
+ std::u16string Expiration4DigitYearAsString() const;
// Whether the cardholder name was created from separate first name and last
// name fields.
@@ -308,31 +307,31 @@ class CreditCard : public AutofillDataModel {
bool HasNonEmptyValidNickname() const;
// Should be used ONLY by tests.
- base::string16 NicknameAndLastFourDigitsForTesting() const;
+ std::u16string NicknameAndLastFourDigitsForTesting() const;
private:
FRIEND_TEST_ALL_PREFIXES(CreditCardTest, SetExpirationDateFromString);
FRIEND_TEST_ALL_PREFIXES(CreditCardTest, SetExpirationYearFromString);
- base::string16 Expiration2DigitYearAsString() const;
+ std::u16string Expiration2DigitYearAsString() const;
// FormGroup:
void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override;
- base::string16 GetInfoImpl(const AutofillType& type,
+ std::u16string GetInfoImpl(const AutofillType& type,
const std::string& app_locale) const override;
bool SetInfoWithVerificationStatusImpl(
const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale,
structured_address::VerificationStatus status) override;
// The issuer network of the card to fill in to the page, e.g. 'Mastercard'.
- base::string16 NetworkForFill() const;
+ std::u16string NetworkForFill() const;
// A label for this card formatted as 'Nickname - ****2345'. Always call
// HasNonEmptyValidNickname() before calling this.
- base::string16 NicknameAndLastFourDigits(
- base::string16 customized_nickname = base::string16()) const;
+ std::u16string NicknameAndLastFourDigits(
+ std::u16string customized_nickname = std::u16string()) const;
// Sets the name_on_card_ value based on the saved name parts.
void SetNameOnCardFromSeparateParts();
@@ -342,10 +341,10 @@ class CreditCard : public AutofillDataModel {
// The card number. For MASKED_SERVER_CARDs, this number will just contain the
// last four digits of the card number.
- base::string16 number_;
+ std::u16string number_;
// The cardholder's name. May be empty.
- base::string16 name_on_card_;
+ std::u16string name_on_card_;
// The network issuer of the card. This is one of the k...Card constants
// below.
@@ -373,14 +372,14 @@ class CreditCard : public AutofillDataModel {
// The credit card holder's name parts. Used when creating a new card to hold
// on to the value until the credit card holder's other name part is set,
// since we only store the full name.
- base::string16 temp_card_first_name_;
- base::string16 temp_card_last_name_;
+ std::u16string temp_card_first_name_;
+ std::u16string temp_card_last_name_;
// Info of tokenizized credit card if available.
sync_pb::CloudTokenData cloud_token_data_;
// The nickname of the card. May be empty when nickname is not set.
- base::string16 nickname_;
+ std::u16string nickname_;
// The issuer for the card. This is populated from the sync response. It has a
// default value of CreditCard::ISSUER_UNKNOWN.
diff --git a/chromium/components/autofill/core/browser/data_model/credit_card_cloud_token_data.cc b/chromium/components/autofill/core/browser/data_model/credit_card_cloud_token_data.cc
index 6a45c22e962..f4d3de94ec5 100644
--- a/chromium/components/autofill/core/browser/data_model/credit_card_cloud_token_data.cc
+++ b/chromium/components/autofill/core/browser/data_model/credit_card_cloud_token_data.cc
@@ -24,26 +24,26 @@ bool CreditCardCloudTokenData::operator!=(
return Compare(other_data) != 0;
}
-base::string16 CreditCardCloudTokenData::ExpirationMonthAsString() const {
+std::u16string CreditCardCloudTokenData::ExpirationMonthAsString() const {
return data_util::Expiration2DigitMonthAsString(exp_month);
}
-base::string16 CreditCardCloudTokenData::Expiration2DigitYearAsString() const {
+std::u16string CreditCardCloudTokenData::Expiration2DigitYearAsString() const {
return data_util::Expiration2DigitYearAsString(exp_year);
}
-base::string16 CreditCardCloudTokenData::Expiration4DigitYearAsString() const {
+std::u16string CreditCardCloudTokenData::Expiration4DigitYearAsString() const {
return data_util::Expiration4DigitYearAsString(exp_year);
}
void CreditCardCloudTokenData::SetExpirationMonthFromString(
- const base::string16& month) {
+ const std::u16string& month) {
data_util::ParseExpirationMonth(month, /*app_locale=*/std::string(),
&exp_month);
}
void CreditCardCloudTokenData::SetExpirationYearFromString(
- const base::string16& year) {
+ const std::u16string& year) {
data_util::ParseExpirationYear(year, &exp_year);
}
diff --git a/chromium/components/autofill/core/browser/data_model/credit_card_cloud_token_data.h b/chromium/components/autofill/core/browser/data_model/credit_card_cloud_token_data.h
index 516fbbaec57..b43f7eb1c0a 100644
--- a/chromium/components/autofill/core/browser/data_model/credit_card_cloud_token_data.h
+++ b/chromium/components/autofill/core/browser/data_model/credit_card_cloud_token_data.h
@@ -7,7 +7,6 @@
#include <string>
-#include "base/strings/string16.h"
namespace autofill {
@@ -21,11 +20,11 @@ struct CreditCardCloudTokenData {
bool operator==(const CreditCardCloudTokenData&) const;
bool operator!=(const CreditCardCloudTokenData&) const;
- base::string16 ExpirationMonthAsString() const;
- base::string16 Expiration2DigitYearAsString() const;
- base::string16 Expiration4DigitYearAsString() const;
- void SetExpirationMonthFromString(const base::string16& month);
- void SetExpirationYearFromString(const base::string16& year);
+ std::u16string ExpirationMonthAsString() const;
+ std::u16string Expiration2DigitYearAsString() const;
+ std::u16string Expiration4DigitYearAsString() const;
+ void SetExpirationMonthFromString(const std::u16string& month);
+ void SetExpirationYearFromString(const std::u16string& year);
// Used by Autofill Wallet sync bridge to compute the difference between two
// CreditCardCloudTokenData.
@@ -35,7 +34,7 @@ struct CreditCardCloudTokenData {
std::string masked_card_id;
// The last 4-5 digits of the Cloud Primary Account Number (CPAN).
- base::string16 suffix;
+ std::u16string suffix;
// The expiration month of the CPAN.
int exp_month = 0;
diff --git a/chromium/components/autofill/core/browser/data_model/credit_card_unittest.cc b/chromium/components/autofill/core/browser/data_model/credit_card_unittest.cc
index 21923678ee9..86c808a92d9 100644
--- a/chromium/components/autofill/core/browser/data_model/credit_card_unittest.cc
+++ b/chromium/components/autofill/core/browser/data_model/credit_card_unittest.cc
@@ -4,9 +4,10 @@
#include <stddef.h>
+#include <string>
+
#include "base/guid.h"
#include "base/macros.h"
-#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
@@ -80,7 +81,7 @@ const char* const kEmptyNickname = "";
// Time moves on. Today is yesterday's tomorrow. Tests don't like time moving
// on, in particular if Credit Card expiration is compared to local time.
// Use this function to generate a year in the future.
-base::string16 GetYearInTheFuture() {
+std::u16string GetYearInTheFuture() {
base::Time::Exploded now;
AutofillClock::Now().LocalExplode(&now);
return base::NumberToString16(now.year + 4);
@@ -89,9 +90,9 @@ base::string16 GetYearInTheFuture() {
} // namespace
TEST(CreditCardTest, GetObfuscatedStringForCardDigits) {
- const base::string16 digits = base::ASCIIToUTF16("1235");
- const base::string16 expected =
- base::string16() + base::i18n::kLeftToRightEmbeddingMark +
+ const std::u16string digits = u"1235";
+ const std::u16string expected =
+ std::u16string() + base::i18n::kLeftToRightEmbeddingMark +
kMidlineEllipsis + digits + base::i18n::kPopDirectionalFormatting;
EXPECT_EQ(expected, internal::GetObfuscatedStringForCardDigits(digits));
}
@@ -100,30 +101,30 @@ TEST(CreditCardTest, GetObfuscatedStringForCardDigits) {
// of different possible summary strings. Variations occur based on the
// existence of credit card number, month, and year fields.
TEST(CreditCardTest, PreviewSummaryAndNetworkAndLastFourDigitsStrings) {
- base::string16 valid_nickname = ASCIIToUTF16("My Visa Card");
+ std::u16string valid_nickname = u"My Visa Card";
// Case 0: empty credit card.
CreditCard credit_card0(base::GenerateGUID(), "https://www.example.com/");
- base::string16 summary0 = credit_card0.Label();
- EXPECT_EQ(base::string16(), summary0);
- base::string16 obfuscated0 = credit_card0.NetworkAndLastFourDigits();
+ std::u16string summary0 = credit_card0.Label();
+ EXPECT_EQ(std::u16string(), summary0);
+ std::u16string obfuscated0 = credit_card0.NetworkAndLastFourDigits();
EXPECT_EQ(ASCIIToUTF16(std::string("Card")), obfuscated0);
// Case 00: Empty credit card with empty strings.
CreditCard credit_card00(base::GenerateGUID(), "https://www.example.com/");
test::SetCreditCardInfo(&credit_card00, "John Dillinger", "", "", "", "");
- base::string16 summary00 = credit_card00.Label();
- EXPECT_EQ(base::string16(ASCIIToUTF16("John Dillinger")), summary00);
- base::string16 obfuscated00 = credit_card00.NetworkAndLastFourDigits();
+ std::u16string summary00 = credit_card00.Label();
+ EXPECT_EQ(std::u16string(u"John Dillinger"), summary00);
+ std::u16string obfuscated00 = credit_card00.NetworkAndLastFourDigits();
EXPECT_EQ(ASCIIToUTF16(std::string("Card")), obfuscated00);
// Case 1: No credit card number.
CreditCard credit_card1(base::GenerateGUID(), "https://www.example.com/");
test::SetCreditCardInfo(&credit_card1, "John Dillinger", "", "01", "2010",
"1");
- base::string16 summary1 = credit_card1.Label();
- EXPECT_EQ(base::string16(ASCIIToUTF16("John Dillinger")), summary1);
- base::string16 obfuscated1 = credit_card1.NetworkAndLastFourDigits();
+ std::u16string summary1 = credit_card1.Label();
+ EXPECT_EQ(std::u16string(u"John Dillinger"), summary1);
+ std::u16string obfuscated1 = credit_card1.NetworkAndLastFourDigits();
EXPECT_EQ(ASCIIToUTF16(std::string("Card")), obfuscated1);
// Case 1.1: No credit card number, but has nickname.
@@ -131,20 +132,20 @@ TEST(CreditCardTest, PreviewSummaryAndNetworkAndLastFourDigitsStrings) {
test::SetCreditCardInfo(&credit_card11, "John Dillinger", "", "01", "2010",
"1");
credit_card11.SetNickname(valid_nickname);
- base::string16 summary11 = credit_card11.Label();
+ std::u16string summary11 = credit_card11.Label();
EXPECT_EQ(valid_nickname, summary11);
- base::string16 obfuscated11 = credit_card11.NetworkAndLastFourDigits();
+ std::u16string obfuscated11 = credit_card11.NetworkAndLastFourDigits();
EXPECT_EQ(ASCIIToUTF16(std::string("Card")), obfuscated11);
// Case 2: No month.
CreditCard credit_card2(base::GenerateGUID(), "https://www.example.com/");
test::SetCreditCardInfo(&credit_card2, "John Dillinger",
"5105 1051 0510 5100", "", "2010", "1");
- base::string16 summary2 = credit_card2.Label();
+ std::u16string summary2 = credit_card2.Label();
EXPECT_EQ(UTF8ToUTF16(std::string("Mastercard ") +
test::ObfuscatedCardDigitsAsUTF8("5100")),
summary2);
- base::string16 obfuscated2 = credit_card2.NetworkAndLastFourDigits();
+ std::u16string obfuscated2 = credit_card2.NetworkAndLastFourDigits();
EXPECT_EQ(UTF8ToUTF16(std::string("Mastercard ") +
test::ObfuscatedCardDigitsAsUTF8("5100")),
obfuscated2);
@@ -153,11 +154,11 @@ TEST(CreditCardTest, PreviewSummaryAndNetworkAndLastFourDigitsStrings) {
CreditCard credit_card3(base::GenerateGUID(), "https://www.example.com/");
test::SetCreditCardInfo(&credit_card3, "John Dillinger",
"5105 1051 0510 5100", "01", "", "1");
- base::string16 summary3 = credit_card3.Label();
+ std::u16string summary3 = credit_card3.Label();
EXPECT_EQ(UTF8ToUTF16(std::string("Mastercard ") +
test::ObfuscatedCardDigitsAsUTF8("5100")),
summary3);
- base::string16 obfuscated3 = credit_card3.NetworkAndLastFourDigits();
+ std::u16string obfuscated3 = credit_card3.NetworkAndLastFourDigits();
EXPECT_EQ(UTF8ToUTF16(std::string("Mastercard ") +
test::ObfuscatedCardDigitsAsUTF8("5100")),
obfuscated3);
@@ -166,11 +167,11 @@ TEST(CreditCardTest, PreviewSummaryAndNetworkAndLastFourDigitsStrings) {
CreditCard credit_card4(base::GenerateGUID(), "https://www.example.com/");
test::SetCreditCardInfo(&credit_card4, "John Dillinger",
"5105 1051 0510 5100", "01", "2010", "1");
- base::string16 summary4 = credit_card4.Label();
+ std::u16string summary4 = credit_card4.Label();
EXPECT_EQ(UTF8ToUTF16(std::string("Mastercard ") +
test::ObfuscatedCardDigitsAsUTF8("5100") + ", 01/2010"),
summary4);
- base::string16 obfuscated4 = credit_card4.NetworkAndLastFourDigits();
+ std::u16string obfuscated4 = credit_card4.NetworkAndLastFourDigits();
EXPECT_EQ(UTF8ToUTF16(std::string("Mastercard ") +
test::ObfuscatedCardDigitsAsUTF8("5100")),
obfuscated4);
@@ -181,11 +182,11 @@ TEST(CreditCardTest, PreviewSummaryAndNetworkAndLastFourDigitsStrings) {
&credit_card5, "John Dillinger",
"0123456789 0123456789 0123456789 5105 1051 0510 5100", "01", "2010",
"1");
- base::string16 summary5 = credit_card5.Label();
+ std::u16string summary5 = credit_card5.Label();
EXPECT_EQ(UTF8ToUTF16(std::string("Card ") +
test::ObfuscatedCardDigitsAsUTF8("5100") + ", 01/2010"),
summary5);
- base::string16 obfuscated5 = credit_card5.NetworkAndLastFourDigits();
+ std::u16string obfuscated5 = credit_card5.NetworkAndLastFourDigits();
EXPECT_EQ(UTF8ToUTF16(std::string("Card ") +
test::ObfuscatedCardDigitsAsUTF8("5100")),
obfuscated5);
@@ -195,7 +196,7 @@ TEST(CreditCardTest, PreviewSummaryAndNetworkAndLastFourDigitsStrings) {
test::SetCreditCardInfo(&credit_card6, "John Dillinger",
"5105 1051 0510 5100", "01", "2010", "1");
credit_card6.SetNickname(valid_nickname);
- base::string16 summary6 = credit_card6.Label();
+ std::u16string summary6 = credit_card6.Label();
EXPECT_EQ(
valid_nickname +
UTF8ToUTF16(std::string(" ") +
@@ -204,7 +205,7 @@ TEST(CreditCardTest, PreviewSummaryAndNetworkAndLastFourDigitsStrings) {
}
TEST(CreditCardTest, NicknameAndLastFourDigitsStrings) {
- base::string16 valid_nickname = ASCIIToUTF16("My Visa Card");
+ std::u16string valid_nickname = u"My Visa Card";
// Case 1: No credit card number but has nickname. Only return nickname.
CreditCard credit_card1(base::GenerateGUID(), "https://www.example.com/");
@@ -226,9 +227,8 @@ TEST(CreditCardTest, NicknameAndLastFourDigitsStrings) {
TEST(CreditCardTest, CardIdentifierStringsForAutofillDisplay) {
base::test::ScopedFeatureList scoped_feature_list;
- base::string16 valid_nickname = ASCIIToUTF16("My Visa Card");
- base::string16 invalid_nickname =
- ASCIIToUTF16("Nickname length exceeds 25 characters");
+ std::u16string valid_nickname = u"My Visa Card";
+ std::u16string invalid_nickname = u"Nickname length exceeds 25 characters";
// Case 1: Nickname name is invalid -> show network name.
CreditCard credit_card1(base::GenerateGUID(), "https://www.example.com/");
@@ -271,7 +271,7 @@ TEST(CreditCardTest, CardIdentifierStringForIssuedCard) {
credit_card1.CardIdentifierStringForAutofillDisplay());
// Case 2: Card Issuer set to GOOGLE with nickname.
- base::string16 valid_nickname = ASCIIToUTF16("My Visa Card");
+ std::u16string valid_nickname = u"My Visa Card";
credit_card1.SetNickname(valid_nickname);
EXPECT_EQ(
valid_nickname + UTF8ToUTF16(std::string(" ") +
@@ -305,7 +305,7 @@ TEST(CreditCardTest, CardIdentifierStringForIssuedCardExpOff) {
credit_card1.CardIdentifierStringForAutofillDisplay());
// Case 2: Card Issuer set to GOOGLE with nickname.
- base::string16 valid_nickname = ASCIIToUTF16("My Visa Card");
+ std::u16string valid_nickname = u"My Visa Card";
credit_card1.SetNickname(valid_nickname);
EXPECT_EQ(
valid_nickname + UTF8ToUTF16(std::string(" ") +
@@ -681,18 +681,18 @@ TEST(CreditCardTest, HasSameNumberAs) {
// Cards with the same number are the same.
a.set_record_type(CreditCard::LOCAL_CARD);
- a.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
+ a.SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111");
b.set_record_type(CreditCard::LOCAL_CARD);
- b.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
+ b.SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111");
EXPECT_TRUE(a.HasSameNumberAs(b));
EXPECT_TRUE(b.HasSameNumberAs(a));
// Local cards with different overall numbers shouldn't match even if the last
// four digits are the same.
a.set_record_type(CreditCard::LOCAL_CARD);
- a.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
+ a.SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111");
b.set_record_type(CreditCard::LOCAL_CARD);
- b.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111222222221111"));
+ b.SetRawInfo(CREDIT_CARD_NUMBER, u"4111222222221111");
EXPECT_FALSE(a.HasSameNumberAs(b));
EXPECT_FALSE(b.HasSameNumberAs(a));
@@ -700,66 +700,66 @@ TEST(CreditCardTest, HasSameNumberAs) {
// cards have different overall numbers but the same last four digits, they
// should not match.
a.set_record_type(CreditCard::FULL_SERVER_CARD);
- a.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
+ a.SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111");
b.set_record_type(CreditCard::LOCAL_CARD);
- b.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111222222221111"));
+ b.SetRawInfo(CREDIT_CARD_NUMBER, u"4111222222221111");
EXPECT_FALSE(a.HasSameNumberAs(b));
EXPECT_FALSE(b.HasSameNumberAs(a));
// When one card is a masked server card, the other is a local card, and the
// cards have the same last four digits, they should match.
a.set_record_type(CreditCard::MASKED_SERVER_CARD);
- a.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
+ a.SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111");
b.set_record_type(CreditCard::LOCAL_CARD);
- b.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4331111111111111"));
+ b.SetRawInfo(CREDIT_CARD_NUMBER, u"4331111111111111");
EXPECT_TRUE(a.HasSameNumberAs(b));
EXPECT_TRUE(b.HasSameNumberAs(a));
// When one card is a masked server card, the other is a full server card, and
// the cards have the same last four digits, they should match.
a.set_record_type(CreditCard::MASKED_SERVER_CARD);
- a.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
+ a.SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111");
b.set_record_type(CreditCard::FULL_SERVER_CARD);
- b.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4331111111111111"));
+ b.SetRawInfo(CREDIT_CARD_NUMBER, u"4331111111111111");
EXPECT_TRUE(a.HasSameNumberAs(b));
EXPECT_TRUE(b.HasSameNumberAs(a));
// If one card is masked, then partial or missing expiration date information
// should not prevent the function from returning true.
a.set_record_type(CreditCard::MASKED_SERVER_CARD);
- a.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
- a.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("01"));
- a.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2025"));
+ a.SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111");
+ a.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"01");
+ a.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2025");
b.set_record_type(CreditCard::LOCAL_CARD);
- b.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16(""));
- b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16(""));
+ b.SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111");
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"");
+ b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"");
EXPECT_TRUE(a.HasSameNumberAs(b));
EXPECT_TRUE(b.HasSameNumberAs(a));
// If one card is masked, then non-matching expiration months should cause the
// function to return false.
a.set_record_type(CreditCard::MASKED_SERVER_CARD);
- a.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
- a.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("01"));
- a.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16(""));
+ a.SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111");
+ a.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"01");
+ a.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"");
b.set_record_type(CreditCard::LOCAL_CARD);
- b.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("03"));
- b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16(""));
+ b.SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111");
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"03");
+ b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"");
EXPECT_FALSE(a.HasSameNumberAs(b));
EXPECT_FALSE(b.HasSameNumberAs(a));
// If one card is masked, then non-matching expiration years should cause the
// function to return false.
a.set_record_type(CreditCard::MASKED_SERVER_CARD);
- a.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
- a.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16(""));
- a.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2025"));
+ a.SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111");
+ a.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"");
+ a.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2025");
b.set_record_type(CreditCard::LOCAL_CARD);
- b.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16(""));
- b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2026"));
+ b.SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111");
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"");
+ b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2026");
EXPECT_FALSE(a.HasSameNumberAs(b));
EXPECT_FALSE(b.HasSameNumberAs(a));
}
@@ -787,12 +787,12 @@ TEST(CreditCardTest, Compare) {
EXPECT_EQ(0, a.Compare(b));
// Difference in nickname counts.
- a.SetNickname(ASCIIToUTF16("My Visa Card"));
- b.SetNickname(ASCIIToUTF16("Grocery Cashback Card"));
+ a.SetNickname(u"My Visa Card");
+ b.SetNickname(u"Grocery Cashback Card");
EXPECT_LT(0, a.Compare(b));
// Reset the nickname to empty, empty nickname cards are the same.
- a.SetNickname(ASCIIToUTF16(""));
- b.SetNickname(ASCIIToUTF16(""));
+ a.SetNickname(u"");
+ b.SetNickname(u"");
EXPECT_EQ(0, a.Compare(b));
// Local is different from server.
@@ -833,7 +833,7 @@ TEST(CreditCardTest, IconResourceId) {
}
TEST(CreditCardTest, UpdateFromImportedCard_UpdatedWithNameAndExpirationDate) {
- const base::string16 kYearInFuture = GetYearInTheFuture();
+ const std::u16string kYearInFuture = GetYearInTheFuture();
CreditCard original_card(base::GenerateGUID(), test::kEmptyOrigin);
test::SetCreditCardInfo(&original_card, "John Dillinger", "123456789012",
@@ -843,21 +843,21 @@ TEST(CreditCardTest, UpdateFromImportedCard_UpdatedWithNameAndExpirationDate) {
// The new card has a different name, expiration date.
CreditCard b = a;
b.set_guid(base::GenerateGUID());
- b.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("J. Dillinger"));
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("08"));
+ b.SetRawInfo(CREDIT_CARD_NAME_FULL, u"J. Dillinger");
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"08");
b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, kYearInFuture);
// |a| should be updated with the information from |b|.
EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US"));
EXPECT_EQ(test::kEmptyOrigin, a.origin());
- EXPECT_EQ(ASCIIToUTF16("J. Dillinger"), a.GetRawInfo(CREDIT_CARD_NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("08"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ EXPECT_EQ(u"J. Dillinger", a.GetRawInfo(CREDIT_CARD_NAME_FULL));
+ EXPECT_EQ(u"08", a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
EXPECT_EQ(kYearInFuture, a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
}
TEST(CreditCardTest,
UpdateFromImportedCard_UpdatedWithNameAndInvalidExpirationDateMonth) {
- const base::string16 kYearInFuture = GetYearInTheFuture();
+ const std::u16string kYearInFuture = GetYearInTheFuture();
CreditCard original_card(base::GenerateGUID(), test::kEmptyOrigin);
test::SetCreditCardInfo(&original_card, "John Dillinger", "123456789012",
@@ -870,15 +870,15 @@ TEST(CreditCardTest,
// date.
CreditCard b = a;
b.set_guid(base::GenerateGUID());
- b.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("J. Dillinger"));
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("0"));
+ b.SetRawInfo(CREDIT_CARD_NAME_FULL, u"J. Dillinger");
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"0");
b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, kYearInFuture);
EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US"));
EXPECT_EQ(test::kEmptyOrigin, a.origin());
- EXPECT_EQ(ASCIIToUTF16("J. Dillinger"), a.GetRawInfo(CREDIT_CARD_NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("09"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
- EXPECT_EQ(ASCIIToUTF16("2017"), a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
+ EXPECT_EQ(u"J. Dillinger", a.GetRawInfo(CREDIT_CARD_NAME_FULL));
+ EXPECT_EQ(u"09", a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ EXPECT_EQ(u"2017", a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
}
TEST(CreditCardTest,
@@ -896,20 +896,20 @@ TEST(CreditCardTest,
CreditCard b = a;
b.set_guid(base::GenerateGUID());
b.set_origin(test::kEmptyOrigin);
- b.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("J. Dillinger"));
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("09"));
- b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16(""));
+ b.SetRawInfo(CREDIT_CARD_NAME_FULL, u"J. Dillinger");
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"09");
+ b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"");
EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US"));
EXPECT_EQ(test::kEmptyOrigin, a.origin());
- EXPECT_EQ(ASCIIToUTF16("J. Dillinger"), a.GetRawInfo(CREDIT_CARD_NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("09"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
- EXPECT_EQ(ASCIIToUTF16("2017"), a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
+ EXPECT_EQ(u"J. Dillinger", a.GetRawInfo(CREDIT_CARD_NAME_FULL));
+ EXPECT_EQ(u"09", a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ EXPECT_EQ(u"2017", a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
}
TEST(CreditCardTest,
UpdateFromImportedCard_UpdatedWithEmptyNameAndValidExpirationDate) {
- const base::string16 kYearInFuture = GetYearInTheFuture();
+ const std::u16string kYearInFuture = GetYearInTheFuture();
CreditCard original_card(base::GenerateGUID(), test::kEmptyOrigin);
test::SetCreditCardInfo(&original_card, "John Dillinger", "123456789012",
@@ -921,22 +921,21 @@ TEST(CreditCardTest,
// name.
CreditCard b = a;
b.set_guid(base::GenerateGUID());
- b.SetRawInfo(CREDIT_CARD_NAME_FULL, base::string16());
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("08"));
+ b.SetRawInfo(CREDIT_CARD_NAME_FULL, std::u16string());
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"08");
b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, kYearInFuture);
EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US"));
EXPECT_EQ(test::kEmptyOrigin, a.origin());
- EXPECT_EQ(ASCIIToUTF16("John Dillinger"),
- a.GetRawInfo(CREDIT_CARD_NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("08"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ EXPECT_EQ(u"John Dillinger", a.GetRawInfo(CREDIT_CARD_NAME_FULL));
+ EXPECT_EQ(u"08", a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
EXPECT_EQ(kYearInFuture, a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
}
TEST(
CreditCardTest,
UpdateFromImportedCard_VerifiedCardNotUpdatedWithEmptyExpirationDateMonth) {
- const base::string16 kYearInFuture = GetYearInTheFuture();
+ const std::u16string kYearInFuture = GetYearInTheFuture();
CreditCard original_card(base::GenerateGUID(), test::kEmptyOrigin);
test::SetCreditCardInfo(&original_card, "John Dillinger", "123456789012",
@@ -950,16 +949,15 @@ TEST(
b.set_guid(base::GenerateGUID());
a.set_origin("Chrome settings");
b.set_origin(test::kEmptyOrigin);
- b.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("J. Dillinger"));
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("0"));
+ b.SetRawInfo(CREDIT_CARD_NAME_FULL, u"J. Dillinger");
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"0");
b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, kYearInFuture);
EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US"));
EXPECT_EQ("Chrome settings", a.origin());
- EXPECT_EQ(ASCIIToUTF16("John Dillinger"),
- a.GetRawInfo(CREDIT_CARD_NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("09"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
- EXPECT_EQ(ASCIIToUTF16("2017"), a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
+ EXPECT_EQ(u"John Dillinger", a.GetRawInfo(CREDIT_CARD_NAME_FULL));
+ EXPECT_EQ(u"09", a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ EXPECT_EQ(u"2017", a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
}
TEST(CreditCardTest,
@@ -975,16 +973,15 @@ TEST(CreditCardTest,
b.set_guid(base::GenerateGUID());
a.set_origin("Chrome settings");
b.set_origin(test::kEmptyOrigin);
- b.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("J. Dillinger"));
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("09"));
- b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("0"));
+ b.SetRawInfo(CREDIT_CARD_NAME_FULL, u"J. Dillinger");
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"09");
+ b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"0");
EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US"));
EXPECT_EQ("Chrome settings", a.origin());
- EXPECT_EQ(ASCIIToUTF16("John Dillinger"),
- a.GetRawInfo(CREDIT_CARD_NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("09"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
- EXPECT_EQ(ASCIIToUTF16("2017"), a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
+ EXPECT_EQ(u"John Dillinger", a.GetRawInfo(CREDIT_CARD_NAME_FULL));
+ EXPECT_EQ(u"09", a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ EXPECT_EQ(u"2017", a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
}
TEST(CreditCardTest,
@@ -1000,21 +997,20 @@ TEST(CreditCardTest,
b.set_guid(base::GenerateGUID());
a.set_origin(kSettingsOrigin);
b.set_origin(test::kEmptyOrigin);
- b.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("J. Dillinger"));
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("08"));
- b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2017"));
+ b.SetRawInfo(CREDIT_CARD_NAME_FULL, u"J. Dillinger");
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"08");
+ b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2017");
EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US"));
EXPECT_EQ(kSettingsOrigin, a.origin());
- EXPECT_EQ(ASCIIToUTF16("John Dillinger"),
- a.GetRawInfo(CREDIT_CARD_NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("09"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
- EXPECT_EQ(ASCIIToUTF16("2017"), a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
+ EXPECT_EQ(u"John Dillinger", a.GetRawInfo(CREDIT_CARD_NAME_FULL));
+ EXPECT_EQ(u"09", a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ EXPECT_EQ(u"2017", a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
}
TEST(CreditCardTest,
UpdateFromImportedCard_ExpiredVerifiedCardNotUpdatedWithDifferentName) {
- const base::string16 kYearInFuture = GetYearInTheFuture();
+ const std::u16string kYearInFuture = GetYearInTheFuture();
CreditCard original_card(base::GenerateGUID(), test::kEmptyOrigin);
test::SetCreditCardInfo(&original_card, "John Dillinger", "123456789012",
@@ -1029,21 +1025,20 @@ TEST(CreditCardTest,
a.SetExpirationYear(2010);
b.set_guid(base::GenerateGUID());
b.set_origin(test::kEmptyOrigin);
- b.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("J. Dillinger"));
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("08"));
+ b.SetRawInfo(CREDIT_CARD_NAME_FULL, u"J. Dillinger");
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"08");
b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, kYearInFuture);
EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US"));
EXPECT_EQ("Chrome settings", a.origin());
- EXPECT_EQ(ASCIIToUTF16("John Dillinger"),
- a.GetRawInfo(CREDIT_CARD_NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("09"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
- EXPECT_EQ(ASCIIToUTF16("2010"), a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
+ EXPECT_EQ(u"John Dillinger", a.GetRawInfo(CREDIT_CARD_NAME_FULL));
+ EXPECT_EQ(u"09", a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ EXPECT_EQ(u"2010", a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
}
TEST(CreditCardTest,
UpdateFromImportedCard_ExpiredVerifiedCardUpdatedWithSameName) {
- const base::string16 kYearInFuture = GetYearInTheFuture();
+ const std::u16string kYearInFuture = GetYearInTheFuture();
CreditCard original_card(base::GenerateGUID(), test::kEmptyOrigin);
test::SetCreditCardInfo(&original_card, "John Dillinger", "123456789012",
@@ -1058,14 +1053,13 @@ TEST(CreditCardTest,
a.SetExpirationYear(2010);
b.set_guid(base::GenerateGUID());
b.set_origin(test::kEmptyOrigin);
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("08"));
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"08");
b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, kYearInFuture);
EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US"));
EXPECT_EQ("Chrome settings", a.origin());
- EXPECT_EQ(ASCIIToUTF16("John Dillinger"),
- a.GetRawInfo(CREDIT_CARD_NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("08"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ EXPECT_EQ(u"John Dillinger", a.GetRawInfo(CREDIT_CARD_NAME_FULL));
+ EXPECT_EQ(u"08", a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
EXPECT_EQ(kYearInFuture, a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
}
@@ -1084,20 +1078,19 @@ TEST(CreditCardTest,
a.SetExpirationYear(2010);
b.set_guid(base::GenerateGUID());
b.set_origin(test::kEmptyOrigin);
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("08"));
- b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2009"));
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"08");
+ b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2009");
EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US"));
EXPECT_EQ("Chrome settings", a.origin());
- EXPECT_EQ(ASCIIToUTF16("John Dillinger"),
- a.GetRawInfo(CREDIT_CARD_NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("09"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
- EXPECT_EQ(ASCIIToUTF16("2010"), a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
+ EXPECT_EQ(u"John Dillinger", a.GetRawInfo(CREDIT_CARD_NAME_FULL));
+ EXPECT_EQ(u"09", a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ EXPECT_EQ(u"2010", a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
}
TEST(CreditCardTest,
UpdateFromImportedCard_VerifiedCardUpdatedWithVerifiedCard) {
- const base::string16 kYearInFuture = GetYearInTheFuture();
+ const std::u16string kYearInFuture = GetYearInTheFuture();
CreditCard original_card(base::GenerateGUID(), test::kEmptyOrigin);
test::SetCreditCardInfo(&original_card, "John Dillinger", "123456789012",
@@ -1111,20 +1104,19 @@ TEST(CreditCardTest,
a.set_origin("Chrome settings");
b.set_guid(base::GenerateGUID());
b.set_origin(kSettingsOrigin);
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("08"));
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"08");
b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, kYearInFuture);
EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US"));
EXPECT_EQ("Chrome settings", a.origin());
- EXPECT_EQ(ASCIIToUTF16("John Dillinger"),
- a.GetRawInfo(CREDIT_CARD_NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("08"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ EXPECT_EQ(u"John Dillinger", a.GetRawInfo(CREDIT_CARD_NAME_FULL));
+ EXPECT_EQ(u"08", a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
EXPECT_EQ(kYearInFuture, a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
}
TEST(CreditCardTest,
UpdateFromImportedCard_VerifiedCardNotUpdatedWithDifferentCard) {
- const base::string16 kYearInFuture = GetYearInTheFuture();
+ const std::u16string kYearInFuture = GetYearInTheFuture();
CreditCard original_card(base::GenerateGUID(), test::kEmptyOrigin);
test::SetCreditCardInfo(&original_card, "John Dillinger", "123456789012",
@@ -1138,16 +1130,15 @@ TEST(CreditCardTest,
a.set_origin("Chrome settings");
b.set_guid(base::GenerateGUID());
b.set_origin(kSettingsOrigin);
- b.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
- b.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("08"));
+ b.SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111");
+ b.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"08");
b.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, kYearInFuture);
EXPECT_FALSE(a.UpdateFromImportedCard(b, "en-US"));
EXPECT_EQ("Chrome settings", a.origin());
- EXPECT_EQ(ASCIIToUTF16("John Dillinger"),
- a.GetRawInfo(CREDIT_CARD_NAME_FULL));
- EXPECT_EQ(ASCIIToUTF16("09"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
- EXPECT_EQ(ASCIIToUTF16("2017"), a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
+ EXPECT_EQ(u"John Dillinger", a.GetRawInfo(CREDIT_CARD_NAME_FULL));
+ EXPECT_EQ(u"09", a.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ EXPECT_EQ(u"2017", a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
}
TEST(CreditCardTest, IsValidCardNumberAndExpiryDate) {
@@ -1160,15 +1151,15 @@ TEST(CreditCardTest, IsValidCardNumberAndExpiryDate) {
base::NumberToString16(now_exploded.month));
card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR,
base::NumberToString16(now_exploded.year - 1));
- card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
+ card.SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111");
EXPECT_FALSE(card.IsValid());
EXPECT_FALSE(card.HasValidExpirationDate());
EXPECT_TRUE(card.HasValidCardNumber());
// Invalid because card number is not complete
- card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("12"));
- card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2999"));
- card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("41111"));
+ card.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"12");
+ card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2999");
+ card.SetRawInfo(CREDIT_CARD_NUMBER, u"41111");
EXPECT_FALSE(card.IsValid());
for (const char* valid_number : kValidNumbers) {
@@ -1235,40 +1226,36 @@ TEST(CreditCardTest, SetRawInfoCreditCardNumber) {
test::SetCreditCardInfo(&card, "Bob Dylan", "4321-5432-6543-xxxx", "07",
"2013", "1");
- EXPECT_EQ(ASCIIToUTF16("4321-5432-6543-xxxx"),
- card.GetRawInfo(CREDIT_CARD_NUMBER));
+ EXPECT_EQ(u"4321-5432-6543-xxxx", card.GetRawInfo(CREDIT_CARD_NUMBER));
}
// Verify that we can handle both numeric and named months.
TEST(CreditCardTest, SetExpirationMonth) {
CreditCard card(base::GenerateGUID(), "https://www.example.com/");
- card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("05"));
- EXPECT_EQ(ASCIIToUTF16("05"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ card.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"05");
+ EXPECT_EQ(u"05", card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
EXPECT_EQ(5, card.expiration_month());
- card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("7"));
- EXPECT_EQ(ASCIIToUTF16("07"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ card.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"7");
+ EXPECT_EQ(u"07", card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
EXPECT_EQ(7, card.expiration_month());
// This should fail, and preserve the previous value.
- card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("January"));
- EXPECT_EQ(ASCIIToUTF16("07"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ card.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"January");
+ EXPECT_EQ(u"07", card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
EXPECT_EQ(7, card.expiration_month());
- card.SetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("January"),
- "en-US");
- EXPECT_EQ(ASCIIToUTF16("01"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ card.SetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), u"January", "en-US");
+ EXPECT_EQ(u"01", card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
EXPECT_EQ(1, card.expiration_month());
- card.SetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("Apr"),
- "en-US");
- EXPECT_EQ(ASCIIToUTF16("04"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ card.SetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), u"Apr", "en-US");
+ EXPECT_EQ(u"04", card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
EXPECT_EQ(4, card.expiration_month());
- card.SetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), UTF8ToUTF16("FÉVRIER"),
- "fr-FR");
- EXPECT_EQ(ASCIIToUTF16("02"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
+ card.SetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), u"FÉVRIER", "fr-FR");
+ EXPECT_EQ(u"02", card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
EXPECT_EQ(2, card.expiration_month());
}
@@ -1278,44 +1265,44 @@ TEST(CreditCardTest, SetNickname) {
CreditCard card(base::GenerateGUID(), "https://www.example.com/");
// Normal input nickname.
- card.SetNickname(ASCIIToUTF16("Grocery card"));
- EXPECT_EQ(ASCIIToUTF16("Grocery card"), card.nickname());
+ card.SetNickname(u"Grocery card");
+ EXPECT_EQ(u"Grocery card", card.nickname());
// Input nickname has leading and trailing whitespaces.
- card.SetNickname(ASCIIToUTF16(" Grocery card "));
- EXPECT_EQ(ASCIIToUTF16("Grocery card"), card.nickname());
+ card.SetNickname(u" Grocery card ");
+ EXPECT_EQ(u"Grocery card", card.nickname());
// Input nickname has newlines.
- card.SetNickname(ASCIIToUTF16("\r\n Grocery\ncard \r\n"));
- EXPECT_EQ(ASCIIToUTF16("Grocery card"), card.nickname());
+ card.SetNickname(u"\r\n Grocery\ncard \r\n");
+ EXPECT_EQ(u"Grocery card", card.nickname());
// Input nickname has tabs.
- card.SetNickname(ASCIIToUTF16(" \tGrocery\t card\t "));
- EXPECT_EQ(ASCIIToUTF16("Grocery card"), card.nickname());
+ card.SetNickname(u" \tGrocery\t card\t ");
+ EXPECT_EQ(u"Grocery card", card.nickname());
// Input nickname has newlines & whitespaces & tabs.
- card.SetNickname(ASCIIToUTF16("\n\t Grocery \tcard \n \r\n"));
- EXPECT_EQ(ASCIIToUTF16("Grocery card"), card.nickname());
+ card.SetNickname(u"\n\t Grocery \tcard \n \r\n");
+ EXPECT_EQ(u"Grocery card", card.nickname());
}
TEST(CreditCardTest, CreditCardType) {
CreditCard card(base::GenerateGUID(), "https://www.example.com/");
// The card type cannot be set directly.
- card.SetRawInfo(CREDIT_CARD_TYPE, ASCIIToUTF16("Visa"));
- EXPECT_EQ(base::string16(), card.GetRawInfo(CREDIT_CARD_TYPE));
+ card.SetRawInfo(CREDIT_CARD_TYPE, u"Visa");
+ EXPECT_EQ(std::u16string(), card.GetRawInfo(CREDIT_CARD_TYPE));
// Setting the number should implicitly set the type.
- card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111 1111 1111 1111"));
- EXPECT_EQ(ASCIIToUTF16("Visa"), card.GetRawInfo(CREDIT_CARD_TYPE));
+ card.SetRawInfo(CREDIT_CARD_NUMBER, u"4111 1111 1111 1111");
+ EXPECT_EQ(u"Visa", card.GetRawInfo(CREDIT_CARD_TYPE));
}
TEST(CreditCardTest, CreditCardVerificationCode) {
CreditCard card(base::GenerateGUID(), "https://www.example.com/");
// The verification code cannot be set, as Chrome does not store this data.
- card.SetRawInfo(CREDIT_CARD_VERIFICATION_CODE, ASCIIToUTF16("999"));
- EXPECT_EQ(base::string16(), card.GetRawInfo(CREDIT_CARD_VERIFICATION_CODE));
+ card.SetRawInfo(CREDIT_CARD_VERIFICATION_CODE, u"999");
+ EXPECT_EQ(std::u16string(), card.GetRawInfo(CREDIT_CARD_VERIFICATION_CODE));
}
// Tests that the card in only deletable if it is expired before the threshold.
@@ -1387,7 +1374,7 @@ TEST_P(CreditCardMatchingTypesTest, Cases) {
auto test_case = GetParam();
CreditCard card(base::GenerateGUID(), "https://www.example.com/");
card.set_record_type(test_case.record_type);
- card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4012888888881881"));
+ card.SetRawInfo(CREDIT_CARD_NUMBER, u"4012888888881881");
card.SetRawInfo(CREDIT_CARD_EXP_MONTH,
ASCIIToUTF16(test_case.card_exp_month));
card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR,
@@ -1463,7 +1450,7 @@ class GetCardNetworkTestBatch1
TEST_P(GetCardNetworkTestBatch1, GetCardNetwork) {
auto test_case = GetParam();
- base::string16 card_number = ASCIIToUTF16(test_case.card_number);
+ std::u16string card_number = ASCIIToUTF16(test_case.card_number);
SCOPED_TRACE(card_number);
EXPECT_EQ(test_case.issuer_network, CreditCard::GetCardNetwork(card_number));
EXPECT_EQ(test_case.is_valid, IsValidCreditCardNumber(card_number));
@@ -1526,7 +1513,7 @@ class GetCardNetworkTestBatch2
TEST_P(GetCardNetworkTestBatch2, GetCardNetwork) {
auto test_case = GetParam();
- base::string16 card_number = ASCIIToUTF16(test_case.card_number);
+ std::u16string card_number = ASCIIToUTF16(test_case.card_number);
SCOPED_TRACE(card_number);
EXPECT_EQ(test_case.issuer_network, CreditCard::GetCardNetwork(card_number));
EXPECT_EQ(test_case.is_valid, IsValidCreditCardNumber(card_number));
@@ -1583,7 +1570,7 @@ class GetCardNetworkTestBatch3
TEST_P(GetCardNetworkTestBatch3, GetCardNetwork) {
auto test_case = GetParam();
- base::string16 card_number = ASCIIToUTF16(test_case.card_number);
+ std::u16string card_number = ASCIIToUTF16(test_case.card_number);
SCOPED_TRACE(card_number);
EXPECT_EQ(test_case.issuer_network, CreditCard::GetCardNetwork(card_number));
EXPECT_EQ(test_case.is_valid, IsValidCreditCardNumber(card_number));
@@ -1599,7 +1586,9 @@ INSTANTIATE_TEST_SUITE_P(
GetCardNetworkTestCase{"2202", kMirCard, false},
GetCardNetworkTestCase{"2203", kMirCard, false},
GetCardNetworkTestCase{"2204", kMirCard, false},
- GetCardNetworkTestCase{"2205", kTroyCard, false},
+ GetCardNetworkTestCase{"22050", kTroyCard, false},
+ GetCardNetworkTestCase{"22051", kTroyCard, false},
+ GetCardNetworkTestCase{"22052", kTroyCard, false},
GetCardNetworkTestCase{"2221", kMasterCard, false},
GetCardNetworkTestCase{"2720", kMasterCard, false},
GetCardNetworkTestCase{"300", kDinersCard, false},
@@ -1645,7 +1634,7 @@ class GetCardNetworkTestBatch4
TEST_P(GetCardNetworkTestBatch4, GetCardNetwork) {
auto test_case = GetParam();
- base::string16 card_number = ASCIIToUTF16(test_case.card_number);
+ std::u16string card_number = ASCIIToUTF16(test_case.card_number);
SCOPED_TRACE(card_number);
EXPECT_EQ(test_case.issuer_network, CreditCard::GetCardNetwork(card_number));
EXPECT_EQ(test_case.is_valid, IsValidCreditCardNumber(card_number));
@@ -1670,6 +1659,7 @@ INSTANTIATE_TEST_SUITE_P(
// Unknown IINs.
GetCardNetworkTestCase{"0", kGenericCard, false},
GetCardNetworkTestCase{"1", kGenericCard, false},
+ GetCardNetworkTestCase{"22053", kGenericCard, false},
GetCardNetworkTestCase{"306", kGenericCard, false},
GetCardNetworkTestCase{"307", kGenericCard, false},
GetCardNetworkTestCase{"308", kGenericCard, false},
@@ -1722,28 +1712,25 @@ INSTANTIATE_TEST_SUITE_P(
TEST(CreditCardTest, LastFourDigits) {
CreditCard card(base::GenerateGUID(), "https://www.example.com/");
- ASSERT_EQ(base::string16(), card.LastFourDigits());
- ASSERT_EQ(internal::GetObfuscatedStringForCardDigits(base::string16()),
+ ASSERT_EQ(std::u16string(), card.LastFourDigits());
+ ASSERT_EQ(internal::GetObfuscatedStringForCardDigits(std::u16string()),
card.ObfuscatedLastFourDigits());
test::SetCreditCardInfo(&card, "Baby Face Nelson", "5212341234123489", "01",
"2010", "1");
- ASSERT_EQ(base::ASCIIToUTF16("3489"), card.LastFourDigits());
- ASSERT_EQ(
- internal::GetObfuscatedStringForCardDigits(base::ASCIIToUTF16("3489")),
- card.ObfuscatedLastFourDigits());
-
- card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("3489"));
- ASSERT_EQ(base::ASCIIToUTF16("3489"), card.LastFourDigits());
- ASSERT_EQ(
- internal::GetObfuscatedStringForCardDigits(base::ASCIIToUTF16("3489")),
- card.ObfuscatedLastFourDigits());
-
- card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("489"));
- ASSERT_EQ(base::ASCIIToUTF16("489"), card.LastFourDigits());
- ASSERT_EQ(
- internal::GetObfuscatedStringForCardDigits(base::ASCIIToUTF16("489")),
- card.ObfuscatedLastFourDigits());
+ ASSERT_EQ(u"3489", card.LastFourDigits());
+ ASSERT_EQ(internal::GetObfuscatedStringForCardDigits(u"3489"),
+ card.ObfuscatedLastFourDigits());
+
+ card.SetRawInfo(CREDIT_CARD_NUMBER, u"3489");
+ ASSERT_EQ(u"3489", card.LastFourDigits());
+ ASSERT_EQ(internal::GetObfuscatedStringForCardDigits(u"3489"),
+ card.ObfuscatedLastFourDigits());
+
+ card.SetRawInfo(CREDIT_CARD_NUMBER, u"489");
+ ASSERT_EQ(u"489", card.LastFourDigits());
+ ASSERT_EQ(internal::GetObfuscatedStringForCardDigits(u"489"),
+ card.ObfuscatedLastFourDigits());
}
// Verifies that a credit card should be updated.
diff --git a/chromium/components/autofill/core/browser/data_model/data_model_utils.cc b/chromium/components/autofill/core/browser/data_model/data_model_utils.cc
index 023b70402cc..ff18194d928 100644
--- a/chromium/components/autofill/core/browser/data_model/data_model_utils.cc
+++ b/chromium/components/autofill/core/browser/data_model/data_model_utils.cc
@@ -9,7 +9,6 @@
#include "base/macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "components/autofill/core/browser/autofill_regex_constants.h"
#include "components/autofill/core/browser/autofill_regexes.h"
@@ -21,41 +20,41 @@ namespace autofill {
namespace data_util {
-base::string16 Expiration2DigitMonthAsString(int expiration_month) {
+std::u16string Expiration2DigitMonthAsString(int expiration_month) {
if (expiration_month < 1 || expiration_month > 12)
- return base::string16();
+ return std::u16string();
- base::string16 month = base::NumberToString16(expiration_month);
+ std::u16string month = base::NumberToString16(expiration_month);
if (expiration_month >= 10)
return month;
- base::string16 zero = base::ASCIIToUTF16("0");
+ std::u16string zero = u"0";
return zero.append(month);
}
-base::string16 Expiration2DigitYearAsString(int expiration_year) {
+std::u16string Expiration2DigitYearAsString(int expiration_year) {
if (expiration_year == 0)
- return base::string16();
+ return std::u16string();
- base::string16 year = base::NumberToString16(expiration_year % 100);
+ std::u16string year = base::NumberToString16(expiration_year % 100);
if (expiration_year >= 10)
return year;
- base::string16 zero = base::ASCIIToUTF16("0");
+ std::u16string zero = u"0";
return zero.append(year);
}
-base::string16 Expiration4DigitYearAsString(int expiration_year) {
+std::u16string Expiration4DigitYearAsString(int expiration_year) {
if (expiration_year == 0)
- return base::string16();
+ return std::u16string();
return base::NumberToString16(expiration_year);
}
-bool ParseExpirationMonth(const base::string16& text,
+bool ParseExpirationMonth(const std::u16string& text,
const std::string& app_locale,
int* expiration_month) {
- base::string16 trimmed;
+ std::u16string trimmed;
base::TrimWhitespace(text, base::TRIM_ALL, &trimmed);
if (trimmed.empty())
@@ -80,7 +79,7 @@ bool ParseExpirationMonth(const base::string16& text,
int32_t num_months;
const icu::UnicodeString* months = date_format_symbols.getMonths(num_months);
for (int32_t i = 0; i < num_months; ++i) {
- const base::string16 icu_month(
+ const std::u16string icu_month(
base::i18n::UnicodeStringToString16(months[i]));
// We look for the ICU-defined month in |trimmed|.
if (base::i18n::StringSearchIgnoringCaseAndAccents(icu_month, trimmed,
@@ -92,10 +91,10 @@ bool ParseExpirationMonth(const base::string16& text,
// Abbreviated months (jan., janv., fév.) Some abbreviations have . at the end
// (e.g., "janv." in French). The period is removed.
months = date_format_symbols.getShortMonths(num_months);
- base::TrimString(trimmed, base::ASCIIToUTF16("."), &trimmed);
+ base::TrimString(trimmed, u".", &trimmed);
for (int32_t i = 0; i < num_months; ++i) {
- base::string16 icu_month(base::i18n::UnicodeStringToString16(months[i]));
- base::TrimString(icu_month, base::ASCIIToUTF16("."), &icu_month);
+ std::u16string icu_month(base::i18n::UnicodeStringToString16(months[i]));
+ base::TrimString(icu_month, u".", &icu_month);
// We look for the ICU-defined month in |trimmed_month|.
if (base::i18n::StringSearchIgnoringCaseAndAccents(icu_month, trimmed,
nullptr, nullptr)) {
@@ -107,8 +106,8 @@ bool ParseExpirationMonth(const base::string16& text,
return false;
}
-bool ParseExpirationYear(const base::string16& text, int* expiration_year) {
- base::string16 trimmed;
+bool ParseExpirationYear(const std::u16string& text, int* expiration_year) {
+ std::u16string trimmed;
base::TrimWhitespace(text, base::TRIM_ALL, &trimmed);
int year = 0;
@@ -143,16 +142,15 @@ bool SetExpirationYear(int value, int* expiration_year) {
return true;
}
-base::string16 FindPossiblePhoneCountryCode(const base::string16& text) {
- base::string16 candidate;
- if (text.find(base::ASCIIToUTF16("00")) != base::string16::npos ||
- text.find('+') != base::string16::npos) {
- if (MatchesPattern(text, base::ASCIIToUTF16(kAugmentedPhoneCountryCodeRe),
- &candidate, 1))
+std::u16string FindPossiblePhoneCountryCode(const std::u16string& text) {
+ std::u16string candidate;
+ if (text.find(u"00") != std::u16string::npos ||
+ text.find('+') != std::u16string::npos) {
+ if (MatchesPattern(text, kAugmentedPhoneCountryCodeRe, &candidate, 1))
return candidate;
}
- return base::string16();
+ return std::u16string();
}
} // namespace data_util
diff --git a/chromium/components/autofill/core/browser/data_model/data_model_utils.h b/chromium/components/autofill/core/browser/data_model/data_model_utils.h
index f1324537936..61792a0c728 100644
--- a/chromium/components/autofill/core/browser/data_model/data_model_utils.h
+++ b/chromium/components/autofill/core/browser/data_model/data_model_utils.h
@@ -7,28 +7,27 @@
#include <string>
-#include "base/strings/string16.h"
namespace autofill {
namespace data_util {
-// Converts the integer |expiration_month| to base::string16. Returns a value
+// Converts the integer |expiration_month| to std::u16string. Returns a value
// between ["01"-"12"].
-base::string16 Expiration2DigitMonthAsString(int expiration_month);
+std::u16string Expiration2DigitMonthAsString(int expiration_month);
-// Converts the integer |expiration_year| to base::string16. Returns a value
+// Converts the integer |expiration_year| to std::u16string. Returns a value
// between ["00"-"99"].
-base::string16 Expiration2DigitYearAsString(int expiration_year);
+std::u16string Expiration2DigitYearAsString(int expiration_year);
-// Converts the integer |expiration_year| to base::string16.
-base::string16 Expiration4DigitYearAsString(int expiration_year);
+// Converts the integer |expiration_year| to std::u16string.
+std::u16string Expiration4DigitYearAsString(int expiration_year);
// Converts a string representation of a month (such as "February" or "feb."
// or "2") into a numeric value in [1, 12]. Returns true on successful
// conversion or false if a month was not recognized. When conversion fails,
// |expiration_month| is not modified.
-bool ParseExpirationMonth(const base::string16& text,
+bool ParseExpirationMonth(const std::u16string& text,
const std::string& app_locale,
int* expiration_month);
@@ -36,7 +35,7 @@ bool ParseExpirationMonth(const base::string16& text,
// |*expiration_year|. This function accepts two digit years as well as
// four digit years between 2000 and 2999. Returns true on success.
// On failure, no change is made to |*expiration_year|.
-bool ParseExpirationYear(const base::string16& text, int* expiration_year);
+bool ParseExpirationYear(const std::u16string& text, int* expiration_year);
// Sets |*expiration_month| to |value| if |value| is a valid month (1-12).
// Returns if any change is made to |*expiration_month|.
@@ -49,7 +48,7 @@ bool SetExpirationYear(int value, int* expiration_year);
// Finds possible country code in |text| by fetching the first sub-group when
// matched with |kAugmentedPhoneCountryCodeRe| regex.
-base::string16 FindPossiblePhoneCountryCode(const base::string16& text);
+std::u16string FindPossiblePhoneCountryCode(const std::u16string& text);
} // namespace data_util
diff --git a/chromium/components/autofill/core/browser/data_model/form_group.cc b/chromium/components/autofill/core/browser/data_model/form_group.cc
index bf2416f988c..6e58c43a709 100644
--- a/chromium/components/autofill/core/browser/data_model/form_group.cc
+++ b/chromium/components/autofill/core/browser/data_model/form_group.cc
@@ -15,7 +15,7 @@ namespace autofill {
using structured_address::VerificationStatus;
-void FormGroup::GetMatchingTypes(const base::string16& text,
+void FormGroup::GetMatchingTypes(const std::u16string& text,
const std::string& app_locale,
ServerFieldTypeSet* matching_types) const {
if (text.empty()) {
@@ -28,7 +28,7 @@ void FormGroup::GetMatchingTypes(const base::string16& text,
return;
}
- base::string16 canonicalized_text = comparator.NormalizeForComparison(text);
+ std::u16string canonicalized_text = comparator.NormalizeForComparison(text);
ServerFieldTypeSet types;
GetSupportedTypes(&types);
for (const auto& type : types) {
@@ -53,12 +53,12 @@ bool FormGroup::HasRawInfo(ServerFieldType type) const {
return !GetRawInfo(type).empty();
}
-base::string16 FormGroup::GetInfo(ServerFieldType type,
+std::u16string FormGroup::GetInfo(ServerFieldType type,
const std::string& app_locale) const {
return GetInfoImpl(AutofillType(type), app_locale);
}
-base::string16 FormGroup::GetInfo(const AutofillType& type,
+std::u16string FormGroup::GetInfo(const AutofillType& type,
const std::string& app_locale) const {
return GetInfoImpl(type, app_locale);
}
@@ -82,21 +82,21 @@ int FormGroup::GetVerificationStatusInt(const AutofillType& type) const {
}
bool FormGroup::SetInfo(ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale) {
return SetInfoWithVerificationStatus(type, value, app_locale,
VerificationStatus::kNoStatus);
}
bool FormGroup::SetInfo(const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale) {
return SetInfoWithVerificationStatus(type, value, app_locale,
VerificationStatus::kNoStatus);
}
bool FormGroup::SetInfoWithVerificationStatus(ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale,
const VerificationStatus status) {
return SetInfoWithVerificationStatusImpl(AutofillType(type), value,
@@ -104,7 +104,7 @@ bool FormGroup::SetInfoWithVerificationStatus(ServerFieldType type,
}
bool FormGroup::SetInfoWithVerificationStatus(const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale,
VerificationStatus status) {
return SetInfoWithVerificationStatusImpl(type, value, app_locale, status);
@@ -120,25 +120,25 @@ bool FormGroup::HasInfo(const AutofillType& type) const {
return !GetInfo(type, "en-US").empty();
}
-base::string16 FormGroup::GetInfoImpl(const AutofillType& type,
+std::u16string FormGroup::GetInfoImpl(const AutofillType& type,
const std::string& app_locale) const {
return GetRawInfo(type.GetStorableType());
}
bool FormGroup::SetInfoWithVerificationStatusImpl(const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale,
VerificationStatus status) {
SetRawInfoWithVerificationStatus(type.GetStorableType(), value, status);
return true;
}
-void FormGroup::SetRawInfo(ServerFieldType type, const base::string16& value) {
+void FormGroup::SetRawInfo(ServerFieldType type, const std::u16string& value) {
SetRawInfoWithVerificationStatus(type, value, VerificationStatus::kNoStatus);
}
void FormGroup::SetRawInfoWithVerificationStatusInt(ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
int status) {
SetRawInfoWithVerificationStatus(type, value,
static_cast<VerificationStatus>(status));
diff --git a/chromium/components/autofill/core/browser/data_model/form_group.h b/chromium/components/autofill/core/browser/data_model/form_group.h
index 18760f3253a..9d58c0d1ade 100644
--- a/chromium/components/autofill/core/browser/data_model/form_group.h
+++ b/chromium/components/autofill/core/browser/data_model/form_group.h
@@ -7,7 +7,6 @@
#include <string>
-#include "base/strings/string16.h"
#include "components/autofill/core/browser/field_types.h"
namespace autofill {
@@ -27,7 +26,7 @@ class FormGroup {
// enters into the field, interpreted in the given |app_locale| if
// appropriate. The field types can then be reported back to the server. This
// method is additive on |matching_types|.
- virtual void GetMatchingTypes(const base::string16& text,
+ virtual void GetMatchingTypes(const std::u16string& text,
const std::string& app_locale,
ServerFieldTypeSet* matching_types) const;
@@ -38,7 +37,7 @@ class FormGroup {
// Returns the string associated with |type|, without canonicalizing the
// returned value. For user-visible strings, use GetInfo() instead.
- virtual base::string16 GetRawInfo(ServerFieldType type) const = 0;
+ virtual std::u16string GetRawInfo(ServerFieldType type) const = 0;
// Finalization routine that should be called after importing a FormGroup.
// Returns true if the finalization was successful.
@@ -50,18 +49,18 @@ class FormGroup {
// Accepts a verification status.
virtual void SetRawInfoWithVerificationStatus(
ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
structured_address::VerificationStatus status) = 0;
// Convenience wrapper to allow passing the status as an integer.
void SetRawInfoWithVerificationStatusInt(ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
int status);
// Convenience wrapper to add
// |structured_address::VerificationStatus::kNoStatus| to
// |SetRawInfoWithVerificationStatus|.
- void SetRawInfo(ServerFieldType type, const base::string16& value);
+ void SetRawInfo(ServerFieldType type, const std::u16string& value);
// Returns true iff the string associated with |type| is nonempty (without
// canonicalizing its value).
@@ -69,9 +68,9 @@ class FormGroup {
// Returns the string that should be auto-filled into a text field given the
// type of that field, localized to the given |app_locale| if appropriate.
- base::string16 GetInfo(ServerFieldType type,
+ std::u16string GetInfo(ServerFieldType type,
const std::string& app_locale) const;
- base::string16 GetInfo(const AutofillType& type,
+ std::u16string GetInfo(const AutofillType& type,
const std::string& app_locale) const;
// Returns the verification status associated with the type.
@@ -89,22 +88,22 @@ class FormGroup {
// Used to populate this FormGroup object with data. Canonicalizes the data
// according to the specified |app_locale| prior to storing, if appropriate.
bool SetInfo(ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale);
bool SetInfo(const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale);
// Same as |SetInfo| but supports a verification status.
bool SetInfoWithVerificationStatus(
ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale,
const structured_address::VerificationStatus status);
bool SetInfoWithVerificationStatus(
const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale,
const structured_address::VerificationStatus status);
@@ -123,14 +122,14 @@ class FormGroup {
// Returns the string that should be auto-filled into a text field given the
// type of that field, localized to the given |app_locale| if appropriate.
- virtual base::string16 GetInfoImpl(const AutofillType& type,
+ virtual std::u16string GetInfoImpl(const AutofillType& type,
const std::string& app_locale) const;
// Used to populate this FormGroup object with data. Canonicalizes the data
// according to the specified |app_locale| prior to storing, if appropriate.
virtual bool SetInfoWithVerificationStatusImpl(
const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale,
const structured_address::VerificationStatus status);
diff --git a/chromium/components/autofill/core/browser/data_model/phone_number.cc b/chromium/components/autofill/core/browser/data_model/phone_number.cc
index 3eb07f06293..6b2509d3937 100644
--- a/chromium/components/autofill/core/browser/data_model/phone_number.cc
+++ b/chromium/components/autofill/core/browser/data_model/phone_number.cc
@@ -31,7 +31,7 @@ namespace {
// code corresponding to the |app_locale|.
std::string GetRegion(const AutofillProfile& profile,
const std::string& app_locale) {
- base::string16 country_code = profile.GetRawInfo(ADDRESS_HOME_COUNTRY);
+ std::u16string country_code = profile.GetRawInfo(ADDRESS_HOME_COUNTRY);
if (!country_code.empty())
return base::UTF16ToASCII(country_code);
@@ -73,7 +73,7 @@ void PhoneNumber::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
supported_types->insert(PHONE_HOME_COUNTRY_CODE);
}
-base::string16 PhoneNumber::GetRawInfo(ServerFieldType type) const {
+std::u16string PhoneNumber::GetRawInfo(ServerFieldType type) const {
DCHECK_EQ(FieldTypeGroup::kPhoneHome, AutofillType(type).group());
if (type == PHONE_HOME_WHOLE_NUMBER)
return number_;
@@ -81,11 +81,11 @@ base::string16 PhoneNumber::GetRawInfo(ServerFieldType type) const {
// Only the whole number is available as raw data. All of the other types are
// parsed from this raw info, and parsing requires knowledge of the phone
// number's region, which is only available via GetInfo().
- return base::string16();
+ return std::u16string();
}
void PhoneNumber::SetRawInfoWithVerificationStatus(ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
VerificationStatus status) {
DCHECK_EQ(FieldTypeGroup::kPhoneHome, AutofillType(type).group());
if (type != PHONE_HOME_CITY_AND_NUMBER && type != PHONE_HOME_WHOLE_NUMBER) {
@@ -100,7 +100,7 @@ void PhoneNumber::SetRawInfoWithVerificationStatus(ServerFieldType type,
cached_parsed_phone_ = i18n::PhoneObject();
}
-void PhoneNumber::GetMatchingTypes(const base::string16& text,
+void PhoneNumber::GetMatchingTypes(const std::u16string& text,
const std::string& app_locale,
ServerFieldTypeSet* matching_types) const {
// Strip the common phone number non numerical characters before calling the
@@ -108,17 +108,17 @@ void PhoneNumber::GetMatchingTypes(const base::string16& text,
// would become the stripped text "5141211523". Since the base matching
// function only does simple canonicalization to match against the stored
// data, some domain specific cases will be covered below.
- base::string16 stripped_text = text;
- base::RemoveChars(stripped_text, base::ASCIIToUTF16(" .()-"), &stripped_text);
+ std::u16string stripped_text = text;
+ base::RemoveChars(stripped_text, u" .()-", &stripped_text);
FormGroup::GetMatchingTypes(stripped_text, app_locale, matching_types);
// For US numbers, also compare to the three-digit prefix and the four-digit
// suffix, since web sites often split numbers into these two fields.
- base::string16 number = GetInfo(AutofillType(PHONE_HOME_NUMBER), app_locale);
+ std::u16string number = GetInfo(AutofillType(PHONE_HOME_NUMBER), app_locale);
if (GetRegion(*profile_, app_locale) == "US" &&
number.size() == (kPrefixLength + kSuffixLength)) {
- base::string16 prefix = number.substr(kPrefixOffset, kPrefixLength);
- base::string16 suffix = number.substr(kSuffixOffset, kSuffixLength);
+ std::u16string prefix = number.substr(kPrefixOffset, kPrefixLength);
+ std::u16string suffix = number.substr(kSuffixOffset, kSuffixLength);
if (text == prefix || text == suffix)
matching_types->insert(PHONE_HOME_NUMBER);
}
@@ -131,10 +131,10 @@ void PhoneNumber::GetMatchingTypes(const base::string16& text,
// "+33249197070" whereas the US number "+1 (234) 567-8901" would be
// normalized to "12345678901".
if (matching_types->find(PHONE_HOME_WHOLE_NUMBER) == matching_types->end()) {
- base::string16 whole_number =
+ std::u16string whole_number =
GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), app_locale);
if (!whole_number.empty()) {
- base::string16 normalized_number =
+ std::u16string normalized_number =
i18n::NormalizePhoneNumber(text, GetRegion(*profile_, app_locale));
if (normalized_number == whole_number)
matching_types->insert(PHONE_HOME_WHOLE_NUMBER);
@@ -145,9 +145,9 @@ void PhoneNumber::GetMatchingTypes(const base::string16& text,
// the digits extracted from the |stripped_text| match the |country_code|.
if (base::FeatureList::IsEnabled(
features::kAutofillEnableAugmentedPhoneCountryCode)) {
- base::string16 candidate =
+ std::u16string candidate =
data_util::FindPossiblePhoneCountryCode(stripped_text);
- base::string16 country_code =
+ std::u16string country_code =
GetInfo(AutofillType(PHONE_HOME_COUNTRY_CODE), app_locale);
if (candidate.size() > 0 && candidate == country_code)
matching_types->insert(PHONE_HOME_COUNTRY_CODE);
@@ -158,7 +158,7 @@ void PhoneNumber::GetMatchingTypes(const base::string16& text,
// (650)2345678 -> 6502345678
// 1-800-FLOWERS -> 18003569377
// If the phone cannot be normalized, returns the stored value verbatim.
-base::string16 PhoneNumber::GetInfoImpl(const AutofillType& type,
+std::u16string PhoneNumber::GetInfoImpl(const AutofillType& type,
const std::string& app_locale) const {
ServerFieldType storable_type = type.GetStorableType();
UpdateCacheIfNeeded(app_locale);
@@ -171,7 +171,7 @@ base::string16 PhoneNumber::GetInfoImpl(const AutofillType& type,
storable_type == PHONE_HOME_CITY_AND_NUMBER) {
return cached_parsed_phone_.GetWholeNumber();
}
- return base::string16();
+ return std::u16string();
}
switch (storable_type) {
@@ -191,7 +191,7 @@ base::string16 PhoneNumber::GetInfoImpl(const AutofillType& type,
// Just concatenating city code and phone number is insufficient because
// a number of non-US countries (e.g. Germany and France) use a leading 0
// to indicate that the next digits represent a city code.
- base::string16 national_number =
+ std::u16string national_number =
cached_parsed_phone_.GetNationallyFormattedNumber();
// GetNationallyFormattedNumber optimizes for screen display, e.g. it
// shows a US number as (888) 123-1234. The following retains only the
@@ -204,17 +204,17 @@ base::string16 PhoneNumber::GetInfoImpl(const AutofillType& type,
}
case PHONE_HOME_EXTENSION:
- return base::string16();
+ return std::u16string();
default:
NOTREACHED();
- return base::string16();
+ return std::u16string();
}
}
bool PhoneNumber::SetInfoWithVerificationStatusImpl(
const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale,
VerificationStatus status) {
SetRawInfoWithVerificationStatus(type.GetStorableType(), value, status);
@@ -225,7 +225,7 @@ bool PhoneNumber::SetInfoWithVerificationStatusImpl(
// Store a formatted (i.e., pretty printed) version of the number if either
// the number doesn't contain formatting marks.
UpdateCacheIfNeeded(app_locale);
- if (base::ContainsOnlyChars(number_, base::ASCIIToUTF16("+0123456789"))) {
+ if (base::ContainsOnlyChars(number_, u"+0123456789")) {
number_ = cached_parsed_phone_.GetFormattedNumber();
} else if (i18n::NormalizePhoneNumber(number_,
GetRegion(*profile_, app_locale))
@@ -247,7 +247,7 @@ PhoneNumber::PhoneCombineHelper::PhoneCombineHelper() {}
PhoneNumber::PhoneCombineHelper::~PhoneCombineHelper() {}
bool PhoneNumber::PhoneCombineHelper::SetInfo(const AutofillType& type,
- const base::string16& value) {
+ const std::u16string& value) {
ServerFieldType storable_type = type.GetStorableType();
if (storable_type == PHONE_HOME_COUNTRY_CODE) {
country_ = value;
@@ -280,7 +280,7 @@ bool PhoneNumber::PhoneCombineHelper::SetInfo(const AutofillType& type,
bool PhoneNumber::PhoneCombineHelper::ParseNumber(
const AutofillProfile& profile,
const std::string& app_locale,
- base::string16* value) {
+ std::u16string* value) {
if (IsEmpty())
return false;
diff --git a/chromium/components/autofill/core/browser/data_model/phone_number.h b/chromium/components/autofill/core/browser/data_model/phone_number.h
index ef29aeee5d9..556941e6291 100644
--- a/chromium/components/autofill/core/browser/data_model/phone_number.h
+++ b/chromium/components/autofill/core/browser/data_model/phone_number.h
@@ -10,7 +10,6 @@
#include <string>
#include <vector>
-#include "base/strings/string16.h"
#include "components/autofill/core/browser/data_model/form_group.h"
#include "components/autofill/core/browser/geo/phone_number_i18n.h"
@@ -32,13 +31,13 @@ class PhoneNumber : public FormGroup {
void set_profile(const AutofillProfile* profile) { profile_ = profile; }
// FormGroup implementation:
- void GetMatchingTypes(const base::string16& text,
+ void GetMatchingTypes(const std::u16string& text,
const std::string& app_locale,
ServerFieldTypeSet* matching_types) const override;
- base::string16 GetRawInfo(ServerFieldType type) const override;
+ std::u16string GetRawInfo(ServerFieldType type) const override;
void SetRawInfoWithVerificationStatus(
ServerFieldType type,
- const base::string16& value,
+ const std::u16string& value,
structured_address::VerificationStatus status) override;
// Size and offset of the prefix and suffix portions of phone numbers.
@@ -55,7 +54,7 @@ class PhoneNumber : public FormGroup {
// If |type| is a phone field type, saves the |value| accordingly and
// returns true. For all other field types returns false.
- bool SetInfo(const AutofillType& type, const base::string16& value);
+ bool SetInfo(const AutofillType& type, const std::u16string& value);
// Parses the number built up from pieces stored via SetInfo() according to
// the specified |profile|'s country code, falling back to the given
@@ -63,26 +62,26 @@ class PhoneNumber : public FormGroup {
// true if parsing was successful, false otherwise.
bool ParseNumber(const AutofillProfile& profile,
const std::string& app_locale,
- base::string16* value);
+ std::u16string* value);
// Returns true if both |phone_| and |whole_number_| are empty.
bool IsEmpty() const;
private:
- base::string16 country_;
- base::string16 city_;
- base::string16 phone_;
- base::string16 whole_number_;
+ std::u16string country_;
+ std::u16string city_;
+ std::u16string phone_;
+ std::u16string whole_number_;
};
private:
// FormGroup:
void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override;
- base::string16 GetInfoImpl(const AutofillType& type,
+ std::u16string GetInfoImpl(const AutofillType& type,
const std::string& app_locale) const override;
bool SetInfoWithVerificationStatusImpl(
const AutofillType& type,
- const base::string16& value,
+ const std::u16string& value,
const std::string& app_locale,
structured_address::VerificationStatus status) override;
@@ -91,7 +90,7 @@ class PhoneNumber : public FormGroup {
void UpdateCacheIfNeeded(const std::string& app_locale) const;
// The phone number.
- base::string16 number_;
+ std::u16string number_;
// Profile which stores the region used as hint when normalizing the number.
const AutofillProfile* profile_; // WEAK
diff --git a/chromium/components/autofill/core/browser/data_model/phone_number_unittest.cc b/chromium/components/autofill/core/browser/data_model/phone_number_unittest.cc
index 2a28625d1d9..b774dfaec0a 100644
--- a/chromium/components/autofill/core/browser/data_model/phone_number_unittest.cc
+++ b/chromium/components/autofill/core/browser/data_model/phone_number_unittest.cc
@@ -4,7 +4,8 @@
#include "components/autofill/core/browser/data_model/phone_number.h"
-#include "base/strings/string16.h"
+#include <string>
+
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill/core/browser/autofill_type.h"
@@ -21,69 +22,66 @@ namespace autofill {
TEST(PhoneNumberTest, Matcher) {
AutofillProfile profile;
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US");
// Set phone number so country_code == 1, city_code = 650, number = 2345678.
- base::string16 phone(ASCIIToUTF16("1 [650] 234-5678"));
+ std::u16string phone(u"1 [650] 234-5678");
PhoneNumber phone_number(&profile);
phone_number.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), phone, "US");
ServerFieldTypeSet matching_types;
- phone_number.GetMatchingTypes(base::string16(), "US", &matching_types);
+ phone_number.GetMatchingTypes(std::u16string(), "US", &matching_types);
EXPECT_EQ(1U, matching_types.size());
EXPECT_TRUE(matching_types.find(EMPTY_TYPE) != matching_types.end());
matching_types.clear();
- phone_number.GetMatchingTypes(ASCIIToUTF16("1"), "US", &matching_types);
+ phone_number.GetMatchingTypes(u"1", "US", &matching_types);
EXPECT_EQ(1U, matching_types.size());
EXPECT_TRUE(matching_types.find(PHONE_HOME_COUNTRY_CODE) !=
matching_types.end());
matching_types.clear();
- phone_number.GetMatchingTypes(ASCIIToUTF16("16"), "US", &matching_types);
+ phone_number.GetMatchingTypes(u"16", "US", &matching_types);
EXPECT_EQ(0U, matching_types.size());
- phone_number.GetMatchingTypes(ASCIIToUTF16("165"), "US", &matching_types);
+ phone_number.GetMatchingTypes(u"165", "US", &matching_types);
EXPECT_EQ(0U, matching_types.size());
- phone_number.GetMatchingTypes(ASCIIToUTF16("1650"), "US", &matching_types);
+ phone_number.GetMatchingTypes(u"1650", "US", &matching_types);
EXPECT_EQ(0U, matching_types.size());
- phone_number.GetMatchingTypes(ASCIIToUTF16("16502"), "US", &matching_types);
+ phone_number.GetMatchingTypes(u"16502", "US", &matching_types);
EXPECT_EQ(0U, matching_types.size());
- phone_number.GetMatchingTypes(ASCIIToUTF16("165023"), "US", &matching_types);
+ phone_number.GetMatchingTypes(u"165023", "US", &matching_types);
EXPECT_EQ(0U, matching_types.size());
- phone_number.GetMatchingTypes(ASCIIToUTF16("1650234"), "US", &matching_types);
+ phone_number.GetMatchingTypes(u"1650234", "US", &matching_types);
EXPECT_EQ(0U, matching_types.size());
matching_types.clear();
- phone_number.GetMatchingTypes(ASCIIToUTF16("16502345678"), "US",
- &matching_types);
+ phone_number.GetMatchingTypes(u"16502345678", "US", &matching_types);
EXPECT_EQ(1U, matching_types.size());
EXPECT_TRUE(matching_types.find(PHONE_HOME_WHOLE_NUMBER) !=
matching_types.end());
matching_types.clear();
- phone_number.GetMatchingTypes(ASCIIToUTF16("650"), "US", &matching_types);
+ phone_number.GetMatchingTypes(u"650", "US", &matching_types);
EXPECT_EQ(1U, matching_types.size());
EXPECT_TRUE(matching_types.find(PHONE_HOME_CITY_CODE) !=
matching_types.end());
matching_types.clear();
- phone_number.GetMatchingTypes(ASCIIToUTF16("2345678"), "US", &matching_types);
+ phone_number.GetMatchingTypes(u"2345678", "US", &matching_types);
EXPECT_EQ(1U, matching_types.size());
EXPECT_TRUE(matching_types.find(PHONE_HOME_NUMBER) != matching_types.end());
matching_types.clear();
- phone_number.GetMatchingTypes(ASCIIToUTF16("234"), "US", &matching_types);
+ phone_number.GetMatchingTypes(u"234", "US", &matching_types);
EXPECT_EQ(1U, matching_types.size());
EXPECT_TRUE(matching_types.find(PHONE_HOME_NUMBER) != matching_types.end());
matching_types.clear();
- phone_number.GetMatchingTypes(ASCIIToUTF16("5678"), "US", &matching_types);
+ phone_number.GetMatchingTypes(u"5678", "US", &matching_types);
EXPECT_EQ(1U, matching_types.size());
EXPECT_TRUE(matching_types.find(PHONE_HOME_NUMBER) != matching_types.end());
matching_types.clear();
- phone_number.GetMatchingTypes(ASCIIToUTF16("2345"), "US", &matching_types);
+ phone_number.GetMatchingTypes(u"2345", "US", &matching_types);
EXPECT_EQ(0U, matching_types.size());
matching_types.clear();
- phone_number.GetMatchingTypes(ASCIIToUTF16("6502345678"), "US",
- &matching_types);
+ phone_number.GetMatchingTypes(u"6502345678", "US", &matching_types);
EXPECT_EQ(1U, matching_types.size());
EXPECT_TRUE(matching_types.find(PHONE_HOME_CITY_AND_NUMBER) !=
matching_types.end());
matching_types.clear();
- phone_number.GetMatchingTypes(ASCIIToUTF16("(650)2345678"), "US",
- &matching_types);
+ phone_number.GetMatchingTypes(u"(650)2345678", "US", &matching_types);
EXPECT_EQ(1U, matching_types.size());
EXPECT_TRUE(matching_types.find(PHONE_HOME_CITY_AND_NUMBER) !=
matching_types.end());
@@ -92,202 +90,176 @@ TEST(PhoneNumberTest, Matcher) {
TEST(PhoneNumberTest, Matcher_DE) {
// Verify that the derived types of German numbers are correct.
AutofillProfile profile;
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE"));
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"DE");
PhoneNumber phone_number(&profile);
- phone_number.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
- ASCIIToUTF16("+491741234567"), "DE");
+ phone_number.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), u"+491741234567",
+ "DE");
ServerFieldTypeSet matching_types;
- phone_number.GetMatchingTypes(ASCIIToUTF16("+491741234567"), "de-DE",
- &matching_types);
+ phone_number.GetMatchingTypes(u"+491741234567", "de-DE", &matching_types);
EXPECT_THAT(matching_types, testing::ElementsAre(PHONE_HOME_WHOLE_NUMBER));
matching_types.clear();
- phone_number.GetMatchingTypes(ASCIIToUTF16("01741234567"), "de-DE",
- &matching_types);
+ phone_number.GetMatchingTypes(u"01741234567", "de-DE", &matching_types);
EXPECT_THAT(matching_types, testing::ElementsAre(PHONE_HOME_CITY_AND_NUMBER));
matching_types.clear();
- phone_number.GetMatchingTypes(ASCIIToUTF16("1234567"), "de-DE",
- &matching_types);
+ phone_number.GetMatchingTypes(u"1234567", "de-DE", &matching_types);
EXPECT_THAT(matching_types, testing::ElementsAre(PHONE_HOME_NUMBER));
// TODO(crbug.com/638795) This is incorrect and should be 0174.
matching_types.clear();
- phone_number.GetMatchingTypes(ASCIIToUTF16("174"), "de-DE", &matching_types);
+ phone_number.GetMatchingTypes(u"174", "de-DE", &matching_types);
EXPECT_THAT(matching_types, testing::ElementsAre(PHONE_HOME_CITY_CODE));
}
// Verify that PhoneNumber::SetInfo() correctly formats the incoming number.
TEST(PhoneNumberTest, SetInfo) {
AutofillProfile profile;
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US");
PhoneNumber phone(&profile);
- EXPECT_EQ(base::string16(), phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
+ EXPECT_EQ(std::u16string(), phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
// Set the formatted info directly.
EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
- ASCIIToUTF16("(650) 234-5678"), "US"));
- EXPECT_EQ(ASCIIToUTF16("(650) 234-5678"),
- phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
+ u"(650) 234-5678", "US"));
+ EXPECT_EQ(u"(650) 234-5678", phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
// Unformatted numbers should be formatted.
EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
- ASCIIToUTF16("8887776666"), "US"));
- EXPECT_EQ(ASCIIToUTF16("(888) 777-6666"),
- phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
+ u"8887776666", "US"));
+ EXPECT_EQ(u"(888) 777-6666", phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
- ASCIIToUTF16("+18887776666"), "US"));
- EXPECT_EQ(ASCIIToUTF16("1 888-777-6666"),
- phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
+ u"+18887776666", "US"));
+ EXPECT_EQ(u"1 888-777-6666", phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
// Differently formatted numbers should be left alone.
EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
- ASCIIToUTF16("800-432-8765"), "US"));
- EXPECT_EQ(ASCIIToUTF16("800-432-8765"),
- phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
+ u"800-432-8765", "US"));
+ EXPECT_EQ(u"800-432-8765", phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
// SetRawInfo should not try to format.
- phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("8004328765"));
- EXPECT_EQ(ASCIIToUTF16("8004328765"),
- phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
+ phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"8004328765");
+ EXPECT_EQ(u"8004328765", phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
// Invalid numbers should not be stored. In the US, phone numbers cannot
// start with the digit '1'.
- EXPECT_FALSE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
- ASCIIToUTF16("650111111"), "US"));
- EXPECT_EQ(base::string16(), phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
+ EXPECT_FALSE(
+ phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), u"650111111", "US"));
+ EXPECT_EQ(std::u16string(), phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
// If the stored number is invalid due to metadata mismatch(non-existing
// carrier code for example), but otherwise is a possible number and can be
// parsed into different components, we should respond to queries with best
// effort as if it is a valid number.
EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
- ASCIIToUTF16("5141231234"), "US"));
- EXPECT_EQ(ASCIIToUTF16("5141231234"),
- phone.GetInfo(PHONE_HOME_CITY_AND_NUMBER, "CA"));
- EXPECT_EQ(ASCIIToUTF16("5141231234"),
- phone.GetInfo(PHONE_HOME_WHOLE_NUMBER, "CA"));
- EXPECT_EQ(ASCIIToUTF16("514"), phone.GetInfo(PHONE_HOME_CITY_CODE, "CA"));
+ u"5141231234", "US"));
+ EXPECT_EQ(u"5141231234", phone.GetInfo(PHONE_HOME_CITY_AND_NUMBER, "CA"));
+ EXPECT_EQ(u"5141231234", phone.GetInfo(PHONE_HOME_WHOLE_NUMBER, "CA"));
+ EXPECT_EQ(u"514", phone.GetInfo(PHONE_HOME_CITY_CODE, "CA"));
}
// Test that cached phone numbers are correctly invalidated and updated.
TEST(PhoneNumberTest, UpdateCachedPhoneNumber) {
AutofillProfile profile;
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US");
PhoneNumber phone(&profile);
- phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("6502345678"));
- EXPECT_EQ(ASCIIToUTF16("650"),
- phone.GetInfo(AutofillType(PHONE_HOME_CITY_CODE), "US"));
+ phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"6502345678");
+ EXPECT_EQ(u"650", phone.GetInfo(AutofillType(PHONE_HOME_CITY_CODE), "US"));
// Update the area code.
- phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("8322345678"));
- EXPECT_EQ(ASCIIToUTF16("832"),
- phone.GetInfo(AutofillType(PHONE_HOME_CITY_CODE), "US"));
+ phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"8322345678");
+ EXPECT_EQ(u"832", phone.GetInfo(AutofillType(PHONE_HOME_CITY_CODE), "US"));
// Change the phone number to have a UK format, but try to parse with the
// wrong locale.
- phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("07023456789"));
- EXPECT_EQ(base::string16(),
+ phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"07023456789");
+ EXPECT_EQ(std::u16string(),
phone.GetInfo(AutofillType(PHONE_HOME_CITY_CODE), "US"));
// Now try parsing using the correct locale. Note that the profile's country
// code should override the app locale, which is still set to "US".
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("GB"));
- phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("07023456789"));
- EXPECT_EQ(ASCIIToUTF16("70"),
- phone.GetInfo(AutofillType(PHONE_HOME_CITY_CODE), "US"));
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"GB");
+ phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"07023456789");
+ EXPECT_EQ(u"70", phone.GetInfo(AutofillType(PHONE_HOME_CITY_CODE), "US"));
}
TEST(PhoneNumberTest, PhoneCombineHelper) {
AutofillProfile profile;
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US");
PhoneNumber::PhoneCombineHelper number1;
- EXPECT_FALSE(
- number1.SetInfo(AutofillType(ADDRESS_BILLING_CITY), ASCIIToUTF16("1")));
- EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_COUNTRY_CODE),
- ASCIIToUTF16("1")));
- EXPECT_TRUE(
- number1.SetInfo(AutofillType(PHONE_HOME_CITY_CODE), ASCIIToUTF16("650")));
- EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_NUMBER),
- ASCIIToUTF16("2345678")));
- base::string16 parsed_phone;
+ EXPECT_FALSE(number1.SetInfo(AutofillType(ADDRESS_BILLING_CITY), u"1"));
+ EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_COUNTRY_CODE), u"1"));
+ EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_CITY_CODE), u"650"));
+ EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_NUMBER), u"2345678"));
+ std::u16string parsed_phone;
EXPECT_TRUE(number1.ParseNumber(profile, "en-US", &parsed_phone));
// International format as it has a country code.
- EXPECT_EQ(ASCIIToUTF16("1 650-234-5678"), parsed_phone);
+ EXPECT_EQ(u"1 650-234-5678", parsed_phone);
PhoneNumber::PhoneCombineHelper number3;
- EXPECT_TRUE(
- number3.SetInfo(AutofillType(PHONE_HOME_CITY_CODE), ASCIIToUTF16("650")));
- EXPECT_TRUE(number3.SetInfo(AutofillType(PHONE_HOME_NUMBER),
- ASCIIToUTF16("2345680")));
+ EXPECT_TRUE(number3.SetInfo(AutofillType(PHONE_HOME_CITY_CODE), u"650"));
+ EXPECT_TRUE(number3.SetInfo(AutofillType(PHONE_HOME_NUMBER), u"2345680"));
EXPECT_TRUE(number3.ParseNumber(profile, "en-US", &parsed_phone));
// National format as it does not have a country code.
- EXPECT_EQ(ASCIIToUTF16("(650) 234-5680"), parsed_phone);
+ EXPECT_EQ(u"(650) 234-5680", parsed_phone);
PhoneNumber::PhoneCombineHelper number4;
EXPECT_TRUE(number4.SetInfo(AutofillType(PHONE_HOME_CITY_CODE),
- ASCIIToUTF16("123"))); // Incorrect city code.
- EXPECT_TRUE(number4.SetInfo(AutofillType(PHONE_HOME_NUMBER),
- ASCIIToUTF16("2345680")));
+ u"123")); // Incorrect city code.
+ EXPECT_TRUE(number4.SetInfo(AutofillType(PHONE_HOME_NUMBER), u"2345680"));
EXPECT_TRUE(number4.ParseNumber(profile, "en-US", &parsed_phone));
- EXPECT_EQ(ASCIIToUTF16("1232345680"), parsed_phone);
+ EXPECT_EQ(u"1232345680", parsed_phone);
PhoneNumber::PhoneCombineHelper number5;
- EXPECT_TRUE(number5.SetInfo(AutofillType(PHONE_HOME_CITY_AND_NUMBER),
- ASCIIToUTF16("6502345681")));
+ EXPECT_TRUE(
+ number5.SetInfo(AutofillType(PHONE_HOME_CITY_AND_NUMBER), u"6502345681"));
EXPECT_TRUE(number5.ParseNumber(profile, "en-US", &parsed_phone));
- EXPECT_EQ(ASCIIToUTF16("(650) 234-5681"), parsed_phone);
+ EXPECT_EQ(u"(650) 234-5681", parsed_phone);
PhoneNumber::PhoneCombineHelper number6;
- EXPECT_TRUE(
- number6.SetInfo(AutofillType(PHONE_HOME_CITY_CODE), ASCIIToUTF16("650")));
- EXPECT_TRUE(
- number6.SetInfo(AutofillType(PHONE_HOME_NUMBER), ASCIIToUTF16("234")));
- EXPECT_TRUE(
- number6.SetInfo(AutofillType(PHONE_HOME_NUMBER), ASCIIToUTF16("5682")));
+ EXPECT_TRUE(number6.SetInfo(AutofillType(PHONE_HOME_CITY_CODE), u"650"));
+ EXPECT_TRUE(number6.SetInfo(AutofillType(PHONE_HOME_NUMBER), u"234"));
+ EXPECT_TRUE(number6.SetInfo(AutofillType(PHONE_HOME_NUMBER), u"5682"));
EXPECT_TRUE(number6.ParseNumber(profile, "en-US", &parsed_phone));
- EXPECT_EQ(ASCIIToUTF16("(650) 234-5682"), parsed_phone);
+ EXPECT_EQ(u"(650) 234-5682", parsed_phone);
// Ensure parsing is possible when falling back to detecting the country code
// based on the app locale.
PhoneNumber::PhoneCombineHelper number7;
- EXPECT_TRUE(
- number7.SetInfo(AutofillType(PHONE_HOME_CITY_CODE), ASCIIToUTF16("650")));
- EXPECT_TRUE(
- number7.SetInfo(AutofillType(PHONE_HOME_NUMBER), ASCIIToUTF16("234")));
- EXPECT_TRUE(
- number7.SetInfo(AutofillType(PHONE_HOME_NUMBER), ASCIIToUTF16("5682")));
+ EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_CITY_CODE), u"650"));
+ EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER), u"234"));
+ EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER), u"5682"));
EXPECT_TRUE(number7.ParseNumber(AutofillProfile(), "en-US", &parsed_phone));
- EXPECT_EQ(ASCIIToUTF16("(650) 234-5682"), parsed_phone);
+ EXPECT_EQ(u"(650) 234-5682", parsed_phone);
}
TEST(PhoneNumberTest, InternationalPhoneHomeCityAndNumber_US) {
AutofillProfile profile;
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US");
// Set phone number so country_code == 1, city_code = 650, number = 2345678.
- base::string16 phone(ASCIIToUTF16("+1 (650) 234-5678"));
+ std::u16string phone(u"+1 (650) 234-5678");
PhoneNumber phone_number(&profile);
phone_number.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), phone, "en-US");
- EXPECT_EQ(ASCIIToUTF16("6502345678"),
+ EXPECT_EQ(u"6502345678",
phone_number.GetInfo(PHONE_HOME_CITY_AND_NUMBER, "en-US"));
}
// This is a regression test for crbug.com/638795.
TEST(PhoneNumberTest, InternationalPhoneHomeCityAndNumber_DE) {
AutofillProfile profile;
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE"));
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"DE");
// Set phone number so country_code == 49, city_code = 174, number = 12 34
// 567.
- base::string16 phone(ASCIIToUTF16("+49 (174) 12 34 567"));
+ std::u16string phone(u"+49 (174) 12 34 567");
PhoneNumber phone_number(&profile);
phone_number.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), phone, "en-US");
// Note that for German numbers (unlike US numbers), the
// PHONE_HOME_CITY_AND_NUMBER should start with a 0.
- EXPECT_EQ(ASCIIToUTF16("01741234567"),
+ EXPECT_EQ(u"01741234567",
phone_number.GetInfo(PHONE_HOME_CITY_AND_NUMBER, "en-US"));
}
@@ -299,10 +271,10 @@ TEST(PhoneNumberTest, CountryCodeInMatchingTypes) {
features::kAutofillEnableAugmentedPhoneCountryCode);
AutofillProfile profile;
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US");
// Set the phone number such that country_code == 1, city_code = 650,
// number = 2345678.
- base::string16 phone(ASCIIToUTF16("1 [650] 234-5678"));
+ std::u16string phone(u"1 [650] 234-5678");
PhoneNumber phone_number(&profile);
phone_number.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), phone, "US");
@@ -319,8 +291,8 @@ TEST(PhoneNumberTest, CountryCodeInMatchingTypes) {
EXPECT_THAT(matching_types, testing::ElementsAre(PHONE_HOME_COUNTRY_CODE));
}
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE"));
- base::string16 de_phone(ASCIIToUTF16("+49 0151 6679586"));
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"DE");
+ std::u16string de_phone(u"+49 0151 6679586");
PhoneNumber phone_number_de(&profile);
phone_number_de.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), de_phone,
"DE");
@@ -345,9 +317,9 @@ TEST(PhoneNumberTest, CountryCodeNotInMatchingTypes) {
features::kAutofillEnableAugmentedPhoneCountryCode);
AutofillProfile profile;
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US");
// Set phone number so country_code == 1, city_code = 650, number = 2345678.
- base::string16 phone(ASCIIToUTF16("1 [650] 234-5678"));
+ std::u16string phone(u"1 [650] 234-5678");
PhoneNumber phone_number(&profile);
phone_number.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), phone, "US");
diff --git a/chromium/components/autofill/core/browser/data_model/test_data_creator.cc b/chromium/components/autofill/core/browser/data_model/test_data_creator.cc
index edb610199dc..aae60b06afd 100644
--- a/chromium/components/autofill/core/browser/data_model/test_data_creator.cc
+++ b/chromium/components/autofill/core/browser/data_model/test_data_creator.cc
@@ -81,23 +81,16 @@ AutofillProfile TestDataCreator::CreateBasicTestAddress() {
const base::Time use_date =
AutofillClock::Now() - base::TimeDelta::FromDays(20);
AutofillProfile profile;
- profile.SetInfo(NAME_FULL, base::UTF8ToUTF16("John McTester"), app_locale_);
- profile.SetInfo(COMPANY_NAME, base::UTF8ToUTF16("Test Inc."), app_locale_);
- profile.SetInfo(EMAIL_ADDRESS,
- base::UTF8ToUTF16("jmctester@fake.chromium.org"),
- app_locale_);
- profile.SetInfo(ADDRESS_HOME_LINE1, base::UTF8ToUTF16("123 Invented Street"),
- app_locale_);
- profile.SetInfo(ADDRESS_HOME_LINE2, base::UTF8ToUTF16("Suite A"),
- app_locale_);
- profile.SetInfo(ADDRESS_HOME_CITY, base::UTF8ToUTF16("Mountain View"),
- app_locale_);
- profile.SetInfo(ADDRESS_HOME_STATE, base::UTF8ToUTF16("California"),
- app_locale_);
- profile.SetInfo(ADDRESS_HOME_ZIP, base::UTF8ToUTF16("94043"), app_locale_);
- profile.SetInfo(ADDRESS_HOME_COUNTRY, base::UTF8ToUTF16("US"), app_locale_);
- profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, base::UTF8ToUTF16("844-555-0173"),
- app_locale_);
+ profile.SetInfo(NAME_FULL, u"John McTester", app_locale_);
+ profile.SetInfo(COMPANY_NAME, u"Test Inc.", app_locale_);
+ profile.SetInfo(EMAIL_ADDRESS, u"jmctester@fake.chromium.org", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_LINE1, u"123 Invented Street", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_LINE2, u"Suite A", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_CITY, u"Mountain View", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_STATE, u"California", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_ZIP, u"94043", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_COUNTRY, u"US", app_locale_);
+ profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, u"844-555-0173", app_locale_);
profile.set_use_date(use_date);
return profile;
}
@@ -106,24 +99,21 @@ AutofillProfile TestDataCreator::CreateDisusedTestAddress() {
const base::Time use_date =
AutofillClock::Now() - base::TimeDelta::FromDays(185);
AutofillProfile profile;
- profile.SetInfo(NAME_FULL, base::UTF8ToUTF16("Polly Disused"), app_locale_);
+ profile.SetInfo(NAME_FULL, u"Polly Disused", app_locale_);
profile.SetInfo(COMPANY_NAME,
base::UTF8ToUTF16(base::StringPrintf(
"%" PRIu64 " Inc.",
use_date.ToDeltaSinceWindowsEpoch().InMicroseconds())),
app_locale_);
- profile.SetInfo(EMAIL_ADDRESS,
- base::UTF8ToUTF16("polly.disused@fake.chromium.org"),
- app_locale_);
- profile.SetInfo(ADDRESS_HOME_LINE1, base::UTF8ToUTF16("456 Disused Lane"),
- app_locale_);
- profile.SetInfo(ADDRESS_HOME_LINE2, base::UTF8ToUTF16("Apt. B"), app_locale_);
- profile.SetInfo(ADDRESS_HOME_CITY, base::UTF8ToUTF16("Austin"), app_locale_);
- profile.SetInfo(ADDRESS_HOME_STATE, base::UTF8ToUTF16("Texas"), app_locale_);
- profile.SetInfo(ADDRESS_HOME_ZIP, base::UTF8ToUTF16("73301"), app_locale_);
- profile.SetInfo(ADDRESS_HOME_COUNTRY, base::UTF8ToUTF16("US"), app_locale_);
- profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, base::UTF8ToUTF16("844-555-0174"),
+ profile.SetInfo(EMAIL_ADDRESS, u"polly.disused@fake.chromium.org",
app_locale_);
+ profile.SetInfo(ADDRESS_HOME_LINE1, u"456 Disused Lane", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_LINE2, u"Apt. B", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_CITY, u"Austin", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_STATE, u"Texas", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_ZIP, u"73301", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_COUNTRY, u"US", app_locale_);
+ profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, u"844-555-0174", app_locale_);
profile.set_use_date(use_date);
return profile;
}
@@ -132,24 +122,21 @@ AutofillProfile TestDataCreator::CreateDisusedDeletableTestAddress() {
const base::Time use_date =
AutofillClock::Now() - base::TimeDelta::FromDays(400);
AutofillProfile profile;
- profile.SetInfo(NAME_FULL, base::UTF8ToUTF16("Polly Deletable"), app_locale_);
+ profile.SetInfo(NAME_FULL, u"Polly Deletable", app_locale_);
profile.SetInfo(COMPANY_NAME,
base::UTF8ToUTF16(base::StringPrintf(
"%" PRIu64 " Inc.",
use_date.ToDeltaSinceWindowsEpoch().InMicroseconds())),
app_locale_);
- profile.SetInfo(EMAIL_ADDRESS,
- base::UTF8ToUTF16("polly.deletable@fake.chromium.org"),
- app_locale_);
- profile.SetInfo(ADDRESS_HOME_LINE1, base::UTF8ToUTF16("459 Deletable Lane"),
- app_locale_);
- profile.SetInfo(ADDRESS_HOME_LINE2, base::UTF8ToUTF16("Apt. B"), app_locale_);
- profile.SetInfo(ADDRESS_HOME_CITY, base::UTF8ToUTF16("Austin"), app_locale_);
- profile.SetInfo(ADDRESS_HOME_STATE, base::UTF8ToUTF16("Texas"), app_locale_);
- profile.SetInfo(ADDRESS_HOME_ZIP, base::UTF8ToUTF16("73301"), app_locale_);
- profile.SetInfo(ADDRESS_HOME_COUNTRY, base::UTF8ToUTF16("US"), app_locale_);
- profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, base::UTF8ToUTF16("844-555-0274"),
+ profile.SetInfo(EMAIL_ADDRESS, u"polly.deletable@fake.chromium.org",
app_locale_);
+ profile.SetInfo(ADDRESS_HOME_LINE1, u"459 Deletable Lane", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_LINE2, u"Apt. B", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_CITY, u"Austin", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_STATE, u"Texas", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_ZIP, u"73301", app_locale_);
+ profile.SetInfo(ADDRESS_HOME_COUNTRY, u"US", app_locale_);
+ profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, u"844-555-0274", app_locale_);
profile.set_use_date(use_date);
return profile;
}
@@ -162,10 +149,8 @@ CreditCard TestDataCreator::CreateBasicTestCreditCard() {
(now + base::TimeDelta::FromDays(500)).LocalExplode(&expiry_date);
CreditCard credit_card;
- credit_card.SetInfo(CREDIT_CARD_NAME_FULL,
- base::UTF8ToUTF16("Alice Testerson"), app_locale_);
- credit_card.SetInfo(CREDIT_CARD_NUMBER, base::UTF8ToUTF16("4545454545454545"),
- app_locale_);
+ credit_card.SetInfo(CREDIT_CARD_NAME_FULL, u"Alice Testerson", app_locale_);
+ credit_card.SetInfo(CREDIT_CARD_NUMBER, u"4545454545454545", app_locale_);
credit_card.SetExpirationMonth(expiry_date.month);
credit_card.SetExpirationYear(expiry_date.year);
credit_card.set_use_date(use_date);
@@ -179,10 +164,8 @@ CreditCard TestDataCreator::CreateDisusedTestCreditCard() {
(now - base::TimeDelta::FromDays(200)).LocalExplode(&expiry_date);
CreditCard credit_card;
- credit_card.SetInfo(CREDIT_CARD_NAME_FULL, base::UTF8ToUTF16("Bob Disused"),
- app_locale_);
- credit_card.SetInfo(CREDIT_CARD_NUMBER, base::UTF8ToUTF16("4111111111111111"),
- app_locale_);
+ credit_card.SetInfo(CREDIT_CARD_NAME_FULL, u"Bob Disused", app_locale_);
+ credit_card.SetInfo(CREDIT_CARD_NUMBER, u"4111111111111111", app_locale_);
credit_card.SetExpirationMonth(expiry_date.month);
credit_card.SetExpirationYear(expiry_date.year);
credit_card.set_use_date(use_date);
@@ -197,10 +180,8 @@ CreditCard TestDataCreator::CreateDisusedDeletableTestCreditCard() {
.LocalExplode(&expiry_date);
CreditCard credit_card;
- credit_card.SetInfo(CREDIT_CARD_NAME_FULL,
- base::UTF8ToUTF16("Charlie Deletable"), app_locale_);
- credit_card.SetInfo(CREDIT_CARD_NUMBER, base::UTF8ToUTF16("378282246310005"),
- app_locale_);
+ credit_card.SetInfo(CREDIT_CARD_NAME_FULL, u"Charlie Deletable", app_locale_);
+ credit_card.SetInfo(CREDIT_CARD_NUMBER, u"378282246310005", app_locale_);
credit_card.SetExpirationMonth(expiry_date.month);
credit_card.SetExpirationYear(expiry_date.year);
credit_card.set_use_date(use_date);