diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-09-01 11:08:40 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-10-01 12:16:21 +0000 |
commit | 03c549e0392f92c02536d3f86d5e1d8dfa3435ac (patch) | |
tree | fe49d170a929b34ba82cd10db1a0bd8e3760fa4b /chromium/components/autofill/core | |
parent | 5d013f5804a0d91fcf6c626b2d6fb6eca5c845b0 (diff) | |
download | qtwebengine-chromium-03c549e0392f92c02536d3f86d5e1d8dfa3435ac.tar.gz |
BASELINE: Update Chromium to 91.0.4472.160
Change-Id: I0def1f08a2412aeed79a9ab95dd50eb5c3f65f31
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/autofill/core')
342 files changed, 10279 insertions, 9927 deletions
diff --git a/chromium/components/autofill/core/browser/BUILD.gn b/chromium/components/autofill/core/browser/BUILD.gn index d6ce1fbbc51..b947cefc2be 100644 --- a/chromium/components/autofill/core/browser/BUILD.gn +++ b/chromium/components/autofill/core/browser/BUILD.gn @@ -152,6 +152,8 @@ static_library("browser") { "form_parsing/field_candidates.h", "form_parsing/form_field.cc", "form_parsing/form_field.h", + "form_parsing/merchant_promo_code_field.cc", + "form_parsing/merchant_promo_code_field.h", "form_parsing/name_field.cc", "form_parsing/name_field.h", "form_parsing/phone_field.cc", @@ -350,6 +352,8 @@ static_library("browser") { if (is_ios || is_android) { sources += [ + "autofill_save_address_profile_delegate_ios.cc", + "autofill_save_address_profile_delegate_ios.h", "payments/autofill_credit_card_filling_infobar_delegate_mobile.cc", "payments/autofill_credit_card_filling_infobar_delegate_mobile.h", "payments/autofill_offer_notification_infobar_delegate_mobile.cc", @@ -607,6 +611,20 @@ bundle_data("unit_tests_bundle_data") { "//components/test/data/autofill/merge/output/primarycase.out", "//components/test/data/autofill/merge/output/singlemerge.out", "//components/test/data/autofill/merge/output/validation.out", + "//components/test/data/autofill/merge_structured_names/input/ambiguous.in", + "//components/test/data/autofill/merge_structured_names/input/case.in", + "//components/test/data/autofill/merge_structured_names/input/email.in", + "//components/test/data/autofill/merge_structured_names/input/identical.in", + "//components/test/data/autofill/merge_structured_names/input/primarycase.in", + "//components/test/data/autofill/merge_structured_names/input/singlemerge.in", + "//components/test/data/autofill/merge_structured_names/input/validation.in", + "//components/test/data/autofill/merge_structured_names/output/ambiguous.out", + "//components/test/data/autofill/merge_structured_names/output/case.out", + "//components/test/data/autofill/merge_structured_names/output/email.out", + "//components/test/data/autofill/merge_structured_names/output/identical.out", + "//components/test/data/autofill/merge_structured_names/output/primarycase.out", + "//components/test/data/autofill/merge_structured_names/output/singlemerge.out", + "//components/test/data/autofill/merge_structured_names/output/validation.out", ] outputs = [ "{{bundle_resources_dir}}/" + "{{source_root_relative_dir}}/{{source_file_part}}" ] @@ -658,6 +676,7 @@ source_set("unit_tests") { "form_parsing/credit_card_field_unittest.cc", "form_parsing/field_candidates_unittest.cc", "form_parsing/form_field_unittest.cc", + "form_parsing/merchant_promo_code_field_unittest.cc", "form_parsing/name_field_unittest.cc", "form_parsing/parsing_test_utils.cc", "form_parsing/parsing_test_utils.h", @@ -717,6 +736,7 @@ source_set("unit_tests") { if (is_ios || is_android) { sources += [ + "autofill_save_address_profile_delegate_ios_unittest.cc", "ui/mobile_label_formatter_unittest.cc", "ui/payments/card_expiration_date_fix_flow_controller_impl_unittest.cc", "ui/payments/card_name_fix_flow_controller_impl_unittest.cc", diff --git a/chromium/components/autofill/core/browser/address_normalizer_impl_unittest.cc b/chromium/components/autofill/core/browser/address_normalizer_impl_unittest.cc index dc3206e2822..d3b6d2dac89 100644 --- a/chromium/components/autofill/core/browser/address_normalizer_impl_unittest.cc +++ b/chromium/components/autofill/core/browser/address_normalizer_impl_unittest.cc @@ -145,7 +145,7 @@ TEST_F(AddressNormalizerTest, NormalizeAddressAsync_RulesLoaded) { WaitForAddressValidatorInitialization(); AutofillProfile profile = autofill::test::GetFullProfile(); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("California")); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"California"); const std::string kCountryCode = base::UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)); @@ -174,7 +174,7 @@ TEST_F(AddressNormalizerTest, WaitForAddressValidatorInitialization(); AutofillProfile profile = autofill::test::GetFullProfile(); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("California")); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"California"); // Make sure the rules will not be loaded in the NormalizeAddressAsync // call. @@ -234,7 +234,7 @@ TEST_F(AddressNormalizerTest, NormalizeAddressAsync_RulesNotLoaded_WillLoad) { WaitForAddressValidatorInitialization(); AutofillProfile profile = autofill::test::GetFullProfile(); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("California")); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"California"); // Do the normalization. normalizer()->NormalizeAddressAsync( @@ -259,9 +259,8 @@ TEST_F(AddressNormalizerTest, FormatPhone_AddressNormalizedAsync) { WaitForAddressValidatorInitialization(); AutofillProfile profile = autofill::test::GetFullProfile(); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::UTF8ToUTF16("(515) 223-1234")); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("California")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"(515) 223-1234"); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"California"); const std::string kCountryCode = base::UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)); @@ -292,9 +291,8 @@ TEST_F(AddressNormalizerTest, FormatInvalidPhone_AddressNormalizedAsync) { AutofillProfile profile = autofill::test::GetFullProfile(); // The number below is not a valid US number. - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::UTF8ToUTF16("(515) 123-1234")); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("California")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"(515) 123-1234"); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"California"); const std::string kCountryCode = base::UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)); @@ -323,9 +321,8 @@ TEST_F(AddressNormalizerTest, FormatPhone_AddressNotNormalizedAsync) { WaitForAddressValidatorInitialization(); AutofillProfile profile = autofill::test::GetFullProfile(); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("California")); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::UTF8ToUTF16("515-223-1234")); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"California"); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"515-223-1234"); // Make sure the rules will not be loaded in the NormalizeAddressAsync // call. @@ -357,9 +354,8 @@ TEST_F(AddressNormalizerTest, NormalizeAddressSync_RulesNotLoaded) { WaitForAddressValidatorInitialization(); AutofillProfile profile = autofill::test::GetFullProfile(); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("California")); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::UTF8ToUTF16("515-223-1234")); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"California"); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"515-223-1234"); // Do the normalization. EXPECT_FALSE(normalizer()->NormalizeAddressSync(&profile)); @@ -379,9 +375,8 @@ TEST_F(AddressNormalizerTest, NormalizeAddressSync_RulesLoaded) { WaitForAddressValidatorInitialization(); AutofillProfile profile = autofill::test::GetFullProfile(); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("California")); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::UTF8ToUTF16("515-223-1234")); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"California"); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"515-223-1234"); const std::string kCountryCode = base::UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)); @@ -404,9 +399,8 @@ TEST_F(AddressNormalizerTest, NormalizeAddressSync_RulesLoaded) { // the validator is initialized. TEST_F(AddressNormalizerTest, NormalizeAddressSync_UninitializedValidator) { AutofillProfile profile = autofill::test::GetFullProfile(); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("California")); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::UTF8ToUTF16("515-223-1234")); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"California"); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"515-223-1234"); const std::string kCountryCode = base::UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)); @@ -429,7 +423,7 @@ TEST_F(AddressNormalizerTest, NormalizeAddressSync_UninitializedValidator) { // initialized. TEST_F(AddressNormalizerTest, NormalizeAddressAsync_UninitializedValidator) { AutofillProfile profile = autofill::test::GetFullProfile(); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("California")); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"California"); // Do the normalization. normalizer()->NormalizeAddressAsync( diff --git a/chromium/components/autofill/core/browser/address_rewriter.cc b/chromium/components/autofill/core/browser/address_rewriter.cc index c2d8533e376..5f53bc4c0da 100644 --- a/chromium/components/autofill/core/browser/address_rewriter.cc +++ b/chromium/components/autofill/core/browser/address_rewriter.cc @@ -140,7 +140,7 @@ class Cache { } // namespace AddressRewriter AddressRewriter::ForCountryCode( - const base::string16& country_code) { + const std::u16string& country_code) { const std::string region = base::UTF16ToUTF8(base::i18n::ToUpper(country_code)); const CompiledRuleVector* rules = @@ -159,7 +159,7 @@ AddressRewriter AddressRewriter::ForCustomRules( return rewriter; } -base::string16 AddressRewriter::Rewrite(const base::string16& text) const { +std::u16string AddressRewriter::Rewrite(const std::u16string& text) const { if (impl_ == nullptr) return base::CollapseWhitespace(text, true); diff --git a/chromium/components/autofill/core/browser/address_rewriter.h b/chromium/components/autofill/core/browser/address_rewriter.h index 4323a76ed72..e3e663f51ca 100644 --- a/chromium/components/autofill/core/browser/address_rewriter.h +++ b/chromium/components/autofill/core/browser/address_rewriter.h @@ -5,7 +5,8 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_ADDRESS_REWRITER_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_ADDRESS_REWRITER_H_ -#include "base/strings/string16.h" +#include <string> + #include "base/strings/string_piece.h" #include "base/strings/string_util.h" @@ -17,13 +18,13 @@ namespace autofill { class AddressRewriter { public: // Get an AddressRewrite instance which applies the rules for |country_code|. - static AddressRewriter ForCountryCode(const base::string16& country_code); + static AddressRewriter ForCountryCode(const std::u16string& country_code); // Gets an AddressRewrite instance for tests with custom rules. static AddressRewriter ForCustomRules(const std::string& custom_rules); // Apply the rewrite rules to |text| and return the result. - base::string16 Rewrite(const base::string16& text) const; + std::u16string Rewrite(const std::u16string& text) const; private: // A handle to the internal rewrite rules this instance is using. diff --git a/chromium/components/autofill/core/browser/address_rewriter_unittest.cc b/chromium/components/autofill/core/browser/address_rewriter_unittest.cc index 6ce637e7162..fdd1ead86a0 100644 --- a/chromium/components/autofill/core/browser/address_rewriter_unittest.cc +++ b/chromium/components/autofill/core/browser/address_rewriter_unittest.cc @@ -11,9 +11,9 @@ using base::UTF8ToUTF16; using autofill::AddressRewriter; TEST(AddressRewriterTest, InvalidCountryCode) { - AddressRewriter ad = AddressRewriter::ForCountryCode(UTF8ToUTF16("ZZZZ")); - const base::string16 kSomeRandomText = UTF8ToUTF16("some random text"); - const base::string16 kOtherRandomText = UTF8ToUTF16("other random text"); + AddressRewriter ad = AddressRewriter::ForCountryCode(u"ZZZZ"); + const std::u16string kSomeRandomText = u"some random text"; + const std::u16string kOtherRandomText = u"other random text"; EXPECT_EQ(ad.Rewrite(kSomeRandomText), ad.Rewrite(kSomeRandomText)); EXPECT_EQ(ad.Rewrite(kOtherRandomText), ad.Rewrite(kOtherRandomText)); @@ -26,285 +26,243 @@ TEST(AddressRewriterTest, LastRule) { AddressRewriter large_rewrite = AddressRewriter::ForCustomRules("1\tonelongrewrite\n2\tshort\n"); - EXPECT_EQ(last_rule.Rewrite(UTF8ToUTF16("3")), - last_rule.Rewrite(UTF8ToUTF16("4"))); + EXPECT_EQ(last_rule.Rewrite(u"3"), last_rule.Rewrite(u"4")); // Checks if last rule works when previous rewrite is larger than last rule. - EXPECT_EQ(large_rewrite.Rewrite(UTF8ToUTF16("2")), - large_rewrite.Rewrite(UTF8ToUTF16("short"))); + EXPECT_EQ(large_rewrite.Rewrite(u"2"), large_rewrite.Rewrite(u"short")); } TEST(AddressRewriterTest, AD) { - AddressRewriter ad = AddressRewriter::ForCountryCode(UTF8ToUTF16("ad")); - EXPECT_EQ(ad.Rewrite(UTF8ToUTF16("parroquia de andorra la vella")), - ad.Rewrite(UTF8ToUTF16("andorra la vella"))); - EXPECT_EQ(ad.Rewrite(UTF8ToUTF16("principal de andorra")), - ad.Rewrite(UTF8ToUTF16("an"))); - EXPECT_EQ(ad.Rewrite(UTF8ToUTF16("or")), ad.Rewrite(UTF8ToUTF16("ordino"))); + AddressRewriter ad = AddressRewriter::ForCountryCode(u"ad"); + EXPECT_EQ(ad.Rewrite(u"parroquia de andorra la vella"), + ad.Rewrite(u"andorra la vella")); + EXPECT_EQ(ad.Rewrite(u"principal de andorra"), ad.Rewrite(u"an")); + EXPECT_EQ(ad.Rewrite(u"or"), ad.Rewrite(u"ordino")); } TEST(AddressRewriterTest, AR) { - AddressRewriter ar = AddressRewriter::ForCountryCode(UTF8ToUTF16("ar")); + AddressRewriter ar = AddressRewriter::ForCountryCode(u"ar"); EXPECT_EQ(ar.Rewrite(UTF8ToUTF16( "tierra del fuego antartida e islas del atlantico sur")), - ar.Rewrite(UTF8ToUTF16("tierra del fuego"))); - EXPECT_EQ(ar.Rewrite(UTF8ToUTF16("ciudad autonoma de buenos aires")), - ar.Rewrite(UTF8ToUTF16("capital federal"))); + ar.Rewrite(u"tierra del fuego")); + EXPECT_EQ(ar.Rewrite(u"ciudad autonoma de buenos aires"), + ar.Rewrite(u"capital federal")); } TEST(AddressRewriterTest, AU) { - AddressRewriter au = AddressRewriter::ForCountryCode(UTF8ToUTF16("au")); - EXPECT_EQ(au.Rewrite(UTF8ToUTF16("australian capital territory")), - au.Rewrite(UTF8ToUTF16("act"))); - EXPECT_EQ(au.Rewrite(UTF8ToUTF16("jervis bay territory")), - au.Rewrite(UTF8ToUTF16("jbt"))); + AddressRewriter au = AddressRewriter::ForCountryCode(u"au"); + EXPECT_EQ(au.Rewrite(u"australian capital territory"), au.Rewrite(u"act")); + EXPECT_EQ(au.Rewrite(u"jervis bay territory"), au.Rewrite(u"jbt")); } TEST(AddressRewriterTest, BE) { - AddressRewriter be = AddressRewriter::ForCountryCode(UTF8ToUTF16("be")); - EXPECT_EQ(be.Rewrite(UTF8ToUTF16("brussels hoofdstedelijk gewest")), - be.Rewrite(UTF8ToUTF16("region de bruxelles capitale"))); - EXPECT_EQ(be.Rewrite(UTF8ToUTF16("arrondissement administratif de foo")), - be.Rewrite(UTF8ToUTF16("foo"))); + AddressRewriter be = AddressRewriter::ForCountryCode(u"be"); + EXPECT_EQ(be.Rewrite(u"brussels hoofdstedelijk gewest"), + be.Rewrite(u"region de bruxelles capitale")); + EXPECT_EQ(be.Rewrite(u"arrondissement administratif de foo"), + be.Rewrite(u"foo")); } TEST(AddressRewriterTest, BR) { - AddressRewriter br = AddressRewriter::ForCountryCode(UTF8ToUTF16("br")); - EXPECT_EQ(br.Rewrite(UTF8ToUTF16("rio grande do norte")), - br.Rewrite(UTF8ToUTF16("rn"))); + AddressRewriter br = AddressRewriter::ForCountryCode(u"br"); + EXPECT_EQ(br.Rewrite(u"rio grande do norte"), br.Rewrite(u"rn")); } TEST(AddressRewriterTest, CA) { - AddressRewriter ca = AddressRewriter::ForCountryCode(UTF8ToUTF16("ca")); - EXPECT_EQ(ca.Rewrite(UTF8ToUTF16("qc")), ca.Rewrite(UTF8ToUTF16("quebec"))); - EXPECT_EQ(ca.Rewrite(UTF8ToUTF16("prince edward island")), - ca.Rewrite(UTF8ToUTF16("pei"))); - EXPECT_EQ(ca.Rewrite(UTF8ToUTF16("prince edward island")), - ca.Rewrite(UTF8ToUTF16("ile du prince edouard"))); - EXPECT_EQ(ca.Rewrite(UTF8ToUTF16("cul-de-sac")), - ca.Rewrite(UTF8ToUTF16("cul de sac"))); - EXPECT_EQ(ca.Rewrite(UTF8ToUTF16("st")), ca.Rewrite(UTF8ToUTF16("street"))); - EXPECT_EQ(ca.Rewrite(UTF8ToUTF16("sainte")), - ca.Rewrite(UTF8ToUTF16("saint"))); + AddressRewriter ca = AddressRewriter::ForCountryCode(u"ca"); + EXPECT_EQ(ca.Rewrite(u"qc"), ca.Rewrite(u"quebec")); + EXPECT_EQ(ca.Rewrite(u"prince edward island"), ca.Rewrite(u"pei")); + EXPECT_EQ(ca.Rewrite(u"prince edward island"), + ca.Rewrite(u"ile du prince edouard")); + EXPECT_EQ(ca.Rewrite(u"cul-de-sac"), ca.Rewrite(u"cul de sac")); + EXPECT_EQ(ca.Rewrite(u"st"), ca.Rewrite(u"street")); + EXPECT_EQ(ca.Rewrite(u"sainte"), ca.Rewrite(u"saint")); } TEST(AddressRewriterTest, CH) { - AddressRewriter ch = AddressRewriter::ForCountryCode(UTF8ToUTF16("ch")); - EXPECT_EQ(ch.Rewrite(UTF8ToUTF16("appenzell rhodes exterieures")), - ch.Rewrite(UTF8ToUTF16("appenzell ausserrhoden"))); - EXPECT_EQ(ch.Rewrite(UTF8ToUTF16("prettigovia davos")), - ch.Rewrite(UTF8ToUTF16("prattigau davos"))); + AddressRewriter ch = AddressRewriter::ForCountryCode(u"ch"); + EXPECT_EQ(ch.Rewrite(u"appenzell rhodes exterieures"), + ch.Rewrite(u"appenzell ausserrhoden")); + EXPECT_EQ(ch.Rewrite(u"prettigovia davos"), ch.Rewrite(u"prattigau davos")); } TEST(AddressRewriterTest, CL) { - AddressRewriter cl = AddressRewriter::ForCountryCode(UTF8ToUTF16("cl")); - EXPECT_EQ( - cl.Rewrite(UTF8ToUTF16("aisen del general carlos ibanez del campo")), - cl.Rewrite(UTF8ToUTF16("xi"))); - EXPECT_EQ(cl.Rewrite(UTF8ToUTF16("libertador general bernardo o'higgins")), - cl.Rewrite(UTF8ToUTF16("vi"))); - EXPECT_EQ(cl.Rewrite(UTF8ToUTF16("metropolitana de santiago de chile")), - cl.Rewrite(UTF8ToUTF16("metropolitana de santiago"))); + AddressRewriter cl = AddressRewriter::ForCountryCode(u"cl"); + EXPECT_EQ(cl.Rewrite(u"aisen del general carlos ibanez del campo"), + cl.Rewrite(u"xi")); + EXPECT_EQ(cl.Rewrite(u"libertador general bernardo o'higgins"), + cl.Rewrite(u"vi")); + EXPECT_EQ(cl.Rewrite(u"metropolitana de santiago de chile"), + cl.Rewrite(u"metropolitana de santiago")); } TEST(AddressRewriterTest, CO) { - AddressRewriter co = AddressRewriter::ForCountryCode(UTF8ToUTF16("co")); - EXPECT_EQ(co.Rewrite(UTF8ToUTF16("columbia")), - co.Rewrite(UTF8ToUTF16("colombia"))); + AddressRewriter co = AddressRewriter::ForCountryCode(u"co"); + EXPECT_EQ(co.Rewrite(u"columbia"), co.Rewrite(u"colombia")); } TEST(AddressRewriterTest, DE) { - AddressRewriter de = AddressRewriter::ForCountryCode(UTF8ToUTF16("de")); - EXPECT_EQ(de.Rewrite(UTF8ToUTF16("federal republic of germany")), - de.Rewrite(UTF8ToUTF16("deutschland"))); - EXPECT_EQ(de.Rewrite(UTF8ToUTF16("germany")), - de.Rewrite(UTF8ToUTF16("bundesrepublik deutschland"))); + AddressRewriter de = AddressRewriter::ForCountryCode(u"de"); + EXPECT_EQ(de.Rewrite(u"federal republic of germany"), + de.Rewrite(u"deutschland")); + EXPECT_EQ(de.Rewrite(u"germany"), de.Rewrite(u"bundesrepublik deutschland")); } TEST(AddressRewriterTest, DK) { - AddressRewriter dk = AddressRewriter::ForCountryCode(UTF8ToUTF16("dk")); - EXPECT_EQ(dk.Rewrite(UTF8ToUTF16("denmark")), - dk.Rewrite(UTF8ToUTF16("danmark"))); + AddressRewriter dk = AddressRewriter::ForCountryCode(u"dk"); + EXPECT_EQ(dk.Rewrite(u"denmark"), dk.Rewrite(u"danmark")); } TEST(AddressRewriterTest, ES) { - AddressRewriter es = AddressRewriter::ForCountryCode(UTF8ToUTF16("es")); - EXPECT_EQ(es.Rewrite(UTF8ToUTF16("balearic islands")), - es.Rewrite(UTF8ToUTF16("islas baleares"))); + AddressRewriter es = AddressRewriter::ForCountryCode(u"es"); + EXPECT_EQ(es.Rewrite(u"balearic islands"), es.Rewrite(u"islas baleares")); } TEST(AddressRewriterTest, FR) { - AddressRewriter fr = AddressRewriter::ForCountryCode(UTF8ToUTF16("fr")); - EXPECT_EQ(fr.Rewrite(UTF8ToUTF16("quatorzieme")), - fr.Rewrite(UTF8ToUTF16("14"))); + AddressRewriter fr = AddressRewriter::ForCountryCode(u"fr"); + EXPECT_EQ(fr.Rewrite(u"quatorzieme"), fr.Rewrite(u"14")); } TEST(AddressRewriterTest, GB) { - AddressRewriter gb = AddressRewriter::ForCountryCode(UTF8ToUTF16("gb")); - EXPECT_EQ(gb.Rewrite(UTF8ToUTF16("north east lincolnshire")), - gb.Rewrite(UTF8ToUTF16("gb-nel"))); + AddressRewriter gb = AddressRewriter::ForCountryCode(u"gb"); + EXPECT_EQ(gb.Rewrite(u"north east lincolnshire"), gb.Rewrite(u"gb-nel")); - EXPECT_NE(gb.Rewrite(UTF8ToUTF16("norfolk")), - gb.Rewrite(UTF8ToUTF16("suffolk"))); + EXPECT_NE(gb.Rewrite(u"norfolk"), gb.Rewrite(u"suffolk")); } TEST(AddressRewriterTest, GR) { - AddressRewriter gr = AddressRewriter::ForCountryCode(UTF8ToUTF16("gr")); - EXPECT_EQ(gr.Rewrite(UTF8ToUTF16("aitolia kai akarnania")), - gr.Rewrite(UTF8ToUTF16("aitoloakarnania"))); + AddressRewriter gr = AddressRewriter::ForCountryCode(u"gr"); + EXPECT_EQ(gr.Rewrite(u"aitolia kai akarnania"), + gr.Rewrite(u"aitoloakarnania")); } TEST(AddressRewriterTest, HK) { - AddressRewriter hk = AddressRewriter::ForCountryCode(UTF8ToUTF16("hk")); - EXPECT_EQ(hk.Rewrite(UTF8ToUTF16("hong kong")), - hk.Rewrite(UTF8ToUTF16("hk"))); + AddressRewriter hk = AddressRewriter::ForCountryCode(u"hk"); + EXPECT_EQ(hk.Rewrite(u"hong kong"), hk.Rewrite(u"hk")); } TEST(AddressRewriterTest, ID) { - AddressRewriter id = AddressRewriter::ForCountryCode(UTF8ToUTF16("id")); - EXPECT_EQ(id.Rewrite(UTF8ToUTF16("nanggroe aceh darussalam")), - id.Rewrite(UTF8ToUTF16("aceh"))); + AddressRewriter id = AddressRewriter::ForCountryCode(u"id"); + EXPECT_EQ(id.Rewrite(u"nanggroe aceh darussalam"), id.Rewrite(u"aceh")); } TEST(AddressRewriterTest, IE) { - AddressRewriter ie = AddressRewriter::ForCountryCode(UTF8ToUTF16("ie")); - EXPECT_EQ(ie.Rewrite(UTF8ToUTF16("avenue")), ie.Rewrite(UTF8ToUTF16("ave"))); + AddressRewriter ie = AddressRewriter::ForCountryCode(u"ie"); + EXPECT_EQ(ie.Rewrite(u"avenue"), ie.Rewrite(u"ave")); } TEST(AddressRewriterTest, IN) { - AddressRewriter in = AddressRewriter::ForCountryCode(UTF8ToUTF16("in")); - EXPECT_EQ(in.Rewrite(UTF8ToUTF16("thiruvananthapuram")), - in.Rewrite(UTF8ToUTF16("tiruvananthapuram"))); - EXPECT_EQ(in.Rewrite(UTF8ToUTF16("jammu & kashmir")), - in.Rewrite(UTF8ToUTF16("j&k"))); - EXPECT_EQ(in.Rewrite(UTF8ToUTF16("cross-road")), - in.Rewrite(UTF8ToUTF16("xrd"))); - EXPECT_EQ(in.Rewrite(UTF8ToUTF16("j & k")), in.Rewrite(UTF8ToUTF16("j&k"))); - EXPECT_EQ(in.Rewrite(UTF8ToUTF16("i.n.d.i.a")), - in.Rewrite(UTF8ToUTF16("india"))); - EXPECT_NE(in.Rewrite(UTF8ToUTF16("i\\_n\\_d\\_i\\_a")), - in.Rewrite(UTF8ToUTF16("india"))); + AddressRewriter in = AddressRewriter::ForCountryCode(u"in"); + EXPECT_EQ(in.Rewrite(u"thiruvananthapuram"), + in.Rewrite(u"tiruvananthapuram")); + EXPECT_EQ(in.Rewrite(u"jammu & kashmir"), in.Rewrite(u"j&k")); + EXPECT_EQ(in.Rewrite(u"cross-road"), in.Rewrite(u"xrd")); + EXPECT_EQ(in.Rewrite(u"j & k"), in.Rewrite(u"j&k")); + EXPECT_EQ(in.Rewrite(u"i.n.d.i.a"), in.Rewrite(u"india")); + EXPECT_NE(in.Rewrite(UTF8ToUTF16("i\\_n\\_d\\_i\\_a")), in.Rewrite(u"india")); } TEST(AddressRewriterTest, IT) { - AddressRewriter it = AddressRewriter::ForCountryCode(UTF8ToUTF16("it")); - EXPECT_EQ(it.Rewrite(UTF8ToUTF16("trentino alto adige")), - it.Rewrite(UTF8ToUTF16("trentino sudtirol"))); + AddressRewriter it = AddressRewriter::ForCountryCode(u"it"); + EXPECT_EQ(it.Rewrite(u"trentino alto adige"), + it.Rewrite(u"trentino sudtirol")); } TEST(AddressRewriterTest, LU) { - AddressRewriter lu = AddressRewriter::ForCountryCode(UTF8ToUTF16("lu")); - EXPECT_EQ(lu.Rewrite(UTF8ToUTF16("esplanade")), - lu.Rewrite(UTF8ToUTF16("espl"))); + AddressRewriter lu = AddressRewriter::ForCountryCode(u"lu"); + EXPECT_EQ(lu.Rewrite(u"esplanade"), lu.Rewrite(u"espl")); } TEST(AddressRewriterTest, MX) { - AddressRewriter mx = AddressRewriter::ForCountryCode(UTF8ToUTF16("mx")); - EXPECT_EQ(mx.Rewrite(UTF8ToUTF16("estado de mexico")), - mx.Rewrite(UTF8ToUTF16("mexico"))); + AddressRewriter mx = AddressRewriter::ForCountryCode(u"mx"); + EXPECT_EQ(mx.Rewrite(u"estado de mexico"), mx.Rewrite(u"mexico")); } TEST(AddressRewriterTest, MY) { - AddressRewriter my = AddressRewriter::ForCountryCode(UTF8ToUTF16("my")); - EXPECT_EQ(my.Rewrite(UTF8ToUTF16("malaysia")), my.Rewrite(UTF8ToUTF16("my"))); + AddressRewriter my = AddressRewriter::ForCountryCode(u"my"); + EXPECT_EQ(my.Rewrite(u"malaysia"), my.Rewrite(u"my")); } TEST(AddressRewriterTest, NL) { - AddressRewriter nl = AddressRewriter::ForCountryCode(UTF8ToUTF16("nl")); - EXPECT_EQ(nl.Rewrite(UTF8ToUTF16("nordholland")), - nl.Rewrite(UTF8ToUTF16("noord holland"))); + AddressRewriter nl = AddressRewriter::ForCountryCode(u"nl"); + EXPECT_EQ(nl.Rewrite(u"nordholland"), nl.Rewrite(u"noord holland")); } TEST(AddressRewriterTest, NZ) { - AddressRewriter nz = AddressRewriter::ForCountryCode(UTF8ToUTF16("nz")); - EXPECT_EQ(nz.Rewrite(UTF8ToUTF16("oceanbeach")), - nz.Rewrite(UTF8ToUTF16("ocean beach"))); + AddressRewriter nz = AddressRewriter::ForCountryCode(u"nz"); + EXPECT_EQ(nz.Rewrite(u"oceanbeach"), nz.Rewrite(u"ocean beach")); } TEST(AddressRewriterTest, PE) { - AddressRewriter pe = AddressRewriter::ForCountryCode(UTF8ToUTF16("pe")); - EXPECT_EQ(pe.Rewrite(UTF8ToUTF16("avenida")), pe.Rewrite(UTF8ToUTF16("av"))); + AddressRewriter pe = AddressRewriter::ForCountryCode(u"pe"); + EXPECT_EQ(pe.Rewrite(u"avenida"), pe.Rewrite(u"av")); } TEST(AddressRewriterTest, PH) { - AddressRewriter ph = AddressRewriter::ForCountryCode(UTF8ToUTF16("ph")); - EXPECT_EQ(ph.Rewrite(UTF8ToUTF16("philippines")), - ph.Rewrite(UTF8ToUTF16("ph"))); + AddressRewriter ph = AddressRewriter::ForCountryCode(u"ph"); + EXPECT_EQ(ph.Rewrite(u"philippines"), ph.Rewrite(u"ph")); } TEST(AddressRewriterTest, PL) { - AddressRewriter pl = AddressRewriter::ForCountryCode(UTF8ToUTF16("pl")); - EXPECT_EQ(pl.Rewrite(UTF8ToUTF16("warmian masurian")), - pl.Rewrite(UTF8ToUTF16("warminsko"))); + AddressRewriter pl = AddressRewriter::ForCountryCode(u"pl"); + EXPECT_EQ(pl.Rewrite(u"warmian masurian"), pl.Rewrite(u"warminsko")); } TEST(AddressRewriterTest, PR) { - AddressRewriter pr = AddressRewriter::ForCountryCode(UTF8ToUTF16("pr")); - EXPECT_EQ(pr.Rewrite(UTF8ToUTF16("san juan antiguo")), - pr.Rewrite(UTF8ToUTF16("old san juan"))); + AddressRewriter pr = AddressRewriter::ForCountryCode(u"pr"); + EXPECT_EQ(pr.Rewrite(u"san juan antiguo"), pr.Rewrite(u"old san juan")); } TEST(AddressRewriterTest, PT) { - AddressRewriter pt = AddressRewriter::ForCountryCode(UTF8ToUTF16("pt")); - EXPECT_EQ(pt.Rewrite(UTF8ToUTF16("doctor")), - pt.Rewrite(UTF8ToUTF16("doutor"))); + AddressRewriter pt = AddressRewriter::ForCountryCode(u"pt"); + EXPECT_EQ(pt.Rewrite(u"doctor"), pt.Rewrite(u"doutor")); } TEST(AddressRewriterTest, RO) { - AddressRewriter ro = AddressRewriter::ForCountryCode(UTF8ToUTF16("ro")); - EXPECT_EQ(ro.Rewrite(UTF8ToUTF16("romania")), ro.Rewrite(UTF8ToUTF16("ro"))); + AddressRewriter ro = AddressRewriter::ForCountryCode(u"ro"); + EXPECT_EQ(ro.Rewrite(u"romania"), ro.Rewrite(u"ro")); } TEST(AddressRewriterTest, RU) { - AddressRewriter ru = AddressRewriter::ForCountryCode(UTF8ToUTF16("ru")); + AddressRewriter ru = AddressRewriter::ForCountryCode(u"ru"); // TODO(rogerm): UTF8 matching isnt' working as expected. Fix it! - EXPECT_NE(ru.Rewrite(UTF8ToUTF16("россия")), - ru.Rewrite(UTF8ToUTF16("russia"))); + EXPECT_NE(ru.Rewrite(u"россия"), ru.Rewrite(u"russia")); } TEST(AddressRewriterTest, SE) { - AddressRewriter se = AddressRewriter::ForCountryCode(UTF8ToUTF16("se")); - EXPECT_EQ(se.Rewrite(UTF8ToUTF16("oestergoetland")), - se.Rewrite(UTF8ToUTF16("vastergoetland"))); + AddressRewriter se = AddressRewriter::ForCountryCode(u"se"); + EXPECT_EQ(se.Rewrite(u"oestergoetland"), se.Rewrite(u"vastergoetland")); } TEST(AddressRewriterTest, TH) { - AddressRewriter th = AddressRewriter::ForCountryCode(UTF8ToUTF16("th")); + AddressRewriter th = AddressRewriter::ForCountryCode(u"th"); // TODO(rogerm): UTF8 matching isnt' working as expected. Fix it! - EXPECT_NE(th.Rewrite(UTF8ToUTF16("ประเทศไทย")), - th.Rewrite(UTF8ToUTF16("thailand"))); + EXPECT_NE(th.Rewrite(u"ประเทศไทย"), th.Rewrite(u"thailand")); } TEST(AddressRewriterTest, TR) { - AddressRewriter tr = AddressRewriter::ForCountryCode(UTF8ToUTF16("tr")); - EXPECT_EQ(tr.Rewrite(UTF8ToUTF16("turkiye")), - tr.Rewrite(UTF8ToUTF16("turkey"))); + AddressRewriter tr = AddressRewriter::ForCountryCode(u"tr"); + EXPECT_EQ(tr.Rewrite(u"turkiye"), tr.Rewrite(u"turkey")); } TEST(AddressRewriterTest, US) { - AddressRewriter us = AddressRewriter::ForCountryCode(UTF8ToUTF16("us")); - EXPECT_EQ(us.Rewrite(UTF8ToUTF16("ca")), - us.Rewrite(UTF8ToUTF16("california"))); - EXPECT_EQ(us.Rewrite(UTF8ToUTF16("west virginia")), - us.Rewrite(UTF8ToUTF16("wv"))); - EXPECT_EQ(us.Rewrite(UTF8ToUTF16("virginia")), us.Rewrite(UTF8ToUTF16("va"))); - EXPECT_EQ(us.Rewrite(UTF8ToUTF16("washington d c")), - us.Rewrite(UTF8ToUTF16("washington dc"))); + AddressRewriter us = AddressRewriter::ForCountryCode(u"us"); + EXPECT_EQ(us.Rewrite(u"ca"), us.Rewrite(u"california")); + EXPECT_EQ(us.Rewrite(u"west virginia"), us.Rewrite(u"wv")); + EXPECT_EQ(us.Rewrite(u"virginia"), us.Rewrite(u"va")); + EXPECT_EQ(us.Rewrite(u"washington d c"), us.Rewrite(u"washington dc")); // Similar names, but not the same. - EXPECT_NE(us.Rewrite(UTF8ToUTF16("west virginia")), - us.Rewrite(UTF8ToUTF16("virginia"))); - EXPECT_NE(us.Rewrite(UTF8ToUTF16("washington")), - us.Rewrite(UTF8ToUTF16("washington dc"))); + EXPECT_NE(us.Rewrite(u"west virginia"), us.Rewrite(u"virginia")); + EXPECT_NE(us.Rewrite(u"washington"), us.Rewrite(u"washington dc")); } TEST(AddressRewriterTest, VN) { - AddressRewriter vn = AddressRewriter::ForCountryCode(UTF8ToUTF16("vn")); - EXPECT_EQ(vn.Rewrite(UTF8ToUTF16("viet nam")), - vn.Rewrite(UTF8ToUTF16("vietnam"))); + AddressRewriter vn = AddressRewriter::ForCountryCode(u"vn"); + EXPECT_EQ(vn.Rewrite(u"viet nam"), vn.Rewrite(u"vietnam")); } TEST(AddressRewriterTest, ZA) { - AddressRewriter za = AddressRewriter::ForCountryCode(UTF8ToUTF16("za")); - EXPECT_EQ(za.Rewrite(UTF8ToUTF16("republic of south africa")), - za.Rewrite(UTF8ToUTF16("south africa"))); + AddressRewriter za = AddressRewriter::ForCountryCode(u"za"); + EXPECT_EQ(za.Rewrite(u"republic of south africa"), + za.Rewrite(u"south africa")); } diff --git a/chromium/components/autofill/core/browser/autocomplete_history_manager.cc b/chromium/components/autofill/core/browser/autocomplete_history_manager.cc index 6ffe717feb3..e860b3027c7 100644 --- a/chromium/components/autofill/core/browser/autocomplete_history_manager.cc +++ b/chromium/components/autofill/core/browser/autocomplete_history_manager.cc @@ -4,6 +4,7 @@ #include "components/autofill/core/browser/autocomplete_history_manager.h" +#include <string> #include <unordered_map> #include <utility> #include <vector> @@ -11,7 +12,6 @@ #include "base/bind.h" #include "base/memory/weak_ptr.h" #include "base/stl_util.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_experiments.h" #include "components/autofill/core/browser/autofill_metrics.h" @@ -48,7 +48,7 @@ bool IsTextField(const FormFieldData& field) { // An input field name 'field_2' bears no semantic meaning and there is a chance // that a different website or different form uses the same field name for a // totally different purpose. -bool IsMeaningfulFieldName(const base::string16& name) { +bool IsMeaningfulFieldName(const std::u16string& name) { // If the corresponding feature is not enabled, every field name is considered // as meaningful. if (!base::FeatureList::IsEnabled( @@ -63,7 +63,7 @@ bool IsMeaningfulFieldName(const base::string16& name) { } // namespace void AutocompleteHistoryManager::UMARecorder::OnGetAutocompleteSuggestions( - const base::string16& name, + const std::u16string& name, WebDataServiceBase::Handle pending_query_handle) { // log only if the current field is different than the latest one that has // been logged. we assume that user works at the same field if @@ -98,7 +98,7 @@ void AutocompleteHistoryManager::UMARecorder::OnWebDataServiceRequestDone( AutocompleteHistoryManager::QueryHandler::QueryHandler( int client_query_id, bool autoselect_first_suggestion, - base::string16 prefix, + std::u16string prefix, base::WeakPtr<SuggestionsHandler> handler) : client_query_id_(client_query_id), autoselect_first_suggestion_(autoselect_first_suggestion), @@ -165,8 +165,8 @@ void AutocompleteHistoryManager::OnGetAutocompleteSuggestions( int query_id, bool is_autocomplete_enabled, bool autoselect_first_suggestion, - const base::string16& name, - const base::string16& prefix, + const std::u16string& name, + const std::u16string& prefix, const std::string& form_control_type, base::WeakPtr<SuggestionsHandler> handler) { CancelPendingQueries(handler.get()); @@ -216,13 +216,14 @@ void AutocompleteHistoryManager::OnWillSubmitForm( } void AutocompleteHistoryManager::OnRemoveAutocompleteEntry( - const base::string16& name, const base::string16& value) { + const std::u16string& name, + const std::u16string& value) { if (profile_database_) profile_database_->RemoveFormValueForElementName(name, value); } void AutocompleteHistoryManager::OnAutocompleteEntrySelected( - const base::string16& value) { + const std::u16string& value) { // Try to find the AutofillEntry associated with the given suggestion. auto last_entries_iter = last_entries_.find(value); if (last_entries_iter == last_entries_.end()) { @@ -384,7 +385,7 @@ bool AutocompleteHistoryManager::IsFieldValueSaveable( // We don't want to save a trimmed string, but we want to make sure that the // value is non-empty nor only whitespaces. bool is_value_valid = false; - for (const base::string16::value_type& c : field.value) { + for (const std::u16string::value_type& c : field.value) { if (c != ' ') { is_value_valid = true; break; diff --git a/chromium/components/autofill/core/browser/autocomplete_history_manager.h b/chromium/components/autofill/core/browser/autocomplete_history_manager.h index 9892f8a14a5..4c4f8ed570a 100644 --- a/chromium/components/autofill/core/browser/autocomplete_history_manager.h +++ b/chromium/components/autofill/core/browser/autocomplete_history_manager.h @@ -77,8 +77,8 @@ class AutocompleteHistoryManager : public KeyedService, int query_id, bool is_autocomplete_enabled, bool autoselect_first_suggestion, - const base::string16& name, - const base::string16& prefix, + const std::u16string& name, + const std::u16string& prefix, const std::string& form_control_type, base::WeakPtr<SuggestionsHandler> handler); @@ -99,13 +99,13 @@ class AutocompleteHistoryManager : public KeyedService, virtual void CancelPendingQueries(const SuggestionsHandler* handler); // Must be public for the autofill manager to use. - virtual void OnRemoveAutocompleteEntry(const base::string16& name, - const base::string16& value); + virtual void OnRemoveAutocompleteEntry(const std::u16string& name, + const std::u16string& value); // Invoked when the user selected |value| in the Autocomplete drop-down. This // function logs the DaysSinceLastUse of the Autocomplete entry associated // with |value|. - virtual void OnAutocompleteEntrySelected(const base::string16& value); + virtual void OnAutocompleteEntrySelected(const std::u16string& value); private: friend class AutocompleteHistoryManagerTest; @@ -122,7 +122,7 @@ class AutocompleteHistoryManager : public KeyedService, ~UMARecorder() = default; void OnGetAutocompleteSuggestions( - const base::string16& name, + const std::u16string& name, WebDataServiceBase::Handle pending_query_handle); void OnWebDataServiceRequestDone( WebDataServiceBase::Handle pending_query_handle, @@ -134,7 +134,7 @@ class AutocompleteHistoryManager : public KeyedService, // The name of field that is currently measured, we don't repeatedly measure // the query of the same field while user is filling the field. - base::string16 measuring_name_; + std::u16string measuring_name_; DISALLOW_COPY_AND_ASSIGN(UMARecorder); }; @@ -144,7 +144,7 @@ class AutocompleteHistoryManager : public KeyedService, struct QueryHandler { QueryHandler(int client_query_id, bool autoselect_first_suggestion, - base::string16 prefix, + std::u16string prefix, base::WeakPtr<SuggestionsHandler> handler); QueryHandler(const QueryHandler& original); ~QueryHandler(); @@ -159,7 +159,7 @@ class AutocompleteHistoryManager : public KeyedService, bool autoselect_first_suggestion_; // Prefix used to search suggestions, submitted by the handler. - base::string16 prefix_; + std::u16string prefix_; // Weak pointer to the handler instance which will be called-back when // we get the response for the associate query. @@ -222,7 +222,7 @@ class AutocompleteHistoryManager : public KeyedService, // Cached results of the last batch of autocomplete suggestions. // Key are the suggestions' values, and values are the associated // AutofillEntry. - std::map<base::string16, AutofillEntry> last_entries_; + std::map<std::u16string, AutofillEntry> last_entries_; // Whether the service is associated with an off-the-record browser context. bool is_off_the_record_ = false; diff --git a/chromium/components/autofill/core/browser/autocomplete_history_manager_unittest.cc b/chromium/components/autofill/core/browser/autocomplete_history_manager_unittest.cc index 853dc159546..9f13c0aaf34 100644 --- a/chromium/components/autofill/core/browser/autocomplete_history_manager_unittest.cc +++ b/chromium/components/autofill/core/browser/autocomplete_history_manager_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <string> #include <vector> #include "base/macros.h" @@ -9,7 +10,6 @@ #include "base/memory/weak_ptr.h" #include "base/run_loop.h" #include "base/stl_util.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "base/synchronization/waitable_event.h" #include "base/test/metrics/histogram_tester.h" @@ -129,8 +129,8 @@ class AutocompleteHistoryManagerTest : public testing::Test { } AutofillEntry GetAutofillEntry( - const base::string16& name, - const base::string16& value, + const std::u16string& name, + const std::u16string& value, const base::Time& date_created = AutofillClock::Now(), const base::Time& date_last_used = AutofillClock::Now()) { return AutofillEntry(AutofillKey(name, value), date_created, @@ -147,15 +147,15 @@ class AutocompleteHistoryManagerTest : public testing::Test { // Tests that credit card numbers are not sent to the WebDatabase to be saved. TEST_F(AutocompleteHistoryManagerTest, CreditCardNumberValue) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("http://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); // Valid Visa credit card number pulled from the paypal help site. FormFieldData valid_cc; - valid_cc.label = ASCIIToUTF16("Credit Card"); - valid_cc.name = ASCIIToUTF16("ccnum"); - valid_cc.value = ASCIIToUTF16("4012888888881881"); + valid_cc.label = u"Credit Card"; + valid_cc.name = u"ccnum"; + valid_cc.value = u"4012888888881881"; valid_cc.properties_mask |= kUserTyped; valid_cc.form_control_type = "text"; form.fields.push_back(valid_cc); @@ -170,15 +170,15 @@ TEST_F(AutocompleteHistoryManagerTest, CreditCardNumberValue) { // to the WebDatabase to be saved. TEST_F(AutocompleteHistoryManagerTest, NonCreditCardNumberValue) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("http://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); // Invalid credit card number. FormFieldData invalid_cc; - invalid_cc.label = ASCIIToUTF16("Credit Card"); - invalid_cc.name = ASCIIToUTF16("ccnum"); - invalid_cc.value = ASCIIToUTF16("4580123456789012"); + invalid_cc.label = u"Credit Card"; + invalid_cc.name = u"ccnum"; + invalid_cc.value = u"4580123456789012"; invalid_cc.properties_mask |= kUserTyped; invalid_cc.form_control_type = "text"; form.fields.push_back(invalid_cc); @@ -191,14 +191,14 @@ TEST_F(AutocompleteHistoryManagerTest, NonCreditCardNumberValue) { // Tests that SSNs are not sent to the WebDatabase to be saved. TEST_F(AutocompleteHistoryManagerTest, SSNValue) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("http://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); FormFieldData ssn; - ssn.label = ASCIIToUTF16("Social Security Number"); - ssn.name = ASCIIToUTF16("ssn"); - ssn.value = ASCIIToUTF16("078-05-1120"); + ssn.label = u"Social Security Number"; + ssn.name = u"ssn"; + ssn.value = u"078-05-1120"; ssn.properties_mask |= kUserTyped; ssn.form_control_type = "text"; form.fields.push_back(ssn); @@ -211,15 +211,15 @@ TEST_F(AutocompleteHistoryManagerTest, SSNValue) { // Verify that autocomplete text is saved for search fields. TEST_F(AutocompleteHistoryManagerTest, SearchField) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("http://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); // Search field. FormFieldData search_field; - search_field.label = ASCIIToUTF16("Search"); - search_field.name = ASCIIToUTF16("search"); - search_field.value = ASCIIToUTF16("my favorite query"); + search_field.label = u"Search"; + search_field.name = u"search"; + search_field.value = u"my favorite query"; search_field.properties_mask |= kUserTyped; search_field.form_control_type = "search"; form.fields.push_back(search_field); @@ -231,15 +231,15 @@ TEST_F(AutocompleteHistoryManagerTest, SearchField) { TEST_F(AutocompleteHistoryManagerTest, AutocompleteFeatureOff) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("http://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); // Search field. FormFieldData search_field; - search_field.label = ASCIIToUTF16("Search"); - search_field.name = ASCIIToUTF16("search"); - search_field.value = ASCIIToUTF16("my favorite query"); + search_field.label = u"Search"; + search_field.name = u"search"; + search_field.value = u"my favorite query"; search_field.properties_mask |= kUserTyped; search_field.form_control_type = "search"; form.fields.push_back(search_field); @@ -252,7 +252,7 @@ TEST_F(AutocompleteHistoryManagerTest, AutocompleteFeatureOff) { // Verify that we don't save invalid values in Autocomplete. TEST_F(AutocompleteHistoryManagerTest, InvalidValues) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("http://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); @@ -260,25 +260,25 @@ TEST_F(AutocompleteHistoryManagerTest, InvalidValues) { FormFieldData search_field; // Empty value. - search_field.label = ASCIIToUTF16("Search"); - search_field.name = ASCIIToUTF16("search"); - search_field.value = ASCIIToUTF16(""); + search_field.label = u"Search"; + search_field.name = u"search"; + search_field.value = u""; search_field.properties_mask |= kUserTyped; search_field.form_control_type = "search"; form.fields.push_back(search_field); // Single whitespace. - search_field.label = ASCIIToUTF16("Search2"); - search_field.name = ASCIIToUTF16("other search"); - search_field.value = ASCIIToUTF16(" "); + search_field.label = u"Search2"; + search_field.name = u"other search"; + search_field.value = u" "; search_field.properties_mask |= kUserTyped; search_field.form_control_type = "search"; form.fields.push_back(search_field); // Multiple whitespaces. - search_field.label = ASCIIToUTF16("Search3"); - search_field.name = ASCIIToUTF16("other search"); - search_field.value = ASCIIToUTF16(" "); + search_field.label = u"Search3"; + search_field.name = u"other search"; + search_field.value = u" "; search_field.properties_mask |= kUserTyped; search_field.form_control_type = "search"; form.fields.push_back(search_field); @@ -294,15 +294,15 @@ TEST_F(AutocompleteHistoryManagerTest, InvalidValues) { // See AutofillManagerTest.DontSaveCvcInAutocompleteHistory TEST_F(AutocompleteHistoryManagerTest, FieldWithAutocompleteOff) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("http://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); // Field specifying autocomplete="off". FormFieldData field; - field.label = ASCIIToUTF16("Something esoteric"); - field.name = ASCIIToUTF16("esoterica"); - field.value = ASCIIToUTF16("a truly esoteric value, I assure you"); + field.label = u"Something esoteric"; + field.name = u"esoterica"; + field.value = u"a truly esoteric value, I assure you"; field.properties_mask |= kUserTyped; field.form_control_type = "text"; field.should_autocomplete = false; @@ -318,15 +318,15 @@ TEST_F(AutocompleteHistoryManagerTest, Incognito) { autocomplete_manager_->Init(web_data_service_, prefs_.get(), /*is_off_the_record_=*/true); FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("http://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); // Search field. FormFieldData search_field; - search_field.label = ASCIIToUTF16("Search"); - search_field.name = ASCIIToUTF16("search"); - search_field.value = ASCIIToUTF16("my favorite query"); + search_field.label = u"Search"; + search_field.name = u"search"; + search_field.value = u"my favorite query"; search_field.properties_mask |= kUserTyped; search_field.form_control_type = "search"; form.fields.push_back(search_field); @@ -342,15 +342,15 @@ TEST_F(AutocompleteHistoryManagerTest, Incognito) { // because |properties_mask| is not set on iOS. TEST_F(AutocompleteHistoryManagerTest, UserInputNotFocusable) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("http://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); // Search field. FormFieldData search_field; - search_field.label = ASCIIToUTF16("Search"); - search_field.name = ASCIIToUTF16("search"); - search_field.value = ASCIIToUTF16("my favorite query"); + search_field.label = u"Search"; + search_field.name = u"search"; + search_field.value = u"my favorite query"; search_field.form_control_type = "search"; search_field.properties_mask |= kUserTyped; search_field.is_focusable = false; @@ -366,15 +366,15 @@ TEST_F(AutocompleteHistoryManagerTest, UserInputNotFocusable) { // WebDatabase to be saved. TEST_F(AutocompleteHistoryManagerTest, PresentationField) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("http://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); // Presentation field. FormFieldData field; - field.label = ASCIIToUTF16("Something esoteric"); - field.name = ASCIIToUTF16("esoterica"); - field.value = ASCIIToUTF16("a truly esoteric value, I assure you"); + field.label = u"Something esoteric"; + field.name = u"esoterica"; + field.value = u"a truly esoteric value, I assure you"; field.properties_mask |= kUserTyped; field.form_control_type = "text"; field.role = FormFieldData::RoleAttribute::kPresentation; @@ -563,7 +563,7 @@ TEST_F(AutocompleteHistoryManagerTest, auto test_prefix = ASCIIToUTF16("SomePrefix"); std::vector<AutofillEntry> expected_values = { - GetAutofillEntry(test_name, ASCIIToUTF16("SomePrefixOne"))}; + GetAutofillEntry(test_name, u"SomePrefixOne")}; std::unique_ptr<WDTypedResult> mocked_results = GetMockedDbResults(expected_values); @@ -603,7 +603,7 @@ TEST_F(AutocompleteHistoryManagerTest, auto test_prefix = ASCIIToUTF16("SomePrefix"); std::vector<AutofillEntry> expected_values = { - GetAutofillEntry(test_name, ASCIIToUTF16("SomePrefixOne"))}; + GetAutofillEntry(test_name, u"SomePrefixOne")}; std::unique_ptr<WDTypedResult> mocked_results = GetMockedDbResults(expected_values); @@ -682,7 +682,7 @@ TEST_F(AutocompleteHistoryManagerTest, auto test_prefix = ASCIIToUTF16("SomePrefix"); std::vector<AutofillEntry> expected_values = { - GetAutofillEntry(test_name, ASCIIToUTF16("someprefix"))}; + GetAutofillEntry(test_name, u"someprefix")}; std::unique_ptr<WDTypedResult> mocked_results = GetMockedDbResults(expected_values); @@ -776,10 +776,10 @@ TEST_F(AutocompleteHistoryManagerTest, auto test_prefix = ASCIIToUTF16("SomePrefix"); std::vector<AutofillEntry> expected_values_first = { - GetAutofillEntry(test_name, ASCIIToUTF16("SomePrefixOne"))}; + GetAutofillEntry(test_name, u"SomePrefixOne")}; std::vector<AutofillEntry> expected_values_second = { - GetAutofillEntry(test_name, ASCIIToUTF16("SomePrefixTwo"))}; + GetAutofillEntry(test_name, u"SomePrefixTwo")}; std::unique_ptr<WDTypedResult> mocked_results_first = GetMockedDbResults(expected_values_first); @@ -845,10 +845,10 @@ TEST_F(AutocompleteHistoryManagerTest, auto test_prefix = ASCIIToUTF16("SomePrefix"); std::vector<AutofillEntry> expected_values_first = { - GetAutofillEntry(test_name, ASCIIToUTF16("SomePrefixOne"))}; + GetAutofillEntry(test_name, u"SomePrefixOne")}; std::vector<AutofillEntry> expected_values_second = { - GetAutofillEntry(test_name, ASCIIToUTF16("SomePrefixTwo"))}; + GetAutofillEntry(test_name, u"SomePrefixTwo")}; std::unique_ptr<WDTypedResult> mocked_results_first = GetMockedDbResults(expected_values_first); @@ -910,7 +910,7 @@ TEST_F(AutocompleteHistoryManagerTest, int mocked_db_query_id_one = 100; int test_query_id_one = 1; std::vector<AutofillEntry> expected_values_one = { - GetAutofillEntry(test_name, ASCIIToUTF16("SomePrefixOne"))}; + GetAutofillEntry(test_name, u"SomePrefixOne")}; std::unique_ptr<WDTypedResult> mocked_results_one = GetMockedDbResults(expected_values_one); @@ -919,7 +919,7 @@ TEST_F(AutocompleteHistoryManagerTest, int test_query_id_two = 2; int mocked_db_query_id_two = 101; std::vector<AutofillEntry> expected_values_two = { - GetAutofillEntry(test_name, ASCIIToUTF16("SomePrefixTwo"))}; + GetAutofillEntry(test_name, u"SomePrefixTwo")}; std::unique_ptr<WDTypedResult> mocked_results_two = GetMockedDbResults(expected_values_two); @@ -969,7 +969,7 @@ TEST_F(AutocompleteHistoryManagerTest, // // logged correctly. TEST_F(AutocompleteHistoryManagerTest, NoAutocompleteSuggestionsForTextarea) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("http://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); @@ -1051,7 +1051,7 @@ TEST_F(AutocompleteHistoryManagerTest, AutocompleteUMAQueryCreated) { // Mock one suggestion returned and verify that the suggestion UMA is correct. std::vector<AutofillEntry> values; - values.push_back(GetAutofillEntry(field.name, ASCIIToUTF16("value"))); + values.push_back(GetAutofillEntry(field.name, u"value")); result = GetMockedDbResults(values); autocomplete_manager_->OnWebDataServiceRequestDone(mock_handle, std::move(result)); diff --git a/chromium/components/autofill/core/browser/autofill_address_policy_handler.cc b/chromium/components/autofill/core/browser/autofill_address_policy_handler.cc index 5afc719388c..f5d857cf955 100644 --- a/chromium/components/autofill/core/browser/autofill_address_policy_handler.cc +++ b/chromium/components/autofill/core/browser/autofill_address_policy_handler.cc @@ -22,11 +22,8 @@ void AutofillAddressPolicyHandler::ApplyPolicySettings( const policy::PolicyMap& policies, PrefValueMap* prefs) { const base::Value* value = policies.GetValue(policy_name()); - bool autofill_profile_enabled; - if (value && value->GetAsBoolean(&autofill_profile_enabled) && - !autofill_profile_enabled) { + if (value && value->is_bool() && !value->GetBool()) prefs->SetBoolean(autofill::prefs::kAutofillProfileEnabled, false); - } } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/autofill_address_policy_handler_unittest.cc b/chromium/components/autofill/core/browser/autofill_address_policy_handler_unittest.cc index 88867c5160f..a3a58a44be0 100644 --- a/chromium/components/autofill/core/browser/autofill_address_policy_handler_unittest.cc +++ b/chromium/components/autofill/core/browser/autofill_address_policy_handler_unittest.cc @@ -55,10 +55,8 @@ TEST_F(AutofillAddressPolicyHandlerTest, Disabled) { const base::Value* value = nullptr; EXPECT_TRUE(prefs.GetValue(autofill::prefs::kAutofillProfileEnabled, &value)); ASSERT_TRUE(value); - bool autofill_profile_enabled = true; - bool result = value->GetAsBoolean(&autofill_profile_enabled); - ASSERT_TRUE(result); - EXPECT_FALSE(autofill_profile_enabled); + ASSERT_TRUE(value->is_bool()); + EXPECT_FALSE(value->GetBool()); } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/autofill_and_password_manager_internals/autofill_and_password_manager_internals.html b/chromium/components/autofill/core/browser/autofill_and_password_manager_internals/autofill_and_password_manager_internals.html index 83dbe8e0995..96c753f5b3a 100644 --- a/chromium/components/autofill/core/browser/autofill_and_password_manager_internals/autofill_and_password_manager_internals.html +++ b/chromium/components/autofill/core/browser/autofill_and_password_manager_internals/autofill_and_password_manager_internals.html @@ -5,9 +5,7 @@ Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. --> <meta charset="utf-8"> -<script src="chrome://resources/js/assert.js"></script> -<script src="chrome://resources/js/util.js"></script> -<script src="autofill_and_password_manager_internals.js"></script> +<script type="module" src="autofill_and_password_manager_internals.js"></script> <link rel="stylesheet" href="chrome://resources/css/chrome_shared.css"> <link rel="stylesheet" href="autofill_and_password_manager_internals.css"> </head> diff --git a/chromium/components/autofill/core/browser/autofill_and_password_manager_internals/autofill_and_password_manager_internals.js b/chromium/components/autofill/core/browser/autofill_and_password_manager_internals/autofill_and_password_manager_internals.js index a9915dea864..1f248f2c6e8 100644 --- a/chromium/components/autofill/core/browser/autofill_and_password_manager_internals/autofill_and_password_manager_internals.js +++ b/chromium/components/autofill/core/browser/autofill_and_password_manager_internals/autofill_and_password_manager_internals.js @@ -2,6 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// <if expr="is_ios"> +import 'chrome://resources/js/ios/web_ui.js'; +// </if> + +import {addWebUIListener} from 'chrome://resources/js/cr.m.js'; +import {$} from 'chrome://resources/js/util.m.js'; + // Renders a simple dialog with |text| as a message and a close button. function showModalDialog(text) { const dialog = document.createElement('div'); @@ -273,11 +280,16 @@ function setUpLogDisplayConfig() { }); } -function notifyResetDone(message) { - showModalDialog(message); -} +document.addEventListener('DOMContentLoaded', function(event) { + addWebUIListener('enable-reset-cache-button', enableResetCacheButton); + addWebUIListener('notify-about-incognito', notifyAboutIncognito); + addWebUIListener('notify-about-variations', notifyAboutVariations); + addWebUIListener('notify-reset-done', message => showModalDialog(message)); + addWebUIListener('add-raw-log', addRawLog); + addWebUIListener('setup-autofill-internals', setUpAutofillInternals); + addWebUIListener( + 'setup-password-manager-internals', setUpPasswordManagerInternals); -document.addEventListener("DOMContentLoaded", function(event) { chrome.send('loaded'); const resetCacheFakeButton = diff --git a/chromium/components/autofill/core/browser/autofill_and_password_manager_internals/autofill_and_password_manager_internals_ios.html b/chromium/components/autofill/core/browser/autofill_and_password_manager_internals/autofill_and_password_manager_internals_ios.html index 918dd3bfa40..e88900fcce9 100644 --- a/chromium/components/autofill/core/browser/autofill_and_password_manager_internals/autofill_and_password_manager_internals_ios.html +++ b/chromium/components/autofill/core/browser/autofill_and_password_manager_internals/autofill_and_password_manager_internals_ios.html @@ -5,14 +5,7 @@ Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. --> <meta charset="utf-8"> - -<!-- TODO(crbug.com/487000): Remove this entire html file once the following is -injected by web. --> -<script src="chrome://resources/js/ios/web_ui.js"></script> - -<script src="chrome://resources/js/assert.js"></script> -<script src="chrome://resources/js/util.js"></script> -<script src="autofill_and_password_manager_internals.js"></script> +<script type="module" src="autofill_and_password_manager_internals.js"></script> <link rel="stylesheet" href="chrome://resources/css/chrome_shared.css"> <link rel="stylesheet" href="autofill_and_password_manager_internals.css"> </head> diff --git a/chromium/components/autofill/core/browser/autofill_client.cc b/chromium/components/autofill/core/browser/autofill_client.cc index 05229af8b02..1f72eb155c4 100644 --- a/chromium/components/autofill/core/browser/autofill_client.cc +++ b/chromium/components/autofill/core/browser/autofill_client.cc @@ -66,6 +66,10 @@ void AutofillClient::ShowOfferNotificationIfApplicable( // ChromeAutofillClient (Chrome Desktop and Clank) implement this. } +bool AutofillClient::IsAutofillAssistantShowing() { + return false; +} + LogManager* AutofillClient::GetLogManager() const { return nullptr; } diff --git a/chromium/components/autofill/core/browser/autofill_client.h b/chromium/components/autofill/core/browser/autofill_client.h index 1a8c8b2f652..36894e498b2 100644 --- a/chromium/components/autofill/core/browser/autofill_client.h +++ b/chromium/components/autofill/core/browser/autofill_client.h @@ -14,7 +14,6 @@ #include "base/containers/span.h" #include "base/i18n/rtl.h" #include "base/memory/weak_ptr.h" -#include "base/strings/string16.h" #include "base/types/strong_alias.h" #include "base/values.h" #include "build/build_config.h" @@ -146,9 +145,9 @@ class AutofillClient : public RiskDataLoader { // Used for explicitly requesting the user to enter/confirm cardholder name, // expiration date month and year. struct UserProvidedCardDetails { - base::string16 cardholder_name; - base::string16 expiration_date_month; - base::string16 expiration_date_year; + std::u16string cardholder_name; + std::u16string expiration_date_month; + std::u16string expiration_date_year; }; // Used for options of upload prompt. @@ -365,7 +364,7 @@ class AutofillClient : public RiskDataLoader { // one invalid card from local storage. virtual void ShowLocalCardMigrationResults( const bool has_server_error, - const base::string16& tip_message, + const std::u16string& tip_message, const std::vector<MigratableCreditCard>& migratable_credit_cards, MigrationDeleteCardCallback delete_local_card_callback) = 0; @@ -410,14 +409,14 @@ class AutofillClient : public RiskDataLoader { // Display the cardholder name fix flow prompt and run the |callback| if // the card should be uploaded to payments with updated name from the user. virtual void ConfirmAccountNameFixFlow( - base::OnceCallback<void(const base::string16&)> callback) = 0; + base::OnceCallback<void(const std::u16string&)> callback) = 0; // Display the expiration date fix flow prompt with the |card| details // and run the |callback| if the card should be uploaded to payments with // updated expiration date from the user. virtual void ConfirmExpirationDateFixFlow( const CreditCard& card, - base::OnceCallback<void(const base::string16&, const base::string16&)> + base::OnceCallback<void(const std::u16string&, const std::u16string&)> callback) = 0; #endif @@ -481,8 +480,8 @@ class AutofillClient : public RiskDataLoader { // Update the data list values shown by the Autofill popup, if visible. virtual void UpdateAutofillPopupDataListValues( - const std::vector<base::string16>& values, - const std::vector<base::string16>& labels) = 0; + const std::vector<std::u16string>& values, + const std::vector<std::u16string>& labels) = 0; // Informs the client that the popup needs to be kept alive. Call before // |UpdatePopup| to update the open popup in-place. @@ -519,6 +518,9 @@ class AutofillClient : public RiskDataLoader { const GURL& offer_details_url, const CreditCard* card); + // Returns true if the Autofill Assistant UI is currently being shown. + virtual bool IsAutofillAssistantShowing(); + // Whether the Autocomplete feature of Autofill should be enabled. virtual bool IsAutocompleteEnabled() = 0; @@ -530,8 +532,8 @@ class AutofillClient : public RiskDataLoader { // Inform the client that the field has been filled. virtual void DidFillOrPreviewField( - const base::string16& autofilled_value, - const base::string16& profile_full_name) = 0; + const std::u16string& autofilled_value, + const std::u16string& profile_full_name) = 0; // If the context is secure. virtual bool IsContextSecure() const = 0; diff --git a/chromium/components/autofill/core/browser/autofill_credit_card_policy_handler.cc b/chromium/components/autofill/core/browser/autofill_credit_card_policy_handler.cc index 9a8b1f4606a..012e8a1aa6a 100644 --- a/chromium/components/autofill/core/browser/autofill_credit_card_policy_handler.cc +++ b/chromium/components/autofill/core/browser/autofill_credit_card_policy_handler.cc @@ -22,11 +22,8 @@ void AutofillCreditCardPolicyHandler::ApplyPolicySettings( const policy::PolicyMap& policies, PrefValueMap* prefs) { const base::Value* value = policies.GetValue(policy_name()); - bool autofill_credit_card_enabled; - if (value && value->GetAsBoolean(&autofill_credit_card_enabled) && - !autofill_credit_card_enabled) { + if (value && value->is_bool() && !value->GetBool()) prefs->SetBoolean(autofill::prefs::kAutofillCreditCardEnabled, false); - } } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/autofill_credit_card_policy_handler_unittest.cc b/chromium/components/autofill/core/browser/autofill_credit_card_policy_handler_unittest.cc index 2c5554a99e4..7074667418f 100644 --- a/chromium/components/autofill/core/browser/autofill_credit_card_policy_handler_unittest.cc +++ b/chromium/components/autofill/core/browser/autofill_credit_card_policy_handler_unittest.cc @@ -56,10 +56,8 @@ TEST_F(AutofillCreditCardPolicyHandlerTest, Disabled) { EXPECT_TRUE( prefs.GetValue(autofill::prefs::kAutofillCreditCardEnabled, &value)); ASSERT_TRUE(value); - bool autofill_credt_card_enabled = true; - bool result = value->GetAsBoolean(&autofill_credt_card_enabled); - ASSERT_TRUE(result); - EXPECT_FALSE(autofill_credt_card_enabled); + ASSERT_TRUE(value->is_bool()); + EXPECT_FALSE(value->GetBool()); } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/autofill_data_util.cc b/chromium/components/autofill/core/browser/autofill_data_util.cc index ab3195e97b5..572db92a1aa 100644 --- a/chromium/components/autofill/core/browser/autofill_data_util.cc +++ b/chromium/components/autofill/core/browser/autofill_data_util.cc @@ -107,7 +107,7 @@ bool ContainsString(const char* const set[], return false; base::StringPiece16 trimmed_element = - base::TrimString(element, base::ASCIIToUTF16("."), base::TRIM_ALL); + base::TrimString(element, u".", base::TRIM_ALL); for (size_t i = 0; i < set_size; ++i) { if (base::LowerCaseEqualsASCII(trimmed_element, set[i])) @@ -148,7 +148,7 @@ void StripSuffixes(std::vector<base::StringPiece16>* name_tokens) { size_t StartsWithAny(base::StringPiece16 name, const char** prefixes, size_t prefix_count) { - base::string16 buffer; + std::u16string buffer; for (size_t i = 0; i < prefix_count; i++) { buffer.clear(); base::UTF8ToUTF16(prefixes[i], strlen(prefixes[i]), &buffer); @@ -231,15 +231,15 @@ bool SplitCJKName(const std::vector<base::StringPiece16>& name_tokens, 1, StartsWithAny(name, common_cjk_multi_char_surnames, base::size(common_cjk_multi_char_surnames))); } - parts->family = base::string16(name.substr(0, surname_length)); - parts->given = base::string16(name.substr(surname_length)); + parts->family = std::u16string(name.substr(0, surname_length)); + parts->given = std::u16string(name.substr(surname_length)); return true; } if (name_tokens.size() == 2) { // The user entered a space between the two name parts. This makes our job // easier. Family name first, given name second. - parts->family = base::string16(name_tokens[0]); - parts->given = base::string16(name_tokens[1]); + parts->family = std::u16string(name_tokens[0]); + parts->given = std::u16string(name_tokens[1]); return true; } // We don't know what to do if there are more than 2 tokens. @@ -361,9 +361,9 @@ bool IsCJKName(base::StringPiece16 name) { // well. // // The middle dot is used as a separator for foreign names in Japanese. - static const base::char16 kKatakanaMiddleDot = u'\u30FB'; + static const char16_t kKatakanaMiddleDot = u'\u30FB'; // A (common?) typo for 'KATAKANA MIDDLE DOT' (U+30FB). - static const base::char16 kMiddleDot = u'\u00B7'; + static const char16_t kMiddleDot = u'\u00B7'; bool previous_was_cjk = false; size_t word_count = 0; for (base::i18n::UTF16CharIterator iter(name); !iter.end(); iter.Advance()) { @@ -382,7 +382,7 @@ bool IsCJKName(base::StringPiece16 name) { } NameParts SplitName(base::StringPiece16 name) { - static const base::char16 kWordSeparators[] = { + static const char16_t kWordSeparators[] = { u' ', // ASCII space. u',', // ASCII comma. u'\u3000', // 'IDEOGRAPHIC SPACE' (U+3000). @@ -411,13 +411,13 @@ NameParts SplitName(base::StringPiece16 name) { if (name_tokens.empty()) { // Bad things have happened; just assume the whole thing is a given name. - parts.given = base::string16(name); + parts.given = std::u16string(name); return parts; } // Only one token, assume given name. if (name_tokens.size() == 1) { - parts.given = base::string16(name_tokens[0]); + parts.given = std::u16string(name_tokens[0]); return parts; } @@ -435,22 +435,22 @@ NameParts SplitName(base::StringPiece16 name) { std::vector<base::StringPiece16> family_tokens(reverse_family_tokens.rbegin(), reverse_family_tokens.rend()); - parts.family = base::JoinString(family_tokens, base::ASCIIToUTF16(" ")); + parts.family = base::JoinString(family_tokens, u" "); // Take the last remaining token as the middle name (if there are at least 2 // tokens). if (name_tokens.size() >= 2) { - parts.middle = base::string16(name_tokens.back()); + parts.middle = std::u16string(name_tokens.back()); name_tokens.pop_back(); } // Remainder is given name. - parts.given = base::JoinString(name_tokens, base::ASCIIToUTF16(" ")); + parts.given = base::JoinString(name_tokens, u" "); return parts; } -base::string16 JoinNameParts(base::StringPiece16 given, +std::u16string JoinNameParts(base::StringPiece16 given, base::StringPiece16 middle, base::StringPiece16 family) { // First Middle Last @@ -510,7 +510,7 @@ bool IsValidCountryCode(const std::string& country_code) { return re2::RE2::FullMatch(country_code, "^[A-Z]{2}$"); } -bool IsValidCountryCode(const base::string16& country_code) { +bool IsValidCountryCode(const std::u16string& country_code) { return IsValidCountryCode(base::UTF16ToUTF8(country_code)); } diff --git a/chromium/components/autofill/core/browser/autofill_data_util.h b/chromium/components/autofill/core/browser/autofill_data_util.h index 144a1acd942..316a6358571 100644 --- a/chromium/components/autofill/core/browser/autofill_data_util.h +++ b/chromium/components/autofill/core/browser/autofill_data_util.h @@ -8,7 +8,6 @@ #include <string> #include <vector> -#include "base/strings/string16.h" #include "base/strings/string_piece_forward.h" #include "components/autofill/core/browser/field_types.h" @@ -20,9 +19,9 @@ class FormStructure; namespace data_util { struct NameParts { - base::string16 given; - base::string16 middle; - base::string16 family; + std::u16string given; + std::u16string middle; + std::u16string family; }; namespace bit_field_type_groups { @@ -95,7 +94,7 @@ NameParts SplitName(base::StringPiece16 name); // Concatenates the name parts together in the correct order (based on script), // and returns the result. -base::string16 JoinNameParts(base::StringPiece16 given, +std::u16string JoinNameParts(base::StringPiece16 given, base::StringPiece16 middle, base::StringPiece16 family); @@ -117,7 +116,7 @@ bool IsValidBasicCardIssuerNetwork( // Returns whether the specified |country_code| is a valid country code. bool IsValidCountryCode(const std::string& country_code); -bool IsValidCountryCode(const base::string16& country_code); +bool IsValidCountryCode(const std::u16string& country_code); // Returns a country code to be used when validating this profile. If the // profile has a valid country code set, it is returned. If not, a country code diff --git a/chromium/components/autofill/core/browser/autofill_data_util_unittest.cc b/chromium/components/autofill/core/browser/autofill_data_util_unittest.cc index ba78732dafc..f8f2f399c8d 100644 --- a/chromium/components/autofill/core/browser/autofill_data_util_unittest.cc +++ b/chromium/components/autofill/core/browser/autofill_data_util_unittest.cc @@ -214,7 +214,7 @@ class JoinNamePartsTest : public testing::TestWithParam<FullNameTestCase> {}; TEST_P(JoinNamePartsTest, JoinNameParts) { auto test_case = GetParam(); - base::string16 joined = + std::u16string joined = JoinNameParts(base::UTF8ToUTF16(test_case.given_name), base::UTF8ToUTF16(test_case.middle_name), base::UTF8ToUTF16(test_case.family_name)); diff --git a/chromium/components/autofill/core/browser/autofill_download_manager.cc b/chromium/components/autofill/core/browser/autofill_download_manager.cc index 097f5b9db03..b7fa97bf3b0 100644 --- a/chromium/components/autofill/core/browser/autofill_download_manager.cc +++ b/chromium/components/autofill/core/browser/autofill_download_manager.cc @@ -857,8 +857,17 @@ bool AutofillDownloadManager::StartRequest(FormRequestData request_data) { // As it is shared, it is not trusted and we cannot assign trusted_params // to the network request. #if !defined(OS_IOS) - resource_request->trusted_params = network::ResourceRequest::TrustedParams(); - resource_request->trusted_params->isolation_info = driver_->IsolationInfo(); + // Do not call IsolationInfo() for REQUEST_UPLOADs because Password Manager + // uploads when RenderFrameHostImpl::DidCommitNavigation() is called, in which + // case IsolationInfo() may crash because there is no committing + // NavigationRequest. This is safe because no information about the response + // is passed to the renderer, or is otherwise visible to a page. + // crbug/1176635#c22 + if (request_data.request_type != AutofillDownloadManager::REQUEST_UPLOAD) { + resource_request->trusted_params = + network::ResourceRequest::TrustedParams(); + resource_request->trusted_params->isolation_info = driver_->IsolationInfo(); + } #endif // Add Chrome experiment state to the request headers. diff --git a/chromium/components/autofill/core/browser/autofill_download_manager_unittest.cc b/chromium/components/autofill/core/browser/autofill_download_manager_unittest.cc index bf06e7d2e2f..ddaf6fd8c7f 100644 --- a/chromium/components/autofill/core/browser/autofill_download_manager_unittest.cc +++ b/chromium/components/autofill/core/browser/autofill_download_manager_unittest.cc @@ -263,38 +263,38 @@ TEST_F(AutofillDownloadManagerTest, QueryAndUploadTest) { FormData form; FormFieldData field; - field.label = UTF8ToUTF16("username"); - field.name = UTF8ToUTF16("username"); + field.label = u"username"; + field.name = u"username"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("First Name"); - field.name = UTF8ToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("Last Name"); - field.name = UTF8ToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("email"); - field.name = UTF8ToUTF16("email"); + field.label = u"email"; + field.name = u"email"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("email2"); - field.name = UTF8ToUTF16("email2"); + field.label = u"email2"; + field.name = u"email2"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("password"); - field.name = UTF8ToUTF16("password"); + field.label = u"password"; + field.name = u"password"; field.form_control_type = "password"; form.fields.push_back(field); - field.label = base::string16(); - field.name = UTF8ToUTF16("Submit"); + field.label = std::u16string(); + field.name = u"Submit"; field.form_control_type = "submit"; form.fields.push_back(field); @@ -303,23 +303,23 @@ TEST_F(AutofillDownloadManagerTest, QueryAndUploadTest) { form.fields.clear(); - field.label = UTF8ToUTF16("address"); - field.name = UTF8ToUTF16("address"); + field.label = u"address"; + field.name = u"address"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("address2"); - field.name = UTF8ToUTF16("address2"); + field.label = u"address2"; + field.name = u"address2"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("city"); - field.name = UTF8ToUTF16("city"); + field.label = u"city"; + field.name = u"city"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = base::string16(); - field.name = UTF8ToUTF16("Submit"); + field.label = std::u16string(); + field.name = u"Submit"; field.form_control_type = "submit"; form.fields.push_back(field); @@ -327,18 +327,18 @@ TEST_F(AutofillDownloadManagerTest, QueryAndUploadTest) { form.fields.clear(); - field.label = UTF8ToUTF16("username"); - field.name = UTF8ToUTF16("username"); + field.label = u"username"; + field.name = u"username"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("password"); - field.name = UTF8ToUTF16("password"); + field.label = u"password"; + field.name = u"password"; field.form_control_type = "password"; form.fields.push_back(field); - field.label = base::string16(); - field.name = UTF8ToUTF16("Submit"); + field.label = std::u16string(); + field.name = u"Submit"; field.form_control_type = "submit"; form.fields.push_back(field); @@ -449,8 +449,8 @@ TEST_F(AutofillDownloadManagerTest, QueryAndUploadTest) { responses_.pop_front(); // Modify form structures to miss the cache. - field.label = UTF8ToUTF16("Address line 2"); - field.name = UTF8ToUTF16("address2"); + field.label = u"Address line 2"; + field.name = u"address2"; field.form_control_type = "text"; form.fields.push_back(field); form_structures.push_back(std::make_unique<FormStructure>(form)); @@ -501,8 +501,8 @@ TEST_F(AutofillDownloadManagerTest, QueryAndUploadTest) { fl2.InitAndDisableFeature(features::kAutofillCacheQueryResponses); // Don't hit the in-mem cache. - field.label = UTF8ToUTF16("Address line 3"); - field.name = UTF8ToUTF16("address3"); + field.label = u"Address line 3"; + field.name = u"address3"; field.form_control_type = "text"; form.fields.push_back(field); form_structures.push_back(std::make_unique<FormStructure>(form)); @@ -524,13 +524,13 @@ TEST_F(AutofillDownloadManagerTest, QueryAPITest) { FormData form; FormFieldData field; - field.label = UTF8ToUTF16("First Name"); - field.name = UTF8ToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("Last Name"); - field.name = UTF8ToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; field.form_control_type = "text"; form.fields.push_back(field); @@ -623,8 +623,8 @@ TEST_F(AutofillDownloadManagerTest, QueryAPITestWhenTooLongUrl) { // Build the form structures that we want to query. FormData form; FormFieldData field; - field.label = UTF8ToUTF16("First Name"); - field.name = UTF8ToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; field.form_control_type = "text"; form.fields.push_back(field); @@ -732,13 +732,13 @@ TEST_F(AutofillDownloadManagerTest, UploadToAPITest) { FormData form; FormFieldData field; - field.label = UTF8ToUTF16("First Name"); - field.name = UTF8ToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("Last Name"); - field.name = UTF8ToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; field.form_control_type = "text"; form.fields.push_back(field); FormStructure form_structure(form); @@ -808,14 +808,14 @@ TEST_F(AutofillDownloadManagerTest, UploadWithRawMetadata) { << is_raw_metadata_uploading_enabled); // Build the form structures that we want to upload. FormData form; - form.name = UTF8ToUTF16("form1"); + form.name = u"form1"; FormFieldData field; - field.name = UTF8ToUTF16("firstname"); + field.name = u"firstname"; field.form_control_type = "text"; form.fields.push_back(field); - field.name = UTF8ToUTF16("lastname"); + field.name = u"lastname"; field.form_control_type = "text"; form.fields.push_back(field); FormStructure form_structure(form); @@ -871,23 +871,23 @@ TEST_F(AutofillDownloadManagerTest, UploadWithRawMetadata) { TEST_F(AutofillDownloadManagerTest, BackoffLogic_Query) { FormData form; FormFieldData field; - field.label = UTF8ToUTF16("address"); - field.name = UTF8ToUTF16("address"); + field.label = u"address"; + field.name = u"address"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("address2"); - field.name = UTF8ToUTF16("address2"); + field.label = u"address2"; + field.name = u"address2"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("city"); - field.name = UTF8ToUTF16("city"); + field.label = u"city"; + field.name = u"city"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = base::string16(); - field.name = UTF8ToUTF16("Submit"); + field.label = std::u16string(); + field.name = u"Submit"; field.form_control_type = "submit"; form.fields.push_back(field); @@ -942,23 +942,23 @@ TEST_F(AutofillDownloadManagerTest, BackoffLogic_Query) { TEST_F(AutofillDownloadManagerTest, BackoffLogic_Upload) { FormData form; FormFieldData field; - field.label = UTF8ToUTF16("address"); - field.name = UTF8ToUTF16("address"); + field.label = u"address"; + field.name = u"address"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("address2"); - field.name = UTF8ToUTF16("address2"); + field.label = u"address2"; + field.name = u"address2"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("city"); - field.name = UTF8ToUTF16("city"); + field.label = u"city"; + field.name = u"city"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = base::string16(); - field.name = UTF8ToUTF16("Submit"); + field.label = std::u16string(); + field.name = u"Submit"; field.form_control_type = "submit"; form.fields.push_back(field); @@ -1030,23 +1030,23 @@ TEST_F(AutofillDownloadManagerTest, BackoffLogic_Upload) { TEST_F(AutofillDownloadManagerTest, RetryLimit_Query) { FormData form; FormFieldData field; - field.label = UTF8ToUTF16("address"); - field.name = UTF8ToUTF16("address"); + field.label = u"address"; + field.name = u"address"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("address2"); - field.name = UTF8ToUTF16("address2"); + field.label = u"address2"; + field.name = u"address2"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("city"); - field.name = UTF8ToUTF16("city"); + field.label = u"city"; + field.name = u"city"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = base::string16(); - field.name = UTF8ToUTF16("Submit"); + field.label = std::u16string(); + field.name = u"Submit"; field.form_control_type = "submit"; form.fields.push_back(field); @@ -1107,23 +1107,23 @@ TEST_F(AutofillDownloadManagerTest, RetryLimit_Query) { TEST_F(AutofillDownloadManagerTest, RetryLimit_Upload) { FormData form; FormFieldData field; - field.label = UTF8ToUTF16("address"); - field.name = UTF8ToUTF16("address"); + field.label = u"address"; + field.name = u"address"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("address2"); - field.name = UTF8ToUTF16("address2"); + field.label = u"address2"; + field.name = u"address2"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("city"); - field.name = UTF8ToUTF16("city"); + field.label = u"city"; + field.name = u"city"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = base::string16(); - field.name = UTF8ToUTF16("Submit"); + field.label = std::u16string(); + field.name = u"Submit"; field.form_control_type = "submit"; form.fields.push_back(field); @@ -1231,32 +1231,32 @@ TEST_F(AutofillDownloadManagerTest, CacheQueryTest) { FormFieldData field; field.form_control_type = "text"; - field.label = UTF8ToUTF16("username"); - field.name = UTF8ToUTF16("username"); + field.label = u"username"; + field.name = u"username"; form.fields.push_back(field); - field.label = UTF8ToUTF16("First Name"); - field.name = UTF8ToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; form.fields.push_back(field); - field.label = UTF8ToUTF16("Last Name"); - field.name = UTF8ToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; form.fields.push_back(field); std::vector<std::unique_ptr<FormStructure>> form_structures0; form_structures0.push_back(std::make_unique<FormStructure>(form)); // Add a slightly different form, which should result in a different request. - field.label = UTF8ToUTF16("email"); - field.name = UTF8ToUTF16("email"); + field.label = u"email"; + field.name = u"email"; form.fields.push_back(field); std::vector<std::unique_ptr<FormStructure>> form_structures1; form_structures1.push_back(std::make_unique<FormStructure>(form)); // Add another slightly different form, which should also result in a // different request. - field.label = UTF8ToUTF16("email2"); - field.name = UTF8ToUTF16("email2"); + field.label = u"email2"; + field.name = u"email2"; form.fields.push_back(field); std::vector<std::unique_ptr<FormStructure>> form_structures2; form_structures2.push_back(std::make_unique<FormStructure>(form)); @@ -1579,8 +1579,8 @@ TEST_P(AutofillServerCommunicationTest, Query) { FormData form; FormFieldData field; - field.label = UTF8ToUTF16("First Name:"); - field.name = UTF8ToUTF16("firstname"); + field.label = u"First Name:"; + field.name = u"firstname"; field.form_control_type = "text"; form.fields.push_back(field); @@ -1594,18 +1594,18 @@ TEST_P(AutofillServerCommunicationTest, Upload) { FormData form; FormFieldData field; - field.label = UTF8ToUTF16("First Name:"); - field.name = UTF8ToUTF16("firstname"); + field.label = u"First Name:"; + field.name = u"firstname"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("Last Name:"); - field.name = UTF8ToUTF16("lastname"); + field.label = u"Last Name:"; + field.name = u"lastname"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("Email:"); - field.name = UTF8ToUTF16("email"); + field.label = u"Email:"; + field.name = u"email"; field.form_control_type = "text"; form.fields.push_back(field); @@ -1626,8 +1626,8 @@ using AutofillQueryTest = AutofillServerCommunicationTest; TEST_P(AutofillQueryTest, CacheableResponse) { FormFieldData field; - field.label = UTF8ToUTF16("First Name:"); - field.name = UTF8ToUTF16("firstname"); + field.label = u"First Name:"; + field.name = u"firstname"; field.form_control_type = "text"; FormData form; @@ -1666,8 +1666,8 @@ TEST_P(AutofillQueryTest, CacheableResponse) { TEST_P(AutofillQueryTest, SendsExperiment) { FormFieldData field; - field.label = UTF8ToUTF16("First Name:"); - field.name = UTF8ToUTF16("firstname"); + field.label = u"First Name:"; + field.name = u"firstname"; field.form_control_type = "text"; FormData form; @@ -1737,8 +1737,8 @@ TEST_P(AutofillQueryTest, SendsExperiment) { TEST_P(AutofillQueryTest, ExpiredCacheInResponse) { FormFieldData field; - field.label = UTF8ToUTF16("First Name:"); - field.name = UTF8ToUTF16("firstname"); + field.label = u"First Name:"; + field.name = u"firstname"; field.form_control_type = "text"; FormData form; @@ -1790,45 +1790,45 @@ TEST_P(AutofillQueryTest, RichMetadata_Enabled) { FormData form; form.url = GURL("https://origin.com"); form.action = GURL("https://origin.com/submit-me"); - form.id_attribute = UTF8ToUTF16("form-id-attribute"); - form.name_attribute = UTF8ToUTF16("form-name-attribute"); + form.id_attribute = u"form-id-attribute"; + form.name_attribute = u"form-name-attribute"; form.name = form.name_attribute; // Add field 0. FormFieldData field; - field.id_attribute = UTF8ToUTF16("field-id-attribute-1"); - field.name_attribute = UTF8ToUTF16("field-name-attribute-1"); + field.id_attribute = u"field-id-attribute-1"; + field.name_attribute = u"field-name-attribute-1"; field.name = field.name_attribute; - field.label = UTF8ToUTF16("field-label"); - field.aria_label = UTF8ToUTF16("field-aria-label"); - field.aria_description = UTF8ToUTF16("field-aria-description"); + field.label = u"field-label"; + field.aria_label = u"field-aria-label"; + field.aria_description = u"field-aria-description"; field.form_control_type = "text"; - field.css_classes = UTF8ToUTF16("field-css-classes"); - field.placeholder = UTF8ToUTF16("field-placeholder"); + field.css_classes = u"field-css-classes"; + field.placeholder = u"field-placeholder"; form.fields.push_back(field); // Add field 1. - field.id_attribute = UTF8ToUTF16("field-id-attribute-2"); - field.name_attribute = UTF8ToUTF16("field-name-attribute-2"); + field.id_attribute = u"field-id-attribute-2"; + field.name_attribute = u"field-name-attribute-2"; field.name = field.name_attribute; - field.label = UTF8ToUTF16("field-label"); - field.aria_label = UTF8ToUTF16("field-aria-label"); - field.aria_description = UTF8ToUTF16("field-aria-description"); + field.label = u"field-label"; + field.aria_label = u"field-aria-label"; + field.aria_description = u"field-aria-description"; field.form_control_type = "text"; - field.css_classes = UTF8ToUTF16("field-css-classes"); - field.placeholder = UTF8ToUTF16("field-placeholder"); + field.css_classes = u"field-css-classes"; + field.placeholder = u"field-placeholder"; form.fields.push_back(field); // Add field 2. - field.id_attribute = UTF8ToUTF16("field-id-attribute-3"); - field.name_attribute = UTF8ToUTF16("field-name-attribute-3"); + field.id_attribute = u"field-id-attribute-3"; + field.name_attribute = u"field-name-attribute-3"; field.name = field.name_attribute; - field.label = UTF8ToUTF16("field-label"); - field.aria_label = UTF8ToUTF16("field-aria-label"); - field.aria_description = UTF8ToUTF16("field-aria-description"); + field.label = u"field-label"; + field.aria_label = u"field-aria-label"; + field.aria_description = u"field-aria-description"; field.form_control_type = "text"; - field.css_classes = UTF8ToUTF16("field-css-classes"); - field.placeholder = UTF8ToUTF16("field-placeholder"); + field.css_classes = u"field-css-classes"; + field.placeholder = u"field-placeholder"; form.fields.push_back(field); // Setup the form structures to query. @@ -1890,45 +1890,45 @@ TEST_P(AutofillQueryTest, RichMetadata_Disabled) { FormData form; form.url = GURL("https://origin.com"); form.action = GURL("https://origin.com/submit-me"); - form.id_attribute = UTF8ToUTF16("form-id-attribute"); - form.name_attribute = UTF8ToUTF16("form-name-attribute"); + form.id_attribute = u"form-id-attribute"; + form.name_attribute = u"form-name-attribute"; form.name = form.name_attribute; // Add field 0. FormFieldData field; - field.id_attribute = UTF8ToUTF16("field-id-attribute-1"); - field.name_attribute = UTF8ToUTF16("field-name-attribute-1"); + field.id_attribute = u"field-id-attribute-1"; + field.name_attribute = u"field-name-attribute-1"; field.name = field.name_attribute; - field.label = UTF8ToUTF16("field-label"); - field.aria_label = UTF8ToUTF16("field-aria-label"); - field.aria_description = UTF8ToUTF16("field-aria-description"); + field.label = u"field-label"; + field.aria_label = u"field-aria-label"; + field.aria_description = u"field-aria-description"; field.form_control_type = "text"; - field.css_classes = UTF8ToUTF16("field-css-classes"); - field.placeholder = UTF8ToUTF16("field-placeholder"); + field.css_classes = u"field-css-classes"; + field.placeholder = u"field-placeholder"; form.fields.push_back(field); // Add field 1. - field.id_attribute = UTF8ToUTF16("field-id-attribute-2"); - field.name_attribute = UTF8ToUTF16("field-name-attribute-2"); + field.id_attribute = u"field-id-attribute-2"; + field.name_attribute = u"field-name-attribute-2"; field.name = field.name_attribute; - field.label = UTF8ToUTF16("field-label"); - field.aria_label = UTF8ToUTF16("field-aria-label"); - field.aria_description = UTF8ToUTF16("field-aria-description"); + field.label = u"field-label"; + field.aria_label = u"field-aria-label"; + field.aria_description = u"field-aria-description"; field.form_control_type = "text"; - field.css_classes = UTF8ToUTF16("field-css-classes"); - field.placeholder = UTF8ToUTF16("field-placeholder"); + field.css_classes = u"field-css-classes"; + field.placeholder = u"field-placeholder"; form.fields.push_back(field); // Add field 2. - field.id_attribute = UTF8ToUTF16("field-id-attribute-3"); - field.name_attribute = UTF8ToUTF16("field-name-attribute-3"); + field.id_attribute = u"field-id-attribute-3"; + field.name_attribute = u"field-name-attribute-3"; field.name = field.name_attribute; - field.label = UTF8ToUTF16("field-label"); - field.aria_label = UTF8ToUTF16("field-aria-label"); - field.aria_description = UTF8ToUTF16("field-aria-description"); + field.label = u"field-label"; + field.aria_label = u"field-aria-label"; + field.aria_description = u"field-aria-description"; field.form_control_type = "text"; - field.css_classes = UTF8ToUTF16("field-css-classes"); - field.placeholder = UTF8ToUTF16("field-placeholder"); + field.css_classes = u"field-css-classes"; + field.placeholder = u"field-placeholder"; form.fields.push_back(field); // Setup the form structures to query. @@ -1981,42 +1981,42 @@ TEST_P(AutofillUploadTest, RichMetadata) { form.url = GURL("https://origin.com"); form.full_url = GURL("https://origin.com?foo=bar#foo"); form.action = GURL("https://origin.com/submit-me"); - form.id_attribute = UTF8ToUTF16("form-id_attribute"); - form.name_attribute = UTF8ToUTF16("form-id_attribute"); + form.id_attribute = u"form-id_attribute"; + form.name_attribute = u"form-id_attribute"; form.name = form.name_attribute; FormFieldData field; - field.id_attribute = UTF8ToUTF16("field-id-attribute-1"); - field.name_attribute = UTF8ToUTF16("field-name-attribute-1"); + field.id_attribute = u"field-id-attribute-1"; + field.name_attribute = u"field-name-attribute-1"; field.name = field.name_attribute; - field.label = UTF8ToUTF16("field-label"); - field.aria_label = UTF8ToUTF16("field-aria-label"); - field.aria_description = UTF8ToUTF16("field-aria-descriptionm"); + field.label = u"field-label"; + field.aria_label = u"field-aria-label"; + field.aria_description = u"field-aria-descriptionm"; field.form_control_type = "text"; - field.css_classes = UTF8ToUTF16("field-css-classes"); - field.placeholder = UTF8ToUTF16("field-placeholder"); + field.css_classes = u"field-css-classes"; + field.placeholder = u"field-placeholder"; form.fields.push_back(field); - field.id_attribute = UTF8ToUTF16("field-id-attribute-2"); - field.name_attribute = UTF8ToUTF16("field-name-attribute-2"); + field.id_attribute = u"field-id-attribute-2"; + field.name_attribute = u"field-name-attribute-2"; field.name = field.name_attribute; - field.label = UTF8ToUTF16("field-label"); - field.aria_label = UTF8ToUTF16("field-aria-label"); - field.aria_description = UTF8ToUTF16("field-aria-descriptionm"); + field.label = u"field-label"; + field.aria_label = u"field-aria-label"; + field.aria_description = u"field-aria-descriptionm"; field.form_control_type = "text"; - field.css_classes = UTF8ToUTF16("field-css-classes"); - field.placeholder = UTF8ToUTF16("field-placeholder"); + field.css_classes = u"field-css-classes"; + field.placeholder = u"field-placeholder"; form.fields.push_back(field); - field.id_attribute = UTF8ToUTF16("field-id-attribute-3"); - field.name_attribute = UTF8ToUTF16("field-name-attribute-3"); + field.id_attribute = u"field-id-attribute-3"; + field.name_attribute = u"field-name-attribute-3"; field.name = field.name_attribute; - field.label = UTF8ToUTF16("field-label"); - field.aria_label = UTF8ToUTF16("field-aria-label"); - field.aria_description = UTF8ToUTF16("field-aria-descriptionm"); + field.label = u"field-label"; + field.aria_label = u"field-aria-label"; + field.aria_description = u"field-aria-descriptionm"; field.form_control_type = "text"; - field.css_classes = UTF8ToUTF16("field-css-classes"); - field.placeholder = UTF8ToUTF16("field-placeholder"); + field.css_classes = u"field-css-classes"; + field.placeholder = u"field-placeholder"; form.fields.push_back(field); AutofillDownloadManager download_manager(driver_.get(), this); @@ -2087,18 +2087,18 @@ TEST_P(AutofillUploadTest, Throttling) { FormData form; FormFieldData field; - field.label = UTF8ToUTF16("First Name:"); - field.name = UTF8ToUTF16("firstname"); + field.label = u"First Name:"; + field.name = u"firstname"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("Last Name:"); - field.name = UTF8ToUTF16("lastname"); + field.label = u"Last Name:"; + field.name = u"lastname"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("Email:"); - field.name = UTF8ToUTF16("email"); + field.label = u"Email:"; + field.name = u"email"; field.form_control_type = "text"; form.fields.push_back(field); @@ -2144,20 +2144,20 @@ TEST_P(AutofillUploadTest, ThrottlingDisabled) { FormData small_form; FormFieldData field; - field.label = UTF8ToUTF16("First Name:"); - field.name = UTF8ToUTF16("firstname"); + field.label = u"First Name:"; + field.name = u"firstname"; field.form_control_type = "text"; form.fields.push_back(field); small_form.fields.push_back(field); - field.label = UTF8ToUTF16("Last Name:"); - field.name = UTF8ToUTF16("lastname"); + field.label = u"Last Name:"; + field.name = u"lastname"; field.form_control_type = "text"; form.fields.push_back(field); small_form.fields.push_back(field); - field.label = UTF8ToUTF16("Email:"); - field.name = UTF8ToUTF16("email"); + field.label = u"Email:"; + field.name = u"email"; field.form_control_type = "text"; form.fields.push_back(field); @@ -2228,18 +2228,18 @@ TEST_P(AutofillUploadTest, PeriodicReset) { FormData form; FormFieldData field; - field.label = UTF8ToUTF16("First Name:"); - field.name = UTF8ToUTF16("firstname"); + field.label = u"First Name:"; + field.name = u"firstname"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("Last Name:"); - field.name = UTF8ToUTF16("lastname"); + field.label = u"Last Name:"; + field.name = u"lastname"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("Email:"); - field.name = UTF8ToUTF16("email"); + field.label = u"Email:"; + field.name = u"email"; field.form_control_type = "text"; form.fields.push_back(field); @@ -2286,18 +2286,18 @@ TEST_P(AutofillUploadTest, ResetOnClearUploadHisotry) { FormData form; FormFieldData field; - field.label = UTF8ToUTF16("First Name:"); - field.name = UTF8ToUTF16("firstname"); + field.label = u"First Name:"; + field.name = u"firstname"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("Last Name:"); - field.name = UTF8ToUTF16("lastname"); + field.label = u"Last Name:"; + field.name = u"lastname"; field.form_control_type = "text"; form.fields.push_back(field); - field.label = UTF8ToUTF16("Email:"); - field.name = UTF8ToUTF16("email"); + field.label = u"Email:"; + field.name = u"email"; field.form_control_type = "text"; form.fields.push_back(field); diff --git a/chromium/components/autofill/core/browser/autofill_driver.h b/chromium/components/autofill/core/browser/autofill_driver.h index dc4905ed640..7e2d219b99d 100644 --- a/chromium/components/autofill/core/browser/autofill_driver.h +++ b/chromium/components/autofill/core/browser/autofill_driver.h @@ -98,7 +98,8 @@ class AutofillDriver { // Tells the renderer to accept data list suggestions for |value|. virtual void RendererShouldAcceptDataListSuggestion( - const base::string16& value) = 0; + const FieldGlobalId& field_id, + const std::u16string& value) = 0; // Tells the renderer to clear the current section of the autofilled values. virtual void RendererShouldClearFilledSection() = 0; @@ -108,15 +109,18 @@ class AutofillDriver { // Tells the renderer to set the node text. virtual void RendererShouldFillFieldWithValue( - const base::string16& value) = 0; + const FieldGlobalId& field_id, + const std::u16string& value) = 0; // Tells the renderer to preview the node with suggested text. virtual void RendererShouldPreviewFieldWithValue( - const base::string16& value) = 0; + const FieldGlobalId& field_id, + const std::u16string& value) = 0; // Tells the renderer to set the currently focused node's corresponding // accessibility node's autofill state to |state|. virtual void RendererShouldSetSuggestionAvailability( + const FieldGlobalId& field_id, const mojom::AutofillState state) = 0; // Informs the renderer that the popup has been hidden. diff --git a/chromium/components/autofill/core/browser/autofill_experiments.cc b/chromium/components/autofill/core/browser/autofill_experiments.cc index 86f1fbca419..e4d9536d62d 100644 --- a/chromium/components/autofill/core/browser/autofill_experiments.cc +++ b/chromium/components/autofill/core/browser/autofill_experiments.cc @@ -4,10 +4,11 @@ #include "components/autofill/core/browser/autofill_experiments.h" +#include <string> + #include "base/command_line.h" #include "base/feature_list.h" #include "base/metrics/field_trial_params.h" -#include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" diff --git a/chromium/components/autofill/core/browser/autofill_experiments.h b/chromium/components/autofill/core/browser/autofill_experiments.h index d5b92be5822..3a9396246cb 100644 --- a/chromium/components/autofill/core/browser/autofill_experiments.h +++ b/chromium/components/autofill/core/browser/autofill_experiments.h @@ -7,7 +7,6 @@ #include <string> -#include "base/strings/string16.h" #include "build/build_config.h" #include "components/autofill/core/browser/sync_utils.h" diff --git a/chromium/components/autofill/core/browser/autofill_external_delegate.cc b/chromium/components/autofill/core/browser/autofill_external_delegate.cc index 0217bbc8696..cebe4690427 100644 --- a/chromium/components/autofill/core/browser/autofill_external_delegate.cc +++ b/chromium/components/autofill/core/browser/autofill_external_delegate.cc @@ -192,12 +192,13 @@ void AutofillExternalDelegate::OnAutofillAvailabilityEvent( const mojom::AutofillState state) { // Availability of suggestions should be communicated to Blink because // accessibility objects live in both the renderer and browser processes. - driver_->RendererShouldSetSuggestionAvailability(state); + driver_->RendererShouldSetSuggestionAvailability(query_field_.global_id(), + state); } void AutofillExternalDelegate::SetCurrentDataListValues( - const std::vector<base::string16>& data_list_values, - const std::vector<base::string16>& data_list_labels) { + const std::vector<std::u16string>& data_list_values, + const std::vector<std::u16string>& data_list_labels) { data_list_values_ = data_list_values; data_list_labels_ = data_list_labels; @@ -229,7 +230,7 @@ void AutofillExternalDelegate::OnPopupSuppressed() { manager_->DidSuppressPopup(query_form_, query_field_); } -void AutofillExternalDelegate::DidSelectSuggestion(const base::string16& value, +void AutofillExternalDelegate::DidSelectSuggestion(const std::u16string& value, int identifier) { ClearPreviewedForm(); @@ -237,10 +238,11 @@ void AutofillExternalDelegate::DidSelectSuggestion(const base::string16& value, if (identifier > 0) FillAutofillFormData(identifier, true); else if (identifier == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) - driver_->RendererShouldPreviewFieldWithValue(value); + driver_->RendererShouldPreviewFieldWithValue(query_field_.global_id(), + value); } -void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value, +void AutofillExternalDelegate::DidAcceptSuggestion(const std::u16string& value, int identifier, int position) { if (identifier == POPUP_ITEM_ID_AUTOFILL_OPTIONS) { @@ -256,10 +258,11 @@ void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value, identifier == POPUP_ITEM_ID_ACCOUNT_STORAGE_USERNAME_ENTRY) { NOTREACHED(); // Should be handled elsewhere. } else if (identifier == POPUP_ITEM_ID_DATALIST_ENTRY) { - driver_->RendererShouldAcceptDataListSuggestion(value); + driver_->RendererShouldAcceptDataListSuggestion(query_field_.global_id(), + value); } else if (identifier == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) { // User selected an Autocomplete, so we fill directly. - driver_->RendererShouldFillFieldWithValue(value); + driver_->RendererShouldFillFieldWithValue(query_field_.global_id(), value); AutofillMetrics::LogAutocompleteSuggestionAcceptedIndex(position); manager_->OnAutocompleteEntrySelected(value); } else if (identifier == POPUP_ITEM_ID_SCAN_CREDIT_CARD) { @@ -302,14 +305,14 @@ void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value, } bool AutofillExternalDelegate::GetDeletionConfirmationText( - const base::string16& value, + const std::u16string& value, int identifier, - base::string16* title, - base::string16* body) { + std::u16string* title, + std::u16string* body) { return manager_->GetDeletionConfirmationText(value, identifier, title, body); } -bool AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, +bool AutofillExternalDelegate::RemoveSuggestion(const std::u16string& value, int identifier) { if (identifier > 0) return manager_->RemoveAutofillProfileOrCreditCard(identifier); @@ -357,7 +360,7 @@ base::WeakPtr<AutofillExternalDelegate> AutofillExternalDelegate::GetWeakPtr() { void AutofillExternalDelegate::OnCreditCardScanned(const CreditCard& card) { manager_->FillCreditCardForm(query_id_, query_form_, query_field_, card, - base::string16()); + std::u16string()); } void AutofillExternalDelegate::FillAutofillFormData(int unique_id, @@ -393,7 +396,7 @@ void AutofillExternalDelegate::ApplyAutofillOptions( // The form has been auto-filled, so give the user the chance to clear the // form. Append the 'Clear form' menu item. if (query_field_.is_autofilled) { - base::string16 value = + std::u16string value = l10n_util::GetStringUTF16(IDS_AUTOFILL_CLEAR_FORM_MENU_ITEM); #if defined(OS_ANDROID) if (IsKeyboardAccessoryEnabled()) @@ -429,7 +432,7 @@ void AutofillExternalDelegate::InsertDataListValues( // Go through the list of autocomplete values and remove them if they are in // the list of datalist values. - std::set<base::string16> data_list_set(data_list_values_.begin(), + std::set<std::u16string> data_list_set(data_list_values_.begin(), data_list_values_.end()); base::EraseIf(*suggestions, [&data_list_set](const Suggestion& suggestion) { return suggestion.frontend_id == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY && @@ -455,7 +458,7 @@ void AutofillExternalDelegate::InsertDataListValues( } } -base::string16 AutofillExternalDelegate::GetSettingsSuggestionValue() const { +std::u16string AutofillExternalDelegate::GetSettingsSuggestionValue() const { switch (GetPopupType()) { case PopupType::kAddresses: return l10n_util::GetStringUTF16(IDS_AUTOFILL_MANAGE_ADDRESSES); @@ -469,7 +472,7 @@ base::string16 AutofillExternalDelegate::GetSettingsSuggestionValue() const { case PopupType::kPasswords: NOTREACHED(); - return base::string16(); + return std::u16string(); } } diff --git a/chromium/components/autofill/core/browser/autofill_external_delegate.h b/chromium/components/autofill/core/browser/autofill_external_delegate.h index b54e4e78ad5..06d94d9eaea 100644 --- a/chromium/components/autofill/core/browser/autofill_external_delegate.h +++ b/chromium/components/autofill/core/browser/autofill_external_delegate.h @@ -5,6 +5,7 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ +#include <string> #include <vector> #include "base/callback.h" @@ -12,7 +13,6 @@ #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/ui/autofill_popup_delegate.h" #include "components/autofill/core/browser/ui/suggestion.h" #include "components/autofill/core/common/form_data.h" @@ -41,16 +41,16 @@ class AutofillExternalDelegate : public AutofillPopupDelegate { void OnPopupShown() override; void OnPopupHidden() override; void OnPopupSuppressed() override; - void DidSelectSuggestion(const base::string16& value, + void DidSelectSuggestion(const std::u16string& value, int identifier) override; - void DidAcceptSuggestion(const base::string16& value, + void DidAcceptSuggestion(const std::u16string& value, int identifier, int position) override; - bool GetDeletionConfirmationText(const base::string16& value, + bool GetDeletionConfirmationText(const std::u16string& value, int identifier, - base::string16* title, - base::string16* body) override; - bool RemoveSuggestion(const base::string16& value, int identifier) override; + std::u16string* title, + std::u16string* body) override; + bool RemoveSuggestion(const std::u16string& value, int identifier) override; void ClearPreviewedForm() override; // Returns PopupType::kUnspecified for all popups prior to |onQuery|, or the @@ -91,8 +91,8 @@ class AutofillExternalDelegate : public AutofillPopupDelegate { // Set the data list value associated with the current field. void SetCurrentDataListValues( - const std::vector<base::string16>& data_list_values, - const std::vector<base::string16>& data_list_labels); + const std::vector<std::u16string>& data_list_values, + const std::vector<std::u16string>& data_list_labels); // Inform the delegate that the text field editing has ended. This is // used to help record the metrics of when a new popup is shown. @@ -142,7 +142,7 @@ class AutofillExternalDelegate : public AutofillPopupDelegate { void InsertDataListValues(std::vector<Suggestion>* suggestions); // Returns the text (i.e. |Suggestion| value) for Chrome autofill options. - base::string16 GetSettingsSuggestionValue() const; + std::u16string GetSettingsSuggestionValue() const; AutofillManager* const manager_; // weak. @@ -173,8 +173,8 @@ class AutofillExternalDelegate : public AutofillPopupDelegate { bool should_show_cards_from_account_option_ = false; // The current data list values. - std::vector<base::string16> data_list_values_; - std::vector<base::string16> data_list_labels_; + std::vector<std::u16string> data_list_values_; + std::vector<std::u16string> data_list_labels_; // If not null then it will be called in destructor. base::OnceClosure deletion_callback_; diff --git a/chromium/components/autofill/core/browser/autofill_external_delegate_unittest.cc b/chromium/components/autofill/core/browser/autofill_external_delegate_unittest.cc index 6a81dc37934..721f0c648c2 100644 --- a/chromium/components/autofill/core/browser/autofill_external_delegate_unittest.cc +++ b/chromium/components/autofill/core/browser/autofill_external_delegate_unittest.cc @@ -3,13 +3,13 @@ // found in the LICENSE file. #include <memory> +#include <string> #include <vector> #include "base/command_line.h" #include "base/compiler_specific.h" #include "base/i18n/rtl.h" #include "base/macros.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/metrics/user_action_tester.h" @@ -56,17 +56,17 @@ class MockAutofillDriver : public TestAutofillDriver { // Mock methods to enable testability. MOCK_METHOD(void, RendererShouldAcceptDataListSuggestion, - (const base::string16&), + (const FieldGlobalId&, const std::u16string&), (override)); MOCK_METHOD(void, RendererShouldClearFilledSection, (), (override)); MOCK_METHOD(void, RendererShouldClearPreviewedForm, (), (override)); MOCK_METHOD(void, RendererShouldFillFieldWithValue, - (const base::string16&), + (const FieldGlobalId&, const std::u16string&), (override)); MOCK_METHOD(void, RendererShouldPreviewFieldWithValue, - (const base::string16&), + (const FieldGlobalId&, const std::u16string&), (override)); private: @@ -87,8 +87,8 @@ class MockAutofillClient : public TestAutofillClient { (override)); MOCK_METHOD(void, UpdateAutofillPopupDataListValues, - (const std::vector<base::string16>& values, - const std::vector<base::string16>& lables), + (const std::vector<std::u16string>& values, + const std::vector<std::u16string>& lables), (override)); MOCK_METHOD(void, HideAutofillPopup, (PopupHidingReason), (override)); MOCK_METHOD(void, ExecuteCommand, (int), (override)); @@ -150,7 +150,7 @@ class MockAutofillManager : public AutofillManager { const FormData& form, const FormFieldData& field, const CreditCard& credit_card, - const base::string16& cvc), + const std::u16string& cvc), (override)); private: @@ -181,8 +181,12 @@ class AutofillExternalDelegateUnitTest : public testing::Test { // Issue an OnQuery call with the given |query_id|. void IssueOnQuery(int query_id) { - const FormData form; + FormData form; + form.host_frame = form_id_.frame_token; + form.unique_renderer_id = form_id_.renderer_id; FormFieldData field; + field.host_frame = field_id_.frame_token; + field.unique_renderer_id = field_id_.renderer_id; field.is_focusable = true; field.should_autocomplete = true; @@ -203,6 +207,9 @@ class AutofillExternalDelegateUnitTest : public testing::Test { std::unique_ptr<testing::NiceMock<MockAutofillDriver>> autofill_driver_; std::unique_ptr<MockAutofillManager> autofill_manager_; std::unique_ptr<AutofillExternalDelegate> external_delegate_; + + FormGlobalId form_id_ = test::MakeFormGlobalId(); + FieldGlobalId field_id_ = test::MakeFieldGlobalId(); }; // Variant for use in cases when we expect the AutofillManager would normally @@ -328,15 +335,15 @@ TEST_F(AutofillExternalDelegateUnitTest, // This should trigger a call to start the signin flow and hide the popup // since we've selected the sign-in promo option. external_delegate_->DidAcceptSuggestion( - base::string16(), POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO, 0); + std::u16string(), POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO, 0); } // Test that data list elements for a node will appear in the Autofill popup. TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateDataList) { IssueOnQuery(kRecentQueryId); - std::vector<base::string16> data_list_items; - data_list_items.push_back(base::string16()); + std::vector<std::u16string> data_list_items; + data_list_items.push_back(std::u16string()); EXPECT_CALL(autofill_client_, UpdateAutofillPopupDataListValues( data_list_items, data_list_items)); @@ -390,8 +397,8 @@ TEST_F(AutofillExternalDelegateUnitTest, UpdateDataListWhileShowingPopup) { // Make sure just setting the data list values doesn't cause the popup to // appear. - std::vector<base::string16> data_list_items; - data_list_items.push_back(base::string16()); + std::vector<std::u16string> data_list_items; + data_list_items.push_back(std::u16string()); EXPECT_CALL(autofill_client_, UpdateAutofillPopupDataListValues( data_list_items, data_list_items)); @@ -425,7 +432,7 @@ TEST_F(AutofillExternalDelegateUnitTest, UpdateDataListWhileShowingPopup) { external_delegate_->OnPopupShown(); // Update the current data list and ensure the popup is updated. - data_list_items.push_back(base::string16()); + data_list_items.push_back(std::u16string()); // The enums must be cast to ints to prevent compile errors on linux_rel. EXPECT_CALL(autofill_client_, UpdateAutofillPopupDataListValues( @@ -440,10 +447,8 @@ TEST_F(AutofillExternalDelegateUnitTest, UpdateDataListWhileShowingPopup) { TEST_F(AutofillExternalDelegateUnitTest, DuplicateAutofillDatalistValues) { IssueOnQuery(kRecentQueryId); - std::vector<base::string16> data_list_values{base::ASCIIToUTF16("Rick"), - base::ASCIIToUTF16("Beyonce")}; - std::vector<base::string16> data_list_labels{base::ASCIIToUTF16("Deckard"), - base::ASCIIToUTF16("Knowles")}; + std::vector<std::u16string> data_list_values{u"Rick", u"Beyonce"}; + std::vector<std::u16string> data_list_labels{u"Deckard", u"Knowles"}; EXPECT_CALL(autofill_client_, UpdateAutofillPopupDataListValues( data_list_values, data_list_labels)); @@ -466,8 +471,8 @@ TEST_F(AutofillExternalDelegateUnitTest, DuplicateAutofillDatalistValues) { // Have an Autofill item that is identical to one of the datalist entries. std::vector<Suggestion> autofill_item; autofill_item.push_back(Suggestion()); - autofill_item[0].value = ASCIIToUTF16("Rick"); - autofill_item[0].label = ASCIIToUTF16("Deckard"); + autofill_item[0].value = u"Rick"; + autofill_item[0].label = u"Deckard"; autofill_item[0].frontend_id = kAutofillProfileId; external_delegate_->OnSuggestionsReturned( kRecentQueryId, autofill_item, /*autoselect_first_suggestion=*/false); @@ -481,10 +486,8 @@ TEST_F(AutofillExternalDelegateUnitTest, DuplicateAutofillDatalistValues) { TEST_F(AutofillExternalDelegateUnitTest, DuplicateAutocompleteDatalistValues) { IssueOnQuery(kRecentQueryId); - std::vector<base::string16> data_list_values{base::ASCIIToUTF16("Rick"), - base::ASCIIToUTF16("Beyonce")}; - std::vector<base::string16> data_list_labels{base::ASCIIToUTF16("Deckard"), - base::ASCIIToUTF16("Knowles")}; + std::vector<std::u16string> data_list_values{u"Rick", u"Beyonce"}; + std::vector<std::u16string> data_list_labels{u"Deckard", u"Knowles"}; EXPECT_CALL(autofill_client_, UpdateAutofillPopupDataListValues( data_list_values, data_list_labels)); @@ -509,10 +512,10 @@ TEST_F(AutofillExternalDelegateUnitTest, DuplicateAutocompleteDatalistValues) { // and one that is distinct. std::vector<Suggestion> autocomplete_items; autocomplete_items.push_back(Suggestion()); - autocomplete_items[0].value = ASCIIToUTF16("Rick"); + autocomplete_items[0].value = u"Rick"; autocomplete_items[0].frontend_id = POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY; autocomplete_items.push_back(Suggestion()); - autocomplete_items[1].value = ASCIIToUTF16("Cain"); + autocomplete_items[1].value = u"Cain"; autocomplete_items[1].frontend_id = POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY; external_delegate_->OnSuggestionsReturned( kRecentQueryId, autocomplete_items, @@ -566,7 +569,7 @@ TEST_F(AutofillExternalDelegateUnitTest, suggestions[0].frontend_id = POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE; suggestions.push_back(Suggestion()); - suggestions[1].value = ASCIIToUTF16("Rick"); + suggestions[1].value = u"Rick"; suggestions[1].frontend_id = POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY; external_delegate_->OnSuggestionsReturned( kRecentQueryId, suggestions, /*autoselect_first_suggestion=*/false); @@ -585,13 +588,13 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) { // Ensure it doesn't try to preview the negative id. EXPECT_CALL(*autofill_manager_, FillOrPreviewForm(_, _, _, _, _)).Times(0); EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); - external_delegate_->DidSelectSuggestion(base::string16(), -1); + external_delegate_->DidSelectSuggestion(std::u16string(), -1); // Ensure it doesn't try to fill the form in with the negative id. EXPECT_CALL(autofill_client_, HideAutofillPopup(PopupHidingReason::kAcceptSuggestion)); EXPECT_CALL(*autofill_manager_, FillOrPreviewForm(_, _, _, _, _)).Times(0); - external_delegate_->DidAcceptSuggestion(base::string16(), -1, 0); + external_delegate_->DidAcceptSuggestion(std::u16string(), -1, 0); } // Test that the ClearPreview call is only sent if the form was being previewed @@ -599,20 +602,21 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) { TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearPreviewedForm) { // Ensure selecting a new password entries or Autofill entries will // cause any previews to get cleared. + IssueOnQuery(123); EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); - external_delegate_->DidSelectSuggestion(ASCIIToUTF16("baz foo"), + external_delegate_->DidSelectSuggestion(u"baz foo", POPUP_ITEM_ID_PASSWORD_ENTRY); EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); EXPECT_CALL( *autofill_manager_, FillOrPreviewForm(AutofillDriver::FORM_DATA_ACTION_PREVIEW, _, _, _, _)); - external_delegate_->DidSelectSuggestion(ASCIIToUTF16("baz foo"), 1); + external_delegate_->DidSelectSuggestion(u"baz foo", 1); // Ensure selecting an autocomplete entry will cause any previews to // get cleared. EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); - EXPECT_CALL(*autofill_driver_, - RendererShouldPreviewFieldWithValue(ASCIIToUTF16("baz foo"))); + EXPECT_CALL(*autofill_driver_, RendererShouldPreviewFieldWithValue( + field_id_, ASCIIToUTF16("baz foo"))); external_delegate_->DidSelectSuggestion(ASCIIToUTF16("baz foo"), POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY); } @@ -632,11 +636,12 @@ TEST_F(AutofillExternalDelegateUnitTest, // that the user accepted the data list suggestion. TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateAcceptDatalistSuggestion) { + IssueOnQuery(0); EXPECT_CALL(autofill_client_, HideAutofillPopup(PopupHidingReason::kAcceptSuggestion)); - base::string16 dummy_string(ASCIIToUTF16("baz qux")); + std::u16string dummy_string(u"baz qux"); EXPECT_CALL(*autofill_driver_, - RendererShouldAcceptDataListSuggestion(dummy_string)); + RendererShouldAcceptDataListSuggestion(field_id_, dummy_string)); external_delegate_->DidAcceptSuggestion(dummy_string, POPUP_ITEM_ID_DATALIST_ENTRY, 0); } @@ -646,7 +651,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateAcceptAutofillSuggestion) { EXPECT_CALL(autofill_client_, HideAutofillPopup(PopupHidingReason::kAcceptSuggestion)); - base::string16 dummy_string(ASCIIToUTF16("John Legend")); + std::u16string dummy_string(u"John Legend"); EXPECT_CALL(*autofill_manager_, FillOrPreviewForm(AutofillDriver::FORM_DATA_ACTION_FILL, _, _, _, kAutofillProfileId)); @@ -661,7 +666,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearForm) { HideAutofillPopup(PopupHidingReason::kAcceptSuggestion)); EXPECT_CALL(*autofill_driver_, RendererShouldClearFilledSection()); - external_delegate_->DidAcceptSuggestion(base::string16(), + external_delegate_->DidAcceptSuggestion(std::u16string(), POPUP_ITEM_ID_CLEAR_FORM, 0); } @@ -673,7 +678,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateHideSuggestions) { HideAutofillPopup(PopupHidingReason::kAcceptSuggestion)); external_delegate_->DidAcceptSuggestion( - base::string16(), POPUP_ITEM_ID_HIDE_AUTOFILL_SUGGESTIONS, 0); + std::u16string(), POPUP_ITEM_ID_HIDE_AUTOFILL_SUGGESTIONS, 0); } // Test that autofill client will scan a credit card after use accepted the @@ -682,7 +687,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ScanCreditCardMenuItem) { EXPECT_CALL(autofill_client_, ScanCreditCard(_)); EXPECT_CALL(autofill_client_, HideAutofillPopup(PopupHidingReason::kAcceptSuggestion)); - external_delegate_->DidAcceptSuggestion(base::string16(), + external_delegate_->DidAcceptSuggestion(std::u16string(), POPUP_ITEM_ID_SCAN_CREDIT_CARD, 0); } @@ -706,7 +711,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ScanCreditCardPromptMetricsTest) { IssueOnQuery(kRecentQueryId); IssueOnSuggestionsReturned(kRecentQueryId); external_delegate_->OnPopupShown(); - external_delegate_->DidAcceptSuggestion(base::string16(), + external_delegate_->DidAcceptSuggestion(std::u16string(), POPUP_ITEM_ID_SCAN_CREDIT_CARD, 0); histogram.ExpectBucketCount("Autofill.ScanCreditCardPrompt", AutofillMetrics::SCAN_CARD_ITEM_SHOWN, 1); @@ -724,7 +729,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ScanCreditCardPromptMetricsTest) { IssueOnQuery(kRecentQueryId); IssueOnSuggestionsReturned(kRecentQueryId); external_delegate_->OnPopupShown(); - external_delegate_->DidAcceptSuggestion(base::string16(), + external_delegate_->DidAcceptSuggestion(std::u16string(), POPUP_ITEM_ID_CLEAR_FORM, 0); histogram.ExpectBucketCount("Autofill.ScanCreditCardPrompt", AutofillMetrics::SCAN_CARD_ITEM_SHOWN, 1); @@ -754,7 +759,7 @@ TEST_F(AutofillExternalDelegateUnitTest, SigninPromoMenuItem) { EXPECT_CALL(autofill_client_, HideAutofillPopup(PopupHidingReason::kAcceptSuggestion)); external_delegate_->DidAcceptSuggestion( - base::string16(), POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO, 0); + std::u16string(), POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO, 0); } MATCHER_P(CreditCardMatches, card, "") { @@ -768,7 +773,7 @@ TEST_F(AutofillExternalDelegateUnitTest, FillCreditCardForm) { test::SetCreditCardInfo(&card, "Alice", "4111", "1", "3000", "1"); EXPECT_CALL( *autofill_manager_, - FillCreditCardForm(_, _, _, CreditCardMatches(card), base::string16())); + FillCreditCardForm(_, _, _, CreditCardMatches(card), std::u16string())); external_delegate_->OnCreditCardScanned(card); } @@ -795,9 +800,10 @@ TEST_F(AutofillExternalDelegateUnitTest, IgnoreAutocompleteOffForAutofill) { TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillFieldWithValue) { EXPECT_CALL(autofill_client_, HideAutofillPopup(PopupHidingReason::kAcceptSuggestion)); - base::string16 dummy_string(ASCIIToUTF16("baz foo")); + IssueOnQuery(456); + std::u16string dummy_string(u"baz foo"); EXPECT_CALL(*autofill_driver_, - RendererShouldFillFieldWithValue(dummy_string)); + RendererShouldFillFieldWithValue(field_id_, dummy_string)); EXPECT_CALL(*autofill_client_.GetMockAutocompleteHistoryManager(), OnAutocompleteEntrySelected(dummy_string)) .Times(1); @@ -858,7 +864,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ShouldUseNewSettingName) { IssueOnQuery(kRecentQueryId); auto element_values = testing::ElementsAre( - base::string16(), l10n_util::GetStringUTF16(IDS_AUTOFILL_MANAGE)); + std::u16string(), l10n_util::GetStringUTF16(IDS_AUTOFILL_MANAGE)); AutofillClient::PopupOpenArgs open_args; EXPECT_CALL(autofill_client_, ShowAutofillPopup) .WillOnce(testing::SaveArg<0>(&open_args)); @@ -883,7 +889,7 @@ TEST_F(AutofillExternalDelegateCardsFromAccountTest, IssueOnQuery(kRecentQueryId); auto element_values = testing::ElementsAre( - base::string16(), + std::u16string(), l10n_util::GetStringUTF16(IDS_AUTOFILL_SHOW_ACCOUNT_CARDS), l10n_util::GetStringUTF16(IDS_AUTOFILL_MANAGE)); AutofillClient::PopupOpenArgs open_args; diff --git a/chromium/components/autofill/core/browser/autofill_field.cc b/chromium/components/autofill/core/browser/autofill_field.cc index f563c4a4c90..0d592cf5e6b 100644 --- a/chromium/components/autofill/core/browser/autofill_field.cc +++ b/chromium/components/autofill/core/browser/autofill_field.cc @@ -29,7 +29,7 @@ AutofillField::AutofillField(const FormFieldData& field) } AutofillField::AutofillField(const FormFieldData& field, - const base::string16& unique_name) + const std::u16string& unique_name) : FormFieldData(field), unique_name_(unique_name), parseable_name_(field.name), diff --git a/chromium/components/autofill/core/browser/autofill_field.h b/chromium/components/autofill/core/browser/autofill_field.h index f3971ad3788..257f457c8d3 100644 --- a/chromium/components/autofill/core/browser/autofill_field.h +++ b/chromium/components/autofill/core/browser/autofill_field.h @@ -14,7 +14,6 @@ #include "base/macros.h" #include "base/optional.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/autofill_type.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" #include "components/autofill/core/browser/field_types.h" @@ -41,7 +40,7 @@ class AutofillField : public FormFieldData { AutofillField(); explicit AutofillField(const FormFieldData& field); - AutofillField(const FormFieldData& field, const base::string16& unique_name); + AutofillField(const FormFieldData& field, const std::u16string& unique_name); virtual ~AutofillField(); // Creates AutofillField that has bare minimum information for uploading @@ -53,7 +52,7 @@ class AutofillField : public FormFieldData { // Unique names are not stable across dynamic change. Use renderer IDs instead // if possible. // TODO(crbug/896689): Remove unique_name. - const base::string16& unique_name() const { return unique_name_; } + const std::u16string& unique_name() const { return unique_name_; } ServerFieldType heuristic_type() const { return heuristic_type_; } ServerFieldType server_type() const { return server_type_; } @@ -76,8 +75,8 @@ class AutofillField : public FormFieldData { } PhonePart phone_part() const { return phone_part_; } bool previously_autofilled() const { return previously_autofilled_; } - const base::string16& parseable_name() const { return parseable_name_; } - const base::string16& parseable_label() const { return parseable_label_; } + const std::u16string& parseable_name() const { return parseable_name_; } + const std::u16string& parseable_label() const { return parseable_label_; } bool only_fill_when_focused() const { return only_fill_when_focused_; } // Setters for the detected types. @@ -112,10 +111,10 @@ class AutofillField : public FormFieldData { void set_previously_autofilled(bool previously_autofilled) { previously_autofilled_ = previously_autofilled; } - void set_parseable_name(const base::string16& parseable_name) { + void set_parseable_name(const std::u16string& parseable_name) { parseable_name_ = parseable_name; } - void set_parseable_label(const base::string16& parseable_label) { + void set_parseable_label(const std::u16string& parseable_label) { parseable_label_ = parseable_label; } @@ -222,7 +221,7 @@ class AutofillField : public FormFieldData { base::Optional<FieldSignature> field_signature_; // The unique name of this field, generated by Autofill. - base::string16 unique_name_; + std::u16string unique_name_; // The type of the field, as determined by the Autofill server. ServerFieldType server_type_ = NO_SERVER_DATA; @@ -286,11 +285,11 @@ class AutofillField : public FormFieldData { // The parseable name attribute, with unnecessary information removed (such as // a common prefix shared with other fields). Will be used for heuristics // parsing. - base::string16 parseable_name_; + std::u16string parseable_name_; // The parseable label attribute is potentially only a part of the original // label when the label is divided between subsequent fields. - base::string16 parseable_label_; + std::u16string parseable_label_; // The type of password generation event, if it happened. AutofillUploadContents::Field::PasswordGenerationType generation_type_ = diff --git a/chromium/components/autofill/core/browser/autofill_form_test_utils.cc b/chromium/components/autofill/core/browser/autofill_form_test_utils.cc index 97d4e4c9b00..fae59e22149 100644 --- a/chromium/components/autofill/core/browser/autofill_form_test_utils.cc +++ b/chromium/components/autofill/core/browser/autofill_form_test_utils.cc @@ -29,56 +29,56 @@ FormFieldData CreateFieldByRole(ServerFieldType role) { switch (role) { case ServerFieldType::USERNAME: - field.label = ASCIIToUTF16("Username"); - field.name = ASCIIToUTF16("username"); + field.label = u"Username"; + field.name = u"username"; break; case ServerFieldType::NAME_FULL: - field.label = ASCIIToUTF16("Full name"); - field.name = ASCIIToUTF16("fullname"); + field.label = u"Full name"; + field.name = u"fullname"; break; case ServerFieldType::NAME_FIRST: - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstName"); + field.label = u"First Name"; + field.name = u"firstName"; break; case ServerFieldType::NAME_LAST: - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastName"); + field.label = u"Last Name"; + field.name = u"lastName"; break; case ServerFieldType::EMAIL_ADDRESS: - field.label = ASCIIToUTF16("E-mail address"); - field.name = ASCIIToUTF16("email"); + field.label = u"E-mail address"; + field.name = u"email"; break; case ServerFieldType::ADDRESS_HOME_LINE1: - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("home_line_one"); + field.label = u"Address"; + field.name = u"home_line_one"; break; case ServerFieldType::ADDRESS_HOME_CITY: - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; break; case ServerFieldType::ADDRESS_HOME_STATE: - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; break; case ServerFieldType::ADDRESS_HOME_COUNTRY: - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; break; case ServerFieldType::ADDRESS_HOME_ZIP: - field.label = ASCIIToUTF16("Zip Code"); - field.name = ASCIIToUTF16("zipCode"); + field.label = u"Zip Code"; + field.name = u"zipCode"; break; case ServerFieldType::PHONE_HOME_NUMBER: - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("phone"); + field.label = u"Phone"; + field.name = u"phone"; break; case ServerFieldType::COMPANY_NAME: - field.label = ASCIIToUTF16("Company"); - field.name = ASCIIToUTF16("company"); + field.label = u"Company"; + field.name = u"company"; break; case ServerFieldType::CREDIT_CARD_NUMBER: - field.label = ASCIIToUTF16("Card Number"); - field.name = ASCIIToUTF16("cardNumber"); + field.label = u"Card Number"; + field.name = u"cardNumber"; break; case ServerFieldType::EMPTY_TYPE: default: @@ -118,7 +118,6 @@ FormData GetFormData(const TestFormAttributes& test_form_attributes) { field.should_autocomplete = field_description.should_autocomplete; form_data.fields.push_back(field); } - form_data.is_formless_checkout = test_form_attributes.is_formless_checkout; form_data.is_form_tag = test_form_attributes.is_form_tag; return form_data; diff --git a/chromium/components/autofill/core/browser/autofill_form_test_utils.h b/chromium/components/autofill/core/browser/autofill_form_test_utils.h index 0c4c9b936c1..660cbcb86c5 100644 --- a/chromium/components/autofill/core/browser/autofill_form_test_utils.h +++ b/chromium/components/autofill/core/browser/autofill_form_test_utils.h @@ -59,7 +59,6 @@ struct TestFormAttributes { const char* url = kFormUrl; const char* action = kFormActionUrl; base::Optional<url::Origin> main_frame_origin = base::nullopt; - bool is_formless_checkout = false; bool is_form_tag = true; }; diff --git a/chromium/components/autofill/core/browser/autofill_handler.cc b/chromium/components/autofill/core/browser/autofill_handler.cc index 99752491c36..7e017bd8693 100644 --- a/chromium/components/autofill/core/browser/autofill_handler.cc +++ b/chromium/components/autofill/core/browser/autofill_handler.cc @@ -35,7 +35,7 @@ const size_t kAutofillHandlerMaxFormCacheSize = 100; AutofillField* FindAutofillFillField(const FormStructure& form, const FormFieldData& field) { for (const auto& f : form) { - if (field.unique_renderer_id == f->unique_renderer_id) + if (field.global_id() == f->global_id()) return f.get(); } for (const auto& cur_field : form) { @@ -207,7 +207,7 @@ void AutofillHandler::OnFormsSeen(const std::vector<FormData>& forms) { for (const FormData& form : forms) { const auto parse_form_start_time = AutofillTickClock::NowTicks(); FormStructure* cached_form_structure = - FindCachedFormByRendererId(form.unique_renderer_id); + FindCachedFormByRendererId(form.global_id()); // Not updating signatures of credit card forms is legacy behaviour. We // believe that the signatures are kept stable for voting purposes. @@ -248,7 +248,7 @@ void AutofillHandler::OnFormsParsed(const std::vector<const FormData*>& forms) { DenseSet<FormType> form_types; for (const FormData* form : forms) { FormStructure* form_structure = - FindCachedFormByRendererId(form->unique_renderer_id); + FindCachedFormByRendererId(form->global_id()); if (!form_structure) { NOTREACHED(); continue; @@ -363,8 +363,7 @@ bool AutofillHandler::GetCachedFormAndField(const FormData& form, FormStructure** form_structure, AutofillField** autofill_field) { // Maybe find an existing FormStructure that corresponds to |form|. - FormStructure* cached_form = - FindCachedFormByRendererId(form.unique_renderer_id); + FormStructure* cached_form = FindCachedFormByRendererId(form.global_id()); if (cached_form) { DCHECK(cached_form); if (!CachedFormNeedsUpdate(form, *cached_form)) { @@ -421,8 +420,8 @@ size_t AutofillHandler::FindCachedFormsBySignature( } FormStructure* AutofillHandler::FindCachedFormByRendererId( - FormRendererId form_renderer_id) const { - auto it = form_structures_.find(form_renderer_id); + FormGlobalId form_id) const { + auto it = form_structures_.find(form_id); return it != form_structures_.end() ? it->second.get() : nullptr; } @@ -468,7 +467,7 @@ FormStructure* AutofillHandler::ParseForm(const FormData& form, // // Note that this insert/update takes ownership of the new form structure // and also destroys the previously cached form structure. - form_structures_[parsed_form_structure->unique_renderer_id()] = + form_structures_[parsed_form_structure->global_id()] = std::move(form_structure); return parsed_form_structure; diff --git a/chromium/components/autofill/core/browser/autofill_handler.h b/chromium/components/autofill/core/browser/autofill_handler.h index 3f1dc3c1259..5f1345c5216 100644 --- a/chromium/components/autofill/core/browser/autofill_handler.h +++ b/chromium/components/autofill/core/browser/autofill_handler.h @@ -22,8 +22,8 @@ #include "components/autofill/core/common/form_data.h" #include "components/autofill/core/common/language_code.h" #include "components/autofill/core/common/mojom/autofill_types.mojom.h" -#include "components/autofill/core/common/renderer_id.h" #include "components/autofill/core/common/signatures.h" +#include "components/autofill/core/common/unique_ids.h" #include "components/translate/core/browser/translate_driver.h" #include "components/version_info/channel.h" @@ -170,8 +170,8 @@ class AutofillHandler AutofillField** autofill_field) WARN_UNUSED_RESULT; // Returns nullptr if no cached form structure is found with a matching - // |renderer_id|. Runs in logarithmic time. - FormStructure* FindCachedFormByRendererId(FormRendererId renderer_id) const; + // |form_id|. Runs in logarithmic time. + FormStructure* FindCachedFormByRendererId(FormGlobalId form_id) const; // Returns the number of forms this Autofill handler is aware of. size_t NumFormsDetected() const { return form_structures_.size(); } @@ -181,7 +181,7 @@ class AutofillHandler } // Returns the present form structures seen by Autofill handler. - const std::map<FormRendererId, std::unique_ptr<FormStructure>>& + const std::map<FormGlobalId, std::unique_ptr<FormStructure>>& form_structures() const { return form_structures_; } @@ -214,7 +214,7 @@ class AutofillHandler #ifdef UNIT_TEST // A public wrapper that calls |mutable_form_structures| for testing purposes // only. - std::map<FormRendererId, std::unique_ptr<FormStructure>>* + std::map<FormGlobalId, std::unique_ptr<FormStructure>>* mutable_form_structures_for_test() { return mutable_form_structures(); } @@ -298,7 +298,7 @@ class AutofillHandler bool value_from_dynamic_change_form_ = false; - std::map<FormRendererId, std::unique_ptr<FormStructure>>* + std::map<FormGlobalId, std::unique_ptr<FormStructure>>* mutable_form_structures() { return &form_structures_; } @@ -350,7 +350,7 @@ class AutofillHandler translate_observation_{this}; // Our copy of the form data. - std::map<FormRendererId, std::unique_ptr<FormStructure>> form_structures_; + std::map<FormGlobalId, std::unique_ptr<FormStructure>> form_structures_; // Handles queries and uploads to Autofill servers. Will be nullptr if // the download manager functionality is disabled. diff --git a/chromium/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc b/chromium/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc index f365bd94f19..fd8db8155ba 100644 --- a/chromium/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc +++ b/chromium/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc @@ -13,7 +13,6 @@ #include "base/check.h" #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/strings/string16.h" #include "base/win/registry.h" #include "components/autofill/core/browser/crypto/rc4_decryptor.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" @@ -186,7 +185,7 @@ bool ImportSingleProfile(const std::string& app_locale, ImportSingleFormGroup(key, reg_to_field, app_locale, profile, &phone); // Now re-construct the phones if needed. - base::string16 constructed_number; + std::u16string constructed_number; if (phone.ParseNumber(*profile, app_locale, &constructed_number)) { has_non_empty_fields = true; profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, constructed_number); @@ -286,7 +285,7 @@ bool ImportCurrentUserProfiles(const std::string& app_locale, credit_card.set_origin(kIEToolbarImportOrigin); if (ImportSingleFormGroup(key, reg_to_field, app_locale, &credit_card, nullptr)) { - base::string16 cc_number = credit_card.GetRawInfo(CREDIT_CARD_NUMBER); + std::u16string cc_number = credit_card.GetRawInfo(CREDIT_CARD_NUMBER); if (!cc_number.empty()) credit_cards->push_back(credit_card); } diff --git a/chromium/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc b/chromium/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc index f1b065de45a..4810bc62427 100644 --- a/chromium/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc +++ b/chromium/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc @@ -6,8 +6,9 @@ #include <stddef.h> +#include <string> + #include "base/stl_util.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "base/win/registry.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" @@ -188,10 +189,9 @@ TEST_F(AutofillIeToolbarImportTest, TestAutofillImport) { profiles[1].GetInfo(AutofillType(PHONE_HOME_COUNTRY_CODE), "US")); EXPECT_EQ(base::WideToUTF16(profile1[6].value), profiles[1].GetInfo(AutofillType(PHONE_HOME_CITY_CODE), "US")); - EXPECT_EQ(STRING16_LITERAL("5555555"), + EXPECT_EQ(u"5555555", profiles[1].GetInfo(AutofillType(PHONE_HOME_NUMBER), "US")); - EXPECT_EQ(STRING16_LITERAL("1 650-555-5555"), - profiles[1].GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); + EXPECT_EQ(u"1 650-555-5555", profiles[1].GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); EXPECT_EQ(base::WideToUTF16(profile2[0].value), profiles[0].GetRawInfo(NAME_FIRST)); @@ -205,7 +205,7 @@ TEST_F(AutofillIeToolbarImportTest, TestAutofillImport) { ASSERT_EQ(1U, credit_cards.size()); EXPECT_EQ(base::WideToUTF16(credit_card[0].value), credit_cards[0].GetRawInfo(CREDIT_CARD_NAME_FULL)); - EXPECT_EQ(STRING16_LITERAL("4111111111111111"), + EXPECT_EQ(u"4111111111111111", credit_cards[0].GetRawInfo(CREDIT_CARD_NUMBER)); EXPECT_EQ(base::WideToUTF16(credit_card[2].value), credit_cards[0].GetRawInfo(CREDIT_CARD_EXP_MONTH)); diff --git a/chromium/components/autofill/core/browser/autofill_manager.cc b/chromium/components/autofill/core/browser/autofill_manager.cc index 5f901aba729..b7d457b8fa9 100644 --- a/chromium/components/autofill/core/browser/autofill_manager.cc +++ b/chromium/components/autofill/core/browser/autofill_manager.cc @@ -12,6 +12,7 @@ #include <map> #include <memory> #include <set> +#include <string> #include <unordered_map> #include <utility> #include <vector> @@ -31,7 +32,6 @@ #include "base/notreached.h" #include "base/path_service.h" #include "base/ranges/algorithm.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" @@ -120,17 +120,17 @@ const int kLimitBeforeRefillMs = 1000; // Returns the credit card field |value| trimmed from whitespace and with stop // characters removed. -base::string16 SanitizeCreditCardFieldValue(const base::string16& value) { - base::string16 sanitized; +std::u16string SanitizeCreditCardFieldValue(const std::u16string& value) { + std::u16string sanitized; // We remove whitespace as well as some invisible unicode characters. base::TrimWhitespace(value, base::TRIM_ALL, &sanitized); base::TrimString(sanitized, - base::string16({base::i18n::kRightToLeftMark, + std::u16string({base::i18n::kRightToLeftMark, base::i18n::kLeftToRightMark}), &sanitized); // Some sites have ____-____-____-____ in their credit card number fields, for // example. - base::RemoveChars(sanitized, base::ASCIIToUTF16("-_"), &sanitized); + base::RemoveChars(sanitized, u"-_", &sanitized); return sanitized; } @@ -187,7 +187,7 @@ void LogDeveloperEngagementUkm(ukm::UkmRecorder* ukm_recorder, } } -ValuePatternsMetric GetValuePattern(const base::string16& value) { +ValuePatternsMetric GetValuePattern(const std::u16string& value) { if (IsUPIVirtualPaymentAddress(value)) return ValuePatternsMetric::kUpiVpa; if (IsInternationalBankAccountNumber(value)) @@ -201,7 +201,7 @@ void LogValuePatternsMetric(const FormData& form) { // Ignore hidden fields. continue; } - base::string16 value; + std::u16string value; base::TrimWhitespace(field.value, base::TRIM_ALL, &value); if (value.empty()) continue; @@ -244,9 +244,9 @@ bool IsAddressForm(FieldTypeGroup field_type_group) { // Finds the first field in |form_structure| with |field.value|=|value|. AutofillField* FindFirstFieldWithValue(const FormStructure& form_structure, - const base::string16& value) { + const std::u16string& value) { for (const auto& field : form_structure) { - base::string16 trimmed_value; + std::u16string trimmed_value; base::TrimWhitespace(field->value, base::TRIM_ALL, &trimmed_value); if (trimmed_value == value) return field.get(); @@ -300,7 +300,7 @@ AutofillField* HeuristicallyFindCVCFieldForUpload( // |UNKNOWN_TYPE| should come alone. DCHECK_EQ(1u, type_set.size()); - base::string16 trimmed_value; + std::u16string trimmed_value; base::TrimWhitespace(field->value, base::TRIM_ALL, &trimmed_value); // Skip the field if it can be confused with a expiration year. @@ -323,7 +323,7 @@ AutofillField* HeuristicallyFindCVCFieldForUpload( // search for the CVC field if any. AutofillField* GetBestPossibleCVCFieldForUpload( const FormStructure& form_structure, - base::string16 last_unlocked_credit_card_cvc) { + std::u16string last_unlocked_credit_card_cvc) { if (!last_unlocked_credit_card_cvc.empty()) { AutofillField* result = FindFirstFieldWithValue(form_structure, last_unlocked_credit_card_cvc); @@ -416,8 +416,8 @@ AutofillManager::FillingContext::FillingContext( const AutofillField& field, absl::variant<const AutofillProfile*, const CreditCard*> profile_or_credit_card, - const base::string16* optional_cvc) - : filled_field_renderer_id(field.unique_renderer_id), + const std::u16string* optional_cvc) + : filled_field_id(field.global_id()), filled_field_signature(field.GetFieldSignature()), filled_field_unique_name(field.unique_name()), original_fill_time(AutofillTickClock::NowTicks()) { @@ -431,7 +431,7 @@ AutofillManager::FillingContext::FillingContext( profile_or_credit_card)) { profile_or_credit_card_with_cvc = std::make_pair(*absl::get<const CreditCard*>(profile_or_credit_card), - optional_cvc ? *optional_cvc : base::string16()); + optional_cvc ? *optional_cvc : std::u16string()); } } @@ -510,7 +510,7 @@ bool AutofillManager::ShouldShowScanCreditCard(const FormData& form, bool is_card_number_field = autofill_field->Type().GetStorableType() == CREDIT_CARD_NUMBER && base::ContainsOnlyChars(CreditCard::StripSeparators(field.value), - base::ASCIIToUTF16("0123456789")); + u"0123456789"); if (!is_card_number_field) return false; @@ -674,6 +674,8 @@ bool AutofillManager::ShouldParseForms(const std::vector<FormData>& forms) { void AutofillManager::OnFormSubmittedImpl(const FormData& form, bool known_success, SubmissionSource source) { + base::UmaHistogramEnumeration("Autofill.FormSubmission.PerProfileType", + client()->GetProfileType()); if (log_manager()) { log_manager()->Log() << LoggingScope::kSubmission << LogMessage::kFormSubmissionDetected << Br{} @@ -708,10 +710,6 @@ void AutofillManager::OnFormSubmittedImpl(const FormData& form, autocomplete_history_manager_->OnWillSubmitForm( form_for_autocomplete, client()->IsAutocompleteEnabled()); - // TODO(https://crbug.com/1167475): Add Test for this metric. - base::UmaHistogramEnumeration("Autofill.FormSubmission.PerProfileType", - client()->GetProfileType()); - if (IsAutofillProfileEnabled()) { address_form_event_logger_->OnWillSubmitForm(sync_state_, *submitted_form); } @@ -838,7 +836,7 @@ void AutofillManager::UpdatePendingForm(const FormData& form) { ProcessPendingFormForUpload(); } // A new pending form is assigned. - pending_form_data_.reset(new FormData(form)); + pending_form_data_ = std::make_unique<FormData>(form); } void AutofillManager::ProcessPendingFormForUpload() { @@ -1125,7 +1123,7 @@ void AutofillManager::FillCreditCardForm(int query_id, const FormData& form, const FormFieldData& field, const CreditCard& credit_card, - const base::string16& cvc) { + const std::u16string& cvc) { if (!IsValidFormData(form) || !IsValidFormFieldData(field) || !driver()->RendererIsAvailable()) { return; @@ -1216,8 +1214,7 @@ void AutofillManager::OnDidFillAutofillFormData(const FormData& form, // Find the FormStructure that corresponds to |form|. Use default form type if // form is not present in our cache, which will happen rarely. - FormStructure* form_structure = - FindCachedFormByRendererId(form.unique_renderer_id); + FormStructure* form_structure = FindCachedFormByRendererId(form.global_id()); DenseSet<FormType> form_types; if (form_structure) { form_types = form_structure->GetFormTypes(); @@ -1291,10 +1288,10 @@ void AutofillManager::OnHidePopup() { client()->HideAutofillPopup(PopupHidingReason::kRendererEvent); } -bool AutofillManager::GetDeletionConfirmationText(const base::string16& value, +bool AutofillManager::GetDeletionConfirmationText(const std::u16string& value, int identifier, - base::string16* title, - base::string16* body) { + std::u16string* title, + std::u16string* body) { if (identifier == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) { if (title) title->assign(value); @@ -1322,7 +1319,7 @@ bool AutofillManager::GetDeletionConfirmationText(const base::string16& value, return false; if (title) { - base::string16 street_address = profile->GetRawInfo(ADDRESS_HOME_CITY); + std::u16string street_address = profile->GetRawInfo(ADDRESS_HOME_CITY); if (!street_address.empty()) title->swap(street_address); else @@ -1359,12 +1356,12 @@ bool AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { return false; } -void AutofillManager::RemoveAutocompleteEntry(const base::string16& name, - const base::string16& value) { +void AutofillManager::RemoveAutocompleteEntry(const std::u16string& name, + const std::u16string& value) { autocomplete_history_manager_->OnRemoveAutocompleteEntry(name, value); } -void AutofillManager::OnAutocompleteEntrySelected(const base::string16& value) { +void AutofillManager::OnAutocompleteEntrySelected(const std::u16string& value) { autocomplete_history_manager_->OnAutocompleteEntrySelected(value); } @@ -1399,8 +1396,8 @@ void AutofillManager::SetTestDelegate(AutofillManagerTestDelegate* delegate) { test_delegate_ = delegate; } -void AutofillManager::SetDataList(const std::vector<base::string16>& values, - const std::vector<base::string16>& labels) { +void AutofillManager::SetDataList(const std::vector<std::u16string>& values, + const std::vector<std::u16string>& labels) { if (!IsValidString16Vector(values) || !IsValidString16Vector(labels) || values.size() != labels.size()) return; @@ -1408,12 +1405,10 @@ void AutofillManager::SetDataList(const std::vector<base::string16>& values, external_delegate_->SetCurrentDataListValues(values, labels); } - void AutofillManager::SelectFieldOptionsDidChange(const FormData& form) { // Look for a cached version of the form. It will be a null pointer if none is // found, which is fine. - FormStructure* cached_form = - FindCachedFormByRendererId(form.unique_renderer_id); + FormStructure* cached_form = FindCachedFormByRendererId(form.global_id()); FormStructure* form_structure = ParseForm(form, cached_form); if (!form_structure) @@ -1431,7 +1426,7 @@ void AutofillManager::PropagateAutofillPredictions( void AutofillManager::OnCreditCardFetched(bool did_succeed, const CreditCard* credit_card, - const base::string16& cvc) { + const std::u16string& cvc) { if (!did_succeed) { driver()->RendererShouldClearPreviewedForm(); return; @@ -1571,7 +1566,7 @@ void AutofillManager::Reset() { credit_card_action_ = AutofillDriver::FORM_DATA_ACTION_PREVIEW; initial_interaction_timestamp_ = TimeTicks(); external_delegate_->Reset(); - filling_context_by_renderer_id_.clear(); + filling_context_by_global_id_.clear(); filling_context_by_unique_name_.clear(); } @@ -1629,7 +1624,7 @@ void AutofillManager::FillOrPreviewDataModelForm( const FormFieldData& field, absl::variant<const AutofillProfile*, const CreditCard*> profile_or_credit_card, - const base::string16* optional_cvc, + const std::u16string* optional_cvc, FormStructure* form_structure, AutofillField* autofill_field, bool is_refill) { @@ -1790,7 +1785,7 @@ void AutofillManager::FillOrPreviewDataModelForm( bool has_value_before = !result.fields[i].value.empty(); bool is_autofilled_before = result.fields[i].is_autofilled; - const base::string16 kEmptyCvc{}; + const std::u16string kEmptyCvc{}; std::string failure_to_fill; // Reason for failing to fill. // Fill the non-empty value from |profile_or_credit_card| into the result @@ -1837,7 +1832,7 @@ std::unique_ptr<FormStructure> AutofillManager::ValidateSubmittedForm( // Ignore forms not present in our cache. These are typically forms with // wonky JavaScript that also makes them not auto-fillable. FormStructure* cached_submitted_form = - FindCachedFormByRendererId(form.unique_renderer_id); + FindCachedFormByRendererId(form.global_id()); if (!cached_submitted_form || !ShouldUploadForm(*cached_submitted_form)) { return nullptr; } @@ -1897,10 +1892,17 @@ std::vector<Suggestion> AutofillManager::GetProfileSuggestions( autofill_field.Type(), field.value, field.is_autofilled, field_types); // Adjust phone number to display in prefix/suffix case. - if (autofill_field.Type().GetStorableType() == PHONE_HOME_NUMBER) { - for (size_t i = 0; i < suggestions.size(); ++i) { - suggestions[i].value = FieldFiller::GetPhoneNumberValue( - autofill_field, suggestions[i].value, field); + if (autofill_field.Type().group() == FieldTypeGroup::kPhoneHome) { + for (auto& suggestion : suggestions) { + const AutofillProfile* profile = + personal_data_->GetProfileByGUID(suggestion.backend_id); + if (profile) { + const std::u16string phone_home_city_and_number = + profile->GetInfo(PHONE_HOME_CITY_AND_NUMBER, app_locale_); + suggestion.value = + FieldFiller::GetPhoneNumberValue(autofill_field, suggestion.value, + phone_home_city_and_number, field); + } } } @@ -2089,7 +2091,7 @@ void AutofillManager::UpdateInitialInteractionTimestamp( void AutofillManager::DeterminePossibleFieldTypesForUpload( const std::vector<AutofillProfile>& profiles, const std::vector<CreditCard>& credit_cards, - const base::string16& last_unlocked_credit_card_cvc, + const std::u16string& last_unlocked_credit_card_cvc, const std::string& app_locale, FormStructure* submitted_form) { // For each field in the |submitted_form|, extract the value. Then for each @@ -2105,7 +2107,7 @@ void AutofillManager::DeterminePossibleFieldTypesForUpload( } ServerFieldTypeSet matching_types; - base::string16 value; + std::u16string value; base::TrimWhitespace(field->value, base::TRIM_ALL, &value); for (const AutofillProfile& profile : profiles) { @@ -2319,7 +2321,7 @@ void AutofillManager::FillFieldWithValue( profile_or_credit_card, FormFieldData* field_data, bool should_notify, - const base::string16& cvc, + const std::u16string& cvc, uint32_t profile_form_bitmask, std::string* failure_to_fill) { if (field_filler_.FillFormField(*autofill_field, profile_or_credit_card, @@ -2356,8 +2358,7 @@ void AutofillManager::SetFillingContext( const FormStructure& form, std::unique_ptr<FillingContext> context) { if (base::FeatureList::IsEnabled(features::kAutofillRefillWithRendererIds)) { - filling_context_by_renderer_id_[form.unique_renderer_id()] = - std::move(context); + filling_context_by_global_id_[form.global_id()] = std::move(context); } else { filling_context_by_unique_name_[form.GetIdentifierForRefill()] = std::move(context); @@ -2368,9 +2369,9 @@ void AutofillManager::SetFillingContext( AutofillManager::FillingContext* AutofillManager::GetFillingContext( const FormStructure& form) { if (base::FeatureList::IsEnabled(features::kAutofillRefillWithRendererIds)) { - auto it = filling_context_by_renderer_id_.find(form.unique_renderer_id()); - return it != filling_context_by_renderer_id_.end() ? it->second.get() - : nullptr; + auto it = filling_context_by_global_id_.find(form.global_id()); + return it != filling_context_by_global_id_.end() ? it->second.get() + : nullptr; } else { auto it = filling_context_by_unique_name_.find(form.GetIdentifierForRefill()); @@ -2380,7 +2381,7 @@ AutofillManager::FillingContext* AutofillManager::GetFillingContext( } bool AutofillManager::ShouldTriggerRefill(const FormStructure& form_structure) { - // Should not refill if a form with the same FormRendererId has not been + // Should not refill if a form with the same FormGlobalId has not been // filled before. FillingContext* filling_context = GetFillingContext(form_structure); if (filling_context == nullptr) @@ -2403,8 +2404,7 @@ bool AutofillManager::ShouldTriggerRefill(const FormStructure& form_structure) { } void AutofillManager::TriggerRefill(const FormData& form) { - FormStructure* form_structure = - FindCachedFormByRendererId(form.unique_renderer_id); + FormStructure* form_structure = FindCachedFormByRendererId(form.global_id()); if (!form_structure) return; @@ -2430,19 +2430,18 @@ void AutofillManager::TriggerRefill(const FormData& form) { filling_context->attempted_refill = true; // Try to find the field from which the original field originated. - // Precedence is given to look up by |filled_field_renderer_id|. + // Precedence is given to look up by |filled_field_id|. // If that is unsuccessful, look up is done by |filled_field_signature|. // TODO(crbug/896689): Clean up after feature launch. AutofillField* autofill_field = nullptr; for (const std::unique_ptr<AutofillField>& field : *form_structure) { // TODO(crbug/896689): Clean up once experiment is over. - if ((base::FeatureList::IsEnabled( - features::kAutofillRefillWithRendererIds) && - field->unique_renderer_id == - filling_context->filled_field_renderer_id) || - (!base::FeatureList::IsEnabled( - features::kAutofillRefillWithRendererIds) && - field->unique_name() == filling_context->filled_field_unique_name)) { + if (((base::FeatureList::IsEnabled( + features::kAutofillRefillWithRendererIds) && + field->global_id() == filling_context->filled_field_id) || + (!base::FeatureList::IsEnabled( + features::kAutofillRefillWithRendererIds) && + field->unique_name() == filling_context->filled_field_unique_name))) { autofill_field = field.get(); break; } @@ -2473,15 +2472,15 @@ void AutofillManager::TriggerRefill(const FormData& form) { return; FormFieldData field = *autofill_field; - if (absl::holds_alternative<std::pair<CreditCard, base::string16>>( + if (absl::holds_alternative<std::pair<CreditCard, std::u16string>>( filling_context->profile_or_credit_card_with_cvc)) { FillOrPreviewDataModelForm( AutofillDriver::RendererFormDataAction::FORM_DATA_ACTION_FILL, /*query_id=*/-1, form, field, - &absl::get<std::pair<CreditCard, base::string16>>( + &absl::get<std::pair<CreditCard, std::u16string>>( filling_context->profile_or_credit_card_with_cvc) .first, - &absl::get<std::pair<CreditCard, base::string16>>( + &absl::get<std::pair<CreditCard, std::u16string>>( filling_context->profile_or_credit_card_with_cvc) .second, form_structure, autofill_field, @@ -2691,7 +2690,7 @@ void AutofillManager::PreProcessStateMatchingTypes( continue; const AutofillType kCountryCode(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE); - const base::string16& country_code = + const std::u16string& country_code = profile.GetInfo(kCountryCode, app_locale_); for (auto& field : *form_structure) { diff --git a/chromium/components/autofill/core/browser/autofill_manager.h b/chromium/components/autofill/core/browser/autofill_manager.h index ab3482f1eb9..ddaffb1a0e4 100644 --- a/chromium/components/autofill/core/browser/autofill_manager.h +++ b/chromium/components/autofill/core/browser/autofill_manager.h @@ -18,7 +18,6 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/optional.h" -#include "base/strings/string16.h" #include "base/time/time.h" #include "base/timer/timer.h" #include "build/build_config.h" @@ -134,7 +133,7 @@ class AutofillManager : public AutofillHandler, const FormData& form, const FormFieldData& field, const CreditCard& credit_card, - const base::string16& cvc); + const std::u16string& cvc); void DidShowSuggestions(bool has_autofill_suggestions, const FormData& form, const FormFieldData& field); @@ -146,21 +145,21 @@ class AutofillManager : public AutofillHandler, // Returns true if the value/identifier is deletable. Fills out // |title| and |body| with relevant user-facing text. - bool GetDeletionConfirmationText(const base::string16& value, + bool GetDeletionConfirmationText(const std::u16string& value, int identifier, - base::string16* title, - base::string16* body); + std::u16string* title, + std::u16string* body); // Remove the credit card or Autofill profile that matches |unique_id| // from the database. Returns true if deletion is allowed. bool RemoveAutofillProfileOrCreditCard(int unique_id); // Remove the specified Autocomplete entry. - void RemoveAutocompleteEntry(const base::string16& name, - const base::string16& value); + void RemoveAutocompleteEntry(const std::u16string& name, + const std::u16string& value); // Invoked when the user selected |value| in the Autocomplete drop-down. - void OnAutocompleteEntrySelected(const base::string16& value); + void OnAutocompleteEntrySelected(const std::u16string& value); // Invoked when the user selects the "Hide Suggestions" item in the // Autocomplete drop-down. @@ -266,7 +265,7 @@ class AutofillManager : public AutofillHandler, static void DeterminePossibleFieldTypesForUploadForTest( const std::vector<AutofillProfile>& profiles, const std::vector<CreditCard>& credit_cards, - const base::string16& last_unlocked_credit_card_cvc, + const std::u16string& last_unlocked_credit_card_cvc, const std::string& app_locale, FormStructure* submitted_form) { DeterminePossibleFieldTypesForUpload(profiles, credit_cards, @@ -382,7 +381,7 @@ class AutofillManager : public AutofillHandler, FillingContext(const AutofillField& field, absl::variant<const AutofillProfile*, const CreditCard*> profile_or_credit_card, - const base::string16* optional_cvc); + const std::u16string* optional_cvc); ~FillingContext(); // Whether a refill attempt was made. @@ -390,14 +389,16 @@ class AutofillManager : public AutofillHandler, // The profile or credit card that was used for the initial fill. // The std::string associated with the credit card is the CVC, which may be // empty. - absl::variant<AutofillProfile, std::pair<CreditCard, base::string16>> + absl::variant<AutofillProfile, std::pair<CreditCard, std::u16string>> profile_or_credit_card_with_cvc; // Possible identifiers of the field that was focused when the form was // initially filled. A refill shall be triggered from the same field. // TODO(crbug/896689): Remove |filled_field_unique_name|. - const FieldRendererId filled_field_renderer_id; + const FieldGlobalId filled_field_id; const FieldSignature filled_field_signature; - const base::string16 filled_field_unique_name; + const std::u16string filled_field_unique_name; + // The security origin from which the field was filled. + url::Origin filled_origin; // The time at which the initial fill occurred. const base::TimeTicks original_fill_time; // The timer used to trigger a refill. @@ -438,7 +439,7 @@ class AutofillManager : public AutofillHandler, void OnCreditCardFetched( bool did_succeed, const CreditCard* credit_card = nullptr, - const base::string16& cvc = base::string16()) override; + const std::u16string& cvc = std::u16string()) override; // Returns false if Autofill is disabled or if no Autofill data is available. bool RefreshDataModels(); @@ -482,7 +483,7 @@ class AutofillManager : public AutofillHandler, const FormFieldData& field, absl::variant<const AutofillProfile*, const CreditCard*> profile_or_credit_card, - const base::string16* optional_cvc, + const std::u16string* optional_cvc, FormStructure* form_structure, AutofillField* autofill_field, bool is_refill = false); @@ -538,7 +539,7 @@ class AutofillManager : public AutofillHandler, static void DeterminePossibleFieldTypesForUpload( const std::vector<AutofillProfile>& profiles, const std::vector<CreditCard>& credit_cards, - const base::string16& last_unlocked_credit_card_cvc, + const std::u16string& last_unlocked_credit_card_cvc, const std::string& app_locale, FormStructure* submitted_form); @@ -566,7 +567,7 @@ class AutofillManager : public AutofillHandler, profile_or_credit_card, FormFieldData* field_data, bool should_notify, - const base::string16& cvc, + const std::u16string& cvc, uint32_t profile_form_bitmask, std::string* failure_to_fill); @@ -616,8 +617,8 @@ class AutofillManager : public AutofillHandler, FormEventLoggerBase* GetEventFormLogger( FieldTypeGroup field_type_group) const; - void SetDataList(const std::vector<base::string16>& values, - const std::vector<base::string16>& labels); + void SetDataList(const std::vector<std::u16string>& values, + const std::vector<std::u16string>& labels); // Delegate to perform external processing (display, selection) on // our behalf. @@ -687,7 +688,7 @@ class AutofillManager : public AutofillHandler, FormData credit_card_form_; FormFieldData credit_card_field_; CreditCard credit_card_; - base::string16 last_unlocked_credit_card_cvc_; + std::u16string last_unlocked_credit_card_cvc_; // Ablation experiment turns off autofill, but logging still has to be kept // for metrics analysis. @@ -705,9 +706,9 @@ class AutofillManager : public AutofillHandler, // A map of form names to FillingContext instances used to make refill // attempts for dynamic forms. // TODO(crbug/896689): Remove code duplication once experiment is finished. - std::map<FormRendererId, std::unique_ptr<FillingContext>> - filling_context_by_renderer_id_; - std::map<base::string16, std::unique_ptr<FillingContext>> + std::map<FormGlobalId, std::unique_ptr<FillingContext>> + filling_context_by_global_id_; + std::map<std::u16string, std::unique_ptr<FillingContext>> filling_context_by_unique_name_; // Used to record metrics. This should be set at the beginning of the diff --git a/chromium/components/autofill/core/browser/autofill_manager_unittest.cc b/chromium/components/autofill/core/browser/autofill_manager_unittest.cc index d00a45b5848..2d39c7208bb 100644 --- a/chromium/components/autofill/core/browser/autofill_manager_unittest.cc +++ b/chromium/components/autofill/core/browser/autofill_manager_unittest.cc @@ -8,6 +8,7 @@ #include <algorithm> #include <memory> +#include <string> #include <tuple> #include <utility> #include <vector> @@ -19,7 +20,6 @@ #include "base/metrics/field_trial.h" #include "base/metrics/metrics_hashes.h" #include "base/stl_util.h" -#include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -100,7 +100,6 @@ using testing::UnorderedElementsAre; namespace autofill { -using features::kAutofillRestrictUnownedFieldsToFormlessCheckout; using mojom::SubmissionIndicatorEvent; using mojom::SubmissionSource; @@ -124,6 +123,7 @@ class MockAutofillClient : public TestAutofillClient { MOCK_METHOD2(ConfirmSaveUpiIdLocally, void(const std::string& upi_id, base::OnceCallback<void(bool user_decision)> callback)); + MOCK_CONST_METHOD0(GetProfileType, profile_metrics::BrowserProfileType()); }; class MockAutofillDownloadManager : public TestAutofillDownloadManager { @@ -186,7 +186,7 @@ void ExpectFilledForm(int page_id, const size_t kCreditCardFormSize = use_month_type ? 4 : 5; EXPECT_EQ(expected_page_id, page_id); - EXPECT_EQ(ASCIIToUTF16("MyForm"), filled_form.name); + EXPECT_EQ(u"MyForm", filled_form.name); EXPECT_EQ(GURL("https://myform.com/form.html"), filled_form.url); EXPECT_EQ(GURL("https://myform.com/submit.html"), filled_form.action); @@ -454,7 +454,7 @@ class AutofillManagerTest : public testing::Test { } void AutocompleteSuggestionsReturned( - const std::vector<base::string16>& results, + const std::vector<std::u16string>& results, int query_id = kDefaultPageID) { std::vector<Suggestion> suggestions; std::transform(results.begin(), results.end(), @@ -515,7 +515,7 @@ class AutofillManagerTest : public testing::Test { void CreateTestCreditCardFormData(FormData* form, bool is_https, bool use_month_type) { - form->name = ASCIIToUTF16("MyForm"); + form->name = u"MyForm"; if (is_https) { form->url = GURL("https://myform.com/form.html"); form->action = GURL("https://myform.com/submit.html"); @@ -581,7 +581,7 @@ class AutofillManagerTest : public testing::Test { // Mock user response. payments::FullCardRequest::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; full_card_request->OnUnmaskPromptAccepted(details); // Mock payments response. @@ -872,8 +872,9 @@ TEST_P(AutofillManagerStructuredProfileTest, // Different form structure. FormData form2; - form2.unique_renderer_id.value() = 2; - form2.name = ASCIIToUTF16("MyForm"); + form2.host_frame = test::GetLocalFrameToken(); + form2.unique_renderer_id = test::MakeFormRendererId(); + form2.name = u"MyForm"; form2.url = GURL("https://myform.com/form.html"); form2.action = GURL("https://myform.com/submit.html"); FormFieldData field; @@ -904,8 +905,9 @@ TEST_P(AutofillManagerStructuredProfileTest, FormData form2; FormFieldData field; test::CreateTestFormField("Querty", "qwerty", "", "text", &field); - form2.unique_renderer_id.value() = 2; - form2.name = ASCIIToUTF16("NonQueryable"); + form2.host_frame = test::GetLocalFrameToken(); + form2.unique_renderer_id = test::MakeFormRendererId(); + form2.name = u"NonQueryable"; form2.url = form1.url; form2.action = GURL("https://myform.com/submit.html"); form2.fields.push_back(field); @@ -925,7 +927,7 @@ TEST_P(AutofillManagerStructuredProfileTest, GetProfileSuggestions_UnrecognizedAttribute) { // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); FormFieldData field; @@ -968,7 +970,7 @@ TEST_P(AutofillManagerStructuredProfileTest, GetProfileSuggestions_MinFieldsEnforced_NoAutocomplete) { // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); FormFieldData field; @@ -999,7 +1001,7 @@ TEST_P(AutofillManagerStructuredProfileTest, GetProfileSuggestions_MinFieldsEnforced_WithOneAutocomplete) { // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); FormFieldData field; @@ -1032,7 +1034,7 @@ TEST_P(AutofillManagerStructuredProfileTest, GetProfileSuggestions_SmallFormWithTwoAutocomplete) { // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); FormFieldData field; @@ -1059,7 +1061,7 @@ TEST_P(AutofillManagerStructuredProfileTest, // Test that the call is properly forwarded to AutocompleteHistoryManager. TEST_P(AutofillManagerStructuredProfileTest, OnAutocompleteEntrySelected) { - base::string16 test_value = ASCIIToUTF16("TestValue"); + std::u16string test_value = u"TestValue"; EXPECT_CALL(*autocomplete_history_manager_.get(), OnAutocompleteEntrySelected(test_value)) .Times(1); @@ -1156,26 +1158,23 @@ TEST_P(SuggestionMatchingTest, // letter for last name. AutofillProfile profile1; profile1.set_guid("00000000-0000-0000-0000-000000000103"); - profile1.SetInfo(NAME_FIRST, ASCIIToUTF16("Robin"), "en-US"); - profile1.SetInfo(NAME_LAST, ASCIIToUTF16("Grimes"), "en-US"); - profile1.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("1234 Smith Blvd."), - "en-US"); + profile1.SetInfo(NAME_FIRST, u"Robin", "en-US"); + profile1.SetInfo(NAME_LAST, u"Grimes", "en-US"); + profile1.SetInfo(ADDRESS_HOME_LINE1, u"1234 Smith Blvd.", "en-US"); personal_data_.AddProfile(profile1); AutofillProfile profile2; profile2.set_guid("00000000-0000-0000-0000-000000000124"); - profile2.SetInfo(NAME_FIRST, ASCIIToUTF16("Carl"), "en-US"); - profile2.SetInfo(NAME_LAST, ASCIIToUTF16("Grimes"), "en-US"); - profile2.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("1234 Smith Blvd."), - "en-US"); + profile2.SetInfo(NAME_FIRST, u"Carl", "en-US"); + profile2.SetInfo(NAME_LAST, u"Grimes", "en-US"); + profile2.SetInfo(ADDRESS_HOME_LINE1, u"1234 Smith Blvd.", "en-US"); personal_data_.AddProfile(profile2); AutofillProfile profile3; profile3.set_guid("00000000-0000-0000-0000-000000000126"); - profile3.SetInfo(NAME_FIRST, ASCIIToUTF16("Aaron"), "en-US"); - profile3.SetInfo(NAME_LAST, ASCIIToUTF16("Googler"), "en-US"); - profile3.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("1600 Amphitheater pkwy"), - "en-US"); + profile3.SetInfo(NAME_FIRST, u"Aaron", "en-US"); + profile3.SetInfo(NAME_LAST, u"Googler", "en-US"); + profile3.SetInfo(ADDRESS_HOME_LINE1, u"1600 Amphitheater pkwy", "en-US"); personal_data_.AddProfile(profile3); FormFieldData field; @@ -1239,7 +1238,7 @@ TEST_P(AutofillManagerStructuredProfileTest, GetProfileSuggestions_UnknownFields) { // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -1391,7 +1390,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FormsSeen(forms); FormFieldData field = form.fields[1]; - field.value = ASCIIToUTF16(" "); + field.value = u" "; GetAutofillSuggestions(form, field); #if defined(OS_ANDROID) || defined(OS_IOS) @@ -1425,7 +1424,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FormsSeen(forms); FormFieldData field = form.fields[1]; - field.value = ASCIIToUTF16("____-____-____-____"); + field.value = u"____-____-____-____"; GetAutofillSuggestions(form, field); #if defined(OS_ANDROID) || defined(OS_IOS) @@ -1459,7 +1458,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FormsSeen(forms); FormFieldData field = form.fields[1]; - field.value = base::string16({0x200E, 0x200F}); + field.value = std::u16string({0x200E, 0x200F}); GetAutofillSuggestions(form, field); #if defined(OS_ANDROID) || defined(OS_IOS) @@ -1502,7 +1501,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FormFieldData field = form.fields[1]; - field.value = ASCIIToUTF16("5255-66__-____-____"); + field.value = u"5255-66__-____-____"; GetAutofillSuggestions(form, field); #if defined(OS_ANDROID) || defined(OS_IOS) @@ -2116,8 +2115,8 @@ TEST_F(AutofillManagerTest, FillTriggeredSection) { false); } -MATCHER(HasEmptyValue, "") { - return arg.value.empty(); +MATCHER_P(HasValue, value, "") { + return arg.value == value; } // Test that if the form cache is outdated because a field has changed, filling @@ -2154,8 +2153,8 @@ TEST_F(AutofillManagerTest, DoNotFillIfFormFieldChanged) { std::vector<FormFieldData> skipped_fields(response_data.fields.begin() + 2, response_data.fields.end()); - EXPECT_THAT(filled_fields, Each(Not(HasEmptyValue()))); - EXPECT_THAT(skipped_fields, Each(HasEmptyValue())); + EXPECT_THAT(filled_fields, Each(Not(HasValue(u"")))); + EXPECT_THAT(skipped_fields, Each(HasValue(u""))); } // Test that if the form cache is outdated because a field was removed, filling @@ -2379,9 +2378,9 @@ TEST_P(AutofillManagerStructuredProfileTest, // Add some Autocomplete suggestions. // This triggers the combined message send. - std::vector<base::string16> suggestions; - suggestions.push_back(ASCIIToUTF16("one")); - suggestions.push_back(ASCIIToUTF16("two")); + std::vector<std::u16string> suggestions; + suggestions.push_back(u"one"); + suggestions.push_back(u"two"); AutocompleteSuggestionsReturned(suggestions); // Test that we sent the right values to the external delegate. @@ -2407,7 +2406,7 @@ TEST_P(SuggestionMatchingTest, GetFieldSuggestionsWithDuplicateValues) { FormFieldData& field = form.fields[0]; field.is_autofilled = true; - field.value = ASCIIToUTF16("Elvis"); + field.value = u"Elvis"; GetAutofillSuggestions(form, field); std::string label; @@ -2434,8 +2433,8 @@ TEST_P(SuggestionMatchingTest, GetProfileSuggestions_FancyPhone) { AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000103"); - profile.SetInfo(NAME_FULL, ASCIIToUTF16("Natty Bumppo"), "en-US"); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("1800PRAIRIE")); + profile.SetInfo(NAME_FULL, u"Natty Bumppo", "en-US"); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"1800PRAIRIE"); personal_data_.AddProfile(profile); const FormFieldData& field = form.fields[9]; @@ -2497,7 +2496,7 @@ TEST_P(AutofillManagerStructuredProfileTest, GetProfileSuggestions_ForPhonePrefixOrSuffix) { // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -2527,7 +2526,7 @@ TEST_P(AutofillManagerStructuredProfileTest, personal_data_.ClearProfiles(); AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000104"); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("1800FLOWERS")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"1800FLOWERS"); personal_data_.AddProfile(profile); const FormFieldData& phone_prefix = form.fields[2]; @@ -2543,13 +2542,38 @@ TEST_P(AutofillManagerStructuredProfileTest, CheckSuggestions(kDefaultPageID, Suggestion("9377", "1800FLOWERS", "", 1)); } +// Tests that the suggestion consists of phone number without the country code +// when a length limit is imposed in the field due to which filling with +// country code is not possible. +TEST_P(AutofillManagerStructuredProfileTest, + GetProfileSuggestions_ForPhoneField) { + FormData form; + test::CreateTestAddressFormData(&form); + form.fields[9].max_length = 10; + std::vector<FormData> forms(1, form); + FormsSeen(forms); + + AutofillProfile profile; + profile.set_guid("00000000-0000-0000-0000-000000000103"); + profile.SetInfo(NAME_FULL, u"Natty Bumppo", "en-US"); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"+886123456789"); + personal_data_.ClearProfiles(); + personal_data_.AddProfile(profile); + + const FormFieldData& field = form.fields[9]; + GetAutofillSuggestions(form, field); + + CheckSuggestions(kDefaultPageID, + Suggestion("123456789", "Natty Bumppo", "", 1)); +} + // Tests that we return email profile suggestions values // when the email field with username autocomplete attribute exist. TEST_P(AutofillManagerStructuredProfileTest, GetProfileSuggestions_ForEmailFieldWithUserNameAutocomplete) { // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -2580,8 +2604,8 @@ TEST_P(AutofillManagerStructuredProfileTest, personal_data_.ClearProfiles(); AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000103"); - profile.SetRawInfo(NAME_FULL, ASCIIToUTF16("Natty Bumppo")); - profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("test@example.com")); + profile.SetRawInfo(NAME_FULL, u"Natty Bumppo"); + profile.SetRawInfo(EMAIL_ADDRESS, u"test@example.com"); personal_data_.AddProfile(profile); GetAutofillSuggestions(form, form.fields[2]); @@ -2626,11 +2650,11 @@ TEST_P(AutofillManagerStructuredProfileTest, WillFillCreditCardNumber) { FormFieldData* name_field = nullptr; FormFieldData* month_field = nullptr; for (size_t i = 0; i < form.fields.size(); ++i) { - if (form.fields[i].name == ASCIIToUTF16("cardnumber")) + if (form.fields[i].name == u"cardnumber") number_field = &form.fields[i]; - else if (form.fields[i].name == ASCIIToUTF16("nameoncard")) + else if (form.fields[i].name == u"nameoncard") name_field = &form.fields[i]; - else if (form.fields[i].name == ASCIIToUTF16("ccmonth")) + else if (form.fields[i].name == u"ccmonth") month_field = &form.fields[i]; } @@ -2639,7 +2663,7 @@ TEST_P(AutofillManagerStructuredProfileTest, WillFillCreditCardNumber) { EXPECT_TRUE(WillFillCreditCardNumber(form, *name_field)); // If the user has entered a value, it won't be overridden. - number_field->value = ASCIIToUTF16("gibberish"); + number_field->value = u"gibberish"; EXPECT_TRUE(WillFillCreditCardNumber(form, *number_field)); EXPECT_FALSE(WillFillCreditCardNumber(form, *name_field)); @@ -2869,7 +2893,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FillOnlyFirstNineteenCreditCardNumberFields) { // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -2881,8 +2905,7 @@ TEST_P(AutofillManagerStructuredProfileTest, // Add 20 credit card number fields with distinct names. for (int i = 0; i < 20; i++) { - base::string16 field_name = - base::ASCIIToUTF16("Card Number ") + base::NumberToString16(i + 1); + std::u16string field_name = u"Card Number " + base::NumberToString16(i + 1); test::CreateTestFormField(base::UTF16ToASCII(field_name).c_str(), "cardnumber", "", "text", &field); form.fields.push_back(field); @@ -2907,8 +2930,7 @@ TEST_P(AutofillManagerStructuredProfileTest, // Verify that the first 19 credit card number fields are filled. for (int i = 0; i < 19; i++) { - base::string16 field_name = - base::ASCIIToUTF16("Card Number ") + base::NumberToString16(i + 1); + std::u16string field_name = u"Card Number " + base::NumberToString16(i + 1); ExpectFilledField(base::UTF16ToASCII(field_name).c_str(), "cardnumber", "4234567890123456", "text", response_data.fields[2 + i]); } @@ -2925,7 +2947,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FillOnlyFirstSixteenIdenticalCreditCardNumberFields) { // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -2975,7 +2997,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FillCreditCardNumberIntoSingleDigitFields) { // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -3011,7 +3033,7 @@ TEST_P(AutofillManagerStructuredProfileTest, response_data.fields[1]); // Verify that the first 19 card number fields are filled. - base::string16 card_number = base::ASCIIToUTF16("4234567890123456"); + std::u16string card_number = u"4234567890123456"; for (unsigned int i = 0; i < 19; i++) { ExpectFilledField("Card Number", "cardnumber", i < card_number.length() @@ -3032,7 +3054,7 @@ TEST_P(AutofillManagerStructuredProfileTest, TEST_P(AutofillManagerStructuredProfileTest, FillCreditCardForm_SplitName) { // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -3073,7 +3095,7 @@ TEST_P(AutofillManagerStructuredProfileTest, .alternative_names = {}}}); // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -3208,7 +3230,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FillAddressAndCreditCardForm) { TEST_P(AutofillManagerStructuredProfileTest, FillAddressForm_UnrecognizedAttribute) { FormData address_form; - address_form.name = ASCIIToUTF16("MyForm"); + address_form.name = u"MyForm"; address_form.url = GURL("https://myform.com/form.html"); address_form.action = GURL("https://myform.com/submit.html"); FormFieldData field; @@ -3252,7 +3274,7 @@ TEST_P(AutofillManagerStructuredProfileTest, TEST_P(AutofillManagerStructuredProfileTest, FillAddressForm_AutocompleteOffNotRespected) { FormData address_form; - address_form.name = ASCIIToUTF16("MyForm"); + address_form.name = u"MyForm"; address_form.url = GURL("https://myform.com/form.html"); address_form.action = GURL("https://myform.com/submit.html"); FormFieldData field; @@ -3294,7 +3316,7 @@ TEST_P(AutofillManagerStructuredProfileTest, TEST_P(AutofillManagerStructuredProfileTest, FillAddressForm_CompanyBirthyear) { // Set up our form data. FormData address_form; - address_form.name = ASCIIToUTF16("MyForm"); + address_form.name = u"MyForm"; address_form.url = GURL("https://myform.com/form.html"); address_form.action = GURL("https://myform.com/submit.html"); @@ -3340,22 +3362,22 @@ TEST_P(AutofillManagerStructuredProfileTest, FillAddressForm_CompanyBirthyear) { TEST_P(AutofillManagerStructuredProfileTest, FillAddressForm_PlaceholderEqualsValue) { FormData address_form; - address_form.name = ASCIIToUTF16("MyForm"); + address_form.name = u"MyForm"; address_form.url = GURL("https://myform.com/form.html"); address_form.action = GURL("https://myform.com/submit.html"); FormFieldData field; // Set the same placeholder and value for each field. test::CreateTestFormField("First name", "firstname", "", "text", &field); - field.placeholder = ASCIIToUTF16("First Name"); - field.value = ASCIIToUTF16("First Name"); + field.placeholder = u"First Name"; + field.value = u"First Name"; address_form.fields.push_back(field); test::CreateTestFormField("Middle name", "middle", "", "text", &field); - field.placeholder = ASCIIToUTF16("Middle Name"); - field.value = ASCIIToUTF16("Middle Name"); + field.placeholder = u"Middle Name"; + field.value = u"Middle Name"; address_form.fields.push_back(field); test::CreateTestFormField("Last name", "lastname", "", "text", &field); - field.placeholder = ASCIIToUTF16("Last Name"); - field.value = ASCIIToUTF16("Last Name"); + field.placeholder = u"Last Name"; + field.value = u"Last Name"; address_form.fields.push_back(field); std::vector<FormData> address_forms(1, address_form); FormsSeen(address_forms); @@ -3383,7 +3405,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FillCreditCardForm_UnrecognizedAttribute) { // Set up the form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -3461,7 +3483,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FillCreditCardForm_ExpiredCard) { // Set up the form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -3515,7 +3537,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FillCreditCardForm_ExpiredCard) { TEST_P(AutofillManagerStructuredProfileTest, FillFormWithNonFocusableFields) { // Create a form with both focusable and non-focusable fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -3576,7 +3598,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FillFormWithMultipleSections) { test::CreateTestAddressFormData(&form); for (size_t i = kAddressFormSize; i < form.fields.size(); ++i) { // Make sure the fields have distinct names. - form.fields[i].name = form.fields[i].name + ASCIIToUTF16("_"); + form.fields[i].name = form.fields[i].name + u"_"; } std::vector<FormData> forms(1, form); FormsSeen(forms); @@ -3593,7 +3615,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FillFormWithMultipleSections) { // The second address section should be empty. ASSERT_EQ(response_data.fields.size(), 2 * kAddressFormSize); for (size_t i = kAddressFormSize; i < form.fields.size(); ++i) { - EXPECT_EQ(base::string16(), response_data.fields[i].value); + EXPECT_EQ(std::u16string(), response_data.fields[i].value); } // The first address section should be filled with Elvis's data. @@ -3618,7 +3640,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FillFormWithMultipleSections) { // The first address section should be empty. ASSERT_EQ(response_data.fields.size(), 2 * kAddressFormSize); for (size_t i = 0; i < kAddressFormSize; ++i) { - EXPECT_EQ(base::string16(), response_data.fields[i].value); + EXPECT_EQ(std::u16string(), response_data.fields[i].value); } // The second address section should be filled with Elvis's data. @@ -3627,8 +3649,8 @@ TEST_P(AutofillManagerStructuredProfileTest, FillFormWithMultipleSections) { secondSection.fields.begin() + kAddressFormSize); for (size_t i = 0; i < kAddressFormSize; ++i) { // Restore the expected field names. - base::string16 name = secondSection.fields[i].name; - base::string16 original_name = name.substr(0, name.size() - 1); + std::u16string name = secondSection.fields[i].name; + std::u16string original_name = name.substr(0, name.size() - 1); secondSection.fields[i].name = original_name; } ExpectFilledAddressFormElvis(response_page_id, secondSection, kPageID2, @@ -3643,7 +3665,7 @@ TEST_P(AutofillManagerStructuredProfileTest, // Create a form with a billing section and an unnamed section, interleaved. // The billing section includes both address and credit card fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -3706,7 +3728,7 @@ TEST_P(AutofillManagerStructuredProfileTest, { SCOPED_TRACE("Unnamed section"); EXPECT_EQ(kDefaultPageID, response_page_id); - EXPECT_EQ(ASCIIToUTF16("MyForm"), response_data.name); + EXPECT_EQ(u"MyForm", response_data.name); EXPECT_EQ(GURL("https://myform.com/form.html"), response_data.url); EXPECT_EQ(GURL("https://myform.com/submit.html"), response_data.action); ASSERT_EQ(11U, response_data.fields.size()); @@ -3737,7 +3759,7 @@ TEST_P(AutofillManagerStructuredProfileTest, { SCOPED_TRACE("Billing address"); EXPECT_EQ(kPageID2, response_page_id); - EXPECT_EQ(ASCIIToUTF16("MyForm"), response_data.name); + EXPECT_EQ(u"MyForm", response_data.name); EXPECT_EQ(GURL("https://myform.com/form.html"), response_data.url); EXPECT_EQ(GURL("https://myform.com/submit.html"), response_data.action); ASSERT_EQ(11U, response_data.fields.size()); @@ -3767,7 +3789,7 @@ TEST_P(AutofillManagerStructuredProfileTest, { SCOPED_TRACE("Credit card"); EXPECT_EQ(kPageID3, response_page_id); - EXPECT_EQ(ASCIIToUTF16("MyForm"), response_data.name); + EXPECT_EQ(u"MyForm", response_data.name); EXPECT_EQ(GURL("https://myform.com/form.html"), response_data.url); EXPECT_EQ(GURL("https://myform.com/submit.html"), response_data.action); ASSERT_EQ(11U, response_data.fields.size()); @@ -3810,8 +3832,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FillFormWithMultipleEmails) { &response_page_id, &response_data); // The second email address should be filled. - EXPECT_EQ(ASCIIToUTF16("theking@gmail.com"), - response_data.fields.back().value); + EXPECT_EQ(u"theking@gmail.com", response_data.fields.back().value); // The remainder of the form should be filled as usual. response_data.fields.pop_back(); @@ -3935,11 +3956,11 @@ TEST_P(AutofillManagerStructuredProfileTest, FillPartlyManuallyFilledForm) { // Michael will be overridden with Elvis because Autofill is triggered from // the first field. - form.fields[0].value = base::ASCIIToUTF16("Michael"); + form.fields[0].value = u"Michael"; form.fields[0].properties_mask |= kUserTyped; // Jackson will be preserved. - form.fields[2].value = base::ASCIIToUTF16("Jackson"); + form.fields[2].value = u"Jackson"; form.fields[2].properties_mask |= kUserTyped; FormsSeen({form}); @@ -3980,13 +4001,13 @@ TEST_P(AutofillManagerStructuredProfileTest, FillPhoneNumber) { // In one form, rely on the max length attribute to imply US phone number // parts. In the other form, rely on the autocomplete type attribute. FormData form_with_us_number_max_length; - form_with_us_number_max_length.name = ASCIIToUTF16("MyMaxlengthPhoneForm"); + form_with_us_number_max_length.name = u"MyMaxlengthPhoneForm"; form_with_us_number_max_length.url = GURL("https://myform.com/phone_form.html"); form_with_us_number_max_length.action = GURL("https://myform.com/phone_submit.html"); FormData form_with_autocompletetype = form_with_us_number_max_length; - form_with_autocompletetype.name = ASCIIToUTF16("MyAutocompletetypePhoneForm"); + form_with_autocompletetype.name = u"MyAutocompletetypePhoneForm"; struct { const char* label; @@ -4022,8 +4043,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FillPhoneNumber) { AutofillProfile* work_profile = personal_data_.GetProfileWithGUID("00000000-0000-0000-0000-000000000002"); ASSERT_TRUE(work_profile != nullptr); - work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - ASCIIToUTF16("16505554567")); + work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"16505554567"); std::string guid(work_profile->guid()); int page_id = 1; @@ -4036,11 +4056,11 @@ TEST_P(AutofillManagerStructuredProfileTest, FillPhoneNumber) { EXPECT_EQ(1, response_page_id); ASSERT_EQ(5U, response_data1.fields.size()); - EXPECT_EQ(ASCIIToUTF16("1"), response_data1.fields[0].value); - EXPECT_EQ(ASCIIToUTF16("650"), response_data1.fields[1].value); - EXPECT_EQ(ASCIIToUTF16("555"), response_data1.fields[2].value); - EXPECT_EQ(ASCIIToUTF16("4567"), response_data1.fields[3].value); - EXPECT_EQ(base::string16(), response_data1.fields[4].value); + EXPECT_EQ(u"1", response_data1.fields[0].value); + EXPECT_EQ(u"650", response_data1.fields[1].value); + EXPECT_EQ(u"555", response_data1.fields[2].value); + EXPECT_EQ(u"4567", response_data1.fields[3].value); + EXPECT_EQ(std::u16string(), response_data1.fields[4].value); page_id = 2; response_page_id = 0; @@ -4052,19 +4072,18 @@ TEST_P(AutofillManagerStructuredProfileTest, FillPhoneNumber) { EXPECT_EQ(2, response_page_id); ASSERT_EQ(5U, response_data2.fields.size()); - EXPECT_EQ(ASCIIToUTF16("1"), response_data2.fields[0].value); - EXPECT_EQ(ASCIIToUTF16("650"), response_data2.fields[1].value); - EXPECT_EQ(ASCIIToUTF16("555"), response_data2.fields[2].value); - EXPECT_EQ(ASCIIToUTF16("4567"), response_data2.fields[3].value); - EXPECT_EQ(base::string16(), response_data2.fields[4].value); + EXPECT_EQ(u"1", response_data2.fields[0].value); + EXPECT_EQ(u"650", response_data2.fields[1].value); + EXPECT_EQ(u"555", response_data2.fields[2].value); + EXPECT_EQ(u"4567", response_data2.fields[3].value); + EXPECT_EQ(std::u16string(), response_data2.fields[4].value); // We should not be able to fill international numbers correctly in a form // containing fields with US max_length. However, the field should fill with // the number of digits equal to the max length specified, starting from the // right. - work_profile->SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("GB")); - work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - ASCIIToUTF16("447700954321")); + work_profile->SetRawInfo(ADDRESS_HOME_COUNTRY, u"GB"); + work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"447700954321"); page_id = 3; response_page_id = 0; FormData response_data3; @@ -4075,11 +4094,11 @@ TEST_P(AutofillManagerStructuredProfileTest, FillPhoneNumber) { EXPECT_EQ(3, response_page_id); ASSERT_EQ(5U, response_data3.fields.size()); - EXPECT_EQ(ASCIIToUTF16("4"), response_data3.fields[0].value); - EXPECT_EQ(ASCIIToUTF16("700"), response_data3.fields[1].value); - EXPECT_EQ(ASCIIToUTF16("321"), response_data3.fields[2].value); - EXPECT_EQ(ASCIIToUTF16("4321"), response_data3.fields[3].value); - EXPECT_EQ(base::string16(), response_data3.fields[4].value); + EXPECT_EQ(u"4", response_data3.fields[0].value); + EXPECT_EQ(u"700", response_data3.fields[1].value); + EXPECT_EQ(u"321", response_data3.fields[2].value); + EXPECT_EQ(u"4321", response_data3.fields[3].value); + EXPECT_EQ(std::u16string(), response_data3.fields[4].value); page_id = 4; response_page_id = 0; @@ -4091,11 +4110,11 @@ TEST_P(AutofillManagerStructuredProfileTest, FillPhoneNumber) { EXPECT_EQ(4, response_page_id); ASSERT_EQ(5U, response_data4.fields.size()); - EXPECT_EQ(ASCIIToUTF16("44"), response_data4.fields[0].value); - EXPECT_EQ(ASCIIToUTF16("7700"), response_data4.fields[1].value); - EXPECT_EQ(ASCIIToUTF16("954321"), response_data4.fields[2].value); - EXPECT_EQ(ASCIIToUTF16("954321"), response_data4.fields[3].value); - EXPECT_EQ(base::string16(), response_data4.fields[4].value); + EXPECT_EQ(u"44", response_data4.fields[0].value); + EXPECT_EQ(u"7700", response_data4.fields[1].value); + EXPECT_EQ(u"954321", response_data4.fields[2].value); + EXPECT_EQ(u"954321", response_data4.fields[3].value); + EXPECT_EQ(std::u16string(), response_data4.fields[4].value); } TEST_P(AutofillManagerStructuredProfileTest, @@ -4103,8 +4122,7 @@ TEST_P(AutofillManagerStructuredProfileTest, AutofillProfile* work_profile = personal_data_.GetProfileWithGUID("00000000-0000-0000-0000-000000000002"); ASSERT_TRUE(work_profile != nullptr); - work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - ASCIIToUTF16("16505554567")); + work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"16505554567"); std::string guid(work_profile->guid()); @@ -4118,7 +4136,7 @@ TEST_P(AutofillManagerStructuredProfileTest, // Default is zero, have to set to a number autofill can process. field.max_length = 10; form_with_multiple_componentized_phone_fields.name = - ASCIIToUTF16("multiple_componentized_number_fields"); + u"multiple_componentized_number_fields"; test::CreateTestFormField("Full Name", "full_name", "", "text", &field); form_with_multiple_componentized_phone_fields.fields.push_back(field); test::CreateTestFormField("country code", "country_code", "", "text", &field); @@ -4157,15 +4175,14 @@ TEST_P(AutofillManagerStructuredProfileTest, // Verify only the first complete set of phone number fields are filled. ASSERT_EQ(8U, response_data.fields.size()); - EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley"), - response_data.fields[0].value); - EXPECT_EQ(ASCIIToUTF16("1"), response_data.fields[1].value); - EXPECT_EQ(ASCIIToUTF16("650"), response_data.fields[2].value); - EXPECT_EQ(ASCIIToUTF16("5554567"), response_data.fields[3].value); - EXPECT_EQ(base::string16(), response_data.fields[4].value); - EXPECT_EQ(base::string16(), response_data.fields[5].value); - EXPECT_EQ(base::string16(), response_data.fields[6].value); - EXPECT_EQ(base::string16(), response_data.fields[7].value); + EXPECT_EQ(u"Charles Hardin Holley", response_data.fields[0].value); + EXPECT_EQ(u"1", response_data.fields[1].value); + EXPECT_EQ(u"650", response_data.fields[2].value); + EXPECT_EQ(u"5554567", response_data.fields[3].value); + EXPECT_EQ(std::u16string(), response_data.fields[4].value); + EXPECT_EQ(std::u16string(), response_data.fields[5].value); + EXPECT_EQ(std::u16string(), response_data.fields[6].value); + EXPECT_EQ(std::u16string(), response_data.fields[7].value); } TEST_P(AutofillManagerStructuredProfileTest, @@ -4173,8 +4190,7 @@ TEST_P(AutofillManagerStructuredProfileTest, AutofillProfile* work_profile = personal_data_.GetProfileWithGUID("00000000-0000-0000-0000-000000000002"); ASSERT_TRUE(work_profile != nullptr); - work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - ASCIIToUTF16("16505554567")); + work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"16505554567"); std::string guid(work_profile->guid()); @@ -4184,8 +4200,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FormFieldData field; // Default is zero, have to set to a number autofill can process. field.max_length = 10; - form_with_multiple_whole_number_fields.name = - ASCIIToUTF16("multiple_whole_number_fields"); + form_with_multiple_whole_number_fields.name = u"multiple_whole_number_fields"; test::CreateTestFormField("Full Name", "full_name", "", "text", &field); form_with_multiple_whole_number_fields.fields.push_back(field); test::CreateTestFormField("number", "phone_number", "", "text", &field); @@ -4214,11 +4229,10 @@ TEST_P(AutofillManagerStructuredProfileTest, // Verify only the first complete set of phone number fields are filled. ASSERT_EQ(4U, response_data.fields.size()); - EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley"), - response_data.fields[0].value); - EXPECT_EQ(ASCIIToUTF16("6505554567"), response_data.fields[1].value); - EXPECT_EQ(base::string16(), response_data.fields[2].value); - EXPECT_EQ(base::string16(), response_data.fields[3].value); + EXPECT_EQ(u"Charles Hardin Holley", response_data.fields[0].value); + EXPECT_EQ(u"6505554567", response_data.fields[1].value); + EXPECT_EQ(std::u16string(), response_data.fields[2].value); + EXPECT_EQ(std::u16string(), response_data.fields[3].value); } TEST_P(AutofillManagerStructuredProfileTest, @@ -4226,8 +4240,7 @@ TEST_P(AutofillManagerStructuredProfileTest, AutofillProfile* work_profile = personal_data_.GetProfileWithGUID("00000000-0000-0000-0000-000000000002"); ASSERT_TRUE(work_profile != nullptr); - work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - ASCIIToUTF16("16505554567")); + work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"16505554567"); std::string guid(work_profile->guid()); @@ -4241,7 +4254,7 @@ TEST_P(AutofillManagerStructuredProfileTest, // Default is zero, have to set to a number autofill can process. field.max_length = 10; form_with_multiple_componentized_phone_fields.name = - ASCIIToUTF16("multiple_componentized_number_fields"); + u"multiple_componentized_number_fields"; test::CreateTestFormField("Full Name", "full_name", "", "text", &field); form_with_multiple_componentized_phone_fields.fields.push_back(field); test::CreateTestFormField("country code", "country_code", "", "text", &field); @@ -4283,15 +4296,14 @@ TEST_P(AutofillManagerStructuredProfileTest, // Verify only the first complete set of phone number fields are filled, // and phone components are not filled more than once. ASSERT_EQ(8U, response_data.fields.size()); - EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley"), - response_data.fields[0].value); - EXPECT_EQ(ASCIIToUTF16("1"), response_data.fields[1].value); - EXPECT_EQ(base::string16(), response_data.fields[2].value); - EXPECT_EQ(ASCIIToUTF16("6505554567"), response_data.fields[3].value); - EXPECT_EQ(base::string16(), response_data.fields[4].value); - EXPECT_EQ(base::string16(), response_data.fields[5].value); - EXPECT_EQ(base::string16(), response_data.fields[6].value); - EXPECT_EQ(base::string16(), response_data.fields[7].value); + EXPECT_EQ(u"Charles Hardin Holley", response_data.fields[0].value); + EXPECT_EQ(u"1", response_data.fields[1].value); + EXPECT_EQ(std::u16string(), response_data.fields[2].value); + EXPECT_EQ(u"6505554567", response_data.fields[3].value); + EXPECT_EQ(std::u16string(), response_data.fields[4].value); + EXPECT_EQ(std::u16string(), response_data.fields[5].value); + EXPECT_EQ(std::u16string(), response_data.fields[6].value); + EXPECT_EQ(std::u16string(), response_data.fields[7].value); } // Verify when extension is misclassified, and there is a complete @@ -4301,8 +4313,7 @@ TEST_P(AutofillManagerStructuredProfileTest, AutofillProfile* work_profile = personal_data_.GetProfileWithGUID("00000000-0000-0000-0000-000000000002"); ASSERT_TRUE(work_profile != nullptr); - work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - ASCIIToUTF16("16505554567")); + work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"16505554567"); std::string guid(work_profile->guid()); @@ -4313,7 +4324,7 @@ TEST_P(AutofillManagerStructuredProfileTest, // Default is zero, have to set to a number autofill can process. field.max_length = 10; form_with_misclassified_extension.name = - ASCIIToUTF16("complete_phone_form_with_extension"); + u"complete_phone_form_with_extension"; test::CreateTestFormField("Full Name", "full_name", "", "text", &field); field.autocomplete_attribute = "name"; form_with_misclassified_extension.fields.push_back(field); @@ -4349,12 +4360,11 @@ TEST_P(AutofillManagerStructuredProfileTest, // Verify the misclassified extension field is not filled. ASSERT_EQ(5U, response_data.fields.size()); - EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley"), - response_data.fields[0].value); - EXPECT_EQ(base::string16(), response_data.fields[1].value); - EXPECT_EQ(ASCIIToUTF16("650"), response_data.fields[2].value); - EXPECT_EQ(ASCIIToUTF16("5554567"), response_data.fields[3].value); - EXPECT_EQ(base::string16(), response_data.fields[4].value); + EXPECT_EQ(u"Charles Hardin Holley", response_data.fields[0].value); + EXPECT_EQ(std::u16string(), response_data.fields[1].value); + EXPECT_EQ(u"650", response_data.fields[2].value); + EXPECT_EQ(u"5554567", response_data.fields[3].value); + EXPECT_EQ(std::u16string(), response_data.fields[4].value); } // Verify when no complete number can be found, we do best-effort filling. @@ -4363,8 +4373,7 @@ TEST_P(AutofillManagerStructuredProfileTest, AutofillProfile* work_profile = personal_data_.GetProfileWithGUID("00000000-0000-0000-0000-000000000002"); ASSERT_TRUE(work_profile != nullptr); - work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - ASCIIToUTF16("16505554567")); + work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"16505554567"); std::string guid(work_profile->guid()); @@ -4374,7 +4383,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FormFieldData field; // Default is zero, have to set to a number autofill can process. field.max_length = 10; - form_with_no_complete_number.name = ASCIIToUTF16("no_complete_phone_form"); + form_with_no_complete_number.name = u"no_complete_phone_form"; test::CreateTestFormField("Full Name", "full_name", "", "text", &field); field.autocomplete_attribute = "name"; form_with_no_complete_number.fields.push_back(field); @@ -4408,12 +4417,10 @@ TEST_P(AutofillManagerStructuredProfileTest, // Verify when there is no complete phone number fields, we do best effort // filling. ASSERT_EQ(4U, response_data.fields.size()); - EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley"), - response_data.fields[0].value); - EXPECT_EQ(ASCIIToUTF16("123 Apple St., unit 6"), - response_data.fields[1].value); - EXPECT_EQ(ASCIIToUTF16("650"), response_data.fields[2].value); - EXPECT_EQ(base::string16(), response_data.fields[3].value); + EXPECT_EQ(u"Charles Hardin Holley", response_data.fields[0].value); + EXPECT_EQ(u"123 Apple St., unit 6", response_data.fields[1].value); + EXPECT_EQ(u"650", response_data.fields[2].value); + EXPECT_EQ(std::u16string(), response_data.fields[3].value); } // When the focus is on second phone field explicitly, we will fill the @@ -4423,8 +4430,7 @@ TEST_P(AutofillManagerStructuredProfileTest, AutofillProfile* work_profile = personal_data_.GetProfileWithGUID("00000000-0000-0000-0000-000000000002"); ASSERT_TRUE(work_profile != nullptr); - work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - ASCIIToUTF16("16505554567")); + work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"16505554567"); std::string guid(work_profile->guid()); @@ -4434,8 +4440,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FormFieldData field; // Default is zero, have to set to a number autofill can process. field.max_length = 10; - form_with_multiple_whole_number_fields.name = - ASCIIToUTF16("multiple_whole_number_fields"); + form_with_multiple_whole_number_fields.name = u"multiple_whole_number_fields"; test::CreateTestFormField("Full Name", "full_name", "", "text", &field); form_with_multiple_whole_number_fields.fields.push_back(field); test::CreateTestFormField("number", "phone_number", "", "text", &field); @@ -4467,11 +4472,10 @@ TEST_P(AutofillManagerStructuredProfileTest, // Verify when the second phone number field is being focused, we fill // that field *AND* the first phone number field. ASSERT_EQ(4U, response_data.fields.size()); - EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley"), - response_data.fields[0].value); - EXPECT_EQ(ASCIIToUTF16("6505554567"), response_data.fields[1].value); - EXPECT_EQ(base::string16(), response_data.fields[2].value); - EXPECT_EQ(ASCIIToUTF16("6505554567"), response_data.fields[3].value); + EXPECT_EQ(u"Charles Hardin Holley", response_data.fields[0].value); + EXPECT_EQ(u"6505554567", response_data.fields[1].value); + EXPECT_EQ(std::u16string(), response_data.fields[2].value); + EXPECT_EQ(u"6505554567", response_data.fields[3].value); } TEST_P(AutofillManagerStructuredProfileTest, @@ -4479,8 +4483,7 @@ TEST_P(AutofillManagerStructuredProfileTest, AutofillProfile* work_profile = personal_data_.GetProfileWithGUID("00000000-0000-0000-0000-000000000002"); ASSERT_TRUE(work_profile != nullptr); - work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - ASCIIToUTF16("16505554567")); + work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"16505554567"); std::string guid(work_profile->guid()); @@ -4490,8 +4493,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FormFieldData field; // Default is zero, have to set to a number autofill can process. field.max_length = 10; - form_with_multiple_whole_number_fields.name = - ASCIIToUTF16("multiple_whole_number_fields"); + form_with_multiple_whole_number_fields.name = u"multiple_whole_number_fields"; test::CreateTestFormField("Full Name", "full_name", "", "text", &field); form_with_multiple_whole_number_fields.fields.push_back(field); test::CreateTestFormField("number", "phone_number", "", "text", &field); @@ -4522,11 +4524,10 @@ TEST_P(AutofillManagerStructuredProfileTest, // Verify hidden/non-focusable phone field is set to only_fill_when_focused. ASSERT_EQ(4U, response_data.fields.size()); - EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley"), - response_data.fields[0].value); - EXPECT_EQ(base::string16(), response_data.fields[1].value); - EXPECT_EQ(base::string16(), response_data.fields[2].value); - EXPECT_EQ(ASCIIToUTF16("6505554567"), response_data.fields[3].value); + EXPECT_EQ(u"Charles Hardin Holley", response_data.fields[0].value); + EXPECT_EQ(std::u16string(), response_data.fields[1].value); + EXPECT_EQ(std::u16string(), response_data.fields[2].value); + EXPECT_EQ(u"6505554567", response_data.fields[3].value); } // The hidden and the presentational fields should be filled, only if their @@ -4535,7 +4536,7 @@ TEST_P(AutofillManagerStructuredProfileTest, TEST_P(AutofillManagerStructuredProfileTest, FormWithHiddenOrPresentationalSelects) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -4606,8 +4607,7 @@ TEST_P(AutofillManagerStructuredProfileTest, AutofillProfile* work_profile = personal_data_.GetProfileWithGUID("00000000-0000-0000-0000-000000000002"); ASSERT_TRUE(work_profile != nullptr); - work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - ASCIIToUTF16("16505554567")); + work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"16505554567"); std::string guid(work_profile->guid()); @@ -4617,7 +4617,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FormFieldData field; // Default is zero, have to set to a number autofill can process. field.max_length = 10; - form_with_multiple_sections.name = ASCIIToUTF16("multiple_section_fields"); + form_with_multiple_sections.name = u"multiple_section_fields"; test::CreateTestFormField("Full Name", "full_name", "", "text", &field); form_with_multiple_sections.fields.push_back(field); test::CreateTestFormField("Address", "address", "", "text", &field); @@ -4661,16 +4661,15 @@ TEST_P(AutofillManagerStructuredProfileTest, // Verify first section is filled with rationalization. ASSERT_EQ(9U, response_data.fields.size()); - EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley"), - response_data.fields[0].value); - EXPECT_EQ(ASCIIToUTF16("123 Apple St."), response_data.fields[1].value); - EXPECT_EQ(ASCIIToUTF16("6505554567"), response_data.fields[2].value); - EXPECT_EQ(base::string16(), response_data.fields[3].value); - EXPECT_EQ(base::string16(), response_data.fields[4].value); - EXPECT_EQ(base::string16(), response_data.fields[5].value); - EXPECT_EQ(base::string16(), response_data.fields[6].value); - EXPECT_EQ(base::string16(), response_data.fields[7].value); - EXPECT_EQ(base::string16(), response_data.fields[8].value); + EXPECT_EQ(u"Charles Hardin Holley", response_data.fields[0].value); + EXPECT_EQ(u"123 Apple St.", response_data.fields[1].value); + EXPECT_EQ(u"6505554567", response_data.fields[2].value); + EXPECT_EQ(std::u16string(), response_data.fields[3].value); + EXPECT_EQ(std::u16string(), response_data.fields[4].value); + EXPECT_EQ(std::u16string(), response_data.fields[5].value); + EXPECT_EQ(std::u16string(), response_data.fields[6].value); + EXPECT_EQ(std::u16string(), response_data.fields[7].value); + EXPECT_EQ(std::u16string(), response_data.fields[8].value); // Fill second section. auto it = form_with_multiple_sections.fields.begin(); @@ -4683,16 +4682,15 @@ TEST_P(AutofillManagerStructuredProfileTest, // Verify second section is filled with rationalization. ASSERT_EQ(9U, response_data.fields.size()); - EXPECT_EQ(base::string16(), response_data.fields[0].value); - EXPECT_EQ(base::string16(), response_data.fields[1].value); - EXPECT_EQ(base::string16(), response_data.fields[2].value); - EXPECT_EQ(base::string16(), response_data.fields[3].value); - EXPECT_EQ(base::string16(), response_data.fields[4].value); - EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley"), - response_data.fields[5].value); - EXPECT_EQ(ASCIIToUTF16("123 Apple St."), response_data.fields[6].value); - EXPECT_EQ(ASCIIToUTF16("6505554567"), response_data.fields[7].value); - EXPECT_EQ(base::string16(), response_data.fields[8].value); + EXPECT_EQ(std::u16string(), response_data.fields[0].value); + EXPECT_EQ(std::u16string(), response_data.fields[1].value); + EXPECT_EQ(std::u16string(), response_data.fields[2].value); + EXPECT_EQ(std::u16string(), response_data.fields[3].value); + EXPECT_EQ(std::u16string(), response_data.fields[4].value); + EXPECT_EQ(u"Charles Hardin Holley", response_data.fields[5].value); + EXPECT_EQ(u"123 Apple St.", response_data.fields[6].value); + EXPECT_EQ(u"6505554567", response_data.fields[7].value); + EXPECT_EQ(std::u16string(), response_data.fields[8].value); } // Test that we can still fill a form when a field has been removed from it. @@ -4763,7 +4761,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FormChangesVisibilityOfFields) { // Default is zero, have to set to a number autofill can process. field.max_length = 10; - form.name = ASCIIToUTF16("multiple_groups_fields"); + form.name = u"multiple_groups_fields"; test::CreateTestFormField("First Name", "first_name", "", "text", &field); form.fields.push_back(field); test::CreateTestFormField("Last Name", "last_name", "", "text", &field); @@ -4878,9 +4876,9 @@ TEST_P(AutofillManagerStructuredProfileTest, FormSubmittedSaveData) { // submissions are still received by AutocompleteHistoryManager. TEST_P(AutofillManagerStructuredProfileTest, FormSubmittedAutocompleteEnabled) { TestAutofillClient client; - autofill_manager_.reset( - new TestAutofillManager(autofill_driver_.get(), &client, &personal_data_, - autocomplete_history_manager_.get())); + autofill_manager_ = std::make_unique<TestAutofillManager>( + autofill_driver_.get(), &client, &personal_data_, + autocomplete_history_manager_.get()); autofill_manager_->SetAutofillProfileEnabled(false); autofill_manager_->SetAutofillCreditCardEnabled(false); @@ -4908,7 +4906,7 @@ TEST_P(AutofillManagerStructuredProfileTest, ValuePatternsMetric) { test::CreateTestFormField("Some label", "my-field", test_case.value, "text", &field); field.is_focusable = true; // The metric skips hidden fields. - form.name = ASCIIToUTF16("my-form"); + form.name = u"my-form"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.fields.push_back(field); @@ -4927,9 +4925,9 @@ TEST_P(AutofillManagerStructuredProfileTest, ValuePatternsMetric) { TEST_P(AutofillManagerStructuredProfileTest, AutocompleteSuggestions_SomeWhenAutofillDisabled) { TestAutofillClient client; - autofill_manager_.reset( - new TestAutofillManager(autofill_driver_.get(), &client, &personal_data_, - autocomplete_history_manager_.get())); + autofill_manager_ = std::make_unique<TestAutofillManager>( + autofill_driver_.get(), &client, &personal_data_, + autocomplete_history_manager_.get()); autofill_manager_->SetAutofillProfileEnabled(false); autofill_manager_->SetAutofillCreditCardEnabled(false); auto external_delegate = std::make_unique<TestAutofillExternalDelegate>( @@ -4957,9 +4955,9 @@ TEST_P(AutofillManagerStructuredProfileTest, TEST_P(AutofillManagerStructuredProfileTest, AutocompleteSuggestions_AutofillDisabledAndFieldShouldNotAutocomplete) { TestAutofillClient client; - autofill_manager_.reset( - new TestAutofillManager(autofill_driver_.get(), &client, &personal_data_, - autocomplete_history_manager_.get())); + autofill_manager_ = std::make_unique<TestAutofillManager>( + autofill_driver_.get(), &client, &personal_data_, + autocomplete_history_manager_.get()); autofill_manager_->SetAutofillProfileEnabled(false); autofill_manager_->SetAutofillCreditCardEnabled(false); auto external_delegate = std::make_unique<TestAutofillExternalDelegate>( @@ -5040,9 +5038,9 @@ TEST_P(AutofillManagerStructuredProfileTest, replacements.SetScheme(url::kHttpScheme, url::Component(0, strlen(url::kHttpScheme))); client.set_form_origin(client.form_origin().ReplaceComponents(replacements)); - autofill_manager_.reset( - new TestAutofillManager(autofill_driver_.get(), &client, &personal_data_, - autocomplete_history_manager_.get())); + autofill_manager_ = std::make_unique<TestAutofillManager>( + autofill_driver_.get(), &client, &personal_data_, + autocomplete_history_manager_.get()); autofill_manager_->SetAutofillProfileEnabled(false); autofill_manager_->SetAutofillCreditCardEnabled(false); auto external_delegate = std::make_unique<TestAutofillExternalDelegate>( @@ -5079,9 +5077,9 @@ TEST_P(AutofillManagerStructuredProfileTest, replacements.SetScheme(url::kHttpScheme, url::Component(0, strlen(url::kHttpScheme))); client.set_form_origin(client.form_origin().ReplaceComponents(replacements)); - autofill_manager_.reset( - new TestAutofillManager(autofill_driver_.get(), &client, &personal_data_, - autocomplete_history_manager_.get())); + autofill_manager_ = std::make_unique<TestAutofillManager>( + autofill_driver_.get(), &client, &personal_data_, + autocomplete_history_manager_.get()); autofill_manager_->SetAutofillProfileEnabled(false); autofill_manager_->SetAutofillCreditCardEnabled(false); auto external_delegate = std::make_unique<TestAutofillExternalDelegate>( @@ -5134,9 +5132,9 @@ TEST_F( TEST_P(AutofillManagerStructuredProfileTest, AutocompleteOffRespectedForAutocomplete) { TestAutofillClient client; - autofill_manager_.reset( - new TestAutofillManager(autofill_driver_.get(), &client, &personal_data_, - autocomplete_history_manager_.get())); + autofill_manager_ = std::make_unique<TestAutofillManager>( + autofill_driver_.get(), &client, &personal_data_, + autocomplete_history_manager_.get()); autofill_manager_->SetAutofillProfileEnabled(false); autofill_manager_->SetAutofillCreditCardEnabled(false); auto external_delegate = std::make_unique<TestAutofillExternalDelegate>( @@ -5183,8 +5181,9 @@ TEST_P(AutofillManagerStructuredProfileTest, TEST_P(AutofillManagerStructuredProfileTest, OnLoadedServerPredictionsFromApi) { // First form on the page. FormData form; - form.unique_renderer_id.value() = 1; - form.name = ASCIIToUTF16("MyForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); FormFieldData field; @@ -5207,8 +5206,9 @@ TEST_P(AutofillManagerStructuredProfileTest, OnLoadedServerPredictionsFromApi) { // Second form on the page. FormData form2; - form2.unique_renderer_id.value() = 2; - form2.name = ASCIIToUTF16("MyForm2"); + form2.host_frame = test::GetLocalFrameToken(); + form2.unique_renderer_id = test::MakeFormRendererId(); + form2.name = u"MyForm2"; form2.url = GURL("https://myform.com/form.html"); form2.action = GURL("https://myform.com/submit.html"); test::CreateTestFormField("Last Name", "lastname", "", "text", &field); @@ -5534,13 +5534,13 @@ TEST_P(AutofillManagerStructuredProfileTest, FormSubmittedWithDefaultValues) { // Set up our form data. FormData form; test::CreateTestAddressFormData(&form); - form.fields[3].value = ASCIIToUTF16("Enter your address"); + form.fields[3].value = u"Enter your address"; // Convert the state field to a <select> popup, to make sure that we only // reject default values for text fields. - ASSERT_TRUE(form.fields[6].name == ASCIIToUTF16("state")); + ASSERT_TRUE(form.fields[6].name == u"state"); form.fields[6].form_control_type = "select-one"; - form.fields[6].value = ASCIIToUTF16("Tennessee"); + form.fields[6].value = u"Tennessee"; std::vector<FormData> forms(1, form); FormsSeen(forms); @@ -5559,7 +5559,7 @@ TEST_P(AutofillManagerStructuredProfileTest, FormSubmittedWithDefaultValues) { EXPECT_EQ(1, personal_data_.num_times_save_imported_profile_called()); // Set the address field's value back to the default value. - response_data.fields[3].value = ASCIIToUTF16("Enter your address"); + response_data.fields[3].value = u"Enter your address"; // Simulate form submission. We should not call into the PDM to try to save // the filled data, since the filled form is effectively missing an address. @@ -5796,7 +5796,7 @@ TEST_P(ProfileMatchingTypesTest, DeterminePossibleFieldTypesForUpload) { credit_cards.push_back(credit_card); FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -5809,7 +5809,7 @@ TEST_P(ProfileMatchingTypesTest, DeterminePossibleFieldTypesForUpload) { base::HistogramTester histogram_tester; AutofillManager::DeterminePossibleFieldTypesForUploadForTest( - profiles, credit_cards, base::string16(), "en-us", &form_structure); + profiles, credit_cards, std::u16string(), "en-us", &form_structure); ASSERT_EQ(1U, form_structure.field_count()); @@ -5838,33 +5838,33 @@ TEST_P(ProfileMatchingTypesTest, DeterminePossibleFieldTypesForUpload) { TEST_P(AutofillManagerStructuredProfileTest, DeterminePossibleFieldTypesForUpload_IsTriggered) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); std::vector<ServerFieldTypeSet> expected_types; - std::vector<base::string16> expected_values; + std::vector<std::u16string> expected_values; // These fields should all match. FormFieldData field; ServerFieldTypeSet types; test::CreateTestFormField("", "1", "", "text", &field); - expected_values.push_back(ASCIIToUTF16("Elvis")); + expected_values.push_back(u"Elvis"); types.clear(); types.insert(NAME_FIRST); form.fields.push_back(field); expected_types.push_back(types); test::CreateTestFormField("", "2", "", "text", &field); - expected_values.push_back(ASCIIToUTF16("Aaron")); + expected_values.push_back(u"Aaron"); types.clear(); types.insert(NAME_MIDDLE); form.fields.push_back(field); expected_types.push_back(types); test::CreateTestFormField("", "3", "", "text", &field); - expected_values.push_back(ASCIIToUTF16("A")); + expected_values.push_back(u"A"); types.clear(); types.insert(NAME_MIDDLE_INITIAL); form.fields.push_back(field); @@ -5941,7 +5941,7 @@ TEST_P(AutofillManagerStructuredProfileTest, for (const std::vector<TestFieldData>& test_fields : test_cases) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -5962,7 +5962,7 @@ TEST_P(AutofillManagerStructuredProfileTest, } AutofillManager::DeterminePossibleFieldTypesForUploadForTest( - profiles, {}, base::string16(), "en-us", &form_structure); + profiles, {}, std::u16string(), "en-us", &form_structure); ASSERT_EQ(test_fields.size(), form_structure.field_count()); @@ -6130,7 +6130,7 @@ TEST_P(AutofillManagerStructuredProfileTest, DisambiguateUploadTypes) { for (const std::vector<TestFieldData>& test_fields : test_cases) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -6148,7 +6148,7 @@ TEST_P(AutofillManagerStructuredProfileTest, DisambiguateUploadTypes) { form_structure.field(i)->set_server_type(test_fields[i].predicted_type); AutofillManager::DeterminePossibleFieldTypesForUploadForTest( - profiles, credit_cards, base::string16(), "en-us", &form_structure); + profiles, credit_cards, std::u16string(), "en-us", &form_structure); ASSERT_EQ(test_fields.size(), form_structure.field_count()); // Make sure the disambiguation method selects the expected upload type. @@ -6200,7 +6200,7 @@ TEST_P(AutofillManagerStructuredProfileTest, CrowdsourceUPIVPA) { FormStructure form_structure(form); AutofillManager::DeterminePossibleFieldTypesForUploadForTest( - profiles, credit_cards, base::string16(), "en-us", &form_structure); + profiles, credit_cards, std::u16string(), "en-us", &form_structure); EXPECT_THAT(form_structure.field(0)->possible_types(), ElementsAre(UPI_VPA)); EXPECT_THAT(form_structure.field(1)->possible_types(), @@ -6295,7 +6295,7 @@ TEST_P(AutofillManagerStructuredProfileTest, std::vector<AutofillProfile> profiles; AutofillManager::DeterminePossibleFieldTypesForUploadForTest( - profiles, credit_cards, base::string16(), "en-us", &form_structure); + profiles, credit_cards, std::u16string(), "en-us", &form_structure); CheckThatOnlyFieldByIndexHasThisPossibleType(form_structure, 2, CREDIT_CARD_VERIFICATION_CODE, @@ -6349,7 +6349,7 @@ TEST_P(AutofillManagerStructuredProfileTest, std::vector<AutofillProfile> profiles; AutofillManager::DeterminePossibleFieldTypesForUploadForTest( - profiles, credit_cards, base::string16(), "en-us", &form_structure); + profiles, credit_cards, std::u16string(), "en-us", &form_structure); CheckThatOnlyFieldByIndexHasThisPossibleType(form_structure, 2, CREDIT_CARD_VERIFICATION_CODE, @@ -6403,7 +6403,7 @@ TEST_P(AutofillManagerStructuredProfileTest, std::vector<AutofillProfile> profiles; AutofillManager::DeterminePossibleFieldTypesForUploadForTest( - profiles, credit_cards, base::string16(), "en-us", &form_structure); + profiles, credit_cards, std::u16string(), "en-us", &form_structure); CheckThatOnlyFieldByIndexHasThisPossibleType(form_structure, 1, CREDIT_CARD_VERIFICATION_CODE, @@ -6457,7 +6457,7 @@ TEST_P(AutofillManagerStructuredProfileTest, std::vector<AutofillProfile> profiles; AutofillManager::DeterminePossibleFieldTypesForUploadForTest( - profiles, credit_cards, base::string16(), "en-us", &form_structure); + profiles, credit_cards, std::u16string(), "en-us", &form_structure); CheckThatNoFieldHasThisPossibleType(form_structure, CREDIT_CARD_VERIFICATION_CODE); } @@ -6508,7 +6508,7 @@ TEST_P(AutofillManagerStructuredProfileTest, std::vector<AutofillProfile> profiles; AutofillManager::DeterminePossibleFieldTypesForUploadForTest( - profiles, credit_cards, base::string16(), "en-us", &form_structure); + profiles, credit_cards, std::u16string(), "en-us", &form_structure); CheckThatNoFieldHasThisPossibleType(form_structure, CREDIT_CARD_VERIFICATION_CODE); @@ -6560,7 +6560,7 @@ TEST_P(AutofillManagerStructuredProfileTest, OnTextFieldDidChangeAndUnfocus_Upload) { // Set up our form data (it's already filled out with user data). FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -6599,9 +6599,9 @@ TEST_P(AutofillManagerStructuredProfileTest, // The fields are edited after calling FormsSeen on them. This is because // default values are not used for upload comparisons. - form.fields[0].value = ASCIIToUTF16("Elvis"); - form.fields[1].value = ASCIIToUTF16("Presley"); - form.fields[2].value = ASCIIToUTF16("theking@gmail.com"); + form.fields[0].value = u"Elvis"; + form.fields[1].value = u"Presley"; + form.fields[2].value = u"theking@gmail.com"; // Simulate editing a field. autofill_manager_->OnTextFieldDidChange( form, form.fields.front(), gfx::RectF(), AutofillTickClock::NowTicks()); @@ -6616,7 +6616,7 @@ TEST_P(AutofillManagerStructuredProfileTest, OnTextFieldDidChangeAndNavigation_Upload) { // Set up our form data (it's already filled out with user data). FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -6652,9 +6652,9 @@ TEST_P(AutofillManagerStructuredProfileTest, // The fields are edited after calling FormsSeen on them. This is because // default values are not used for upload comparisons. - form.fields[0].value = ASCIIToUTF16("Elvis"); - form.fields[1].value = ASCIIToUTF16("Presley"); - form.fields[2].value = ASCIIToUTF16("theking@gmail.com"); + form.fields[0].value = u"Elvis"; + form.fields[1].value = u"Presley"; + form.fields[2].value = u"theking@gmail.com"; // Simulate editing a field. autofill_manager_->OnTextFieldDidChange( form, form.fields.front(), gfx::RectF(), AutofillTickClock::NowTicks()); @@ -6669,7 +6669,7 @@ TEST_P(AutofillManagerStructuredProfileTest, OnDidFillAutofillFormDataAndUnfocus_Upload) { // Set up our form data (empty). FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -6705,9 +6705,9 @@ TEST_P(AutofillManagerStructuredProfileTest, autofill_manager_->SetExpectedObservedSubmission(false); // Form was autofilled with user data. - form.fields[0].value = ASCIIToUTF16("Elvis"); - form.fields[1].value = ASCIIToUTF16("Presley"); - form.fields[2].value = ASCIIToUTF16("theking@gmail.com"); + form.fields[0].value = u"Elvis"; + form.fields[1].value = u"Presley"; + form.fields[2].value = u"theking@gmail.com"; autofill_manager_->OnDidFillAutofillFormData(form, AutofillTickClock::NowTicks()); @@ -6722,7 +6722,7 @@ TEST_P(AutofillManagerStructuredProfileTest, GetCreditCardSuggestions_UnrecognizedAttribute) { // Set up the form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -6760,7 +6760,7 @@ TEST_P(AutofillManagerStructuredProfileTest, GetCreditCardSuggestions_ForNumberSplitAcrossFields) { // Set up our form data with credit card number split across fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -6799,7 +6799,7 @@ TEST_P(AutofillManagerStructuredProfileTest, // Verify whether suggestions are populated correctly for one of the middle // credit card number fields when filled partially. FormFieldData number_field = form.fields[3]; - number_field.value = ASCIIToUTF16("901"); + number_field.value = u"901"; // Get the suggestions for already filled credit card |number_field|. GetAutofillSuggestions(form, number_field); @@ -6827,7 +6827,7 @@ TEST_P(AutofillManagerStructuredProfileTest, DontSaveCvcInAutocompleteHistory) { .WillOnce(SaveArg<0>(&form_seen_by_ahm)); FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -6869,19 +6869,19 @@ TEST_P(AutofillManagerStructuredProfileTest, DontOfferToSavePaymentsCard) { // Manually fill out |form| so we can use it in OnFormSubmitted. for (size_t i = 0; i < form.fields.size(); ++i) { - if (form.fields[i].name == ASCIIToUTF16("cardnumber")) - form.fields[i].value = ASCIIToUTF16("4012888888881881"); - else if (form.fields[i].name == ASCIIToUTF16("nameoncard")) - form.fields[i].value = ASCIIToUTF16("John H Dillinger"); - else if (form.fields[i].name == ASCIIToUTF16("ccmonth")) - form.fields[i].value = ASCIIToUTF16("01"); - else if (form.fields[i].name == ASCIIToUTF16("ccyear")) - form.fields[i].value = ASCIIToUTF16("2017"); + if (form.fields[i].name == u"cardnumber") + form.fields[i].value = u"4012888888881881"; + else if (form.fields[i].name == u"nameoncard") + form.fields[i].value = u"John H Dillinger"; + else if (form.fields[i].name == u"ccmonth") + form.fields[i].value = u"01"; + else if (form.fields[i].name == u"ccyear") + form.fields[i].value = u"2017"; } CardUnmaskDelegate::UserProvidedUnmaskDetails details; details.should_store_pan = false; - details.cvc = ASCIIToUTF16("123"); + details.cvc = u"123"; full_card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::SUCCESS, "4012888888881881"); autofill_manager_->OnFormSubmitted(form, false, @@ -6895,9 +6895,9 @@ TEST_P(AutofillManagerStructuredProfileTest, FillInUpdatedExpirationDate) { CardUnmaskDelegate::UserProvidedUnmaskDetails details; details.should_store_pan = false; - details.cvc = ASCIIToUTF16("123"); - details.exp_month = ASCIIToUTF16("02"); - details.exp_year = ASCIIToUTF16("2018"); + details.cvc = u"123"; + details.exp_month = u"02"; + details.exp_year = u"2018"; full_card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::SUCCESS, "4012888888881881"); } @@ -7359,20 +7359,18 @@ TEST_P(SuggestionMatchingTest, AutofillProfile profile1; profile1.set_guid("00000000-0000-0000-0000-000000000103"); - profile1.SetInfo(NAME_FIRST, ASCIIToUTF16("Robin"), "en-US"); - profile1.SetInfo(NAME_MIDDLE, ASCIIToUTF16("Adam Smith"), "en-US"); - profile1.SetInfo(NAME_LAST, ASCIIToUTF16("Grimes"), "en-US"); - profile1.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("1234 Smith Blvd."), - "en-US"); + profile1.SetInfo(NAME_FIRST, u"Robin", "en-US"); + profile1.SetInfo(NAME_MIDDLE, u"Adam Smith", "en-US"); + profile1.SetInfo(NAME_LAST, u"Grimes", "en-US"); + profile1.SetInfo(ADDRESS_HOME_LINE1, u"1234 Smith Blvd.", "en-US"); personal_data_.AddProfile(profile1); AutofillProfile profile2; profile2.set_guid("00000000-0000-0000-0000-000000000124"); - profile2.SetInfo(NAME_FIRST, ASCIIToUTF16("Carl"), "en-US"); - profile2.SetInfo(NAME_MIDDLE, ASCIIToUTF16("Shawn Smith"), "en-US"); - profile2.SetInfo(NAME_LAST, ASCIIToUTF16("Grimes"), "en-US"); - profile2.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("1234 Smith Blvd."), - "en-US"); + profile2.SetInfo(NAME_FIRST, u"Carl", "en-US"); + profile2.SetInfo(NAME_MIDDLE, u"Shawn Smith", "en-US"); + profile2.SetInfo(NAME_LAST, u"Grimes", "en-US"); + profile2.SetInfo(ADDRESS_HOME_LINE1, u"1234 Smith Blvd.", "en-US"); personal_data_.AddProfile(profile2); FormFieldData field; @@ -7402,7 +7400,7 @@ TEST_P(AutofillManagerStructuredProfileTest, ShouldUploadForm) { // is disabled by default. This tests validates both the disabled and enabled // scenarios. FormData form; - form.name = ASCIIToUTF16("TestForm"); + form.name = u"TestForm"; form.url = GURL("https://example.com/form.html"); form.action = GURL("https://example.com/submit.html"); @@ -7466,7 +7464,7 @@ TEST_P(AutofillManagerStructuredProfileTest, DisplaySuggestions_AutocompleteOffNotRespected_AddressField) { // Set up an address form. FormData mixed_form; - mixed_form.name = ASCIIToUTF16("MyForm"); + mixed_form.name = u"MyForm"; mixed_form.url = GURL("https://myform.com/form.html"); mixed_form.action = GURL("https://myform.com/submit.html"); FormFieldData field; @@ -7501,7 +7499,7 @@ TEST_P(AutofillManagerStructuredProfileTest, DisplaySuggestions_AutocompleteOff_CreditCardField) { // Set up a credit card form. FormData mixed_form; - mixed_form.name = ASCIIToUTF16("MyForm"); + mixed_form.name = u"MyForm"; mixed_form.url = GURL("https://myform.com/form.html"); mixed_form.action = GURL("https://myform.com/submit.html"); FormFieldData field; @@ -7532,7 +7530,7 @@ TEST_P(AutofillManagerStructuredProfileTest, DisplaySuggestionsForUpdatedServerTypedForm) { // Create a form with unknown heuristic fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -7567,7 +7565,7 @@ TEST_P(AutofillManagerStructuredProfileTest, } // Modify one of the fields in the original form. - form.fields[0].css_classes += ASCIIToUTF16("a"); + form.fields[0].css_classes += u"a"; // Expect the form still can be autofilled. for (const FormFieldData& field : form.fields) { @@ -7592,7 +7590,7 @@ TEST_P(AutofillManagerStructuredProfileTest, TEST_P(AutofillManagerStructuredProfileTest, FormWithLongOptionValuesIsAcceptable) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); @@ -7722,7 +7720,7 @@ TEST_P(AutofillManagerStructuredProfileTest, TEST_P(AutofillManagerStructuredProfileTest, DidShowSuggestions_LogAutocompleteShownMetric) { FormData form; - form.name = ASCIIToUTF16("NothingSpecial"); + form.name = u"NothingSpecial"; FormFieldData field; test::CreateTestFormField("Something", "something", "", "text", &field); @@ -7776,10 +7774,9 @@ TEST_P(AutofillManagerStructuredProfileTest, DidShowSuggestions_LogByType_AddressOnly) { // Create a form with name and address fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); - form.button_titles = { - std::make_pair(ASCIIToUTF16("Submit"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; + form.name = u"MyForm"; + form.button_titles = {std::make_pair( + u"Submit", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -7821,10 +7818,9 @@ TEST_P(AutofillManagerStructuredProfileTest, DidShowSuggestions_LogByType_AddressOnlyWithoutName) { // Create a form with address fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); - form.button_titles = { - std::make_pair(ASCIIToUTF16("Submit"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; + form.name = u"MyForm"; + form.button_titles = {std::make_pair( + u"Submit", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -7866,10 +7862,9 @@ TEST_P(AutofillManagerStructuredProfileTest, DidShowSuggestions_LogByType_ContactOnly) { // Create a form with name and contact fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); - form.button_titles = { - std::make_pair(ASCIIToUTF16("Submit"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; + form.name = u"MyForm"; + form.button_titles = {std::make_pair( + u"Submit", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -7910,10 +7905,9 @@ TEST_P(AutofillManagerStructuredProfileTest, DidShowSuggestions_LogByType_ContactOnlyWithoutName) { // Create a form with contact fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); - form.button_titles = { - std::make_pair(ASCIIToUTF16("Submit"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; + form.name = u"MyForm"; + form.button_titles = {std::make_pair( + u"Submit", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -7954,10 +7948,9 @@ TEST_P(AutofillManagerStructuredProfileTest, DidShowSuggestions_LogByType_PhoneOnly) { // Create a form with phone field. FormData form; - form.name = ASCIIToUTF16("MyForm"); - form.button_titles = { - std::make_pair(ASCIIToUTF16("Submit"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; + form.name = u"MyForm"; + form.button_titles = {std::make_pair( + u"Submit", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -7998,10 +7991,9 @@ TEST_P(AutofillManagerStructuredProfileTest, DidShowSuggestions_LogByType_Other) { // Create a form with name fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); - form.button_titles = { - std::make_pair(ASCIIToUTF16("Submit"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; + form.name = u"MyForm"; + form.button_titles = {std::make_pair( + u"Submit", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -8042,10 +8034,9 @@ TEST_P(AutofillManagerStructuredProfileTest, DidShowSuggestions_LogByType_AddressPlusEmail) { // Create a form with name, address, and email fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); - form.button_titles = { - std::make_pair(ASCIIToUTF16("Submit"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; + form.name = u"MyForm"; + form.button_titles = {std::make_pair( + u"Submit", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -8095,10 +8086,9 @@ TEST_P(AutofillManagerStructuredProfileTest, DidShowSuggestions_LogByType_AddressPlusEmailWithoutName) { // Create a form with address and email fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); - form.button_titles = { - std::make_pair(ASCIIToUTF16("Submit"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; + form.name = u"MyForm"; + form.button_titles = {std::make_pair( + u"Submit", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -8146,10 +8136,9 @@ TEST_P(AutofillManagerStructuredProfileTest, DidShowSuggestions_LogByType_AddressPlusPhone) { // Create a form with name fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); - form.button_titles = { - std::make_pair(ASCIIToUTF16("Submit"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; + form.name = u"MyForm"; + form.button_titles = {std::make_pair( + u"Submit", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -8199,10 +8188,9 @@ TEST_P(AutofillManagerStructuredProfileTest, DidShowSuggestions_LogByType_AddressPlusPhoneWithoutName) { // Create a form with name, address, and phone fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); - form.button_titles = { - std::make_pair(ASCIIToUTF16("Submit"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; + form.name = u"MyForm"; + form.button_titles = {std::make_pair( + u"Submit", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -8250,10 +8238,9 @@ TEST_P(AutofillManagerStructuredProfileTest, DidShowSuggestions_LogByType_AddressPlusEmailPlusPhone) { // Create a form with name, address, phone, and email fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); - form.button_titles = { - std::make_pair(ASCIIToUTF16("Submit"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; + form.name = u"MyForm"; + form.button_titles = {std::make_pair( + u"Submit", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -8304,10 +8291,9 @@ TEST_P(AutofillManagerStructuredProfileTest, DidShowSuggestions_LogByType_AddressPlusEmailPlusPhoneWithoutName) { // Create a form with address, phone, and email fields. FormData form; - form.name = ASCIIToUTF16("MyForm"); - form.button_titles = { - std::make_pair(ASCIIToUTF16("Submit"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; + form.name = u"MyForm"; + form.button_titles = {std::make_pair( + u"Submit", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -8476,7 +8462,7 @@ TEST_F(AutofillManagerTest, DontImportUpiIdWhenIncognito) { form.submission_event = mojom::SubmissionIndicatorEvent::SAME_DOCUMENT_NAVIGATION; - form.fields[0].value = ASCIIToUTF16("user@indianbank"); + form.fields[0].value = u"user@indianbank"; FormSubmitted(form); EXPECT_EQ(0, personal_data_.num_times_save_upi_id_called()); @@ -8490,14 +8476,10 @@ TEST_F(AutofillManagerTest, PossibleFieldTypesForEnhancementVotes) { {features::kAutofillEnableSupportForMoreStructureInAddresses}); std::vector<AutofillProfile> profiles = {AutofillProfile()}; - profiles[0].SetRawInfo(ADDRESS_HOME_STREET_NAME, - base::ASCIIToUTF16("StreetName")); - profiles[0].SetRawInfo(ADDRESS_HOME_HOUSE_NUMBER, - base::ASCIIToUTF16("HouseNumber")); - profiles[0].SetRawInfo(ADDRESS_HOME_PREMISE_NAME, - base::ASCIIToUTF16("Premise")); - profiles[0].SetRawInfo(ADDRESS_HOME_SUBPREMISE, - base::ASCIIToUTF16("Subpremise")); + profiles[0].SetRawInfo(ADDRESS_HOME_STREET_NAME, u"StreetName"); + profiles[0].SetRawInfo(ADDRESS_HOME_HOUSE_NUMBER, u"HouseNumber"); + profiles[0].SetRawInfo(ADDRESS_HOME_PREMISE_NAME, u"Premise"); + profiles[0].SetRawInfo(ADDRESS_HOME_SUBPREMISE, u"Subpremise"); FormData form; FormFieldData field1; @@ -8516,7 +8498,7 @@ TEST_F(AutofillManagerTest, PossibleFieldTypesForEnhancementVotes) { FormStructure form_structure(form); AutofillManager::DeterminePossibleFieldTypesForUploadForTest( - profiles, {}, base::string16(), "en-us", &form_structure); + profiles, {}, std::u16string(), "en-us", &form_structure); ASSERT_EQ(4U, form_structure.field_count()); @@ -8535,7 +8517,7 @@ TEST_F(AutofillManagerTest, PossibleFieldTypesForEnhancementVotes) { features::kAutofillAddressEnhancementVotes); AutofillManager::DeterminePossibleFieldTypesForUploadForTest( - profiles, {}, base::string16(), "en-us", &form_structure); + profiles, {}, std::u16string(), "en-us", &form_structure); ASSERT_EQ(4U, form_structure.field_count()); @@ -8555,7 +8537,7 @@ TEST_F(AutofillManagerTest, PageLanguageGetsCorrectlySet) { autofill_manager_->OnFormsSeen({form}); FormStructure* parsed_form = - autofill_manager_->FindCachedFormByRendererId(form.unique_renderer_id); + autofill_manager_->FindCachedFormByRendererId(form.global_id()); ASSERT_TRUE(parsed_form); ASSERT_EQ(LanguageCode(), parsed_form->current_page_language()); @@ -8563,8 +8545,7 @@ TEST_F(AutofillManagerTest, PageLanguageGetsCorrectlySet) { autofill_client_.GetLanguageState()->SetCurrentLanguage("zh"); autofill_manager_->OnFormsSeen({form}); - parsed_form = - autofill_manager_->FindCachedFormByRendererId(form.unique_renderer_id); + parsed_form = autofill_manager_->FindCachedFormByRendererId(form.global_id()); ASSERT_EQ(LanguageCode("zh"), parsed_form->current_page_language()); } @@ -8579,7 +8560,7 @@ TEST_F(AutofillManagerTest, PageLanguageGetsCorrectlyDetected) { autofill_manager_->OnFormsSeen({form}); FormStructure* parsed_form = - autofill_manager_->FindCachedFormByRendererId(form.unique_renderer_id); + autofill_manager_->FindCachedFormByRendererId(form.global_id()); ASSERT_TRUE(parsed_form); ASSERT_EQ(LanguageCode(), parsed_form->current_page_language()); @@ -8590,12 +8571,52 @@ TEST_F(AutofillManagerTest, PageLanguageGetsCorrectlyDetected) { autofill_client_.GetLanguageState()->SetCurrentLanguage("zh"); - parsed_form = - autofill_manager_->FindCachedFormByRendererId(form.unique_renderer_id); + parsed_form = autofill_manager_->FindCachedFormByRendererId(form.global_id()); ASSERT_EQ(LanguageCode("zh"), parsed_form->current_page_language()); } +// AutofillManagerTest with different browser profile types. +class AutofillManagerProfileMetricsTest + : public AutofillManagerTest, + public testing::WithParamInterface<profile_metrics::BrowserProfileType> { + public: + AutofillManagerProfileMetricsTest() : profile_type_(GetParam()) { + EXPECT_CALL(autofill_client_, GetProfileType()) + .WillRepeatedly(Return(profile_type_)); + } + + const profile_metrics::BrowserProfileType profile_type_; +}; + +// Tests if submitting a form in different browser profile types records correct +// |Autofill.FormSubmission.PerProfileType| metric. +TEST_P(AutofillManagerProfileMetricsTest, FormSubmissionPerProfileTypeMetrics) { + // Set up our form data. + FormData form; + test::CreateTestAddressFormData(&form); + std::vector<FormData> forms(1, form); + FormsSeen(forms); + FormFieldData field = form.fields[0]; + GetAutofillSuggestions(form, field); + + base::HistogramTester histogram_tester; + + FormSubmitted(form); + histogram_tester.ExpectBucketCount("Autofill.FormSubmission.PerProfileType", + profile_type_, 1); + histogram_tester.ExpectTotalCount("Autofill.FormSubmission.PerProfileType", + 1); +} + +INSTANTIATE_TEST_SUITE_P( + All, + AutofillManagerProfileMetricsTest, + testing::ValuesIn({profile_metrics::BrowserProfileType::kRegular, + profile_metrics::BrowserProfileType::kIncognito, + profile_metrics::BrowserProfileType::kGuest, + profile_metrics::BrowserProfileType::kEphemeralGuest})); + // AutofillManagerTest with kAutofillDisabledMixedForms feature enabled. class AutofillManagerTestWithMixedForms : public AutofillManagerTest { protected: @@ -8615,7 +8636,7 @@ class AutofillManagerTestWithMixedForms : public AutofillManagerTest { TEST_F(AutofillManagerTestWithMixedForms, GetSuggestions_MixedForm) { // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); FormFieldData field; @@ -8641,7 +8662,7 @@ TEST_F(AutofillManagerTestWithMixedForms, // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); FormFieldData field; @@ -8657,7 +8678,7 @@ TEST_F(AutofillManagerTestWithMixedForms, TEST_F(AutofillManagerTestWithMixedForms, GetSuggestions_MixedFormUserTyped) { // Set up our form data. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); FormFieldData field; @@ -8673,7 +8694,7 @@ TEST_F(AutofillManagerTestWithMixedForms, GetSuggestions_MixedFormUserTyped) { "", POPUP_ITEM_ID_MIXED_FORM_MESSAGE)); // Pretend user started typing and make sure we no longer set suggestions. - form.fields[0].value = base::ASCIIToUTF16("Michael"); + form.fields[0].value = u"Michael"; form.fields[0].properties_mask |= kUserTyped; GetAutofillSuggestions(form, form.fields[0]); external_delegate_->CheckNoSuggestions(kDefaultPageID); @@ -8684,7 +8705,7 @@ TEST_F(AutofillManagerTestWithMixedForms, GetSuggestions_MixedFormUserTyped) { TEST_F(AutofillManagerTestWithMixedForms, GetSuggestions_JavascriptUrlTarget) { // Set up our form data, using a javascript scheme target URL. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("javascript:alert('hello');"); FormFieldData field; @@ -8700,7 +8721,7 @@ TEST_F(AutofillManagerTestWithMixedForms, GetSuggestions_JavascriptUrlTarget) { TEST_F(AutofillManagerTestWithMixedForms, GetSuggestions_AboutBlankTarget) { // Set up our form data, using a javascript scheme target URL. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("about:blank"); FormFieldData field; @@ -8815,7 +8836,7 @@ TEST_F(AutofillManagerTestForVirtualCardOption, ShouldNotShowDueToFormNotHavingCardNumberField) { // Creates an incomplete form without card number field. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -8873,7 +8894,7 @@ TEST_F(AutofillManagerTestForVirtualCardOption, ShouldNotShowDueToFormNotHavingExpirationDateField) { // Creates an incomplete form without expiration date field. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -8900,7 +8921,7 @@ TEST_F(AutofillManagerTestForVirtualCardOption, ShouldNotShowDueToFormNotHavingCvcField) { // Creates an incomplete form without cvc field. FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); form.main_frame_origin = @@ -9000,12 +9021,6 @@ class OnFocusOnFormFieldTest : public AutofillManagerTest, has_active_screen_reader_ = GetParam(); external_delegate_->set_has_active_screen_reader(has_active_screen_reader_); - - scoped_feature_list_.InitWithFeatures( - // Enabled - {}, - // Disabled - {kAutofillRestrictUnownedFieldsToFormlessCheckout}); } void TearDown() override { @@ -9038,7 +9053,7 @@ class OnFocusOnFormFieldTest : public AutofillManagerTest, TEST_P(OnFocusOnFormFieldTest, AddressSuggestions) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); FormFieldData field; @@ -9065,7 +9080,7 @@ TEST_P(OnFocusOnFormFieldTest, AddressSuggestions) { TEST_P(OnFocusOnFormFieldTest, AddressSuggestions_AutocompleteOffNotRespected) { FormData form; - form.name = ASCIIToUTF16("MyForm"); + form.name = u"MyForm"; form.url = GURL("https://myform.com/form.html"); form.action = GURL("https://myform.com/submit.html"); FormFieldData field; diff --git a/chromium/components/autofill/core/browser/autofill_merge_unittest.cc b/chromium/components/autofill/core/browser/autofill_merge_unittest.cc index 1602cab0588..39df0b8f98e 100644 --- a/chromium/components/autofill/core/browser/autofill_merge_unittest.cc +++ b/chromium/components/autofill/core/browser/autofill_merge_unittest.cc @@ -102,12 +102,11 @@ std::string SerializeProfiles(const std::vector<AutofillProfile*>& profiles) { result += kProfileSeparator; result += "\n"; for (const ServerFieldType& type : kProfileFieldTypes) { - base::string16 value = profiles[i]->GetRawInfo(type); + std::u16string value = profiles[i]->GetRawInfo(type); result += AutofillType::ServerFieldTypeToString(type); result += kFieldSeparator; if (!value.empty()) { - base::ReplaceFirstSubstringAfterOffset( - &value, 0, base::ASCIIToUTF16("\\n"), base::ASCIIToUTF16("\n")); + base::ReplaceFirstSubstringAfterOffset(&value, 0, u"\\n", u"\n"); result += " "; result += base::UTF16ToUTF8(value); } @@ -244,7 +243,7 @@ void AutofillMergeTest::MergeProfiles(const std::string& profiles, // Create a test form. FormData form; - form.name = base::ASCIIToUTF16("MyTestForm"); + form.name = u"MyTestForm"; form.url = GURL("https://www.example.com/origin.html"); form.action = GURL("https://www.example.com/action.html"); @@ -258,14 +257,13 @@ void AutofillMergeTest::MergeProfiles(const std::string& profiles, size_t separator_pos = line.find(kFieldSeparator); ASSERT_NE(std::string::npos, separator_pos) << "Wrong format for separator on line " << i; - base::string16 field_type = + std::u16string field_type = base::UTF8ToUTF16(line.substr(0, separator_pos)); do { ++separator_pos; } while (separator_pos < line.size() && line[separator_pos] == ' '); - base::string16 value = base::UTF8ToUTF16(line.substr(separator_pos)); - base::ReplaceFirstSubstringAfterOffset( - &value, 0, base::ASCIIToUTF16("\\n"), base::ASCIIToUTF16("\n")); + std::u16string value = base::UTF8ToUTF16(line.substr(separator_pos)); + base::ReplaceFirstSubstringAfterOffset(&value, 0, u"\\n", u"\n"); FormFieldData field; field.label = field_type; diff --git a/chromium/components/autofill/core/browser/autofill_metrics_unittest.cc b/chromium/components/autofill/core/browser/autofill_metrics_unittest.cc index 7a43731c706..aa595f3fd47 100644 --- a/chromium/components/autofill/core/browser/autofill_metrics_unittest.cc +++ b/chromium/components/autofill/core/browser/autofill_metrics_unittest.cc @@ -7,6 +7,7 @@ #include <stddef.h> #include <memory> +#include <string> #include <utility> #include <vector> @@ -16,7 +17,6 @@ #include "base/macros.h" #include "base/metrics/metrics_hashes.h" #include "base/metrics/statistics_recorder.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/metrics/user_action_tester.h" @@ -54,8 +54,8 @@ #include "components/autofill/core/common/dense_set.h" #include "components/autofill/core/common/form_data.h" #include "components/autofill/core/common/form_field_data.h" -#include "components/autofill/core/common/renderer_id.h" #include "components/autofill/core/common/signatures.h" +#include "components/autofill/core/common/unique_ids.h" #include "components/prefs/pref_service.h" #include "components/sync/driver/test_sync_service.h" #include "components/translate/core/common/language_detection_details.h" @@ -122,13 +122,6 @@ FieldSignature Collapse(FieldSignature sig) { return FieldSignature(sig.value() % 1021); } -// Returns numbers which are distinct from each other within the scope of one -// test. -FormRendererId MakeFormRendererId() { - static uint32_t counter = 10; - return FormRendererId(counter++); -} - struct AddressProfileImportRequirementExpectations { AddressImportRequirements requirement; bool fulfilled; @@ -299,8 +292,9 @@ void TestAddressProfileImportCountrySpecificFieldRequirements( } void CreateSimpleForm(const GURL& origin, FormData& form) { - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(origin); @@ -522,7 +516,7 @@ void AutofillMetricsTest::OnDidGetRealPan( // Fake user response. payments::FullCardRequest::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; full_card_request->OnUnmaskPromptAccepted(details); payments::PaymentsClient::UnmaskResponseDetails response; @@ -547,7 +541,7 @@ void AutofillMetricsTest::RecreateCreditCards( masked_server_credit_card.set_guid("10000000-0000-0000-0000-000000000002"); masked_server_credit_card.set_instrument_id(1); masked_server_credit_card.SetNetworkForMaskedCard(kDiscoverCard); - masked_server_credit_card.SetNumber(ASCIIToUTF16("9424")); + masked_server_credit_card.SetNumber(u"9424"); personal_data_->AddServerCreditCard(masked_server_credit_card); } if (include_full_server_credit_card) { @@ -571,7 +565,7 @@ void AutofillMetricsTest::AddMaskedServerCreditCardWithOffer( masked_server_credit_card.set_guid(guid); masked_server_credit_card.set_instrument_id(id); masked_server_credit_card.SetNetworkForMaskedCard(kDiscoverCard); - masked_server_credit_card.SetNumber(ASCIIToUTF16("9424")); + masked_server_credit_card.SetNumber(u"9424"); personal_data_->AddServerCreditCard(masked_server_credit_card); AutofillOfferData offer_data; @@ -658,7 +652,7 @@ TEST_F(AutofillMetricsTest, NumberOfAutofilledFieldsAtSubmission) { .value = "2345678901", .form_control_type = "tel", .is_autofilled = true}}, - .unique_renderer_id = MakeFormRendererId(), + .unique_renderer_id = test::MakeFormRendererId(), .main_frame_origin = url::Origin::Create( autofill_client_.form_origin())}); @@ -732,7 +726,7 @@ TEST_F(AutofillMetricsTest, QualityMetrics) { .value = "2345678901", .form_control_type = "tel", .is_autofilled = true}}, - .unique_renderer_id = MakeFormRendererId(), + .unique_renderer_id = test::MakeFormRendererId(), .main_frame_origin = url::Origin::Create( autofill_client_.form_origin())}); @@ -1559,8 +1553,9 @@ TEST_F(AutofillMetricsTest, QualityMetrics_LoggedCorrecltyForRationalizationOk) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); @@ -1640,8 +1635,9 @@ TEST_F(AutofillMetricsTest, QualityMetrics_LoggedCorrecltyForRationalizationGood) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); @@ -1708,8 +1704,9 @@ TEST_F(AutofillMetricsTest, LogHiddenRepresentationalFieldSkipDecision) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -1863,8 +1860,9 @@ void AddFieldSuggestionToForm( TEST_F(AutofillMetricsTest, LogRepeatedAddressTypeRationalized) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -1874,17 +1872,17 @@ TEST_F(AutofillMetricsTest, LogRepeatedAddressTypeRationalized) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("fullname"); - field.name = ASCIIToUTF16("fullname"); + field.label = u"fullname"; + field.name = u"fullname"; form.fields.push_back(field); - field.label = ASCIIToUTF16("Street 1"); - field.name = ASCIIToUTF16("street1"); + field.label = u"Street 1"; + field.name = u"street1"; form.fields.push_back(field); field_signature[0] = Collapse(CalculateFieldSignatureForField(field)); - field.label = ASCIIToUTF16("Street 2"); - field.name = ASCIIToUTF16("street2"); + field.label = u"Street 2"; + field.name = u"street2"; form.fields.push_back(field); field_signature[1] = Collapse(CalculateFieldSignatureForField(field)); @@ -1970,8 +1968,9 @@ TEST_F(AutofillMetricsTest, LogRepeatedAddressTypeRationalized) { TEST_F(AutofillMetricsTest, LogRepeatedStateCountryTypeRationalized) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -1981,22 +1980,22 @@ TEST_F(AutofillMetricsTest, LogRepeatedStateCountryTypeRationalized) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; form.fields.push_back(field); field_signature[0] = Collapse(CalculateFieldSignatureForField(field)); - field.label = ASCIIToUTF16("fullname"); - field.name = ASCIIToUTF16("fullname"); + field.label = u"fullname"; + field.name = u"fullname"; form.fields.push_back(field); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; form.fields.push_back(field); field_signature[2] = Collapse(CalculateFieldSignatureForField(field)); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; field.is_focusable = false; field.form_control_type = "select-one"; form.fields.push_back(field); @@ -2110,8 +2109,9 @@ TEST_F(AutofillMetricsTest, QualityMetrics_LoggedCorrecltyForRationalizationBad) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); @@ -2177,8 +2177,9 @@ TEST_F(AutofillMetricsTest, QualityMetrics_LoggedCorrecltyForOnlyFillWhenFocusedField) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); @@ -2485,8 +2486,9 @@ TEST_P(QualityMetricsTest, Classification) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -2661,8 +2663,9 @@ TEST_F(AutofillMetricsTest, TimingMetrics) { base::HistogramTester histogram_tester; FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = @@ -2703,8 +2706,9 @@ TEST_F(AutofillMetricsTest, TimingMetrics) { TEST_F(AutofillMetricsTest, QualityMetrics_NoSubmission) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -2893,8 +2897,9 @@ TEST_F(AutofillMetricsTest, QualityMetrics_NoSubmission) { // on autocomplete attributes present on the fields. TEST_F(AutofillMetricsTest, QualityMetrics_BasedOnAutocomplete) { FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("MyForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"MyForm"; form.url = GURL("http://myform.com/form.html"); form.action = GURL("http://myform.com/submit.html"); form.main_frame_origin = @@ -2925,10 +2930,10 @@ TEST_F(AutofillMetricsTest, QualityMetrics_BasedOnAutocomplete) { std::make_unique<TestFormStructure>(form); TestFormStructure* form_structure_ptr = form_structure.get(); form_structure->DetermineHeuristicTypes(nullptr, nullptr); - ASSERT_TRUE(autofill_manager_->mutable_form_structures_for_test() - ->emplace(form_structure_ptr->unique_renderer_id(), - std::move(form_structure)) - .second); + ASSERT_TRUE( + autofill_manager_->mutable_form_structures_for_test() + ->emplace(form_structure_ptr->global_id(), std::move(form_structure)) + .second); AutofillQueryResponse response; auto* form_suggestion = response.add_form_suggestions(); @@ -3009,8 +3014,9 @@ TEST_F(AutofillMetricsTest, QualityMetrics_BasedOnAutocomplete) { TEST_F(AutofillMetricsTest, UpiVirtualPaymentAddress) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = @@ -3061,8 +3067,9 @@ TEST_F(AutofillMetricsTest, UpiVirtualPaymentAddress) { TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = @@ -3163,8 +3170,9 @@ TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) { TEST_F(AutofillMetricsTest, StoredProfileCountAutofillableFormSubmission) { // Construct a fillable form. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = @@ -3198,8 +3206,9 @@ TEST_F(AutofillMetricsTest, StoredProfileCountAutofillableFormSubmission) { TEST_F(AutofillMetricsTest, StoredProfileCountNonAutofillableFormSubmission) { // Construct a non-fillable form. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = @@ -3231,7 +3240,7 @@ TEST_F(AutofillMetricsTest, StoredProfileCountNonAutofillableFormSubmission) { TEST_F(AutofillMetricsTest, TypeOfEditedAutofilledFieldsUkmLogging) { // Construct a fillable form. FormData form; - form.name = ASCIIToUTF16("TestForm"); + form.name = u"TestForm"; form.url = GURL("https://example.test/form.html"); form.action = GURL("https://example.test/submit.html"); form.main_frame_origin = @@ -3292,7 +3301,7 @@ TEST_F(AutofillMetricsTest, TypeOfEditedAutofilledFieldsUkmLogging) { TEST_F(AutofillMetricsTest, TypeOfEditedAutofilledFieldsUmaLogging) { // Construct a fillable form. FormData form; - form.name = ASCIIToUTF16("TestForm"); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = @@ -3369,8 +3378,9 @@ TEST_F(AutofillMetricsTest, TypeOfEditedAutofilledFieldsUmaLogging) { TEST_F(AutofillMetricsTest, NumberOfEditedAutofilledFields) { // Construct a fillable form. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = @@ -3424,8 +3434,9 @@ TEST_F(AutofillMetricsTest, NumberOfEditedAutofilledFields) { TEST_F(AutofillMetricsTest, NumberOfEditedAutofilledFields_NoSubmission) { // Construct a fillable form. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -3474,8 +3485,9 @@ TEST_F(AutofillMetricsTest, NumberOfEditedAutofilledFields_NoSubmission) { TEST_F(AutofillMetricsTest, DeveloperEngagement) { // Start with a non-fillable form. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -3566,8 +3578,9 @@ TEST_F(AutofillMetricsTest, UkmDeveloperEngagement_LogFillableFormParsedWithoutTypeHints) { // Start with a non-fillable form. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -3610,8 +3623,9 @@ TEST_F(AutofillMetricsTest, TEST_F(AutofillMetricsTest, UkmDeveloperEngagement_LogFillableFormParsedWithTypeHints) { FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -3660,8 +3674,9 @@ TEST_F(AutofillMetricsTest, // developer engagement. TEST_F(AutofillMetricsTest, UkmDeveloperEngagement_LogUpiVpaTypeHint) { FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -3830,12 +3845,12 @@ TEST_F(AutofillMetricsTest, LogStoredCreditCardWithNicknameMetrics) { for (int i = 0; i < num_cards_of_type; ++i) { // Create a card with a nickname. CreditCard card_with_nickname = test::GetRandomCreditCard(record_type); - card_with_nickname.SetNickname(ASCIIToUTF16("Valid nickname")); + card_with_nickname.SetNickname(u"Valid nickname"); // Create a card that doesn't have a nickname. CreditCard card_without_nickname = test::GetRandomCreditCard(record_type); // Set nickname to empty. - card_without_nickname.SetNickname(ASCIIToUTF16("")); + card_without_nickname.SetNickname(u""); // Add the cards to the personal data manager in the appropriate way. auto& repo = @@ -3968,8 +3983,9 @@ TEST_F(AutofillMetricsTest, AutofillCreditCardIsDisabledAtStartup) { TEST_F(AutofillMetricsTest, AddressSuggestionsCount) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("https://example.com/form.html"); form.action = GURL("https://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -4041,8 +4057,9 @@ TEST_F(AutofillMetricsTest, AddressSuggestionsCount) { TEST_F(AutofillMetricsTest, CompanyNameSuggestions) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("https://example.com/form.html"); form.action = GURL("https://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -4082,8 +4099,9 @@ TEST_F(AutofillMetricsTest, CreditCardCheckoutFlowUserActions) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("https://example.com/form.html"); form.action = GURL("https://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -4138,8 +4156,8 @@ TEST_F(AutofillMetricsTest, CreditCardCheckoutFlowUserActions) { std::string guid("10000000-0000-0000-0000-000000000001"); // local card external_delegate_->OnQuery(0, form, form.fields.front(), gfx::RectF()); external_delegate_->DidAcceptSuggestion( - ASCIIToUTF16("Test"), - autofill_manager_->MakeFrontendIDForTest(guid, std::string()), 0); + u"Test", autofill_manager_->MakeFrontendIDForTest(guid, std::string()), + 0); EXPECT_EQ(1, user_action_tester.GetActionCount("Autofill_SelectedSuggestion")); } @@ -4159,7 +4177,7 @@ TEST_F(AutofillMetricsTest, CreditCardCheckoutFlowUserActions) { base::UserActionTester user_action_tester; std::string guid("10000000-0000-0000-0000-000000000001"); // local card external_delegate_->OnQuery(0, form, form.fields.front(), gfx::RectF()); - external_delegate_->DidAcceptSuggestion(base::string16(), + external_delegate_->DidAcceptSuggestion(std::u16string(), POPUP_ITEM_ID_CLEAR_FORM, 0); EXPECT_EQ(1, user_action_tester.GetActionCount("Autofill_ClearedForm")); } @@ -4180,8 +4198,8 @@ TEST_F(AutofillMetricsTest, CreditCardCheckoutFlowUserActions) { std::string guid("10000000-0000-0000-0000-000000000001"); // local card external_delegate_->OnQuery(0, form, form.fields.front(), gfx::RectF()); external_delegate_->DidAcceptSuggestion( - ASCIIToUTF16("Test"), - autofill_manager_->MakeFrontendIDForTest(guid, std::string()), 0); + u"Test", autofill_manager_->MakeFrontendIDForTest(guid, std::string()), + 0); EXPECT_EQ(1, user_action_tester.GetActionCount("Autofill_SelectedSuggestion")); } @@ -4268,8 +4286,9 @@ TEST_F(AutofillMetricsTest, CreditCardCheckoutFlowUserActions) { // Test that the UPI Checkout flow form submit is correctly logged TEST_F(AutofillMetricsTest, UpiVpaUkmTest) { FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -4300,8 +4319,9 @@ TEST_F(AutofillMetricsTest, ProfileCheckoutFlowUserActions) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("https://example.com/form.html"); form.action = GURL("https://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -4355,8 +4375,8 @@ TEST_F(AutofillMetricsTest, ProfileCheckoutFlowUserActions) { std::string guid(kTestGuid); // local profile. external_delegate_->OnQuery(0, form, form.fields.front(), gfx::RectF()); external_delegate_->DidAcceptSuggestion( - ASCIIToUTF16("Test"), - autofill_manager_->MakeFrontendIDForTest(std::string(), guid), 0); + u"Test", autofill_manager_->MakeFrontendIDForTest(std::string(), guid), + 0); EXPECT_EQ(1, user_action_tester.GetActionCount("Autofill_SelectedSuggestion")); } @@ -4442,8 +4462,9 @@ TEST_F(AutofillMetricsTest, PolledCreditCardSuggestions_DebounceLogs) { // Set up the form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://www.foo.com/"); FormFieldData field; @@ -4503,8 +4524,9 @@ TEST_F(AutofillMetricsTest, QueriedCreditCardFormIsSecure) { // Set up the form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -4523,7 +4545,8 @@ TEST_F(AutofillMetricsTest, QueriedCreditCardFormIsSecure) { { // Simulate having seen this insecure form on page load. - form.unique_renderer_id = MakeFormRendererId(); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); // In order to test that the QueriedCreditCardFormIsSecure is logged as @@ -4554,7 +4577,8 @@ TEST_F(AutofillMetricsTest, QueriedCreditCardFormIsSecure) { { // Simulate having seen this secure form on page load. autofill_manager_->Reset(); - form.unique_renderer_id = MakeFormRendererId(); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); form.url = GURL("https://example.com/form.html"); form.action = GURL("https://example.com/submit.html"); form.main_frame_origin = @@ -4578,8 +4602,9 @@ TEST_F(AutofillMetricsTest, PolledProfileSuggestions_DebounceLogs) { // Set up the form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("https://example.com/form.html"); form.action = GURL("https://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -4636,8 +4661,9 @@ TEST_F(AutofillMetricsTest, PolledProfileSuggestions_DebounceLogs) { TEST_P(AutofillMetricsIFrameTest, CreditCardParsedFormEvents) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -4669,8 +4695,9 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardParsedFormEvents) { TEST_P(AutofillMetricsIFrameTest, CreditCardInteractedFormEvents) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -4726,8 +4753,9 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardInteractedFormEvents) { TEST_P(AutofillMetricsIFrameTest, CreditCardPopupSuppressedFormEvents) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -4785,8 +4813,9 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardPopupSuppressedFormEvents) { TEST_P(AutofillMetricsIFrameTest, CreditCardShownFormEvents) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -4868,8 +4897,9 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardSelectedFormEvents) { true /* include_full_server_credit_card */); // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -4950,8 +4980,9 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardFilledFormEvents) { true /* include_full_server_credit_card */); // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -5203,8 +5234,9 @@ TEST_F(AutofillMetricsTest, CreditCardGetRealPanDuration) { false /* include_full_server_credit_card */); // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -5273,8 +5305,9 @@ TEST_F(AutofillMetricsTest, // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -5316,8 +5349,9 @@ TEST_P(AutofillMetricsIFrameTest, // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); @@ -5361,8 +5395,9 @@ TEST_P(AutofillMetricsIFrameTest, // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); @@ -5407,8 +5442,9 @@ TEST_P(AutofillMetricsIFrameTest, // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -5454,8 +5490,9 @@ TEST_P(AutofillMetricsIFrameTest, // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -5501,8 +5538,9 @@ TEST_P(AutofillMetricsIFrameTest, // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -5561,8 +5599,9 @@ TEST_F(AutofillMetricsTest, ShouldNotLogFormEventNoCardForAddressForm) { RecreateProfile(/*is_server=*/false); // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -5603,8 +5642,9 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardSubmittedFormEvents) { true /* include_full_server_credit_card */); // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -6098,8 +6138,9 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardWillSubmitFormEvents) { true /* include_full_server_credit_card */); // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -6415,7 +6456,7 @@ TEST_F(AutofillMetricsTest, LogServerOfferFormEvents) { // Set up our form data. FormData form; - form.name = ASCIIToUTF16("TestForm"); + form.name = u"TestForm"; form.url = GURL("https://example.com/form.html"); form.action = GURL("https://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -6660,14 +6701,210 @@ TEST_F(AutofillMetricsTest, LogServerOfferFormEvents) { EXPECT_EQ(0, histogram_tester.GetTotalCountsForPrefix( "Autofill.Offer")["Autofill.Offer.SubmittedCardHasOffer"]); } + + // Recreate cards and add card that is linked to an offer. + RecreateCreditCards(true /* include_local_credit_card */, + true /* include_masked_server_credit_card */, + true /* include_full_server_credit_card */); + guid = "12340000-0000-0000-0000-000000000003"; + AddMaskedServerCreditCardWithOffer(guid, "$5", autofill_client_.form_origin(), + /*id=*/0x5fff); + + // Reset the autofill manager state. + autofill_manager_->Reset(); + autofill_manager_->AddSeenForm(form, field_types, field_types); + + { + // A masked server card with linked offers. + // Simulating activating the autofill popup for the credit card field, new + // popup being shown, selecting a masked card server suggestion, showing the + // suggestions again, and then submitting the form with previously filled + // card. Verify that all related form events are correctly logged to offer + // sub-histogram. Making suggestions reappear tests confirmation of a fix + // for crbug/1198751. + base::HistogramTester histogram_tester; + autofill_manager_->OnQueryFormFieldAutofill( + 0, form, field, gfx::RectF(), /*autoselect_first_suggestion=*/false); + autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); + // Select the masked server card with the linked offer. + autofill_manager_->FillOrPreviewForm( + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.back(), + autofill_manager_->MakeFrontendIDForTest(guid, std::string())); + OnDidGetRealPan(AutofillClient::SUCCESS, "6011000990139424"); + + // Simulate user showing suggestions but then submitting form with + // previously filled card info. + autofill_manager_->OnQueryFormFieldAutofill( + 0, form, field, gfx::RectF(), /*autoselect_first_suggestion=*/false); + autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); + autofill_manager_->OnFormSubmitted(form, false, + SubmissionSource::FORM_SUBMISSION); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_SUGGESTIONS_SHOWN, 2); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED, 1); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE, 1); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED, 1); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE, 1); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE, 1); + + // Ensure we count the correct number of offers shown. + histogram_tester.ExpectUniqueSample( + "Autofill.Offer.SuggestedCardsHaveOffer", + /*suggestions with offers=*/1, 1); + + // Should track card was selected and form was submitted with that card. + histogram_tester.ExpectBucketCount("Autofill.Offer.SelectedCardHasOffer", + true, 1); + histogram_tester.ExpectUniqueSample("Autofill.Offer.SubmittedCardHasOffer", + true, 1); + } + + // Reset the autofill manager state. + autofill_manager_->Reset(); + autofill_manager_->AddSeenForm(form, field_types, field_types); + + { + // A masked server card with linked offers. + // Simulating activating the autofill popup for the credit card field, new + // popup being shown, selecting a masked card server suggestion, but then + // failing the CVC check and submitting the form anyways. Verify that all + // related form events are correctly logged to offer sub-histogram. + base::HistogramTester histogram_tester; + autofill_manager_->OnQueryFormFieldAutofill( + 0, form, field, gfx::RectF(), /*autoselect_first_suggestion=*/false); + autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); + // Select the masked server card with the linked offer, but fail the CVC + // check. + autofill_manager_->FillOrPreviewForm( + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.back(), + autofill_manager_->MakeFrontendIDForTest(guid, std::string())); + OnDidGetRealPan(AutofillClient::PERMANENT_FAILURE, std::string()); + + // Submitting the form without the filled suggestion. + autofill_manager_->OnFormSubmitted(form, false, + SubmissionSource::FORM_SUBMISSION); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_SUGGESTIONS_SHOWN, 1); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED, 1); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE, 1); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED, 0); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE, 0); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE, 0); + + // Ensure we count the correct number of offers shown. + histogram_tester.ExpectUniqueSample( + "Autofill.Offer.SuggestedCardsHaveOffer", + /*suggestions with offers=*/1, 1); + + // Should track card was selected once, but not submitted. + histogram_tester.ExpectUniqueSample("Autofill.Offer.SelectedCardHasOffer", + true, 1); + histogram_tester.ExpectBucketCount("Autofill.Offer.SubmittedCardHasOffer", + true, 0); + } + + // Reset the autofill manager state. + autofill_manager_->Reset(); + autofill_manager_->AddSeenForm(form, field_types, field_types); + + { + // A masked server card with linked offers. + // Simulating activating the autofill popup for the credit card field, new + // popup being shown, selecting a masked card server suggestion, but then + // selecting a local card instead. Verify that all related form events are + // correctly logged to offer sub-histogram. + base::HistogramTester histogram_tester; + + // Show suggestions and select the card with offer. + autofill_manager_->OnQueryFormFieldAutofill( + 0, form, field, gfx::RectF(), /*autoselect_first_suggestion=*/false); + autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); + autofill_manager_->FillOrPreviewForm( + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.back(), + autofill_manager_->MakeFrontendIDForTest(guid, std::string())); + OnDidGetRealPan(AutofillClient::SUCCESS, "6011000990139424"); + + // Show suggestions again, and select a local card instead. + autofill_manager_->OnQueryFormFieldAutofill( + 0, form, field, gfx::RectF(), /*autoselect_first_suggestion=*/false); + autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); + guid = "10000000-0000-0000-0000-000000000001"; + autofill_manager_->FillOrPreviewForm( + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.back(), + autofill_manager_->MakeFrontendIDForTest(guid, std::string())); + autofill_manager_->OnFormSubmitted(form, false, + SubmissionSource::FORM_SUBMISSION); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_SUGGESTIONS_SHOWN, 2); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED, 1); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE, 1); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED, 1); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE, 1); + histogram_tester.ExpectBucketCount( + "Autofill.FormEvents.CreditCard.WithOffer", + FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE, 1); + + // Ensure we count the correct number of offers shown. + histogram_tester.ExpectBucketCount("Autofill.Offer.SuggestedCardsHaveOffer", + /*suggestions with offers=*/1, 1); + + // Should track card was only selected once. + histogram_tester.ExpectBucketCount("Autofill.Offer.SelectedCardHasOffer", + true, 1); + histogram_tester.ExpectBucketCount("Autofill.Offer.SelectedCardHasOffer", + false, 1); + histogram_tester.ExpectUniqueSample("Autofill.Offer.SubmittedCardHasOffer", + false, 1); + } } // Test that we log parsed form events for address and cards in the same form. TEST_F(AutofillMetricsTest, MixedParsedFormEvents) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -6710,8 +6947,9 @@ TEST_F(AutofillMetricsTest, MixedParsedFormEvents) { TEST_F(AutofillMetricsTest, AddressParsedFormEvents) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -6753,8 +6991,9 @@ TEST_F(AutofillMetricsTest, AddressParsedFormEvents) { TEST_F(AutofillMetricsTest, AddressInteractedFormEvents) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -6830,8 +7069,9 @@ TEST_F(AutofillMetricsTest, AddressSuppressedFormEvents) { RecreateProfile(/*is_server=*/false); // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -6924,8 +7164,9 @@ TEST_F(AutofillMetricsTest, AddressShownFormEvents) { RecreateProfile(/*is_server=*/false); // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -7036,8 +7277,9 @@ TEST_F(AutofillMetricsTest, AddressFilledFormEvents) { RecreateProfile(/*is_server=*/false); // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -7156,8 +7398,9 @@ TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) { RecreateProfile(/*is_server=*/false); // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -7369,8 +7612,9 @@ TEST_F(AutofillMetricsTest, AddressWillSubmitFormEvents) { RecreateProfile(/*is_server=*/false); // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -7554,8 +7798,9 @@ TEST_F(AutofillMetricsTest, AddressWillSubmitFormEvents) { TEST_F(AutofillMetricsTest, RecordStandalonePhoneField) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -7578,8 +7823,9 @@ TEST_F(AutofillMetricsTest, RecordStandalonePhoneField) { TEST_F(AutofillMetricsTest, CreditCardFormEventsAreSegmented) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -7690,8 +7936,9 @@ TEST_F(AutofillMetricsTest, CreditCardFormEventsAreSegmented) { TEST_F(AutofillMetricsTest, AddressFormEventsAreSegmented) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -7800,8 +8047,9 @@ TEST_F(AutofillMetricsTest, DaysSinceLastUse_Profile) { TEST_F(AutofillMetricsTest, AutofillFormSubmittedState) { // Start with a form with insufficiently many fields. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -7864,8 +8112,8 @@ TEST_F(AutofillMetricsTest, AutofillFormSubmittedState) { } // Non fillable form. - form.fields[0].value = ASCIIToUTF16("Unknown Person"); - form.fields[1].value = ASCIIToUTF16("unknown.person@gmail.com"); + form.fields[0].value = u"Unknown Person"; + form.fields[1].value = u"unknown.person@gmail.com"; forms.front() = form; { @@ -7899,9 +8147,9 @@ TEST_F(AutofillMetricsTest, AutofillFormSubmittedState) { } // Fillable form. - form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); - form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); - form.fields[2].value = ASCIIToUTF16("12345678901"); + form.fields[0].value = u"Elvis Aaron Presley"; + form.fields[1].value = u"theking@gmail.com"; + form.fields[2].value = u"12345678901"; forms.front() = form; // Autofilled none with no suggestions shown. @@ -8055,7 +8303,7 @@ TEST_F(AutofillMetricsTest, AutofillFormSubmittedState) { } // Clear out the third field's value. - form.fields[2].value = base::string16(); + form.fields[2].value = std::u16string(); forms.front() = form; } @@ -8065,8 +8313,9 @@ TEST_F( AutofillMetricsTest, AutofillFormSubmittedState_DontCountUnfilledFieldsWithOnlyFillWhenFocused) { FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -8096,11 +8345,11 @@ TEST_F( {AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS}); histogram_tester.ExpectTotalCount("Autofill.FormSubmittedState", 0); - form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); + form.fields[0].value = u"Elvis Aaron Presley"; form.fields[0].is_autofilled = true; - form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); + form.fields[1].value = u"theking@gmail.com"; form.fields[1].is_autofilled = true; - form.fields[2].value = ASCIIToUTF16("12345678901"); + form.fields[2].value = u"12345678901"; form.fields[2].is_autofilled = true; autofill_manager_->OnFormSubmitted(form, false, @@ -8201,8 +8450,9 @@ TEST_F(AutofillMetricsTest, LogUserHappinessMetric_UnknownForm) { TEST_F(AutofillMetricsTest, UserHappinessFormInteraction_EmptyForm) { // Load a fillable form. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -8228,8 +8478,9 @@ TEST_F(AutofillMetricsTest, UserHappinessFormInteraction_CreditCardForm) { // Load a fillable form. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("https://example.com/form.html"); form.action = GURL("https://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -8398,8 +8649,9 @@ TEST_F(AutofillMetricsTest, UserHappinessFormInteraction_CreditCardForm) { TEST_F(AutofillMetricsTest, UserHappinessFormInteraction_AddressForm) { // Load a fillable form. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -8656,8 +8908,9 @@ TEST_F(AutofillMetricsTest, FormFillDuration) { // Load a fillable form. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -8674,22 +8927,23 @@ TEST_F(AutofillMetricsTest, FormFillDuration) { // Fill additional form. FormData second_form = form; - second_form.unique_renderer_id = MakeFormRendererId(); + second_form.host_frame = test::GetLocalFrameToken(); + second_form.unique_renderer_id = test::MakeFormRendererId(); test::CreateTestFormField("Second Phone", "second_phone", "", "text", &field); second_form.fields.push_back(field); std::vector<FormData> second_forms(1, second_form); // Fill the field values for form submission. - form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); - form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); - form.fields[2].value = ASCIIToUTF16("12345678901"); + form.fields[0].value = u"Elvis Aaron Presley"; + form.fields[1].value = u"theking@gmail.com"; + form.fields[2].value = u"12345678901"; // Fill the field values for form submission. - second_form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); - second_form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); - second_form.fields[2].value = ASCIIToUTF16("12345678901"); - second_form.fields[3].value = ASCIIToUTF16("51512345678"); + second_form.fields[0].value = u"Elvis Aaron Presley"; + second_form.fields[1].value = u"theking@gmail.com"; + second_form.fields[2].value = u"12345678901"; + second_form.fields[3].value = u"51512345678"; // Expect only form load metrics to be logged if the form is submitted without // user interaction. @@ -9081,8 +9335,9 @@ TEST_F(AutofillMetricsTest, ProfileActionOnFormSubmitted) { // Load a fillable form. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -9123,32 +9378,32 @@ TEST_F(AutofillMetricsTest, ProfileActionOnFormSubmitted) { std::vector<FormData> fourth_forms(1, fourth_form); // Fill the field values for the first form submission. - form.fields[0].value = ASCIIToUTF16("Albert Canuck"); - form.fields[1].value = ASCIIToUTF16("can@gmail.com"); - form.fields[2].value = ASCIIToUTF16("12345678901"); - form.fields[3].value = ASCIIToUTF16("1234 McGill street."); - form.fields[4].value = ASCIIToUTF16("Montreal"); - form.fields[5].value = ASCIIToUTF16("Canada"); - form.fields[6].value = ASCIIToUTF16("Quebec"); - form.fields[7].value = ASCIIToUTF16("A1A 1A1"); + form.fields[0].value = u"Albert Canuck"; + form.fields[1].value = u"can@gmail.com"; + form.fields[2].value = u"12345678901"; + form.fields[3].value = u"1234 McGill street."; + form.fields[4].value = u"Montreal"; + form.fields[5].value = u"Canada"; + form.fields[6].value = u"Quebec"; + form.fields[7].value = u"A1A 1A1"; // Fill the field values for the second form submission (same as first form). second_form.fields = form.fields; // Fill the field values for the third form submission. - third_form.fields[0].value = ASCIIToUTF16("Jean-Paul Canuck"); - third_form.fields[1].value = ASCIIToUTF16("can2@gmail.com"); - third_form.fields[2].value = ASCIIToUTF16(""); - third_form.fields[3].value = ASCIIToUTF16("1234 McGill street."); - third_form.fields[4].value = ASCIIToUTF16("Montreal"); - third_form.fields[5].value = ASCIIToUTF16("Canada"); - third_form.fields[6].value = ASCIIToUTF16("Quebec"); - third_form.fields[7].value = ASCIIToUTF16("A1A 1A1"); + third_form.fields[0].value = u"Jean-Paul Canuck"; + third_form.fields[1].value = u"can2@gmail.com"; + third_form.fields[2].value = u""; + third_form.fields[3].value = u"1234 McGill street."; + third_form.fields[4].value = u"Montreal"; + third_form.fields[5].value = u"Canada"; + third_form.fields[6].value = u"Quebec"; + third_form.fields[7].value = u"A1A 1A1"; // Fill the field values for the fourth form submission (same as third form // plus phone info). fourth_form.fields = third_form.fields; - fourth_form.fields[2].value = ASCIIToUTF16("12345678901"); + fourth_form.fields[2].value = u"12345678901"; // Expect to log NEW_PROFILE_CREATED for the metric since a new profile is // submitted. @@ -9208,23 +9463,24 @@ class AutofillMetricsParseQueryResponseTest : public testing::Test { public: void SetUp() override { FormData form; - form.unique_renderer_id = MakeFormRendererId(); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); form.url = GURL("http://foo.com"); form.main_frame_origin = url::Origin::Create(GURL("http://foo_root.com")); FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("fullname"); - field.name = ASCIIToUTF16("fullname"); + field.label = u"fullname"; + field.name = u"fullname"; form.fields.push_back(field); - field.label = ASCIIToUTF16("address"); - field.name = ASCIIToUTF16("address"); + field.label = u"address"; + field.name = u"address"; form.fields.push_back(field); // Checkable fields should be ignored in parsing. FormFieldData checkable_field; - checkable_field.label = ASCIIToUTF16("radio_button"); + checkable_field.label = u"radio_button"; checkable_field.form_control_type = "radio"; checkable_field.check_status = FormFieldData::CheckStatus::kCheckableButUnchecked; @@ -9233,12 +9489,12 @@ class AutofillMetricsParseQueryResponseTest : public testing::Test { owned_forms_.push_back(std::make_unique<FormStructure>(form)); forms_.push_back(owned_forms_.back().get()); - field.label = ASCIIToUTF16("email"); - field.name = ASCIIToUTF16("email"); + field.label = u"email"; + field.name = u"email"; form.fields.push_back(field); - field.label = ASCIIToUTF16("password"); - field.name = ASCIIToUTF16("password"); + field.label = u"password"; + field.name = u"password"; field.form_control_type = "password"; form.fields.push_back(field); @@ -9362,8 +9618,9 @@ TEST_F(AutofillMetricsTest, NonsecureCreditCardForm) { // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); GURL frame_origin("http://example_root.com/form.html"); @@ -9421,8 +9678,9 @@ TEST_F(AutofillMetricsTest, // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("https://example.com/form.html"); // Form action needs to be secure on secure page, otherwise this triggers // mixed form warnings and no suggestions are offered. @@ -9548,8 +9806,9 @@ TEST_F(AutofillMetricsTest, DISABLED_AutofillSuggestionShownTest) { false /* include_masked_server_credit_card */, false /* include_full_server_credit_card */); FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example_cc.com/form.html"); form.action = GURL("http://example_cc.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -9583,13 +9842,11 @@ TEST_F(AutofillMetricsTest, DISABLED_AutofillSuggestionShownTest) { } TEST_F(AutofillMetricsTest, DynamicFormMetrics) { - scoped_feature_list_.InitAndDisableFeature( - features::kAutofillRestrictUnownedFieldsToFormlessCheckout); - // Set up our form data. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); FormFieldData field; @@ -9712,8 +9969,9 @@ TEST_F(AutofillMetricsTest, LogUserHappinessBySecurityLevel) { TEST_F(AutofillMetricsTest, LogUserHappinessBySecurityLevel_FromFormEvents) { // Load a fillable form. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -10016,8 +10274,9 @@ TEST_F(AutofillMetricsTest, FrameHasNoForm) { // autocomplete="one-time-code". TEST_F(AutofillMetricsTest, FrameHasAutocompleteOneTimeCode) { FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -10048,8 +10307,9 @@ TEST_F(AutofillMetricsTest, FrameHasAutocompleteOneTimeCode) { // autocomplete="one-time-code". TEST_F(AutofillMetricsTest, FrameDoesNotHaveAutocompleteOneTimeCode) { FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -10075,8 +10335,9 @@ TEST_F(AutofillMetricsTest, FrameDoesNotHaveAutocompleteOneTimeCode) { // autocomplete attribute but there are at least 3 fields in the form. TEST_F(AutofillMetricsTest, FrameHasPhoneNumberFieldWithoutAutocomplete) { FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -10109,8 +10370,9 @@ TEST_F(AutofillMetricsTest, FrameHasPhoneNumberFieldWithoutAutocomplete) { // autocomplete attribute and there are less than 3 fields in the form. TEST_F(AutofillMetricsTest, FrameHasSinglePhoneNumberFieldWithoutAutocomplete) { FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -10157,8 +10419,9 @@ TEST_F(AutofillMetricsTest, FrameHasPhoneNumberFieldWithAutocomplete) { // field. TEST_F(AutofillMetricsTest, FrameDoesNotHavePhoneNumberField) { FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -10561,8 +10824,9 @@ TEST_P(AutofillMetricsFunnelTest, LogFunnelMetrics) { // Load a fillable form. FormData form; - form.unique_renderer_id = MakeFormRendererId(); - form.name = ASCIIToUTF16("TestForm"); + form.host_frame = test::GetLocalFrameToken(); + form.unique_renderer_id = test::MakeFormRendererId(); + form.name = u"TestForm"; form.url = GURL("http://example.com/form.html"); form.action = GURL("http://example.com/submit.html"); form.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); @@ -10716,8 +10980,8 @@ void AutofillMetricsKeyMetricsTest::SetUp() { RecreateProfile(/*is_server=*/false); // Load a fillable form. - form_.unique_renderer_id = MakeFormRendererId(); - form_.name = ASCIIToUTF16("TestForm"); + form_.unique_renderer_id = test::MakeFormRendererId(); + form_.name = u"TestForm"; form_.url = GURL("http://example.com/form.html"); form_.action = GURL("http://example.com/submit.html"); form_.main_frame_origin = url::Origin::Create(autofill_client_.form_origin()); diff --git a/chromium/components/autofill/core/browser/autofill_policy_handler.cc b/chromium/components/autofill/core/browser/autofill_policy_handler.cc index 52c72f98d04..6f1c71d45bb 100644 --- a/chromium/components/autofill/core/browser/autofill_policy_handler.cc +++ b/chromium/components/autofill/core/browser/autofill_policy_handler.cc @@ -34,8 +34,7 @@ void AutofillPolicyHandler::ApplyPolicySettings( } const base::Value* value = policies.GetValue(policy_name()); - bool autofill_enabled; - if (value && value->GetAsBoolean(&autofill_enabled) && !autofill_enabled) { + if (value && value->is_bool() && !value->GetBool()) { prefs->SetBoolean(autofill::prefs::kAutofillEnabledDeprecated, false); // Disable the fine-grained prefs if the main pref is disabled by policy. prefs->SetBoolean(autofill::prefs::kAutofillCreditCardEnabled, false); diff --git a/chromium/components/autofill/core/browser/autofill_profile_sync_util.cc b/chromium/components/autofill/core/browser/autofill_profile_sync_util.cc index 313cd9d1670..0c2feccab94 100644 --- a/chromium/components/autofill/core/browser/autofill_profile_sync_util.cc +++ b/chromium/components/autofill/core/browser/autofill_profile_sync_util.cc @@ -393,7 +393,7 @@ std::unique_ptr<AutofillProfile> CreateAutofillProfileFromSpecifics( // by a newer version of Chrome), or a country name (if set by an older // version of Chrome). // TODO(jkrcal): Move this migration logic into Address::SetRawInfo()? - base::string16 country_name_or_code = + std::u16string country_name_or_code = base::ASCIIToUTF16(specifics.address_home_country()); std::string country_code = CountryNames::GetInstance()->GetCountryCode(country_name_or_code); diff --git a/chromium/components/autofill/core/browser/autofill_profile_sync_util_unittest.cc b/chromium/components/autofill/core/browser/autofill_profile_sync_util_unittest.cc index 1388ab1f0c7..3db6a4ae3d2 100644 --- a/chromium/components/autofill/core/browser/autofill_profile_sync_util_unittest.cc +++ b/chromium/components/autofill/core/browser/autofill_profile_sync_util_unittest.cc @@ -43,34 +43,32 @@ AutofillProfile ConstructCompleteProfile() { profile.set_use_date(base::Time::FromTimeT(1423182152)); // Set testing values and statuses for the name. - profile.SetRawInfoWithVerificationStatus(NAME_HONORIFIC_PREFIX, - ASCIIToUTF16("Dr."), + profile.SetRawInfoWithVerificationStatus(NAME_HONORIFIC_PREFIX, u"Dr.", VerificationStatus::kObserved); profile.SetRawInfoWithVerificationStatus(NAME_FULL_WITH_HONORIFIC_PREFIX, - ASCIIToUTF16("Dr. John K. Doe"), + u"Dr. John K. Doe", VerificationStatus::kFormatted); - profile.SetRawInfoWithVerificationStatus(NAME_FULL, - ASCIIToUTF16("John K. Doe"), + profile.SetRawInfoWithVerificationStatus(NAME_FULL, u"John K. Doe", VerificationStatus::kUserVerified); - profile.SetRawInfoWithVerificationStatus(NAME_FIRST, ASCIIToUTF16("John"), + profile.SetRawInfoWithVerificationStatus(NAME_FIRST, u"John", VerificationStatus::kObserved); - profile.SetRawInfoWithVerificationStatus(NAME_MIDDLE, ASCIIToUTF16("K."), + profile.SetRawInfoWithVerificationStatus(NAME_MIDDLE, u"K.", VerificationStatus::kObserved); - profile.SetRawInfoWithVerificationStatus(NAME_LAST, ASCIIToUTF16("Doe"), + profile.SetRawInfoWithVerificationStatus(NAME_LAST, u"Doe", VerificationStatus::kFormatted); - profile.SetRawInfoWithVerificationStatus(NAME_LAST_FIRST, ASCIIToUTF16("D"), + profile.SetRawInfoWithVerificationStatus(NAME_LAST_FIRST, u"D", VerificationStatus::kParsed); - profile.SetRawInfoWithVerificationStatus(NAME_LAST_SECOND, ASCIIToUTF16("e"), + profile.SetRawInfoWithVerificationStatus(NAME_LAST_SECOND, u"e", + VerificationStatus::kParsed); + profile.SetRawInfoWithVerificationStatus(NAME_LAST_CONJUNCTION, u"o", VerificationStatus::kParsed); - profile.SetRawInfoWithVerificationStatus( - NAME_LAST_CONJUNCTION, ASCIIToUTF16("o"), VerificationStatus::kParsed); // Set email, phone and company testing values. - profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("user@example.com")); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("1.800.555.1234")); - profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Google, Inc.")); + profile.SetRawInfo(EMAIL_ADDRESS, u"user@example.com"); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"1.800.555.1234"); + profile.SetRawInfo(COMPANY_NAME, u"Google, Inc."); profile.SetRawInfoWithVerificationStatus( ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("123 Fake St. Dep Premise\n" @@ -78,55 +76,48 @@ AutofillProfile ConstructCompleteProfile() { VerificationStatus::kObserved); // Set testing values and statuses for the address. - EXPECT_EQ(ASCIIToUTF16("123 Fake St. Dep Premise"), + EXPECT_EQ(u"123 Fake St. Dep Premise", profile.GetRawInfo(ADDRESS_HOME_LINE1)); - EXPECT_EQ(ASCIIToUTF16("Apt. 10 Floor 2"), - profile.GetRawInfo(ADDRESS_HOME_LINE2)); + EXPECT_EQ(u"Apt. 10 Floor 2", profile.GetRawInfo(ADDRESS_HOME_LINE2)); - profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_CITY, - ASCIIToUTF16("Mountain View"), + profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_CITY, u"Mountain View", VerificationStatus::kObserved); - profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_STATE, - ASCIIToUTF16("California"), + profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_STATE, u"California", VerificationStatus::kObserved); - profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_ZIP, ASCIIToUTF16("94043"), VerificationStatus::kObserved); + profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_ZIP, u"94043", + VerificationStatus::kObserved); - profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), VerificationStatus::kObserved); + profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_COUNTRY, u"US", + VerificationStatus::kObserved); - profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_SORTING_CODE, - ASCIIToUTF16("CEDEX"), + profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_SORTING_CODE, u"CEDEX", VerificationStatus::kObserved); profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_DEPENDENT_LOCALITY, - ASCIIToUTF16("Santa Clara"), + u"Santa Clara", VerificationStatus::kObserved); - profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_STREET_NAME, - ASCIIToUTF16("Fake St."), - VerificationStatus::kFormatted); + profile.SetRawInfoWithVerificationStatus( + ADDRESS_HOME_STREET_NAME, u"Fake St.", VerificationStatus::kFormatted); profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_DEPENDENT_STREET_NAME, - ASCIIToUTF16("Dep"), + u"Dep", VerificationStatus::kFormatted); - profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_HOUSE_NUMBER, - ASCIIToUTF16("123"), + profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_HOUSE_NUMBER, u"123", VerificationStatus::kFormatted); profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_SUBPREMISE, - ASCIIToUTF16("Apt. 10 Floor 2"), + u"Apt. 10 Floor 2", VerificationStatus::kObserved); - profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_APT_NUM, ASCIIToUTF16("10"), VerificationStatus::kParsed); - profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_FLOOR, ASCIIToUTF16("2"), VerificationStatus::kParsed); + profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_APT_NUM, u"10", + VerificationStatus::kParsed); + profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_FLOOR, u"2", + VerificationStatus::kParsed); - profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_PREMISE_NAME, - ASCIIToUTF16("Premise"), - VerificationStatus::kFormatted); + profile.SetRawInfoWithVerificationStatus( + ADDRESS_HOME_PREMISE_NAME, u"Premise", VerificationStatus::kFormatted); profile.set_language_code("en"); profile.SetClientValidityFromBitfieldValue(1984); profile.set_is_client_validity_states_updated(true); diff --git a/chromium/components/autofill/core/browser/autofill_profile_validation_util.cc b/chromium/components/autofill/core/browser/autofill_profile_validation_util.cc index aabb458d126..437fb53d36a 100644 --- a/chromium/components/autofill/core/browser/autofill_profile_validation_util.cc +++ b/chromium/components/autofill/core/browser/autofill_profile_validation_util.cc @@ -323,7 +323,7 @@ void ValidateAddressStrictly(const AutofillProfile* profile, } void ValidateEmailAddress(const AutofillProfile* profile) { - const base::string16& email = profile->GetRawInfo(EMAIL_ADDRESS); + const std::u16string& email = profile->GetRawInfo(EMAIL_ADDRESS); if (email.empty()) { profile->SetValidityState(EMAIL_ADDRESS, AutofillDataModel::EMPTY, AutofillDataModel::CLIENT); diff --git a/chromium/components/autofill/core/browser/autofill_profile_validation_util_unittest.cc b/chromium/components/autofill/core/browser/autofill_profile_validation_util_unittest.cc index 59a29b7a650..9cc3178de9c 100644 --- a/chromium/components/autofill/core/browser/autofill_profile_validation_util_unittest.cc +++ b/chromium/components/autofill/core/browser/autofill_profile_validation_util_unittest.cc @@ -136,7 +136,7 @@ TEST_F(AutofillProfileValidationUtilTest, // This is a profile with no country code, therefore it cannot be validated // according to contryinfo.txt. AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(ADDRESS_HOME_COUNTRY, base::UTF8ToUTF16("")); + profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u""); ValidateAddressTest(&profile); EXPECT_EQ(AutofillDataModel::EMPTY, profile.GetValidityState(ADDRESS_HOME_COUNTRY, @@ -209,7 +209,7 @@ TEST_F(AutofillProfileValidationUtilTest, ValidateAddress_AdminAreaNotExists) { TEST_F(AutofillProfileValidationUtilTest, ValidateAddress_EmptyAdminArea) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::UTF8ToUTF16("")); + profile.SetRawInfo(ADDRESS_HOME_STATE, u""); ValidateAddressTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, @@ -402,7 +402,7 @@ TEST_F(AutofillProfileValidationUtilTest, ValidateAddress_InvalidZip) { TEST_F(AutofillProfileValidationUtilTest, ValidateAddress_EmptyZip) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(ADDRESS_HOME_ZIP, base::UTF8ToUTF16("")); + profile.SetRawInfo(ADDRESS_HOME_ZIP, u""); ValidateAddressTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, @@ -427,7 +427,7 @@ TEST_F(AutofillProfileValidationUtilTest, ValidateAddress_EmptyCity) { // field, the field is required. Therefore, a profile without a city field // would be an invalid profile. AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(ADDRESS_HOME_CITY, base::UTF8ToUTF16("")); + profile.SetRawInfo(ADDRESS_HOME_CITY, u""); ValidateAddressTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, @@ -449,10 +449,10 @@ TEST_F(AutofillProfileValidationUtilTest, ValidateAddress_EmptyCity) { TEST_F(AutofillProfileValidationUtilTest, ValidateFullProfile_EmptyFields) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(ADDRESS_HOME_COUNTRY, base::UTF8ToUTF16("")); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::UTF8ToUTF16("")); - profile.SetRawInfo(ADDRESS_HOME_CITY, base::UTF8ToUTF16("")); - profile.SetRawInfo(ADDRESS_HOME_ZIP, base::UTF8ToUTF16("")); + profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u""); + profile.SetRawInfo(ADDRESS_HOME_STATE, u""); + profile.SetRawInfo(ADDRESS_HOME_CITY, u""); + profile.SetRawInfo(ADDRESS_HOME_ZIP, u""); ValidateAddressTest(&profile); EXPECT_EQ(AutofillDataModel::EMPTY, @@ -590,7 +590,7 @@ TEST_F(AutofillProfileValidationUtilTest, // China has a dependent locality field (aka district), but it's not required. AutofillProfile profile(autofill::test::GetFullValidProfileForChina()); - profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, base::UTF8ToUTF16("")); + profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u""); ValidateAddressTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, @@ -616,7 +616,7 @@ TEST_F(AutofillProfileValidationUtilTest, // but we should still validate it. AutofillProfile profile(autofill::test::GetFullValidProfileForChina()); - profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, base::UTF8ToUTF16("赫")); + profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u"赫"); ValidateAddressTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, @@ -644,8 +644,7 @@ TEST_F(AutofillProfileValidationUtilTest, // the district should be considered as INVALID. AutofillProfile profile(autofill::test::GetFullValidProfileForChina()); - profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, - base::UTF8ToUTF16("蒙城县")); + profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u"蒙城县"); ValidateAddressTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, @@ -679,7 +678,7 @@ TEST_F(AutofillProfileValidationUtilTest, ValidatePhone_FullValidProfile) { TEST_F(AutofillProfileValidationUtilTest, ValidatePhone_EmptyPhoneNumber) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, base::string16()); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, std::u16string()); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::EMPTY, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, @@ -706,7 +705,7 @@ TEST_F(AutofillProfileValidationUtilTest, const std::string country_code = "PP"; AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); profile.SetRawInfo(ADDRESS_HOME_COUNTRY, base::UTF8ToUTF16(country_code)); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, base::string16()); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, std::u16string()); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::EMPTY, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, @@ -715,34 +714,31 @@ TEST_F(AutofillProfileValidationUtilTest, TEST_F(AutofillProfileValidationUtilTest, ValidatePhone_InvalidPhoneNumber) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, base::ASCIIToUTF16("33")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"33"); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::INVALID, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, AutofillDataModel::CLIENT)); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::ASCIIToUTF16("151411122334")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"151411122334"); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::INVALID, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, AutofillDataModel::CLIENT)); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::ASCIIToUTF16("1(514)111-22-334")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"1(514)111-22-334"); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::INVALID, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, AutofillDataModel::CLIENT)); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::ASCIIToUTF16("251411122334")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"251411122334"); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::INVALID, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, AutofillDataModel::CLIENT)); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, base::ASCIIToUTF16("Hello!")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"Hello!"); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::INVALID, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, @@ -751,56 +747,49 @@ TEST_F(AutofillProfileValidationUtilTest, ValidatePhone_InvalidPhoneNumber) { TEST_F(AutofillProfileValidationUtilTest, ValidatePhone_ValidPhoneNumber) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, base::ASCIIToUTF16("5141112233")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"5141112233"); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, AutofillDataModel::CLIENT)); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::ASCIIToUTF16("514-111-2233")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"514-111-2233"); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, AutofillDataModel::CLIENT)); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::ASCIIToUTF16("1(514)111-22-33")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"1(514)111-22-33"); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, AutofillDataModel::CLIENT)); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::ASCIIToUTF16("+1 514 111 22 33")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"+1 514 111 22 33"); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, AutofillDataModel::CLIENT)); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::ASCIIToUTF16("+1 (514)-111-22-33")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"+1 (514)-111-22-33"); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, AutofillDataModel::CLIENT)); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::ASCIIToUTF16("(514)-111-22-33")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"(514)-111-22-33"); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, AutofillDataModel::CLIENT)); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::ASCIIToUTF16("+1 650 GOO OGLE")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"+1 650 GOO OGLE"); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, AutofillDataModel::CLIENT)); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::ASCIIToUTF16("778 111 22 33")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"778 111 22 33"); ValidatePhoneTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, profile.GetValidityState(PHONE_HOME_WHOLE_NUMBER, @@ -818,7 +807,7 @@ TEST_F(AutofillProfileValidationUtilTest, ValidateEmail_FullValidProfile) { TEST_F(AutofillProfileValidationUtilTest, ValidateEmail_EmptyEmailAddress) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(EMAIL_ADDRESS, base::string16()); + profile.SetRawInfo(EMAIL_ADDRESS, std::u16string()); ValidateEmailTest(&profile); EXPECT_EQ(AutofillDataModel::EMPTY, profile.GetValidityState(EMAIL_ADDRESS, AutofillDataModel::CLIENT)); @@ -827,23 +816,22 @@ TEST_F(AutofillProfileValidationUtilTest, ValidateEmail_EmptyEmailAddress) { TEST_F(AutofillProfileValidationUtilTest, ValidateEmail_ValidateInvalidEmailAddress) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("Hello!")); + profile.SetRawInfo(EMAIL_ADDRESS, u"Hello!"); ValidateEmailTest(&profile); EXPECT_EQ(AutofillDataModel::INVALID, profile.GetValidityState(EMAIL_ADDRESS, AutofillDataModel::CLIENT)); - profile.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("alice.wonderland")); + profile.SetRawInfo(EMAIL_ADDRESS, u"alice.wonderland"); ValidateEmailTest(&profile); EXPECT_EQ(AutofillDataModel::INVALID, profile.GetValidityState(EMAIL_ADDRESS, AutofillDataModel::CLIENT)); - profile.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("alice@")); + profile.SetRawInfo(EMAIL_ADDRESS, u"alice@"); ValidateEmailTest(&profile); EXPECT_EQ(AutofillDataModel::INVALID, profile.GetValidityState(EMAIL_ADDRESS, AutofillDataModel::CLIENT)); - profile.SetRawInfo(EMAIL_ADDRESS, - base::ASCIIToUTF16("alice@=wonderland.com")); + profile.SetRawInfo(EMAIL_ADDRESS, u"alice@=wonderland.com"); ValidateEmailTest(&profile); EXPECT_EQ(AutofillDataModel::INVALID, profile.GetValidityState(EMAIL_ADDRESS, AutofillDataModel::CLIENT)); @@ -852,19 +840,17 @@ TEST_F(AutofillProfileValidationUtilTest, TEST_F(AutofillProfileValidationUtilTest, ValidateEmail_ValidEmailAddress) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("alice@wonderland")); + profile.SetRawInfo(EMAIL_ADDRESS, u"alice@wonderland"); ValidateEmailTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, profile.GetValidityState(EMAIL_ADDRESS, AutofillDataModel::CLIENT)); - profile.SetRawInfo(EMAIL_ADDRESS, - base::ASCIIToUTF16("alice@wonderland.fiction")); + profile.SetRawInfo(EMAIL_ADDRESS, u"alice@wonderland.fiction"); ValidateEmailTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, profile.GetValidityState(EMAIL_ADDRESS, AutofillDataModel::CLIENT)); - profile.SetRawInfo(EMAIL_ADDRESS, - base::ASCIIToUTF16("alice+cat@wonderland.fiction.book")); + profile.SetRawInfo(EMAIL_ADDRESS, u"alice+cat@wonderland.fiction.book"); ValidateEmailTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, profile.GetValidityState(EMAIL_ADDRESS, AutofillDataModel::CLIENT)); @@ -894,7 +880,7 @@ TEST_F(AutofillProfileValidationUtilTest, ValidateProfile_FullValidProfileWithInvalidZip) { // This is a full valid profile: AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(ADDRESS_HOME_ZIP, base::UTF8ToUTF16("ABC 123")); + profile.SetRawInfo(ADDRESS_HOME_ZIP, u"ABC 123"); ValidateProfileTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, profile.GetValidityState(ADDRESS_HOME_COUNTRY, @@ -922,7 +908,7 @@ TEST_F(AutofillProfileValidationUtilTest, ValidateProfile_FullValidProfileWithInvalidPhone) { // This is a full valid profile: AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, base::ASCIIToUTF16("33")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"33"); ValidateProfileTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, profile.GetValidityState(ADDRESS_HOME_COUNTRY, @@ -950,7 +936,7 @@ TEST_F(AutofillProfileValidationUtilTest, ValidateProfile_FullValidProfileWithInvalidEmail) { // This is a full valid profile: AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("fakeaddress")); + profile.SetRawInfo(EMAIL_ADDRESS, u"fakeaddress"); ValidateProfileTest(&profile); EXPECT_EQ(AutofillDataModel::VALID, profile.GetValidityState(ADDRESS_HOME_COUNTRY, @@ -981,7 +967,7 @@ TEST_F(AutofillProfileValidationUtilTest, // Address Line 2: "Apt 8", City: "Montreal", Province: "QC", // Postal Code: "H3B 2T9", Country Code: "CN", AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(ADDRESS_HOME_COUNTRY, base::ASCIIToUTF16("CN")); + profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"CN"); ValidateProfileTest(&profile); // The fields that depend on country (state and zip) are both invalid, @@ -1022,7 +1008,7 @@ TEST_F(AutofillProfileValidationUtilTest, // District: "赫章县", City: "毕节地区", Province: "贵州省", // Postal Code: "200120", Country Code: "CA", AutofillProfile profile(autofill::test::GetFullValidProfileForChina()); - profile.SetRawInfo(ADDRESS_HOME_COUNTRY, base::ASCIIToUTF16("CA")); + profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"CA"); ValidateProfileTest(&profile); @@ -1066,7 +1052,7 @@ TEST_F(AutofillProfileValidationUtilTest, // District: "赫章县", City: "毕节地区", Province: "海南省", // Postal Code: "200120", Country Code: "CN", AutofillProfile profile(autofill::test::GetFullValidProfileForChina()); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::UTF8ToUTF16("海南省")); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"海南省"); ValidateProfileTest(&profile); @@ -1107,7 +1093,7 @@ TEST_F(AutofillProfileValidationUtilTest, // District: "赫章县", City: "毕节地区", Province: "", // Postal Code: "200120", Country Code: "CN", AutofillProfile profile(autofill::test::GetFullValidProfileForChina()); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::UTF8ToUTF16("")); + profile.SetRawInfo(ADDRESS_HOME_STATE, u""); ValidateProfileTest(&profile); diff --git a/chromium/components/autofill/core/browser/autofill_profile_validator_unittest.cc b/chromium/components/autofill/core/browser/autofill_profile_validator_unittest.cc index 545c62144a8..8f12fd91972 100644 --- a/chromium/components/autofill/core/browser/autofill_profile_validator_unittest.cc +++ b/chromium/components/autofill/core/browser/autofill_profile_validator_unittest.cc @@ -201,7 +201,7 @@ TEST_F(AutofillProfileValidatorTest, ValidateAddress_RuleNotExists) { // When country code is empty, the profile is unvalidated. TEST_F(AutofillProfileValidatorTest, ValidateAddress_EmptyCountryCode) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(ADDRESS_HOME_COUNTRY, base::string16()); + profile.SetRawInfo(ADDRESS_HOME_COUNTRY, std::u16string()); EXPECT_EQ(false, AreRulesLoadedForRegion("")); @@ -221,8 +221,7 @@ TEST_F(AutofillProfileValidatorTest, ValidateAddress_EmptyCountryCode) { // Validate a profile with an invalid phone. TEST_F(AutofillProfileValidatorTest, StartProfileValidation_InvalidPhone) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::UTF8ToUTF16("Invalid Phone")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"Invalid Phone"); // Set up the test expectations. expected_validity_ = { @@ -241,7 +240,7 @@ TEST_F(AutofillProfileValidatorTest, StartProfileValidation_InvalidPhone) { // Validate a profile with a valid phone, valid email and invalid address. TEST_F(AutofillProfileValidatorTest, StartProfileValidation_InvalidAddress) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::UTF8ToUTF16("Invalid State")); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"Invalid State"); // Set up the test expectations. expected_validity_ = { @@ -261,8 +260,8 @@ TEST_F(AutofillProfileValidatorTest, StartProfileValidation_InvalidAddress) { TEST_F(AutofillProfileValidatorTest, StartProfileValidation_EmptyPhone_InvalidAddress) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, base::string16()); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::UTF8ToUTF16("Invalid State")); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, std::u16string()); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"Invalid State"); // Set up the test expectations. expected_validity_ = { @@ -282,8 +281,8 @@ TEST_F(AutofillProfileValidatorTest, TEST_F(AutofillProfileValidatorTest, StartProfileValidation_InvalidEmail_InvalidAddress) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("Invalid Email")); - profile.SetRawInfo(ADDRESS_HOME_ZIP, base::UTF8ToUTF16("Invalid Zip")); + profile.SetRawInfo(EMAIL_ADDRESS, u"Invalid Email"); + profile.SetRawInfo(ADDRESS_HOME_ZIP, u"Invalid Zip"); // Set up the test expectations. expected_validity_ = { @@ -303,8 +302,8 @@ TEST_F(AutofillProfileValidatorTest, TEST_F(AutofillProfileValidatorTest, StartProfileValidation_EmptyEmail_InvalidZip) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(EMAIL_ADDRESS, base::string16()); - profile.SetRawInfo(ADDRESS_HOME_ZIP, base::UTF8ToUTF16("Invalid Zip")); + profile.SetRawInfo(EMAIL_ADDRESS, std::u16string()); + profile.SetRawInfo(ADDRESS_HOME_ZIP, u"Invalid Zip"); // Set up the test expectations. expected_validity_ = { @@ -324,8 +323,8 @@ TEST_F(AutofillProfileValidatorTest, TEST_F(AutofillProfileValidatorTest, StartProfileValidation_InvalidEmail_EmptyZip) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(EMAIL_ADDRESS, base::UTF8ToUTF16("Invalid Email")); - profile.SetRawInfo(ADDRESS_HOME_ZIP, base::string16()); + profile.SetRawInfo(EMAIL_ADDRESS, u"Invalid Email"); + profile.SetRawInfo(ADDRESS_HOME_ZIP, std::u16string()); // Set up the test expectations. expected_validity_ = { @@ -345,9 +344,8 @@ TEST_F(AutofillProfileValidatorTest, TEST_F(AutofillProfileValidatorTest, StartProfileValidation_InvalidEmail_InvalidPhone) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("Invalid Email")); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::UTF8ToUTF16("Invalid Phone")); + profile.SetRawInfo(EMAIL_ADDRESS, u"Invalid Email"); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"Invalid Phone"); // Set up the test expectations. expected_validity_ = { @@ -366,7 +364,7 @@ TEST_F(AutofillProfileValidatorTest, // Validate a profile with an invalid email. TEST_F(AutofillProfileValidatorTest, StartProfileValidation_InvalidEmail) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("Invalid Email")); + profile.SetRawInfo(EMAIL_ADDRESS, u"Invalid Email"); // Set up the test expectations. expected_validity_ = { @@ -386,10 +384,9 @@ TEST_F(AutofillProfileValidatorTest, StartProfileValidation_InvalidEmail) { TEST_F(AutofillProfileValidatorTest, StartProfileValidation_InvalidEmail_InvalidPhone_InvalidAddress) { AutofillProfile profile(autofill::test::GetFullValidProfileForCanada()); - profile.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("Invalid Email.")); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::UTF8ToUTF16("Invalid Phone")); - profile.SetRawInfo(ADDRESS_HOME_STATE, base::UTF8ToUTF16("Invalid State")); + profile.SetRawInfo(EMAIL_ADDRESS, u"Invalid Email."); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"Invalid Phone"); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"Invalid State"); // Set up the test expectations. expected_validity_ = { diff --git a/chromium/components/autofill/core/browser/autofill_provider.cc b/chromium/components/autofill/core/browser/autofill_provider.cc index 0c6c3c5f60e..7c87efad75f 100644 --- a/chromium/components/autofill/core/browser/autofill_provider.cc +++ b/chromium/components/autofill/core/browser/autofill_provider.cc @@ -33,8 +33,9 @@ void AutofillProvider::SendFormDataToRenderer(AutofillHandlerProxy* handler, void AutofillProvider::RendererShouldAcceptDataListSuggestion( AutofillHandlerProxy* handler, - const base::string16& value) { - handler->driver()->RendererShouldAcceptDataListSuggestion(value); + const FieldGlobalId& field_id, + const std::u16string& value) { + handler->driver()->RendererShouldAcceptDataListSuggestion(field_id, value); } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/autofill_provider.h b/chromium/components/autofill/core/browser/autofill_provider.h index 4ea027b0d67..650a93c580d 100644 --- a/chromium/components/autofill/core/browser/autofill_provider.h +++ b/chromium/components/autofill/core/browser/autofill_provider.h @@ -85,9 +85,10 @@ class AutofillProvider { const FormData& formData); // Notifies the renderer should accept the datalist suggestion given by - // |value| and fill the associated input field. + // |value| and fill the input field indified by |field_id|. void RendererShouldAcceptDataListSuggestion(AutofillHandlerProxy* handler, - const base::string16& value); + const FieldGlobalId& field_id, + const std::u16string& value); }; } // namespace autofill diff --git a/chromium/components/autofill/core/browser/autofill_regex_constants.cc b/chromium/components/autofill/core/browser/autofill_regex_constants.cc index ae58f14698e..b561b56d45c 100644 --- a/chromium/components/autofill/core/browser/autofill_regex_constants.cc +++ b/chromium/components/autofill/core/browser/autofill_regex_constants.cc @@ -2,9 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// This file contains UTF8 strings that we want as char arrays. To avoid -// different compilers, we use a script to convert the UTF8 strings into -// numeric literals (\x##). +// This file contains UTF16 strings that we want as char16_t arrays. #include "components/autofill/core/browser/autofill_regex_constants.h" @@ -13,233 +11,233 @@ namespace autofill { ///////////////////////////////////////////////////////////////////////////// // address_field.cc ///////////////////////////////////////////////////////////////////////////// -const char kAttentionIgnoredRe[] = "attention|attn"; -const char kRegionIgnoredRe[] = - "province|region|other" - "|provincia" // es - "|bairro|suburb"; // pt-BR, pt-PT -const char kAddressNameIgnoredRe[] = - "address.*nickname|address.*label" - "|adres ([İi]sim|başlığı|adı)" // tr - "|identificação do endereço" // pt-BR, pt-PT - "|(label|judul|nama) alamat"; // id -const char kCompanyRe[] = - "company|business|organization|organisation" - "|(?<!con)firma|firmenname" // de-DE - "|empresa" // es - "|societe|société" // fr-FR - "|ragione.?sociale" // it-IT - "|会社" // ja-JP - "|название.?компании" // ru - "|单位|公司" // zh-CN - "|شرکت" // fa - "|회사|직장" // ko-KR - "|(nama.?)?perusahaan"; // id -const char kStreetNameRe[] = - "stra(ss|ß)e" // de - "|street" // en - "|улица|название.?улицы" // ru - "|rua|avenida" // pt-PT, pt-BR - "|((?<!do |de )endereço)" // pt-BR - "|calle"; // es-MX -const char kHouseNumberRe[] = - "(house.?|street.?|^)number" // en - "|(haus|^)nummer" // de - "|^\\*?.?número(.?\\*?$| da residência)" // pt-BR, pt-PT - "|дом|номер.?дома" // ru - "|exterior"; // es-MX -const char kApartmentNumberRe[] = - "apartment" // en - "|interior" // es-MX - "|n(u|ú)mero.*app?art(a|e)ment" // es,fr,it - "|Wohnung" // de - "|квартир"; // ru -const char kAddressLine1Re[] = - "^address$|address[_-]?line(one)?|address1|addr1|street" - "|(?:shipping|billing)address$" - "|strasse|straße|hausnummer|housenumber" // de-DE - "|house.?name" // en-GB - "|direccion|dirección" // es - "|adresse" // fr-FR - "|indirizzo" // it-IT - "|^住所$|住所1" // ja-JP - "|morada|((?<!do |de )endereço)" // pt-BR, pt-PT - "|Адрес" // ru - "|地址" // zh-CN - "|(\\b|_)adres(?! tarifi)(\\b|_)" // tr - "|^주소.?$|주소.?1" // ko-KR - "|^alamat"; // id -const char kAddressLine1LabelRe[] = - "(^\\W*address)" - "|(address\\W*$)" - "|(?:shipping|billing|mailing|pick.?up|drop.?off|delivery|sender|postal|" - "recipient|home|work|office|school|business|mail)[\\s\\-]+address" - "|address\\s+(of|for|to|from)" - "|adresse" // fr-FR - "|indirizzo" // it-IT - "|住所" // ja-JP - "|地址" // zh-CN - "|(\\b|_)adres(?! tarifi)(\\b|_)" // tr - "|주소" // ko-KR - "|^alamat" // id +const char16_t kAttentionIgnoredRe[] = u"attention|attn"; +const char16_t kRegionIgnoredRe[] = + u"province|region|other" + u"|provincia" // es + u"|bairro|suburb"; // pt-BR, pt-PT +const char16_t kAddressNameIgnoredRe[] = + u"address.*nickname|address.*label" + u"|adres ([İi]sim|başlığı|adı)" // tr + u"|identificação do endereço" // pt-BR, pt-PT + u"|(label|judul|nama) alamat"; // id +const char16_t kCompanyRe[] = + u"company|business|organization|organisation" + u"|(?<!con)firma|firmenname" // de-DE + u"|empresa" // es + u"|societe|société" // fr-FR + u"|ragione.?sociale" // it-IT + u"|会社" // ja-JP + u"|название.?компании" // ru + u"|单位|公司" // zh-CN + u"|شرکت" // fa + u"|회사|직장" // ko-KR + u"|(nama.?)?perusahaan"; // id +const char16_t kStreetNameRe[] = + u"stra(ss|ß)e" // de + u"|street" // en + u"|улица|название.?улицы" // ru + u"|rua|avenida" // pt-PT, pt-BR + u"|((?<!do |de )endereço)" // pt-BR + u"|calle"; // es-MX +const char16_t kHouseNumberRe[] = + u"(house.?|street.?|^)number" // en + u"|(haus|^)nummer" // de + u"|^\\*?.?número(.?\\*?$| da residência)" // pt-BR, pt-PT + u"|дом|номер.?дома" // ru + u"|exterior"; // es-MX +const char16_t kApartmentNumberRe[] = + u"apartment" // en + u"|interior" // es-MX + u"|n(u|ú)mero.*app?art(a|e)ment" // es,fr,it + u"|Wohnung" // de + u"|квартир"; // ru +const char16_t kAddressLine1Re[] = + u"^address$|address[_-]?line(one)?|address1|addr1|street" + u"|(?:shipping|billing)address$" + u"|strasse|straße|hausnummer|housenumber" // de-DE + u"|house.?name" // en-GB + u"|direccion|dirección" // es + u"|adresse" // fr-FR + u"|indirizzo" // it-IT + u"|^住所$|住所1" // ja-JP + u"|morada|((?<!do |de )endereço)" // pt-BR, pt-PT + u"|Адрес" // ru + u"|地址" // zh-CN + u"|(\\b|_)adres(?! tarifi)(\\b|_)" // tr + u"|^주소.?$|주소.?1" // ko-KR + u"|^alamat"; // id +const char16_t kAddressLine1LabelRe[] = + u"(^\\W*address)" + u"|(address\\W*$)" + u"|(?:shipping|billing|mailing|pick.?up|drop.?off|delivery|sender|postal|" + u"recipient|home|work|office|school|business|mail)[\\s\\-]+address" + u"|address\\s+(of|for|to|from)" + u"|adresse" // fr-FR + u"|indirizzo" // it-IT + u"|住所" // ja-JP + u"|地址" // zh-CN + u"|(\\b|_)adres(?! tarifi)(\\b|_)" // tr + u"|주소" // ko-KR + u"|^alamat" // id // Should contain street and any other address component, in any order - "|street.*(house|building|apartment|floor)" // en - "|(house|building|apartment|floor).*street" - "|(sokak|cadde).*(apartman|bina|daire|mahalle)" // tr - "|(apartman|bina|daire|mahalle).*(sokak|cadde)" - "|улиц.*(дом|корпус|квартир|этаж)|(дом|корпус|квартир|этаж).*улиц"; // ru -const char kAddressLine2Re[] = - "address[_-]?line(2|two)|address2|addr2|street|suite|unit" - "|adresszusatz|ergänzende.?angaben" // de-DE - "|direccion2|colonia|adicional" // es - "|addresssuppl|complementnom|appartement" // fr-FR - "|indirizzo2" // it-IT - "|住所2" // ja-JP - "|complemento|addrcomplement" // pt-BR, pt-PT - "|Улица" // ru - "|地址2" // zh-CN - "|주소.?2"; // ko-KR -const char kAddressLine2LabelRe[] = - "address|line" - "|adresse" // fr-FR - "|indirizzo" // it-IT - "|地址" // zh-CN - "|주소"; // ko-KR -const char kAddressLinesExtraRe[] = - "address.*line[3-9]|address[3-9]|addr[3-9]|street|line[3-9]" - "|municipio" // es - "|batiment|residence" // fr-FR - "|indirizzo[3-9]"; // it-IT -const char kAddressLookupRe[] = "lookup"; -const char kCountryRe[] = - "country|countries" - "|país|pais" // es - "|(\\b|_)land(\\b|_)(?!.*(mark.*))" // de-DE landmark is a type in india. - "|(?<!(入|出))国" // ja-JP - "|国家" // zh-CN - "|국가|나라" // ko-KR - "|(\\b|_)(ülke|ulce|ulke)(\\b|_)" // tr - "|کشور" // fa - "|negara"; // id -const char kCountryLocationRe[] = "location"; -const char kZipCodeRe[] = - "zip|postal|post.*code|pcode" - "|pin.?code" // en-IN - "|postleitzahl" // de-DE - "|\\bcp\\b" // es - "|\\bcdp\\b" // fr-FR - "|\\bcap\\b" // it-IT - "|郵便番号" // ja-JP - "|codigo|codpos|\\bcep\\b" // pt-BR, pt-PT - "|Почтовый.?Индекс" // ru - "|पिन.?कोड" // hi - "|പിന്കോഡ്" // ml - "|邮政编码|邮编" // zh-CN - "|郵遞區號" // zh-TW - "|(\\b|_)posta kodu(\\b|_)" // tr - "|우편.?번호" // ko-KR - "|kode.?pos"; // id -const char kZip4Re[] = - "zip|^-$|post2" - "|codpos2"; // pt-BR, pt-PT -const char kDependentLocalityRe[] = - "neighbo(u)?rhood" // en - "|bairro" // pt-BR, pt-PT - "|mahalle|köy" // tr - "|kecamatan"; // id -const char kCityRe[] = - "city|town" - "|\\bort\\b|stadt" // de-DE - "|suburb" // en-AU - "|ciudad|provincia|localidad|poblacion" // es - "|ville|commune" // fr-FR - "|localita" // it-IT - "|市区町村" // ja-JP - "|cidade|município" // pt-BR, pt-PT - "|Город|Насел(е|ё)нный.?пункт" // ru - "|市" // zh-CN - "|分區" // zh-TW - "|شهر" // fa - "|शहर" // hi for city - "|ग्राम|गाँव" // hi for village - "|നഗരം|ഗ്രാമം" // ml for town|village - "|((\\b|_|\\*)([İii̇]l[cç]e(miz|niz)?)(\\b|_|\\*))" // tr - "|^시[^도·・]|시[·・]?군[·・]?구" // ko-KR - "|kota|kabupaten"; // id -const char kStateRe[] = - "(?<!(united|hist|history).?)state|county|region|province" - "|county|principality" // en-UK - "|都道府県" // ja-JP - "|estado|provincia" // pt-BR, pt-PT - "|область" // ru - "|省" // zh-CN - "|地區" // zh-TW - "|സംസ്ഥാനം" // ml - "|استان" // fa - "|राज्य" // hi - "|((\\b|_|\\*)(eyalet|[şs]ehir|[İii̇]l(imiz)?|kent)(\\b|_|\\*))" // tr - "|^시[·・]?도" // ko-KR - "|provinci"; // id + u"|street.*(house|building|apartment|floor)" // en + u"|(house|building|apartment|floor).*street" + u"|(sokak|cadde).*(apartman|bina|daire|mahalle)" // tr + u"|(apartman|bina|daire|mahalle).*(sokak|cadde)" + u"|улиц.*(дом|корпус|квартир|этаж)|(дом|корпус|квартир|этаж).*улиц"; // ru +const char16_t kAddressLine2Re[] = + u"address[_-]?line(2|two)|address2|addr2|street|suite|unit" + u"|adresszusatz|ergänzende.?angaben" // de-DE + u"|direccion2|colonia|adicional" // es + u"|addresssuppl|complementnom|appartement" // fr-FR + u"|indirizzo2" // it-IT + u"|住所2" // ja-JP + u"|complemento|addrcomplement" // pt-BR, pt-PT + u"|Улица" // ru + u"|地址2" // zh-CN + u"|주소.?2"; // ko-KR +const char16_t kAddressLine2LabelRe[] = + u"address|line" + u"|adresse" // fr-FR + u"|indirizzo" // it-IT + u"|地址" // zh-CN + u"|주소"; // ko-KR +const char16_t kAddressLinesExtraRe[] = + u"address.*line[3-9]|address[3-9]|addr[3-9]|street|line[3-9]" + u"|municipio" // es + u"|batiment|residence" // fr-FR + u"|indirizzo[3-9]"; // it-IT +const char16_t kAddressLookupRe[] = u"lookup"; +const char16_t kCountryRe[] = + u"country|countries" + u"|país|pais" // es + u"|(\\b|_)land(\\b|_)(?!.*(mark.*))" // de-DE landmark is a type in india. + u"|(?<!(入|出))国" // ja-JP + u"|国家" // zh-CN + u"|국가|나라" // ko-KR + u"|(\\b|_)(ülke|ulce|ulke)(\\b|_)" // tr + u"|کشور" // fa + u"|negara"; // id +const char16_t kCountryLocationRe[] = u"location"; +const char16_t kZipCodeRe[] = + u"zip|postal|post.*code|pcode" + u"|pin.?code" // en-IN + u"|postleitzahl" // de-DE + u"|\\bcp\\b" // es + u"|\\bcdp\\b" // fr-FR + u"|\\bcap\\b" // it-IT + u"|郵便番号" // ja-JP + u"|codigo|codpos|\\bcep\\b" // pt-BR, pt-PT + u"|Почтовый.?Индекс" // ru + u"|पिन.?कोड" // hi + u"|പിന്കോഡ്" // ml + u"|邮政编码|邮编" // zh-CN + u"|郵遞區號" // zh-TW + u"|(\\b|_)posta kodu(\\b|_)" // tr + u"|우편.?번호" // ko-KR + u"|kode.?pos"; // id +const char16_t kZip4Re[] = + u"zip|^-$|post2" + u"|codpos2"; // pt-BR, pt-PT +const char16_t kDependentLocalityRe[] = + u"neighbo(u)?rhood" // en + u"|bairro" // pt-BR, pt-PT + u"|mahalle|köy" // tr + u"|kecamatan"; // id +const char16_t kCityRe[] = + u"city|town" + u"|\\bort\\b|stadt" // de-DE + u"|suburb" // en-AU + u"|ciudad|provincia|localidad|poblacion" // es + u"|ville|commune" // fr-FR + u"|localita" // it-IT + u"|市区町村" // ja-JP + u"|cidade|município" // pt-BR, pt-PT + u"|Город|Насел(е|ё)нный.?пункт" // ru + u"|市" // zh-CN + u"|分區" // zh-TW + u"|شهر" // fa + u"|शहर" // hi for city + u"|ग्राम|गाँव" // hi for village + u"|നഗരം|ഗ്രാമം" // ml for town|village + u"|((\\b|_|\\*)([İii̇]l[cç]e(miz|niz)?)(\\b|_|\\*))" // tr + u"|^시[^도·・]|시[·・]?군[·・]?구" // ko-KR + u"|kota|kabupaten"; // id +const char16_t kStateRe[] = + u"(?<!(united|hist|history).?)state|county|region|province" + u"|county|principality" // en-UK + u"|都道府県" // ja-JP + u"|estado|provincia" // pt-BR, pt-PT + u"|область" // ru + u"|省" // zh-CN + u"|地區" // zh-TW + u"|സംസ്ഥാനം" // ml + u"|استان" // fa + u"|राज्य" // hi + u"|((\\b|_|\\*)(eyalet|[şs]ehir|[İii̇]l(imiz)?|kent)(\\b|_|\\*))" // tr + u"|^시[·・]?도" // ko-KR + u"|provinci"; // id ///////////////////////////////////////////////////////////////////////////// // search_field.cc ///////////////////////////////////////////////////////////////////////////// -const char kSearchTermRe[] = - "^q$" - "|search" - "|query" - "|qry" - "|suche.*" // de-DE - "|搜索" // zh-CN zh-TW - "|探す|検索" // ja-JP to search - "|recherch.*" // fr-FR - "|busca" // pt-BR, pt-PT - "|جستجو" // fa - "|искать|найти|поиск"; // ru +const char16_t kSearchTermRe[] = + u"^q$" + u"|search" + u"|query" + u"|qry" + u"|suche.*" // de-DE + u"|搜索" // zh-CN zh-TW + u"|探す|検索" // ja-JP to search + u"|recherch.*" // fr-FR + u"|busca" // pt-BR, pt-PT + u"|جستجو" // fa + u"|искать|найти|поиск"; // ru ///////////////////////////////////////////////////////////////////////////// // field_price.cc ///////////////////////////////////////////////////////////////////////////// -const char kPriceRe[] = - "\\bprice\\b|\\brate\\b|\\bcost\\b" - "|قیمة|سعر" // ar - "|قیمت" // fa - "|\\bprix\\b|\\bcoût\\b|\\bcout\\b|\\btarif\\b"; // fr-CA +const char16_t kPriceRe[] = + u"\\bprice\\b|\\brate\\b|\\bcost\\b" + u"|قیمة|سعر" // ar + u"|قیمت" // fa + u"|\\bprix\\b|\\bcoût\\b|\\bcout\\b|\\btarif\\b"; // fr-CA ///////////////////////////////////////////////////////////////////////////// // credit_card_field.cc ///////////////////////////////////////////////////////////////////////////// -const char kNameOnCardRe[] = - "card.?(?:holder|owner)|name.*(\\b)?on(\\b)?.*card" - "|(?:card|cc).?name|cc.?full.?name" - "|karteninhaber" // de-DE - "|nombre.*tarjeta" // es - "|nom.*carte" // fr-FR - "|nome.*cart" // it-IT - "|名前" // ja-JP - "|Имя.*карты" // ru - "|nama.*kartu" // id - "|信用卡开户名|开户名|持卡人姓名" // zh-CN - "|持卡人姓名"; // zh-TW -const char kNameOnCardContextualRe[] = "name"; -const char kCardNumberRe[] = - "(add)?(?:card|cc|acct).?(?:number|#|no|num|field)" - "|(?<!telefon|haus|person|fødsels)nummer" // de-DE, sv-SE, no - "|カード番号" // ja-JP - "|Номер.*карты" // ru - "|no.*kartu" // id - "|信用卡号|信用卡号码" // zh-CN - "|信用卡卡號" // zh-TW - "|카드" // ko-KR +const char16_t kNameOnCardRe[] = + u"card.?(?:holder|owner)|name.*(\\b)?on(\\b)?.*card" + u"|(?:card|cc).?name|cc.?full.?name" + u"|karteninhaber" // de-DE + u"|nombre.*tarjeta" // es + u"|nom.*carte" // fr-FR + u"|nome.*cart" // it-IT + u"|名前" // ja-JP + u"|Имя.*карты" // ru + u"|nama.*kartu" // id + u"|信用卡开户名|开户名|持卡人姓名" // zh-CN + u"|持卡人姓名"; // zh-TW +const char16_t kNameOnCardContextualRe[] = u"name"; +const char16_t kCardNumberRe[] = + u"(add)?(?:card|cc|acct).?(?:number|#|no|num|field)" + u"|(?<!telefon|haus|person|fødsels)nummer" // de-DE, sv-SE, no + u"|カード番号" // ja-JP + u"|Номер.*карты" // ru + u"|no.*kartu" // id + u"|信用卡号|信用卡号码" // zh-CN + u"|信用卡卡號" // zh-TW + u"|카드" // ko-KR // es/pt/fr - "|(numero|número|numéro)(?!.*(document|fono|phone|réservation))"; + u"|(numero|número|numéro)(?!.*(document|fono|phone|réservation))"; -const char kCardCvcRe[] = - "verification|card.?identification|security.?code|card.?code" - "|security.?value" - "|security.?number|card.?pin|c-v-v" - "|(cvn|cvv|cvc|csc|cvd|cid|ccv)(field)?" - "|\\bcid\\b"; +const char16_t kCardCvcRe[] = + u"verification|card.?identification|security.?code|card.?code" + u"|security.?value" + u"|security.?number|card.?pin|c-v-v" + u"|(cvn|cvv|cvc|csc|cvd|cid|ccv)(field)?" + u"|\\bcid\\b"; // "Expiration date" is the most common label here, but some pages have // "Expires", "exp. date" or "exp. month" and "exp. year". We also look @@ -253,27 +251,27 @@ const char kCardCvcRe[] = // Toolbar Bug 51451: indeed, simply matching "month" is too general for // https://rps.fidelity.com/ftgw/rps/RtlCust/CreatePIN/Init. // Instead, we match only words beginning with "month". -const char kExpirationMonthRe[] = - "expir|exp.*mo|exp.*date|ccmonth|cardmonth|addmonth" - "|gueltig|gültig|monat" // de-DE - "|fecha" // es - "|date.*exp" // fr-FR - "|scadenza" // it-IT - "|有効期限" // ja-JP - "|validade" // pt-BR, pt-PT - "|Срок действия карты" // ru - "|masa berlaku|berlaku hingga" // id - "|月"; // zh-CN -const char kExpirationYearRe[] = - "exp|^/|(add)?year" - "|ablaufdatum|gueltig|gültig|jahr" // de-DE - "|fecha" // es - "|scadenza" // it-IT - "|有効期限" // ja-JP - "|validade" // pt-BR, pt-PT - "|Срок действия карты" // ru - "|masa berlaku|berlaku hingga" // id - "|年|有效期"; // zh-CN +const char16_t kExpirationMonthRe[] = + u"expir|exp.*mo|exp.*date|ccmonth|cardmonth|addmonth" + u"|gueltig|gültig|monat" // de-DE + u"|fecha" // es + u"|date.*exp" // fr-FR + u"|scadenza" // it-IT + u"|有効期限" // ja-JP + u"|validade" // pt-BR, pt-PT + u"|Срок действия карты" // ru + u"|masa berlaku|berlaku hingga" // id + u"|月"; // zh-CN +const char16_t kExpirationYearRe[] = + u"exp|^/|(add)?year" + u"|ablaufdatum|gueltig|gültig|jahr" // de-DE + u"|fecha" // es + u"|scadenza" // it-IT + u"|有効期限" // ja-JP + u"|validade" // pt-BR, pt-PT + u"|Срок действия карты" // ru + u"|masa berlaku|berlaku hingga" // id + u"|年|有效期"; // zh-CN // Used to match a expiration date field with a two digit year. // The following conditions must be met: @@ -282,318 +280,328 @@ const char kExpirationYearRe[] = // - (optional) Separated by white-space and/or a dash or slash. // - (optional) Prepended with some text similar to "Expiration Date". // Tested in components/autofill/core/browser/autofill_regexes_unittest.cc -const char kExpirationDate2DigitYearRe[] = - "(?:exp.*date[^y\\n\\r]*|mm\\s*[-/]?\\s*)yy(?:[^y]|$)"; +const char16_t kExpirationDate2DigitYearRe[] = + u"(?:exp.*date[^y\\n\\r]*|mm\\s*[-/]?\\s*)yy(?:[^y]|$)"; // Used to match a expiration date field with a four digit year. // Same requirements as |kExpirationDate2DigitYearRe| except: // - Exactly four adjacent y's. // Tested in components/autofill/core/browser/autofill_regexes_unittest.cc -const char kExpirationDate4DigitYearRe[] = - "(?:exp.*date[^y\\n\\r]*|mm\\s*[-/]?\\s*)yyyy(?:[^y]|$)"; +const char16_t kExpirationDate4DigitYearRe[] = + u"(?:exp.*date[^y\\n\\r]*|mm\\s*[-/]?\\s*)yyyy(?:[^y]|$)"; // Used to match expiration date fields that do not specify a year length. -const char kExpirationDateRe[] = - "expir|exp.*date|^expfield$" - "|gueltig|gültig" // de-DE - "|fecha" // es - "|date.*exp" // fr-FR - "|scadenza" // it-IT - "|有効期限" // ja-JP - "|validade" // pt-BR, pt-PT - "|Срок действия карты"; // ru -const char kGiftCardRe[] = "gift.?(card|cert)"; -const char kDebitGiftCardRe[] = - "(?:visa|mastercard|discover|amex|american express).*gift.?card"; -const char kDebitCardRe[] = "debit.*card"; -const char kDayRe[] = "day"; +const char16_t kExpirationDateRe[] = + u"expir|exp.*date|^expfield$" + u"|gueltig|gültig" // de-DE + u"|fecha" // es + u"|date.*exp" // fr-FR + u"|scadenza" // it-IT + u"|有効期限" // ja-JP + u"|validade" // pt-BR, pt-PT + u"|Срок действия карты"; // ru +const char16_t kGiftCardRe[] = u"gift.?(card|cert)"; +const char16_t kDebitGiftCardRe[] = + u"(?:visa|mastercard|discover|amex|american express).*gift.?card"; +const char16_t kDebitCardRe[] = u"debit.*card"; +const char16_t kDayRe[] = u"day"; ///////////////////////////////////////////////////////////////////////////// // email_field.cc ///////////////////////////////////////////////////////////////////////////// -const char kEmailRe[] = - "e.?mail" - "|courriel" // fr - "|correo.*electr(o|ó)nico" // es-ES - "|メールアドレス" // ja-JP - "|Электронн(ая|ой).?Почт(а|ы)" // ru - "|邮件|邮箱" // zh-CN - "|電郵地址" // zh-TW - "|ഇ-മെയില്|ഇലക്ട്രോണിക്.?" - "മെയിൽ" // ml - "|ایمیل|پست.*الکترونیک" // fa - "|ईमेल|इलॅक्ट्रॉनिक.?मेल" // hi - "|(\\b|_)eposta(\\b|_)" // tr - "|(?:이메일|전자.?우편|[Ee]-?mail)(.?주소)?"; // ko-KR +const char16_t kEmailRe[] = + u"e.?mail" + u"|courriel" // fr + u"|correo.*electr(o|ó)nico" // es-ES + u"|メールアドレス" // ja-JP + u"|Электронн(ая|ой).?Почт(а|ы)" // ru + u"|邮件|邮箱" // zh-CN + u"|電郵地址" // zh-TW + u"|ഇ-മെയില്|ഇലക്ട്രോണിക്.?" + u"മെയിൽ" // ml + u"|ایمیل|پست.*الکترونیک" // fa + u"|ईमेल|इलॅक्ट्रॉनिक.?मेल" // hi + u"|(\\b|_)eposta(\\b|_)" // tr + u"|(?:이메일|전자.?우편|[Ee]-?mail)(.?주소)?"; // ko-KR ///////////////////////////////////////////////////////////////////////////// // name_field.cc ///////////////////////////////////////////////////////////////////////////// -const char kNameIgnoredRe[] = - "user.?name|user.?id|nickname|maiden name|title|prefix|suffix" - "|vollständiger.?name" // de-DE - "|用户名" // zh-CN - "|(?:사용자.?)?아이디|사용자.?ID"; // ko-KR -const char kNameRe[] = - "^name|full.?name|your.?name|customer.?name|bill.?name|ship.?name" - "|name.*first.*last|firstandlastname|contact.?(name|person)" - "|nombre.*y.*apellidos" // es - "|^nom(?![a-zA-Z])" // fr-FR - "|お名前|氏名" // ja-JP - "|^nome" // pt-BR, pt-PT - "|نام.*نام.*خانوادگی" // fa - "|姓名" // zh-CN - "|контактное.?лицо" // ru - "|(\\b|_|\\*)ad[ı]? soyad[ı]?(\\b|_|\\*)" // tr - "|성명" // ko-KR - "|nama.?(lengkap|penerima|kamu)"; // id -const char kNameSpecificRe[] = - "^name" - "|^nom" // fr-FR - "|^nome"; // pt-BR, pt-PT -const char kFirstNameRe[] = - "first.*name|initials|fname|first$|given.*name" - "|vorname" // de-DE - "|nombre" // es - "|forename|prénom|prenom" // fr-FR - "|名" // ja-JP - "|nome" // pt-BR, pt-PT - "|Имя" // ru - "|نام" // fa - "|이름" // ko-KR - "|പേര്" // ml - "|(\\b|_|\\*)(isim|ad|ad(i|ı|iniz|ınız)?)(\\b|_|\\*)" // tr - "|नाम" // hi - "|nama depan"; // id -const char kMiddleInitialRe[] = "middle.*initial|m\\.i\\.|mi$|\\bmi\\b"; -const char kMiddleNameRe[] = "middle.*name|mname|middle$"; -const char kLastNameRe[] = - "last.*name|lname|surname(?!\\d)|last$|secondname|family.*name" - "|nachname" // de-DE - "|apellidos?" // es - "|famille|^nom(?![a-zA-Z])" // fr-FR - "|cognome" // it-IT - "|姓" // ja-JP - "|apelidos|surename|sobrenome" // pt-BR, pt-PT - "|Фамилия" // ru - "|نام.*خانوادگی" // fa - "|उपनाम" // hi - "|മറുപേര്" // ml - "|(\\b|_|\\*)(soyisim|soyad(i|ı|iniz|ınız)?)(\\b|_|\\*)" // tr - "|\\b성(?:[^명]|\\b)" // ko-KR - "|nama belakang"; // id -const char kNameLastFirstRe[] = - "(primer.*apellido)" // es - "|(apellido1)" // es - "|(apellido.*paterno)" // es - "|surname_?1|first(\\s|_)?surname"; // es -const char kNameLastSecondRe[] = - "(segund.*apellido)" // es - "|(apellido2)" // es - "|(apellido.*materno)" // es - "|surname_?2|second(\\s|_)?surname"; // es -const char kHonorificPrefixRe[] = - "anrede|titel" // de-DE - "|tratamiento|encabezamiento" // es - "|^title:?$" // Matched only if there is no prefix or suffix. - "|(salutation(?! and given name))" // en - "|titolo" // it-IT - "|titre" // fr-FR - "|обращение|звание" // ru - "|προσφώνηση" // el - "|hitap"; // tr +const char16_t kNameIgnoredRe[] = + u"user.?name|user.?id|nickname|maiden name|title|prefix|suffix" + u"|vollständiger.?name" // de-DE + u"|用户名" // zh-CN + u"|(?:사용자.?)?아이디|사용자.?ID"; // ko-KR +const char16_t kNameRe[] = + u"^name|full.?name|your.?name|customer.?name|bill.?name|ship.?name" + u"|name.*first.*last|firstandlastname|contact.?(name|person)" + u"|nombre.*y.*apellidos" // es + u"|^nom(?![a-zA-Z])" // fr-FR + u"|お名前|氏名" // ja-JP + u"|^nome" // pt-BR, pt-PT + u"|نام.*نام.*خانوادگی" // fa + u"|姓名" // zh-CN + u"|контактное.?лицо" // ru + u"|(\\b|_|\\*)ad[ı]? soyad[ı]?(\\b|_|\\*)" // tr + u"|성명" // ko-KR + u"|nama.?(lengkap|penerima|kamu)"; // id +const char16_t kNameSpecificRe[] = + u"^name" + u"|^nom" // fr-FR + u"|^nome"; // pt-BR, pt-PT +const char16_t kFirstNameRe[] = + u"first.*name|initials|fname|first$|given.*name" + u"|vorname" // de-DE + u"|nombre" // es + u"|forename|prénom|prenom" // fr-FR + u"|名" // ja-JP + u"|nome" // pt-BR, pt-PT + u"|Имя" // ru + u"|نام" // fa + u"|이름" // ko-KR + u"|പേര്" // ml + u"|(\\b|_|\\*)(isim|ad|ad(i|ı|iniz|ınız)?)(\\b|_|\\*)" // tr + u"|नाम" // hi + u"|nama depan"; // id +const char16_t kMiddleInitialRe[] = u"middle.*initial|m\\.i\\.|mi$|\\bmi\\b"; +const char16_t kMiddleNameRe[] = u"middle.*name|mname|middle$"; +const char16_t kLastNameRe[] = + u"last.*name|lname|surname(?!\\d)|last$|secondname|family.*name" + u"|nachname" // de-DE + u"|apellidos?" // es + u"|famille|^nom(?![a-zA-Z])" // fr-FR + u"|cognome" // it-IT + u"|姓" // ja-JP + u"|apelidos|surename|sobrenome" // pt-BR, pt-PT + u"|Фамилия" // ru + u"|نام.*خانوادگی" // fa + u"|उपनाम" // hi + u"|മറുപേര്" // ml + u"|(\\b|_|\\*)(soyisim|soyad(i|ı|iniz|ınız)?)(\\b|_|\\*)" // tr + u"|\\b성(?:[^명]|\\b)" // ko-KR + u"|nama belakang"; // id +const char16_t kNameLastFirstRe[] = + u"(primer.*apellido)" // es + u"|(apellido1)" // es + u"|(apellido.*paterno)" // es + u"|surname_?1|first(\\s|_)?surname"; // es +const char16_t kNameLastSecondRe[] = + u"(segund.*apellido)" // es + u"|(apellido2)" // es + u"|(apellido.*materno)" // es + u"|surname_?2|second(\\s|_)?surname"; // es +const char16_t kHonorificPrefixRe[] = + u"anrede|titel" // de-DE + u"|tratamiento|encabezamiento" // es + u"|^title:?$" // Matched only if there is no prefix or suffix. + u"|(salutation(?! and given name))" // en + u"|titolo" // it-IT + u"|titre" // fr-FR + u"|обращение|звание" // ru + u"|προσφώνηση" // el + u"|hitap"; // tr ///////////////////////////////////////////////////////////////////////////// // phone_field.cc ///////////////////////////////////////////////////////////////////////////// -const char kPhoneRe[] = - "phone|mobile|contact.?number" - "|telefonnummer" // de-DE - "|telefono|teléfono" // es - "|telfixe" // fr-FR - "|電話" // ja-JP - "|telefone|telemovel" // pt-BR, pt-PT - "|телефон" // ru - "|मोबाइल" // hi for mobile - "|(\\b|_|\\*)telefon(\\b|_|\\*)" // tr - "|电话" // zh-CN - "|മൊബൈല്" // ml for mobile - "|(?:전화|핸드폰|휴대폰|휴대전화)(?:.?번호)?" // ko-KR - "|telepon|ponsel|(nomor|no\\.?).?(hp|handphone)"; // id -const char kAugmentedPhoneCountryCodeRe[] = - "^[^0-9+]*(?:\\+|00)\\s*([1-9]\\d{0,3})\\D*$"; -const char kCountryCodeRe[] = - "country.*code|ccode|_cc|phone.*code|user.*phone.*code"; -const char kAreaCodeNotextRe[] = "^\\($"; -const char kAreaCodeRe[] = - "area.*code|acode|area" - "|지역.?번호"; // ko-KR -const char kPhonePrefixSeparatorRe[] = "^-$|^\\)$"; -const char kPhoneSuffixSeparatorRe[] = "^-$"; -const char kPhonePrefixRe[] = - "prefix|exchange" - "|preselection" // fr-FR - "|ddd"; // pt-BR, pt-PT -const char kPhoneSuffixRe[] = "suffix"; -const char kPhoneExtensionRe[] = - "\\bext|ext\\b|extension" - "|ramal"; // pt-BR, pt-PT +const char16_t kPhoneRe[] = + u"phone|mobile|contact.?number" + u"|telefonnummer" // de-DE + u"|telefono|teléfono" // es + u"|telfixe" // fr-FR + u"|電話" // ja-JP + u"|telefone|telemovel" // pt-BR, pt-PT + u"|телефон" // ru + u"|मोबाइल" // hi for mobile + u"|(\\b|_|\\*)telefon(\\b|_|\\*)" // tr + u"|电话" // zh-CN + u"|മൊബൈല്" // ml for mobile + u"|(?:전화|핸드폰|휴대폰|휴대전화)(?:.?번호)?" // ko-KR + u"|telepon|ponsel|(nomor|no\\.?).?(hp|handphone)"; // id +const char16_t kAugmentedPhoneCountryCodeRe[] = + u"^[^0-9+]*(?:\\+|00)\\s*([1-9]\\d{0,3})\\D*$"; +const char16_t kCountryCodeRe[] = + u"country.*code|ccode|_cc|phone.*code|user.*phone.*code"; +const char16_t kAreaCodeNotextRe[] = u"^\\($"; +const char16_t kAreaCodeRe[] = + u"area.*code|acode|area" + u"|지역.?번호"; // ko-KR +const char16_t kPhonePrefixSeparatorRe[] = u"^-$|^\\)$"; +const char16_t kPhoneSuffixSeparatorRe[] = u"^-$"; +const char16_t kPhonePrefixRe[] = + u"prefix|exchange" + u"|preselection" // fr-FR + u"|ddd"; // pt-BR, pt-PT +const char16_t kPhoneSuffixRe[] = u"suffix"; +const char16_t kPhoneExtensionRe[] = + u"\\bext|ext\\b|extension" + u"|ramal"; // pt-BR, pt-PT ///////////////////////////////////////////////////////////////////////////// // travel_field.cc ///////////////////////////////////////////////////////////////////////////// -const char kPassportRe[] = - "document.*number|passport" // en-US - "|passeport" // fr-FR - "|numero.*documento|pasaporte" // es-ES - "|書類"; // ja-JP -const char kTravelOriginRe[] = - "point.*of.*entry|arrival" // en-US - "|punto.*internaci(o|ó)n|fecha.*llegada" // es-ES - "|入国"; // ja-JP -const char kTravelDestinationRe[] = - "departure" // en-US - "|fecha.*salida|destino" // es-ES - "|出国"; // ja-JP -const char kFlightRe[] = - "airline|flight" // en-US - "|aerol(i|í)nea|n(u|ú)mero.*vuelo" // es-ES - "|便名|航空会社"; // ja-JP +const char16_t kPassportRe[] = + u"document.*number|passport" // en-US + u"|passeport" // fr-FR + u"|numero.*documento|pasaporte" // es-ES + u"|書類"; // ja-JP +const char16_t kTravelOriginRe[] = + u"point.*of.*entry|arrival" // en-US + u"|punto.*internaci(o|ó)n|fecha.*llegada" // es-ES + u"|入国"; // ja-JP +const char16_t kTravelDestinationRe[] = + u"departure" // en-US + u"|fecha.*salida|destino" // es-ES + u"|出国"; // ja-JP +const char16_t kFlightRe[] = + u"airline|flight" // en-US + u"|aerol(i|í)nea|n(u|ú)mero.*vuelo" // es-ES + u"|便名|航空会社"; // ja-JP ///////////////////////////////////////////////////////////////////////////// // validation.cc ///////////////////////////////////////////////////////////////////////////// -const char kUPIVirtualPaymentAddressRe[] = - "^[\\w.+-_]+@(" // eg user@ - "\\w+\\.ifsc\\.npci|" // IFSC code - "aadhaar\\.npci|" // Aadhaar number - "mobile\\.npci|" // Mobile number - "rupay\\.npci|" // RuPay card number - "airtel|" // List of banks https://www.npci.org.in/upi-live-members - "airtelpaymentsbank|" - "albk|" - "allahabadbank|" - "allbank|" - "andb|" - "apb|" - "apl|" - "axis|" - "axisbank|" - "axisgo|" - "bandhan|" - "barodampay|" - "birla|" - "boi|" - "cbin|" - "cboi|" - "centralbank|" - "cmsidfc|" - "cnrb|" - "csbcash|" - "csbpay|" - "cub|" - "dbs|" - "dcb|" - "dcbbank|" - "denabank|" - "dlb|" - "eazypay|" - "equitas|" - "ezeepay|" - "fbl|" - "federal|" - "finobank|" - "hdfcbank|" - "hsbc|" - "icici|" - "idbi|" - "idbibank|" - "idfc|" - "idfcbank|" - "idfcnetc|" - "ikwik|" - "imobile|" - "indbank|" - "indianbank|" - "indianbk|" - "indus|" - "iob|" - "jkb|" - "jsb|" - "jsbp|" - "karb|" - "karurvysyabank|" - "kaypay|" - "kbl|" - "kbl052|" - "kmb|" - "kmbl|" - "kotak|" - "kvb|" - "kvbank|" - "lime|" - "lvb|" - "lvbank|" - "mahb|" - "obc|" - "okaxis|" - "okbizaxis|" - "okhdfcbank|" - "okicici|" - "oksbi|" - "paytm|" - "payzapp|" - "pingpay|" - "pnb|" - "pockets|" - "psb|" - "purz|" - "rajgovhdfcbank|" - "rbl|" - "sbi|" - "sc|" - "scb|" - "scbl|" - "scmobile|" - "sib|" - "srcb|" - "synd|" - "syndbank|" - "syndicate|" - "tjsb|" - "tjsp|" - "ubi|" - "uboi|" - "uco|" - "unionbank|" - "unionbankofindia|" - "united|" - "upi|" - "utbi|" - "vijayabank|" - "vijb|" - "vjb|" - "ybl|" - "yesbank|" - "yesbankltd" - ")$"; +const char16_t kUPIVirtualPaymentAddressRe[] = + u"^[\\w.+-_]+@(" // eg user@ + u"\\w+\\.ifsc\\.npci|" // IFSC code + u"aadhaar\\.npci|" // Aadhaar number + u"mobile\\.npci|" // Mobile number + u"rupay\\.npci|" // RuPay card number + u"airtel|" // List of banks https://www.npci.org.in/upi-live-members + u"airtelpaymentsbank|" + u"albk|" + u"allahabadbank|" + u"allbank|" + u"andb|" + u"apb|" + u"apl|" + u"axis|" + u"axisbank|" + u"axisgo|" + u"bandhan|" + u"barodampay|" + u"birla|" + u"boi|" + u"cbin|" + u"cboi|" + u"centralbank|" + u"cmsidfc|" + u"cnrb|" + u"csbcash|" + u"csbpay|" + u"cub|" + u"dbs|" + u"dcb|" + u"dcbbank|" + u"denabank|" + u"dlb|" + u"eazypay|" + u"equitas|" + u"ezeepay|" + u"fbl|" + u"federal|" + u"finobank|" + u"hdfcbank|" + u"hsbc|" + u"icici|" + u"idbi|" + u"idbibank|" + u"idfc|" + u"idfcbank|" + u"idfcnetc|" + u"ikwik|" + u"imobile|" + u"indbank|" + u"indianbank|" + u"indianbk|" + u"indus|" + u"iob|" + u"jkb|" + u"jsb|" + u"jsbp|" + u"karb|" + u"karurvysyabank|" + u"kaypay|" + u"kbl|" + u"kbl052|" + u"kmb|" + u"kmbl|" + u"kotak|" + u"kvb|" + u"kvbank|" + u"lime|" + u"lvb|" + u"lvbank|" + u"mahb|" + u"obc|" + u"okaxis|" + u"okbizaxis|" + u"okhdfcbank|" + u"okicici|" + u"oksbi|" + u"paytm|" + u"payzapp|" + u"pingpay|" + u"pnb|" + u"pockets|" + u"psb|" + u"purz|" + u"rajgovhdfcbank|" + u"rbl|" + u"sbi|" + u"sc|" + u"scb|" + u"scbl|" + u"scmobile|" + u"sib|" + u"srcb|" + u"synd|" + u"syndbank|" + u"syndicate|" + u"tjsb|" + u"tjsp|" + u"ubi|" + u"uboi|" + u"uco|" + u"unionbank|" + u"unionbankofindia|" + u"united|" + u"upi|" + u"utbi|" + u"vijayabank|" + u"vijb|" + u"vjb|" + u"ybl|" + u"yesbank|" + u"yesbankltd" + u")$"; -const char kInternationalBankAccountNumberRe[] = - "^[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}$"; +const char16_t kInternationalBankAccountNumberRe[] = + u"^[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}$"; // Matches all 3 and 4 digit numbers. -const char kCreditCardCVCPattern[] = "^\\d{3,4}$"; +const char16_t kCreditCardCVCPattern[] = u"^\\d{3,4}$"; // Matches numbers in the range [2010-2099]. -const char kCreditCard4DigitExpYearPattern[] = "^[2][0][1-9][0-9]$"; +const char16_t kCreditCard4DigitExpYearPattern[] = u"^[2][0][1-9][0-9]$"; ///////////////////////////////////////////////////////////////////////////// // form_structure.cc ///////////////////////////////////////////////////////////////////////////// -const char kUrlSearchActionRe[] = "/search(/|((\\w*\\.\\w+)?$))"; +const char16_t kUrlSearchActionRe[] = u"/search(/|((\\w*\\.\\w+)?$))"; ///////////////////////////////////////////////////////////////////////////// // form_parser.cc ///////////////////////////////////////////////////////////////////////////// -const char kSocialSecurityRe[] = "ssn|social.?security.?(num(ber)?|#)*"; -const char kOneTimePwdRe[] = "one.?time|sms.?(code|token|password|pwd|pass)"; +const char16_t kSocialSecurityRe[] = u"ssn|social.?security.?(num(ber)?|#)*"; +const char16_t kOneTimePwdRe[] = + u"one.?time|sms.?(code|token|password|pwd|pass)"; +// Matches strings that consist of one repeated non alphanumeric symbol, +// that is likely a result of website modifying the value to hide it. +const char16_t kHiddenValueRe[] = u"^(\\W)\\1+$"; + +///////////////////////////////////////////////////////////////////////////// +// merchant_promo_code_field.cc +///////////////////////////////////////////////////////////////////////////// +const char16_t kMerchantPromoCodeRe[] = + u"\\bpromo code\\b|\\bcoupon code\\b|\\bgift code\\b"; } // namespace autofill diff --git a/chromium/components/autofill/core/browser/autofill_regex_constants.h b/chromium/components/autofill/core/browser/autofill_regex_constants.h index d755da5d990..4434193d5e5 100644 --- a/chromium/components/autofill/core/browser/autofill_regex_constants.h +++ b/chromium/components/autofill/core/browser/autofill_regex_constants.h @@ -7,87 +7,89 @@ namespace autofill { -extern const char kAttentionIgnoredRe[]; -extern const char kRegionIgnoredRe[]; -extern const char kAddressNameIgnoredRe[]; -extern const char kCompanyRe[]; -extern const char kHouseNumberRe[]; -extern const char kApartmentNumberRe[]; -extern const char kStreetNameRe[]; -extern const char kAddressLine1Re[]; -extern const char kAddressLine1LabelRe[]; -extern const char kAddressLine2Re[]; -extern const char kAddressLine2LabelRe[]; -extern const char kAddressLinesExtraRe[]; -extern const char kAddressLookupRe[]; -extern const char kCountryRe[]; -extern const char kDependentLocality[]; -extern const char kCountryLocationRe[]; -extern const char kZipCodeRe[]; -extern const char kZip4Re[]; -extern const char kDependentLocalityRe[]; -extern const char kCityRe[]; -extern const char kStateRe[]; -extern const char kNameOnCardRe[]; -extern const char kNameOnCardContextualRe[]; -extern const char kCardNumberRe[]; -extern const char kCardCvcRe[]; -extern const char kCardTypeRe[]; -extern const char kExpirationMonthRe[]; -extern const char kExpirationYearRe[]; -extern const char kExpirationDate2DigitYearRe[]; -extern const char kExpirationDate4DigitYearRe[]; -extern const char kExpirationDateRe[]; -extern const char kCardIgnoredRe[]; -extern const char kGiftCardRe[]; -extern const char kDebitGiftCardRe[]; -extern const char kDebitCardRe[]; -extern const char kDayRe[]; -extern const char kEmailRe[]; -extern const char kNameIgnoredRe[]; -extern const char kNameRe[]; -extern const char kNameSpecificRe[]; -extern const char kFirstNameRe[]; -extern const char kMiddleInitialRe[]; -extern const char kMiddleNameRe[]; -extern const char kLastNameRe[]; -extern const char kHonorificPrefixRe[]; -extern const char kNameLastFirstRe[]; -extern const char kNameLastSecondRe[]; -extern const char kPhoneRe[]; -extern const char kAugmentedPhoneCountryCodeRe[]; -extern const char kCountryCodeRe[]; -extern const char kAreaCodeNotextRe[]; -extern const char kAreaCodeRe[]; -extern const char kFaxRe[]; -extern const char kPhonePrefixSeparatorRe[]; -extern const char kPhoneSuffixSeparatorRe[]; -extern const char kPhonePrefixRe[]; -extern const char kPhoneSuffixRe[]; -extern const char kPhoneExtensionRe[]; -extern const char kSearchTermRe[]; -extern const char kPassportRe[]; -extern const char kTravelOriginRe[]; -extern const char kTravelDestinationRe[]; -extern const char kFlightRe[]; -extern const char kPriceRe[]; -extern const char kCreditCardCVCPattern[]; -extern const char kCreditCard4DigitExpYearPattern[]; -extern const char kSocialSecurityRe[]; -extern const char kOneTimePwdRe[]; +extern const char16_t kAttentionIgnoredRe[]; +extern const char16_t kRegionIgnoredRe[]; +extern const char16_t kAddressNameIgnoredRe[]; +extern const char16_t kCompanyRe[]; +extern const char16_t kHouseNumberRe[]; +extern const char16_t kApartmentNumberRe[]; +extern const char16_t kStreetNameRe[]; +extern const char16_t kAddressLine1Re[]; +extern const char16_t kAddressLine1LabelRe[]; +extern const char16_t kAddressLine2Re[]; +extern const char16_t kAddressLine2LabelRe[]; +extern const char16_t kAddressLinesExtraRe[]; +extern const char16_t kAddressLookupRe[]; +extern const char16_t kCountryRe[]; +extern const char16_t kDependentLocality[]; +extern const char16_t kCountryLocationRe[]; +extern const char16_t kZipCodeRe[]; +extern const char16_t kZip4Re[]; +extern const char16_t kDependentLocalityRe[]; +extern const char16_t kCityRe[]; +extern const char16_t kStateRe[]; +extern const char16_t kNameOnCardRe[]; +extern const char16_t kNameOnCardContextualRe[]; +extern const char16_t kCardNumberRe[]; +extern const char16_t kCardCvcRe[]; +extern const char16_t kCardTypeRe[]; +extern const char16_t kExpirationMonthRe[]; +extern const char16_t kExpirationYearRe[]; +extern const char16_t kExpirationDate2DigitYearRe[]; +extern const char16_t kExpirationDate4DigitYearRe[]; +extern const char16_t kExpirationDateRe[]; +extern const char16_t kCardIgnoredRe[]; +extern const char16_t kGiftCardRe[]; +extern const char16_t kDebitGiftCardRe[]; +extern const char16_t kDebitCardRe[]; +extern const char16_t kDayRe[]; +extern const char16_t kEmailRe[]; +extern const char16_t kNameIgnoredRe[]; +extern const char16_t kNameRe[]; +extern const char16_t kNameSpecificRe[]; +extern const char16_t kFirstNameRe[]; +extern const char16_t kMiddleInitialRe[]; +extern const char16_t kMiddleNameRe[]; +extern const char16_t kLastNameRe[]; +extern const char16_t kHonorificPrefixRe[]; +extern const char16_t kNameLastFirstRe[]; +extern const char16_t kNameLastSecondRe[]; +extern const char16_t kPhoneRe[]; +extern const char16_t kAugmentedPhoneCountryCodeRe[]; +extern const char16_t kCountryCodeRe[]; +extern const char16_t kAreaCodeNotextRe[]; +extern const char16_t kAreaCodeRe[]; +extern const char16_t kFaxRe[]; +extern const char16_t kPhonePrefixSeparatorRe[]; +extern const char16_t kPhoneSuffixSeparatorRe[]; +extern const char16_t kPhonePrefixRe[]; +extern const char16_t kPhoneSuffixRe[]; +extern const char16_t kPhoneExtensionRe[]; +extern const char16_t kSearchTermRe[]; +extern const char16_t kPassportRe[]; +extern const char16_t kTravelOriginRe[]; +extern const char16_t kTravelDestinationRe[]; +extern const char16_t kFlightRe[]; +extern const char16_t kPriceRe[]; +extern const char16_t kCreditCardCVCPattern[]; +extern const char16_t kCreditCard4DigitExpYearPattern[]; +extern const char16_t kSocialSecurityRe[]; +extern const char16_t kOneTimePwdRe[]; +extern const char16_t kHiddenValueRe[]; +extern const char16_t kMerchantPromoCodeRe[]; // Used to match field data that might be a UPI Virtual Payment Address. // See: // - http://crbug.com/702220 // - https://upipayments.co.in/virtual-payment-address-vpa/ -extern const char kUPIVirtualPaymentAddressRe[]; +extern const char16_t kUPIVirtualPaymentAddressRe[]; // Used to match field data that might be an International Bank Account Number. // TODO(crbug.com/977377): The regex doesn't match IBANs for Saint Lucia (LC), // Kazakhstan (KZ) and Romania (RO). Consider replace the regex with something // like "(?:IT|SM)\d{2}[A-Z]\d{22}|CY\d{2}[A-Z]\d{23}...". For reference: // - https://www.swift.com/resource/iban-registry-pdf -extern const char kInternationalBankAccountNumberRe[]; +extern const char16_t kInternationalBankAccountNumberRe[]; // Match the path values for form actions that look like generic search: // e.g. /search @@ -95,7 +97,7 @@ extern const char kInternationalBankAccountNumberRe[]; // /search/products... // /products/search/ // /blah/search_all.jsp -extern const char kUrlSearchActionRe[]; +extern const char16_t kUrlSearchActionRe[]; } // namespace autofill diff --git a/chromium/components/autofill/core/browser/autofill_regexes.cc b/chromium/components/autofill/core/browser/autofill_regexes.cc index fc387879ecf..d644ead4ca0 100644 --- a/chromium/components/autofill/core/browser/autofill_regexes.cc +++ b/chromium/components/autofill/core/browser/autofill_regexes.cc @@ -6,13 +6,13 @@ #include <map> #include <memory> +#include <string> #include <utility> #include "base/check.h" #include "base/i18n/unicodestring.h" #include "base/macros.h" #include "base/no_destructor.h" -#include "base/strings/string16.h" #include "base/synchronization/lock.h" #include "third_party/icu/source/i18n/unicode/regex.h" @@ -34,7 +34,7 @@ class AutofillRegexes { ~AutofillRegexes() = default; // Maps patterns to their corresponding regex matchers. - std::map<base::string16, std::unique_ptr<icu::RegexMatcher>, std::less<>> + std::map<std::u16string, std::unique_ptr<icu::RegexMatcher>, std::less<>> matchers_; DISALLOW_COPY_AND_ASSIGN(AutofillRegexes); @@ -65,7 +65,7 @@ namespace autofill { bool MatchesPattern(const base::StringPiece16& input, const base::StringPiece16& pattern, - base::string16* match, + std::u16string* match, int32_t group_to_be_captured) { static base::NoDestructor<AutofillRegexes> g_autofill_regexes; static base::NoDestructor<base::Lock> g_lock; diff --git a/chromium/components/autofill/core/browser/autofill_regexes.h b/chromium/components/autofill/core/browser/autofill_regexes.h index 4ec3fce0f78..355e17c6917 100644 --- a/chromium/components/autofill/core/browser/autofill_regexes.h +++ b/chromium/components/autofill/core/browser/autofill_regexes.h @@ -5,7 +5,8 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_REGEXES_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_REGEXES_H_ -#include "base/strings/string16.h" +#include <string> + #include "base/strings/string_piece.h" // Parsing utilities. @@ -16,7 +17,7 @@ namespace autofill { // The |group_to_be_captured| numbered group is captured into |match|. bool MatchesPattern(const base::StringPiece16& input, const base::StringPiece16& pattern, - base::string16* match = nullptr, + std::u16string* match = nullptr, int32_t group_to_be_captured = 0); } // namespace autofill diff --git a/chromium/components/autofill/core/browser/autofill_regexes_unittest.cc b/chromium/components/autofill/core/browser/autofill_regexes_unittest.cc index 2adddede044..6110b2c37d4 100644 --- a/chromium/components/autofill/core/browser/autofill_regexes_unittest.cc +++ b/chromium/components/autofill/core/browser/autofill_regexes_unittest.cc @@ -6,19 +6,17 @@ #include <stddef.h> +#include <string> + #include "base/macros.h" -#include "base/strings/string16.h" -#include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_regex_constants.h" #include "testing/gtest/include/gtest/gtest.h" -using base::ASCIIToUTF16; - namespace autofill { struct InputPatternTestCase { - const char* const input; - const char* const pattern; + const char16_t* const input; + const char16_t* const pattern; }; class PositiveSampleTest : public testing::TestWithParam<InputPatternTestCase> { @@ -28,27 +26,26 @@ TEST_P(PositiveSampleTest, SampleRegexes) { auto test_case = GetParam(); SCOPED_TRACE(test_case.input); SCOPED_TRACE(test_case.pattern); - EXPECT_TRUE(MatchesPattern(ASCIIToUTF16(test_case.input), - ASCIIToUTF16(test_case.pattern))); + EXPECT_TRUE(MatchesPattern(test_case.input, test_case.pattern)); } INSTANTIATE_TEST_SUITE_P(AutofillRegexes, PositiveSampleTest, testing::Values( // Empty pattern - InputPatternTestCase{"", ""}, + InputPatternTestCase{u"", u""}, InputPatternTestCase{ - "Look, ma' -- a non-empty string!", ""}, + u"Look, ma' -- a non-empty string!", u""}, // Substring - InputPatternTestCase{"string", "tri"}, + InputPatternTestCase{u"string", u"tri"}, // Substring at beginning - InputPatternTestCase{"string", "str"}, - InputPatternTestCase{"string", "^str"}, + InputPatternTestCase{u"string", u"str"}, + InputPatternTestCase{u"string", u"^str"}, // Substring at end - InputPatternTestCase{"string", "ring"}, - InputPatternTestCase{"string", "ring$"}, + InputPatternTestCase{u"string", u"ring"}, + InputPatternTestCase{u"string", u"ring$"}, // Case-insensitive - InputPatternTestCase{"StRiNg", "string"})); + InputPatternTestCase{u"StRiNg", u"string"})); class NegativeSampleTest : public testing::TestWithParam<InputPatternTestCase> { }; @@ -57,8 +54,7 @@ TEST_P(NegativeSampleTest, SampleRegexes) { auto test_case = GetParam(); SCOPED_TRACE(test_case.input); SCOPED_TRACE(test_case.pattern); - EXPECT_FALSE(MatchesPattern(ASCIIToUTF16(test_case.input), - ASCIIToUTF16(test_case.pattern))); + EXPECT_FALSE(MatchesPattern(test_case.input, test_case.pattern)); } INSTANTIATE_TEST_SUITE_P(AutofillRegexes, @@ -66,18 +62,18 @@ INSTANTIATE_TEST_SUITE_P(AutofillRegexes, testing::Values( // Empty string InputPatternTestCase{ - "", "Look, ma' -- a non-empty pattern!"}, + u"", u"Look, ma' -- a non-empty pattern!"}, // Substring - InputPatternTestCase{"string", "trn"}, + InputPatternTestCase{u"string", u"trn"}, // Substring at beginning - InputPatternTestCase{"string", " str"}, - InputPatternTestCase{"string", "^tri"}, + InputPatternTestCase{u"string", u" str"}, + InputPatternTestCase{u"string", u"^tri"}, // Substring at end - InputPatternTestCase{"string", "ring "}, - InputPatternTestCase{"string", "rin$"})); + InputPatternTestCase{u"string", u"ring "}, + InputPatternTestCase{u"string", u"rin$"})); struct InputTestCase { - const char* const input; + const char16_t* const input; }; class ExpirationDate2DigitYearPositive @@ -86,33 +82,33 @@ class ExpirationDate2DigitYearPositive TEST_P(ExpirationDate2DigitYearPositive, ExpirationDate2DigitYearRegexes) { auto test_case = GetParam(); SCOPED_TRACE(test_case.input); - const base::string16 pattern = ASCIIToUTF16(kExpirationDate2DigitYearRe); - EXPECT_TRUE(MatchesPattern(ASCIIToUTF16(test_case.input), pattern)); + const std::u16string pattern = kExpirationDate2DigitYearRe; + EXPECT_TRUE(MatchesPattern(test_case.input, pattern)); } INSTANTIATE_TEST_SUITE_P( AutofillRegexes, ExpirationDate2DigitYearPositive, - testing::Values(InputTestCase{"mm / yy"}, - InputTestCase{"mm/ yy"}, - InputTestCase{"mm /yy"}, - InputTestCase{"mm/yy"}, - InputTestCase{"mm - yy"}, - InputTestCase{"mm- yy"}, - InputTestCase{"mm -yy"}, - InputTestCase{"mm-yy"}, - InputTestCase{"mmyy"}, + testing::Values(InputTestCase{u"mm / yy"}, + InputTestCase{u"mm/ yy"}, + InputTestCase{u"mm /yy"}, + InputTestCase{u"mm/yy"}, + InputTestCase{u"mm - yy"}, + InputTestCase{u"mm- yy"}, + InputTestCase{u"mm -yy"}, + InputTestCase{u"mm-yy"}, + InputTestCase{u"mmyy"}, // Complex two year cases - InputTestCase{"Expiration Date (MM / YY)"}, - InputTestCase{"Expiration Date (MM/YY)"}, - InputTestCase{"Expiration Date (MM - YY)"}, - InputTestCase{"Expiration Date (MM-YY)"}, - InputTestCase{"Expiration Date MM / YY"}, - InputTestCase{"Expiration Date MM/YY"}, - InputTestCase{"Expiration Date MM - YY"}, - InputTestCase{"Expiration Date MM-YY"}, - InputTestCase{"expiration date yy"}, - InputTestCase{"Exp Date (MM / YY)"})); + InputTestCase{u"Expiration Date (MM / YY)"}, + InputTestCase{u"Expiration Date (MM/YY)"}, + InputTestCase{u"Expiration Date (MM - YY)"}, + InputTestCase{u"Expiration Date (MM-YY)"}, + InputTestCase{u"Expiration Date MM / YY"}, + InputTestCase{u"Expiration Date MM/YY"}, + InputTestCase{u"Expiration Date MM - YY"}, + InputTestCase{u"Expiration Date MM-YY"}, + InputTestCase{u"expiration date yy"}, + InputTestCase{u"Exp Date (MM / YY)"})); class ExpirationDate2DigitYearNegative : public testing::TestWithParam<InputTestCase> {}; @@ -120,113 +116,113 @@ class ExpirationDate2DigitYearNegative TEST_P(ExpirationDate2DigitYearNegative, ExpirationDate2DigitYearRegexes) { auto test_case = GetParam(); SCOPED_TRACE(test_case.input); - const base::string16 pattern = ASCIIToUTF16(kExpirationDate2DigitYearRe); - EXPECT_FALSE(MatchesPattern(ASCIIToUTF16(test_case.input), pattern)); + const std::u16string pattern = kExpirationDate2DigitYearRe; + EXPECT_FALSE(MatchesPattern(test_case.input, pattern)); } INSTANTIATE_TEST_SUITE_P( AutofillRegexes, ExpirationDate2DigitYearNegative, - testing::Values(InputTestCase{""}, - InputTestCase{"Look, ma' -- an invalid string!"}, - InputTestCase{"mmfavouritewordyy"}, - InputTestCase{"mm a yy"}, - InputTestCase{"mm a yyyy"}, + testing::Values(InputTestCase{u""}, + InputTestCase{u"Look, ma' -- an invalid string!"}, + InputTestCase{u"mmfavouritewordyy"}, + InputTestCase{u"mm a yy"}, + InputTestCase{u"mm a yyyy"}, // Simple four year cases - InputTestCase{"mm / yyyy"}, - InputTestCase{"mm/ yyyy"}, - InputTestCase{"mm /yyyy"}, - InputTestCase{"mm/yyyy"}, - InputTestCase{"mm - yyyy"}, - InputTestCase{"mm- yyyy"}, - InputTestCase{"mm -yyyy"}, - InputTestCase{"mm-yyyy"}, - InputTestCase{"mmyyyy"}, + InputTestCase{u"mm / yyyy"}, + InputTestCase{u"mm/ yyyy"}, + InputTestCase{u"mm /yyyy"}, + InputTestCase{u"mm/yyyy"}, + InputTestCase{u"mm - yyyy"}, + InputTestCase{u"mm- yyyy"}, + InputTestCase{u"mm -yyyy"}, + InputTestCase{u"mm-yyyy"}, + InputTestCase{u"mmyyyy"}, // Complex four year cases - InputTestCase{"Expiration Date (MM / YYYY)"}, - InputTestCase{"Expiration Date (MM/YYYY)"}, - InputTestCase{"Expiration Date (MM - YYYY)"}, - InputTestCase{"Expiration Date (MM-YYYY)"}, - InputTestCase{"Expiration Date MM / YYYY"}, - InputTestCase{"Expiration Date MM/YYYY"}, - InputTestCase{"Expiration Date MM - YYYY"}, - InputTestCase{"Expiration Date MM-YYYY"}, - InputTestCase{"expiration date yyyy"}, - InputTestCase{"Exp Date (MM / YYYY)"})); + InputTestCase{u"Expiration Date (MM / YYYY)"}, + InputTestCase{u"Expiration Date (MM/YYYY)"}, + InputTestCase{u"Expiration Date (MM - YYYY)"}, + InputTestCase{u"Expiration Date (MM-YYYY)"}, + InputTestCase{u"Expiration Date MM / YYYY"}, + InputTestCase{u"Expiration Date MM/YYYY"}, + InputTestCase{u"Expiration Date MM - YYYY"}, + InputTestCase{u"Expiration Date MM-YYYY"}, + InputTestCase{u"expiration date yyyy"}, + InputTestCase{u"Exp Date (MM / YYYY)"})); class ExpirationDate4DigitYearPositive : public testing::TestWithParam<InputTestCase> {}; TEST_P(ExpirationDate4DigitYearPositive, ExpirationDate4DigitYearRegexes) { auto test_case = GetParam(); - const base::string16 pattern = ASCIIToUTF16(kExpirationDate4DigitYearRe); + const std::u16string pattern = kExpirationDate4DigitYearRe; SCOPED_TRACE(test_case.input); - EXPECT_TRUE(MatchesPattern(ASCIIToUTF16(test_case.input), pattern)); + EXPECT_TRUE(MatchesPattern(test_case.input, pattern)); } INSTANTIATE_TEST_SUITE_P(AutofillRegexes, ExpirationDate4DigitYearPositive, testing::Values( // Simple four year cases - InputTestCase{"mm / yyyy"}, - InputTestCase{"mm/ yyyy"}, - InputTestCase{"mm /yyyy"}, - InputTestCase{"mm/yyyy"}, - InputTestCase{"mm - yyyy"}, - InputTestCase{"mm- yyyy"}, - InputTestCase{"mm -yyyy"}, - InputTestCase{"mm-yyyy"}, - InputTestCase{"mmyyyy"}, + InputTestCase{u"mm / yyyy"}, + InputTestCase{u"mm/ yyyy"}, + InputTestCase{u"mm /yyyy"}, + InputTestCase{u"mm/yyyy"}, + InputTestCase{u"mm - yyyy"}, + InputTestCase{u"mm- yyyy"}, + InputTestCase{u"mm -yyyy"}, + InputTestCase{u"mm-yyyy"}, + InputTestCase{u"mmyyyy"}, // Complex four year cases - InputTestCase{"Expiration Date (MM / YYYY)"}, - InputTestCase{"Expiration Date (MM/YYYY)"}, - InputTestCase{"Expiration Date (MM - YYYY)"}, - InputTestCase{"Expiration Date (MM-YYYY)"}, - InputTestCase{"Expiration Date MM / YYYY"}, - InputTestCase{"Expiration Date MM/YYYY"}, - InputTestCase{"Expiration Date MM - YYYY"}, - InputTestCase{"Expiration Date MM-YYYY"}, - InputTestCase{"expiration date yyyy"}, - InputTestCase{"Exp Date (MM / YYYY)"})); + InputTestCase{u"Expiration Date (MM / YYYY)"}, + InputTestCase{u"Expiration Date (MM/YYYY)"}, + InputTestCase{u"Expiration Date (MM - YYYY)"}, + InputTestCase{u"Expiration Date (MM-YYYY)"}, + InputTestCase{u"Expiration Date MM / YYYY"}, + InputTestCase{u"Expiration Date MM/YYYY"}, + InputTestCase{u"Expiration Date MM - YYYY"}, + InputTestCase{u"Expiration Date MM-YYYY"}, + InputTestCase{u"expiration date yyyy"}, + InputTestCase{u"Exp Date (MM / YYYY)"})); class ExpirationDate4DigitYearNegative : public testing::TestWithParam<InputTestCase> {}; TEST_P(ExpirationDate4DigitYearNegative, ExpirationDate4DigitYearRegexes) { auto test_case = GetParam(); - const base::string16 pattern = ASCIIToUTF16(kExpirationDate4DigitYearRe); + const std::u16string pattern = kExpirationDate4DigitYearRe; SCOPED_TRACE(test_case.input); - EXPECT_FALSE(MatchesPattern(ASCIIToUTF16(test_case.input), pattern)); + EXPECT_FALSE(MatchesPattern(test_case.input, pattern)); } INSTANTIATE_TEST_SUITE_P( AutofillRegexes, ExpirationDate4DigitYearNegative, - testing::Values(InputTestCase{""}, - InputTestCase{"Look, ma' -- an invalid string!"}, - InputTestCase{"mmfavouritewordyy"}, - InputTestCase{"mm a yy"}, - InputTestCase{"mm a yyyy"}, + testing::Values(InputTestCase{u""}, + InputTestCase{u"Look, ma' -- an invalid string!"}, + InputTestCase{u"mmfavouritewordyy"}, + InputTestCase{u"mm a yy"}, + InputTestCase{u"mm a yyyy"}, // Simple two year cases - InputTestCase{"mm / yy"}, - InputTestCase{"mm/ yy"}, - InputTestCase{"mm /yy"}, - InputTestCase{"mm/yy"}, - InputTestCase{"mm - yy"}, - InputTestCase{"mm- yy"}, - InputTestCase{"mm -yy"}, - InputTestCase{"mm-yy"}, - InputTestCase{"mmyy"}, + InputTestCase{u"mm / yy"}, + InputTestCase{u"mm/ yy"}, + InputTestCase{u"mm /yy"}, + InputTestCase{u"mm/yy"}, + InputTestCase{u"mm - yy"}, + InputTestCase{u"mm- yy"}, + InputTestCase{u"mm -yy"}, + InputTestCase{u"mm-yy"}, + InputTestCase{u"mmyy"}, // Complex two year cases - InputTestCase{"Expiration Date (MM / YY)"}, - InputTestCase{"Expiration Date (MM/YY)"}, - InputTestCase{"Expiration Date (MM - YY)"}, - InputTestCase{"Expiration Date (MM-YY)"}, - InputTestCase{"Expiration Date MM / YY"}, - InputTestCase{"Expiration Date MM/YY"}, - InputTestCase{"Expiration Date MM - YY"}, - InputTestCase{"Expiration Date MM-YY"}, - InputTestCase{"expiration date yy"}, - InputTestCase{"Exp Date (MM / YY)"})); + InputTestCase{u"Expiration Date (MM / YY)"}, + InputTestCase{u"Expiration Date (MM/YY)"}, + InputTestCase{u"Expiration Date (MM - YY)"}, + InputTestCase{u"Expiration Date (MM-YY)"}, + InputTestCase{u"Expiration Date MM / YY"}, + InputTestCase{u"Expiration Date MM/YY"}, + InputTestCase{u"Expiration Date MM - YY"}, + InputTestCase{u"Expiration Date MM-YY"}, + InputTestCase{u"expiration date yy"}, + InputTestCase{u"Exp Date (MM / YY)"})); } // namespace autofill diff --git a/chromium/components/autofill/core/browser/autofill_save_address_profile_delegate_ios.cc b/chromium/components/autofill/core/browser/autofill_save_address_profile_delegate_ios.cc new file mode 100644 index 00000000000..9846405d391 --- /dev/null +++ b/chromium/components/autofill/core/browser/autofill_save_address_profile_delegate_ios.cc @@ -0,0 +1,129 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/autofill/core/browser/autofill_save_address_profile_delegate_ios.h" + +#include <utility> + +#include "base/strings/utf_string_conversions.h" +#include "components/autofill/core/common/autofill_constants.h" +#include "components/grit/components_scaled_resources.h" +#include "components/infobars/core/infobar.h" +#include "components/infobars/core/infobar_manager.h" +#include "components/strings/grit/components_strings.h" +#include "ui/base/l10n/l10n_util.h" + +namespace autofill { + +AutofillSaveAddressProfileDelegateIOS::AutofillSaveAddressProfileDelegateIOS( + const AutofillProfile& profile, + AutofillClient::AddressProfileSavePromptCallback callback) + : profile_(profile), + address_profile_save_prompt_callback_(std::move(callback)) {} + +AutofillSaveAddressProfileDelegateIOS:: + ~AutofillSaveAddressProfileDelegateIOS() = default; + +// static +AutofillSaveAddressProfileDelegateIOS* +AutofillSaveAddressProfileDelegateIOS::FromInfobarDelegate( + infobars::InfoBarDelegate* delegate) { + return delegate->GetIdentifier() == + AUTOFILL_ADDRESS_PROFILE_INFOBAR_DELEGATE_IOS + ? static_cast<AutofillSaveAddressProfileDelegateIOS*>(delegate) + : nullptr; +} + +std::u16string +AutofillSaveAddressProfileDelegateIOS::GetMessageDescriptionText() const { + // TODO(crbug.com/1167062): Replace with proper localized string. + return std::u16string(u"Fill forms faster in Chrome"); +} + +std::u16string AutofillSaveAddressProfileDelegateIOS::GetMessageActionText() + const { + // TODO(crbug.com/1167062): Replace with proper localized string. + return std::u16string(u"Save..."); +} + +const autofill::AutofillProfile* +AutofillSaveAddressProfileDelegateIOS::GetProfile() const { + return &profile_; +} + +bool AutofillSaveAddressProfileDelegateIOS::Accept() { + RunSaveAddressProfilePromptCallback( + AutofillClient::SaveAddressProfileOfferUserDecision::kAccepted); + return true; +} + +void AutofillSaveAddressProfileDelegateIOS::InfoBarDismissed() { + // If the address profile modal dialog is presented, the user will be asked to + // save or cancel the address profile. In case the user cancels, then + // InfoBarDismissed() will be called. + if (modal_is_shown_ && !modal_is_dismissed_) + return; + + RunSaveAddressProfilePromptCallback( + AutofillClient::SaveAddressProfileOfferUserDecision::kDeclined); +} + +bool AutofillSaveAddressProfileDelegateIOS::Cancel() { + RunSaveAddressProfilePromptCallback( + AutofillClient::SaveAddressProfileOfferUserDecision::kDeclined); + return true; +} + +int AutofillSaveAddressProfileDelegateIOS::GetIconId() const { + // TODO(crbug.com/1167062): Replace with proper icon. + return IDR_INFOBAR_AUTOFILL_CC; +} + +std::u16string AutofillSaveAddressProfileDelegateIOS::GetMessageText() const { + // TODO(crbug.com/1167062): Replace with proper localized string. + return std::u16string(u"Save address?"); +} + +infobars::InfoBarDelegate::InfoBarIdentifier +AutofillSaveAddressProfileDelegateIOS::GetIdentifier() const { + return AUTOFILL_ADDRESS_PROFILE_INFOBAR_DELEGATE_IOS; +} + +bool AutofillSaveAddressProfileDelegateIOS::ShouldExpire( + const NavigationDetails& details) const { + // Expire the Infobar unless the navigation was triggered by the form that + // presented the Infobar, or the navigation is a redirect. + return !details.is_form_submission && !details.is_redirect; +} + +int AutofillSaveAddressProfileDelegateIOS::GetButtons() const { + return BUTTON_OK | BUTTON_CANCEL; +} + +std::u16string AutofillSaveAddressProfileDelegateIOS::GetButtonLabel( + InfoBarButton button) const { + if (button == BUTTON_OK) { + // TODO(crbug.com/1167062): Replace with proper localized string. + return std::u16string(u"Save"); + } + + if (button == BUTTON_CANCEL) { + // TODO(crbug.com/1167062): Replace with proper localized string. + return std::u16string(u"No Thanks"); + } + + NOTREACHED() << "Unsupported button label requested."; + return std::u16string(); +} + +void AutofillSaveAddressProfileDelegateIOS::RunSaveAddressProfilePromptCallback( + AutofillClient::SaveAddressProfileOfferUserDecision decision) { + std::move(address_profile_save_prompt_callback_).Run(decision, profile_); + + // Reset the modal dialog flags. + modal_is_shown_ = false; + modal_is_dismissed_ = false; +} + +} // namespace autofill diff --git a/chromium/components/autofill/core/browser/autofill_save_address_profile_delegate_ios.h b/chromium/components/autofill/core/browser/autofill_save_address_profile_delegate_ios.h new file mode 100644 index 00000000000..f059a88849e --- /dev/null +++ b/chromium/components/autofill/core/browser/autofill_save_address_profile_delegate_ios.h @@ -0,0 +1,74 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_SAVE_ADDRESS_PROFILE_DELEGATE_IOS_H_ +#define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_SAVE_ADDRESS_PROFILE_DELEGATE_IOS_H_ + +#include <memory> + +#include "base/callback.h" +#include "components/autofill/core/browser/autofill_client.h" +#include "components/autofill/core/browser/data_model/autofill_profile.h" +#include "components/infobars/core/confirm_infobar_delegate.h" + +namespace autofill { + +// A delegate for the prompt that enables the user to allow or deny storing +// an address profile gathered from a form submission. Only used on iOS. +class AutofillSaveAddressProfileDelegateIOS : public ConfirmInfoBarDelegate { + public: + AutofillSaveAddressProfileDelegateIOS( + const AutofillProfile& profile, + AutofillClient::AddressProfileSavePromptCallback callback); + AutofillSaveAddressProfileDelegateIOS( + const AutofillSaveAddressProfileDelegateIOS&) = delete; + AutofillSaveAddressProfileDelegateIOS& operator=( + const AutofillSaveAddressProfileDelegateIOS&) = delete; + ~AutofillSaveAddressProfileDelegateIOS() override; + + // Returns |delegate| as an AutofillSaveAddressProfileDelegateIOS, or nullptr + // if it is of another type. + static AutofillSaveAddressProfileDelegateIOS* FromInfobarDelegate( + infobars::InfoBarDelegate* delegate); + + std::u16string GetMessageDescriptionText() const; + std::u16string GetMessageActionText() const; + const autofill::AutofillProfile* GetProfile() const; + void set_modal_is_shown_to_true() { modal_is_shown_ = true; } + + void set_modal_is_dismissed_to_true() { modal_is_dismissed_ = true; } + + // ConfirmInfoBarDelegate + int GetIconId() const override; + std::u16string GetMessageText() const override; + infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; + bool ShouldExpire(const NavigationDetails& details) const override; + void InfoBarDismissed() override; + int GetButtons() const override; + std::u16string GetButtonLabel(InfoBarButton button) const override; + bool Accept() override; + bool Cancel() override; + + private: + // Fires the |address_profile_save_prompt_callback_| callback. + void RunSaveAddressProfilePromptCallback( + AutofillClient::SaveAddressProfileOfferUserDecision decision); + + // The profile that will be saved if the user accepts. + AutofillProfile profile_; + + // The callback to run once the user makes a decision. + AutofillClient::AddressProfileSavePromptCallback + address_profile_save_prompt_callback_; + + // True if the AddressProfile modal dialog is shown. + bool modal_is_shown_ = false; + + // True if the modal dialog was presented and then dismissed by the user. + bool modal_is_dismissed_ = false; +}; + +} // namespace autofill + +#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_SAVE_ADDRESS_PROFILE_DELEGATE_IOS_H_ diff --git a/chromium/components/autofill/core/browser/autofill_save_address_profile_delegate_ios_unittest.cc b/chromium/components/autofill/core/browser/autofill_save_address_profile_delegate_ios_unittest.cc new file mode 100644 index 00000000000..c003f597d38 --- /dev/null +++ b/chromium/components/autofill/core/browser/autofill_save_address_profile_delegate_ios_unittest.cc @@ -0,0 +1,29 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/autofill/core/browser/autofill_save_address_profile_delegate_ios.h" + +#include <memory> + +#include "base/test/mock_callback.h" +#include "components/autofill/core/browser/autofill_client.h" +#include "components/autofill/core/browser/autofill_test_utils.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace autofill { + +TEST(AutofillSaveAddressProfileDelegateIOSTest, HandleUserAction_Accepted) { + AutofillProfile profile = test::GetFullProfile(); + base::MockCallback<AutofillClient::AddressProfileSavePromptCallback> callback; + auto delegate = std::make_unique<AutofillSaveAddressProfileDelegateIOS>( + profile, callback.Get()); + + EXPECT_CALL( + callback, + Run(AutofillClient::SaveAddressProfileOfferUserDecision::kAccepted, + profile)); + delegate->Accept(); +} + +} // namespace autofill diff --git a/chromium/components/autofill/core/browser/autofill_test_utils.cc b/chromium/components/autofill/core/browser/autofill_test_utils.cc index 4853951bac6..8ab8fe79845 100644 --- a/chromium/components/autofill/core/browser/autofill_test_utils.cc +++ b/chromium/components/autofill/core/browser/autofill_test_utils.cc @@ -28,7 +28,7 @@ #include "components/autofill/core/common/form_data_predictions.h" #include "components/autofill/core/common/form_field_data.h" #include "components/autofill/core/common/form_field_data_predictions.h" -#include "components/autofill/core/common/renderer_id.h" +#include "components/autofill/core/common/unique_ids.h" #include "components/os_crypt/os_crypt_mocker.h" #include "components/pref_registry/pref_registry_syncable.h" #include "components/prefs/pref_service.h" @@ -71,6 +71,12 @@ std::string GetRandomCardNumber() { return value; } +} // namespace + +LocalFrameToken GetLocalFrameToken() { + return LocalFrameToken(base::UnguessableToken::Deserialize(98765, 43210)); +} + FormRendererId MakeFormRendererId() { static uint32_t counter = 10; return FormRendererId(counter++); @@ -81,7 +87,15 @@ FieldRendererId MakeFieldRendererId() { return FieldRendererId(counter++); } -} // namespace +// Creates new, pairwise distinct FormGlobalIds. +FormGlobalId MakeFormGlobalId() { + return {GetLocalFrameToken(), MakeFormRendererId()}; +} + +// Creates new, pairwise distinct FieldGlobalIds. +FieldGlobalId MakeFieldGlobalId() { + return {GetLocalFrameToken(), MakeFieldRendererId()}; +} void SetFormGroupValues(FormGroup& form_group, const std::vector<FormGroupValue>& values) { @@ -137,6 +151,7 @@ void CreateTestFormField(const char* label, const char* value, const char* type, FormFieldData* field) { + field->host_frame = GetLocalFrameToken(); field->unique_renderer_id = MakeFieldRendererId(); field->label = ASCIIToUTF16(label); field->name = ASCIIToUTF16(name); @@ -155,11 +170,11 @@ void CreateTestSelectField(const char* label, // Fill the base attributes. CreateTestFormField(label, name, value, "select-one", field); - std::vector<base::string16> values16(select_size); + std::vector<std::u16string> values16(select_size); for (size_t i = 0; i < select_size; ++i) values16[i] = base::UTF8ToUTF16(values[i]); - std::vector<base::string16> contents16(select_size); + std::vector<std::u16string> contents16(select_size); for (size_t i = 0; i < select_size; ++i) contents16[i] = base::UTF8ToUTF16(contents[i]); @@ -181,11 +196,11 @@ void CreateTestDatalistField(const char* label, // Fill the base attributes. CreateTestFormField(label, name, value, "text", field); - std::vector<base::string16> values16(values.size()); + std::vector<std::u16string> values16(values.size()); for (size_t i = 0; i < values.size(); ++i) values16[i] = base::UTF8ToUTF16(values[i]); - std::vector<base::string16> label16(labels.size()); + std::vector<std::u16string> label16(labels.size()); for (size_t i = 0; i < labels.size(); ++i) label16[i] = base::UTF8ToUTF16(labels[i]); @@ -201,12 +216,11 @@ void CreateTestAddressFormData(FormData* form, const char* unique_id) { void CreateTestAddressFormData(FormData* form, std::vector<ServerFieldTypeSet>* types, const char* unique_id) { + form->host_frame = GetLocalFrameToken(); form->unique_renderer_id = MakeFormRendererId(); - form->name = - ASCIIToUTF16("MyForm") + ASCIIToUTF16(unique_id ? unique_id : ""); - form->button_titles = { - std::make_pair(ASCIIToUTF16("Submit"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; + form->name = u"MyForm" + ASCIIToUTF16(unique_id ? unique_id : ""); + form->button_titles = {std::make_pair( + u"Submit", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; form->url = GURL("https://myform.com/form.html"); form->full_url = GURL("https://myform.com/form.html?foo=bar"); form->action = GURL("https://myform.com/submit.html"); @@ -287,8 +301,7 @@ void CreateTestAddressFormData(FormData* form, void CreateTestPersonalInformationFormData(FormData* form, const char* unique_id) { form->unique_renderer_id = MakeFormRendererId(); - form->name = - ASCIIToUTF16("MyForm") + ASCIIToUTF16(unique_id ? unique_id : ""); + form->name = u"MyForm" + ASCIIToUTF16(unique_id ? unique_id : ""); form->url = GURL("https://myform.com/form.html"); form->full_url = GURL("https://myform.com/form.html?foo=bar"); form->action = GURL("https://myform.com/submit.html"); @@ -312,8 +325,7 @@ void CreateTestCreditCardFormData(FormData* form, bool split_names, const char* unique_id) { form->unique_renderer_id = MakeFormRendererId(); - form->name = - ASCIIToUTF16("MyForm") + ASCIIToUTF16(unique_id ? unique_id : ""); + form->name = u"MyForm" + ASCIIToUTF16(unique_id ? unique_id : ""); if (is_https) { form->url = GURL("https://myform.com/form.html"); form->full_url = GURL("https://myform.com/form.html?foo=bar"); @@ -439,10 +451,9 @@ AutofillProfile GetServerProfile() { "Apt. 42", "Mountain View", "California", "94043", "US", "1.800.555.1234"); - profile.SetInfo(NAME_FULL, ASCIIToUTF16("John K. Doe"), "en"); - profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, ASCIIToUTF16("CEDEX")); - profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, - ASCIIToUTF16("Santa Clara")); + profile.SetInfo(NAME_FULL, u"John K. Doe", "en"); + profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, u"CEDEX"); + profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u"Santa Clara"); profile.set_language_code("en"); profile.SetClientValidityFromBitfieldValue(kValidityStateBitfield); @@ -462,10 +473,9 @@ AutofillProfile GetServerProfile2() { "Apt. 1032", "Sunnyvale", "California", "10011", "US", "+1 514-123-1234"); - profile.SetInfo(NAME_FULL, ASCIIToUTF16("Jim S. Bristow"), "en"); - profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, ASCIIToUTF16("XEDEC")); - profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, - ASCIIToUTF16("Santa Monica")); + profile.SetInfo(NAME_FULL, u"Jim S. Bristow", "en"); + profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, u"XEDEC"); + profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u"Santa Monica"); profile.set_language_code("en"); profile.SetClientValidityFromBitfieldValue(kValidityStateBitfield); @@ -541,7 +551,7 @@ CreditCard GetMaskedServerCardWithNickname() { test::SetCreditCardInfo(&credit_card, "Test user", "1111" /* Visa */, NextMonth().c_str(), NextYear().c_str(), "1"); credit_card.SetNetworkForMaskedCard(kVisaCard); - credit_card.SetNickname(ASCIIToUTF16("Test nickname")); + credit_card.SetNickname(u"Test nickname"); return credit_card; } @@ -550,7 +560,7 @@ CreditCard GetMaskedServerCardWithInvalidNickname() { test::SetCreditCardInfo(&credit_card, "Test user", "1111" /* Visa */, NextMonth().c_str(), NextYear().c_str(), "1"); credit_card.SetNetworkForMaskedCard(kVisaCard); - credit_card.SetNickname(ASCIIToUTF16("Invalid nickname which is too long")); + credit_card.SetNickname(u"Invalid nickname which is too long"); return credit_card; } @@ -598,7 +608,7 @@ CreditCard GetRandomCreditCard(CreditCard::RecordType record_type) { CreditCardCloudTokenData GetCreditCardCloudTokenData1() { CreditCardCloudTokenData data; data.masked_card_id = "data1_id"; - data.suffix = ASCIIToUTF16("1111"); + data.suffix = u"1111"; data.exp_month = 1; base::StringToInt(NextYear(), &data.exp_year); data.card_art_url = "fake url 1"; @@ -609,7 +619,7 @@ CreditCardCloudTokenData GetCreditCardCloudTokenData1() { CreditCardCloudTokenData GetCreditCardCloudTokenData2() { CreditCardCloudTokenData data; data.masked_card_id = "data2_id"; - data.suffix = ASCIIToUTF16("2222"); + data.suffix = u"2222"; data.exp_month = 2; base::StringToInt(NextYear(), &data.exp_year); data.exp_year += 1; @@ -882,7 +892,7 @@ void GenerateTestAutofillPopup( autofill_external_delegate->OnQuery(query_id, form, field, bounds); std::vector<Suggestion> suggestions; - suggestions.push_back(Suggestion(base::ASCIIToUTF16("Test suggestion"))); + suggestions.push_back(Suggestion(u"Test suggestion")); autofill_external_delegate->OnSuggestionsReturned( query_id, suggestions, /*autoselect_first_suggestion=*/false); } diff --git a/chromium/components/autofill/core/browser/autofill_test_utils.h b/chromium/components/autofill/core/browser/autofill_test_utils.h index 3944ae1c830..75b89b53556 100644 --- a/chromium/components/autofill/core/browser/autofill_test_utils.h +++ b/chromium/components/autofill/core/browser/autofill_test_utils.h @@ -68,6 +68,21 @@ struct FormGroupValue { // Convenience declaration for multiple FormGroup values. using FormGroupValues = std::vector<FormGroupValue>; +// Creates a non-empty LocalFrameToken (no variation among different calls). +LocalFrameToken GetLocalFrameToken(); + +// Creates new, pairwise distinct FormRendererIds. +FormRendererId MakeFormRendererId(); + +// Creates new, pairwise distinct FieldRendererIds. +FieldRendererId MakeFieldRendererId(); + +// Creates new, pairwise distinct FormGlobalIds. +FormGlobalId MakeFormGlobalId(); + +// Creates new, pairwise distinct FieldGlobalIds. +FieldGlobalId MakeFieldGlobalId(); + // Helper function to set values and verification statuses to a form group. void SetFormGroupValues(FormGroup& form_group, const std::vector<FormGroupValue>& values); diff --git a/chromium/components/autofill/core/browser/autofill_type.cc b/chromium/components/autofill/core/browser/autofill_type.cc index 83ceb74943e..9b583bf8d65 100644 --- a/chromium/components/autofill/core/browser/autofill_type.cc +++ b/chromium/components/autofill/core/browser/autofill_type.cc @@ -103,6 +103,11 @@ FieldTypeGroup GroupTypeOfServerFieldType(ServerFieldType field_type) { case COMPANY_NAME: return FieldTypeGroup::kCompany; + case MERCHANT_PROMO_CODE: + // TODO(crbug/1190334): Create new field type group kMerchantPromoCode. + // (This involves updating many switch statements.) + return FieldTypeGroup::kNoGroup; + case PASSWORD: case ACCOUNT_CREATION_PASSWORD: case NOT_ACCOUNT_CREATION_PASSWORD: @@ -125,7 +130,6 @@ FieldTypeGroup GroupTypeOfServerFieldType(ServerFieldType field_type) { case PHONE_FAX_WHOLE_NUMBER: case FIELD_WITH_DEFAULT_VALUE: case MERCHANT_EMAIL_SIGNUP: - case MERCHANT_PROMO_CODE: case UPI_VPA: return FieldTypeGroup::kNoGroup; diff --git a/chromium/components/autofill/core/browser/data_driven_test.h b/chromium/components/autofill/core/browser/data_driven_test.h index 12b98adb845..293e56167a4 100644 --- a/chromium/components/autofill/core/browser/data_driven_test.h +++ b/chromium/components/autofill/core/browser/data_driven_test.h @@ -9,7 +9,6 @@ #include "base/files/file_path.h" #include "base/macros.h" -#include "base/strings/string16.h" namespace autofill { 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); diff --git a/chromium/components/autofill/core/browser/field_filler.cc b/chromium/components/autofill/core/browser/field_filler.cc index 0e574dd27f0..11756bd8d73 100644 --- a/chromium/components/autofill/core/browser/field_filler.cc +++ b/chromium/components/autofill/core/browser/field_filler.cc @@ -45,14 +45,14 @@ namespace { // Returns true if the value was successfully set, meaning |value| was found in // the list of select options in |field|. Optionally, the caller may pass // |best_match_index| which will be set to the index of the best match. -bool SetSelectControlValue(const base::string16& value, +bool SetSelectControlValue(const std::u16string& value, FormFieldData* field, size_t* best_match_index, std::string* failure_to_fill) { l10n::CaseInsensitiveCompare compare; DCHECK_EQ(field->option_values.size(), field->option_contents.size()); - base::string16 best_match; + std::u16string best_match; for (size_t i = 0; i < field->option_values.size(); ++i) { if (value == field->option_values[i] || value == field->option_contents[i]) { @@ -87,7 +87,7 @@ bool SetSelectControlValue(const base::string16& value, // Like SetSelectControlValue, but searches within the field values and options // for |value|. For example, "NC - North Carolina" would match "north carolina". -bool SetSelectControlValueSubstringMatch(const base::string16& value, +bool SetSelectControlValueSubstringMatch(const std::u16string& value, bool ignore_whitespace, FormFieldData* field, std::string* failure_to_fill) { @@ -110,10 +110,10 @@ bool SetSelectControlValueSubstringMatch(const base::string16& value, // Like SetSelectControlValue, but searches within the field values and options // for |value|. First it tokenizes the options, then tries to match against // tokens. For example, "NC - North Carolina" would match "nc" but not "ca". -bool SetSelectControlValueTokenMatch(const base::string16& value, +bool SetSelectControlValueTokenMatch(const std::u16string& value, FormFieldData* field, std::string* failure_to_fill) { - std::vector<base::string16> tokenized; + std::vector<std::u16string> tokenized; DCHECK_EQ(field->option_values.size(), field->option_contents.size()); l10n::CaseInsensitiveCompare compare; @@ -122,7 +122,7 @@ bool SetSelectControlValueTokenMatch(const base::string16& value, base::SplitString(field->option_values[i], base::kWhitespaceASCIIAs16, base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); if (std::find_if(tokenized.begin(), tokenized.end(), - [&compare, value](base::string16& rhs) { + [&compare, value](std::u16string& rhs) { return compare.StringsEqual(value, rhs); }) != tokenized.end()) { field->value = field->option_values[i]; @@ -133,7 +133,7 @@ bool SetSelectControlValueTokenMatch(const base::string16& value, base::SplitString(field->option_contents[i], base::kWhitespaceASCIIAs16, base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); if (std::find_if(tokenized.begin(), tokenized.end(), - [&compare, value](base::string16& rhs) { + [&compare, value](std::u16string& rhs) { return compare.StringsEqual(value, rhs); }) != tokenized.end()) { field->value = field->option_values[i]; @@ -151,7 +151,7 @@ bool SetSelectControlValueTokenMatch(const base::string16& value, // Helper method to normalize the |admin_area| for the given |country_code|. // The value in |admin_area| will be overwritten. -bool NormalizeAdminAreaForCountryCode(base::string16* admin_area, +bool NormalizeAdminAreaForCountryCode(std::u16string* admin_area, const std::string& country_code, AddressNormalizer* address_normalizer) { DCHECK(address_normalizer); @@ -171,7 +171,7 @@ bool NormalizeAdminAreaForCountryCode(base::string16* admin_area, // Will normalize |value| and the options in |field| with |address_normalizer| // (which should not be null), and return whether the fill was successful. -bool SetNormalizedStateSelectControlValue(const base::string16& value, +bool SetNormalizedStateSelectControlValue(const std::u16string& value, FormFieldData* field, const std::string& country_code, AddressNormalizer* address_normalizer, @@ -182,7 +182,7 @@ bool SetNormalizedStateSelectControlValue(const base::string16& value, // the normalizer will fetch the rule for next time it's called. // TODO(crbug.com/788417): We should probably sanitize |value| before // normalizing. - base::string16 field_value = value; + std::u16string field_value = value; if (!NormalizeAdminAreaForCountryCode(&field_value, country_code, address_normalizer)) { if (failure_to_fill) @@ -246,13 +246,13 @@ bool FillNumericSelectControl(int value, return false; } -bool FillStateSelectControl(const base::string16& value, +bool FillStateSelectControl(const std::u16string& value, FormFieldData* field, const std::string& country_code, AddressNormalizer* address_normalizer, std::string* failure_to_fill) { - std::vector<base::string16> abbreviations; - std::vector<base::string16> full_names; + std::vector<std::u16string> abbreviations; + std::vector<std::u16string> full_names; if (base::FeatureList::IsEnabled( features::kAutofillUseAlternativeStateNameMap)) { @@ -273,8 +273,8 @@ bool FillStateSelectControl(const base::string16& value, } } - base::string16 full; - base::string16 abbreviation; + std::u16string full; + std::u16string abbreviation; // |abbreviation| will be empty for non-US countries. state_names::GetNameAndAbbreviation(value, &full, &abbreviation); @@ -331,7 +331,7 @@ bool FillStateSelectControl(const base::string16& value, return false; } -bool FillCountrySelectControl(const base::string16& value, +bool FillCountrySelectControl(const std::u16string& value, FormFieldData* field_data, std::string* failure_to_fill) { std::string country_code = CountryNames::GetInstance()->GetCountryCode(value); @@ -346,8 +346,8 @@ bool FillCountrySelectControl(const base::string16& value, for (size_t i = 0; i < field_data->option_values.size(); ++i) { // Canonicalize each <option> value to a country code, and compare to the // target country code. - base::string16 value = field_data->option_values[i]; - base::string16 contents = field_data->option_contents[i]; + std::u16string value = field_data->option_values[i]; + std::u16string contents = field_data->option_contents[i]; if (country_code == CountryNames::GetInstance()->GetCountryCode(value) || country_code == CountryNames::GetInstance()->GetCountryCode(contents)) { field_data->value = value; @@ -365,7 +365,7 @@ bool FillCountrySelectControl(const base::string16& value, // Attempt to fill the user's expiration month |value| inside the <select> // |field|. Since |value| is well defined but the website's |field| option // values may not be, some heuristics are run to cover all observed cases. -bool FillExpirationMonthSelectControl(const base::string16& value, +bool FillExpirationMonthSelectControl(const std::u16string& value, const std::string& app_locale, FormFieldData* field, std::string* failure_to_fill) { @@ -379,16 +379,16 @@ bool FillExpirationMonthSelectControl(const base::string16& value, // Trim the whitespace and specific prefixes used in AngularJS from the // select values before attempting to convert them to months. - std::vector<base::string16> trimmed_values(field->option_values.size()); - const base::string16 kNumberPrefix = ASCIIToUTF16("number:"); - const base::string16 kStringPrefix = ASCIIToUTF16("string:"); + std::vector<std::u16string> trimmed_values(field->option_values.size()); + const std::u16string kNumberPrefix = u"number:"; + const std::u16string kStringPrefix = u"string:"; for (size_t i = 0; i < field->option_values.size(); ++i) { base::TrimWhitespace(field->option_values[i], base::TRIM_ALL, &trimmed_values[i]); base::ReplaceFirstSubstringAfterOffset(&trimmed_values[i], 0, kNumberPrefix, - ASCIIToUTF16("")); + u""); base::ReplaceFirstSubstringAfterOffset(&trimmed_values[i], 0, kStringPrefix, - ASCIIToUTF16("")); + u""); } if (trimmed_values.size() == 12) { @@ -442,7 +442,7 @@ bool FillExpirationMonthSelectControl(const base::string16& value, } // Returns true if the last two digits in |year| match those in |str|. -bool LastTwoDigitsMatch(const base::string16& year, const base::string16& str) { +bool LastTwoDigitsMatch(const std::u16string& year, const std::u16string& str) { int year_int; int str_int; if (!StringToInt(year, &year_int) || !StringToInt(str, &str_int)) @@ -453,7 +453,7 @@ bool LastTwoDigitsMatch(const base::string16& year, const base::string16& str) { // Try to fill a year |value| into the given |field| by comparing the last two // digits of the year to the field's options. -bool FillYearSelectControl(const base::string16& value, +bool FillYearSelectControl(const std::u16string& value, FormFieldData* field, std::string* failure_to_fill) { if (value.size() != 2U && value.size() != 4U) { @@ -483,7 +483,7 @@ bool FillYearSelectControl(const base::string16& value, // given |field|. We ignore whitespace when filling credit card types to // allow for cases such as "Master card". -bool FillCreditCardTypeSelectControl(const base::string16& value, +bool FillCreditCardTypeSelectControl(const std::u16string& value, FormFieldData* field, std::string* failure_to_fill) { if (SetSelectControlValueSubstringMatch(value, /* ignore_whitespace= */ true, @@ -492,7 +492,7 @@ bool FillCreditCardTypeSelectControl(const base::string16& value, } if (value == l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_AMEX)) { // For American Express, also try filling as "AmEx". - return SetSelectControlValueSubstringMatch(ASCIIToUTF16("AmEx"), + return SetSelectControlValueSubstringMatch(u"AmEx", /* ignore_whitespace= */ true, field, failure_to_fill); } @@ -502,14 +502,15 @@ bool FillCreditCardTypeSelectControl(const base::string16& value, return false; } -// Set |field_data|'s value to |number|, or possibly an appropriate substring of -// |number|. The |field| specifies the type of the phone and whether this is a -// phone prefix or suffix. +// Set |field_data|'s value to |number|, or |phone_home_city_and_number|, or +// possibly an appropriate substring of |number|. The |field| specifies the +// type of the phone and whether this is a phone prefix or suffix. void FillPhoneNumberField(const AutofillField& field, - const base::string16& number, + const std::u16string& number, + const std::u16string& phone_home_city_and_number, FormFieldData* field_data) { - field_data->value = - FieldFiller::GetPhoneNumberValue(field, number, *field_data); + field_data->value = FieldFiller::GetPhoneNumberValue( + field, number, phone_home_city_and_number, *field_data); } // Set |field_data|'s value to |number|, or possibly an appropriate substring @@ -518,15 +519,15 @@ void FillPhoneNumberField(const AutofillField& field, // The |field| specifies the |credit_card_number_offset_| to the substring // within credit card number. void FillCreditCardNumberField(const AutofillField& field, - const base::string16& number, + const std::u16string& number, FormFieldData* field_data) { - base::string16 value = number; + std::u16string value = number; // |field|'s max_length truncates credit card number to fit within. if (field.credit_card_number_offset() < number.length()) { field_data->value = number.substr( field.credit_card_number_offset(), - field.max_length > 0 ? field.max_length : base::string16::npos); + field.max_length > 0 ? field.max_length : std::u16string::npos); } else { // If the offset exceeds the length of the number, simply fill the whole // number. By this, a wrongly detected second credit card number field @@ -538,7 +539,7 @@ void FillCreditCardNumberField(const AutofillField& field, // Fills in the select control |field| with |value|. If an exact match is not // found, falls back to alternate filling strategies based on the |type|. bool FillSelectControl(const AutofillType& type, - const base::string16& value, + const std::u16string& value, absl::variant<const AutofillProfile*, const CreditCard*> profile_or_credit_card, const std::string& app_locale, @@ -592,14 +593,14 @@ bool FillSelectControl(const AutofillType& type, // Fills in the month control |field| with the expiration date in |card|. void FillMonthControl(const CreditCard& card, FormFieldData* field) { - field->value = card.Expiration4DigitYearAsString() + ASCIIToUTF16("-") + + field->value = card.Expiration4DigitYearAsString() + u"-" + card.Expiration2DigitMonthAsString(); } // Fills |field| with the street address in |value|. Translates newlines into // equivalent separators when necessary, i.e. when filling a single-line field. // The separators depend on |address_language_code|. -void FillStreetAddress(const base::string16& value, +void FillStreetAddress(const std::u16string& value, const std::string& address_language_code, FormFieldData* field) { if (field->form_control_type == "textarea") { @@ -627,7 +628,7 @@ void FillStreetAddress(const base::string16& value, // abbreviations are tried. // Does not fill if neither |value| nor the canonical state name nor its // abbreviation fit into the field. -bool FillStateText(const base::string16& value, +bool FillStateText(const std::u16string& value, const std::string& country_code, FormFieldData* field, std::string* failure_to_fill) { @@ -662,7 +663,7 @@ bool FillStateText(const base::string16& value, } // Fill with the state abbreviation. - base::string16 abbreviation; + std::u16string abbreviation; state_names::GetNameAndAbbreviation(value, nullptr, &abbreviation); if (!abbreviation.empty() && field->max_length >= abbreviation.size()) { field->value = base::i18n::ToUpper(abbreviation); @@ -677,7 +678,7 @@ bool FillStateText(const base::string16& value, // Fills the expiration year |value| into the |field|. Uses the |field_type| // and the |field|'s max_length attribute to determine if the |value| needs to // be truncated. -void FillExpirationYearInput(base::string16 value, +void FillExpirationYearInput(std::u16string value, ServerFieldType field_type, FormFieldData* field) { // If the |field_type| requires only 2 digits, keep only the last 2 digits of @@ -700,12 +701,12 @@ void FillExpirationYearInput(base::string16 value, // Uses the |field|'s max_length attribute to determine if the |value| needs to // be truncated. |value| should be a date formatted as either MM/YY or MM/YYYY. // If it isn't, the field doesn't get filled. -bool FillExpirationDateInput(const base::string16& value, +bool FillExpirationDateInput(const std::u16string& value, FormFieldData* field, std::string* failure_to_fill) { - const base::string16 kSeparator = ASCIIToUTF16("/"); + const std::u16string kSeparator = u"/"; // Autofill formats a combined date as month/year. - std::vector<base::string16> pieces = base::SplitString( + std::vector<std::u16string> pieces = base::SplitString( value, kSeparator, base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); if (pieces.size() != 2) { if (failure_to_fill) @@ -713,8 +714,8 @@ bool FillExpirationDateInput(const base::string16& value, return false; } - base::string16 month = pieces[0]; - base::string16 year = pieces[1]; + std::u16string month = pieces[0]; + std::u16string year = pieces[1]; if (month.length() != 2 || (year.length() != 2 && year.length() != 4)) { if (failure_to_fill) *failure_to_fill += "Unexpected length of month or year to fill. "; @@ -751,7 +752,7 @@ bool FillExpirationDateInput(const base::string16& value, case 7: if (year.length() != 4) { // Will normalize 2-digit years to the 4-digit version. - year = ASCIIToUTF16("20") + year; + year = u"20" + year; } if (field->max_length == 6) { @@ -770,8 +771,8 @@ bool FillExpirationDateInput(const base::string16& value, return true; } -base::string16 RemoveWhitespace(const base::string16& value) { - base::string16 stripped_value; +std::u16string RemoveWhitespace(const std::u16string& value) { + std::u16string stripped_value; base::RemoveChars(value, base::kWhitespaceUTF16, &stripped_value); return stripped_value; } @@ -780,7 +781,7 @@ base::string16 RemoveWhitespace(const base::string16& value) { // |country_code|. // If the exact match is not found, extracts the digits (ignoring leading '00' // or '+') from each option and compares them with the |country_code|. -void FillPhoneCountryCodeSelectControl(const base::string16& country_code, +void FillPhoneCountryCodeSelectControl(const std::u16string& country_code, FormFieldData* field, std::string* failure_to_fill) { if (country_code.empty()) @@ -792,10 +793,10 @@ void FillPhoneCountryCodeSelectControl(const base::string16& country_code, return; for (size_t i = 0; i < field->option_contents.size(); i++) { - base::string16 cc_candidate_in_value = + std::u16string cc_candidate_in_value = data_util::FindPossiblePhoneCountryCode( RemoveWhitespace(field->option_values[i])); - base::string16 cc_candidate_in_content = + std::u16string cc_candidate_in_content = data_util::FindPossiblePhoneCountryCode( RemoveWhitespace(field->option_contents[i])); if (cc_candidate_in_value == country_code || @@ -819,11 +820,11 @@ bool FieldFiller::FillFormField( absl::variant<const AutofillProfile*, const CreditCard*> profile_or_credit_card, FormFieldData* field_data, - const base::string16& cvc, + const std::u16string& cvc, std::string* failure_to_fill) { const AutofillType type = field.Type(); - base::string16 value; + std::u16string value; if (absl::holds_alternative<const AutofillProfile*>(profile_or_credit_card)) { const AutofillProfile* profile = absl::get<const AutofillProfile*>(profile_or_credit_card); @@ -861,7 +862,13 @@ bool FieldFiller::FillFormField( type.GetStorableType() == PHONE_HOME_COUNTRY_CODE) { FillPhoneCountryCodeSelectControl(value, field_data, failure_to_fill); } else { - FillPhoneNumberField(field, value, field_data); + DCHECK(absl::holds_alternative<const AutofillProfile*>( + profile_or_credit_card)); + const std::u16string phone_home_city_and_number = + absl::get<const AutofillProfile*>(profile_or_credit_card) + ->GetInfo(PHONE_HOME_CITY_AND_NUMBER, app_locale_); + FillPhoneNumberField(field, value, phone_home_city_and_number, + field_data); } return true; } @@ -915,9 +922,10 @@ bool FieldFiller::FillFormField( // TODO(crbug.com/581514): Add support for filling only the prefix/suffix for // phone numbers with 10 or 11 digits. // static -base::string16 FieldFiller::GetPhoneNumberValue( +std::u16string FieldFiller::GetPhoneNumberValue( const AutofillField& field, - const base::string16& number, + const std::u16string& number, + const std::u16string& phone_home_city_and_number, const FormFieldData& field_data) { // TODO(crbug.com/581485): Investigate the use of libphonenumber here. // Check to see if the |field| size matches the "prefix" or "suffix" size or @@ -941,11 +949,16 @@ base::string16 FieldFiller::GetPhoneNumberValue( if (field_data.max_length == 0) return number; - // If |number| exceeds the maximum size of the field, cut the first part to - // provide a valid number for the field. For example, the number 15142365264 - // with a field with a max length of 10 would return 5142365264, thus removing - // the country code and remaining valid. if (number.length() > field_data.max_length) { + // Try after removing the country code, if |number| exceeds the maximum size + // of the field. + if (phone_home_city_and_number.length() <= field_data.max_length) + return phone_home_city_and_number; + + // If |number| exceeds the maximum size of the field, cut the first part to + // provide a valid number for the field. For example, the number 15142365264 + // with a field with a max length of 10 would return 5142365264, thus + // filling in the last |field_data.max_length| characters from the |number|. return number.substr(number.length() - field_data.max_length, field_data.max_length); } @@ -955,23 +968,23 @@ base::string16 FieldFiller::GetPhoneNumberValue( // static int FieldFiller::FindShortestSubstringMatchInSelect( - const base::string16& value, + const std::u16string& value, bool ignore_whitespace, const FormFieldData* field) { DCHECK_EQ(field->option_values.size(), field->option_contents.size()); int best_match = -1; - base::string16 value_stripped = + std::u16string value_stripped = ignore_whitespace ? RemoveWhitespace(value) : value; base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents searcher( value_stripped); for (size_t i = 0; i < field->option_values.size(); ++i) { - base::string16 option_value = + std::u16string option_value = ignore_whitespace ? RemoveWhitespace(field->option_values[i]) : field->option_values[i]; - base::string16 option_content = + std::u16string option_content = ignore_whitespace ? RemoveWhitespace(field->option_contents[i]) : field->option_contents[i]; if (searcher.Search(option_value, nullptr, nullptr) || diff --git a/chromium/components/autofill/core/browser/field_filler.h b/chromium/components/autofill/core/browser/field_filler.h index d549587b980..7dc1218827f 100644 --- a/chromium/components/autofill/core/browser/field_filler.h +++ b/chromium/components/autofill/core/browser/field_filler.h @@ -8,7 +8,6 @@ #include <string> #include "base/macros.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" #include "components/autofill/core/browser/data_model/credit_card.h" #include "components/autofill/core/common/form_field_data.h" @@ -36,19 +35,21 @@ class FieldFiller { absl::variant<const AutofillProfile*, const CreditCard*> profile_or_credit_card, FormFieldData* field_data, - const base::string16& cvc, + const std::u16string& cvc, std::string* failure_to_fill = nullptr); // Returns the phone number value for the given |field|. The returned value - // might be |number|, or could possibly be a meaningful subset |number|, if - // that's appropriate for the field. - static base::string16 GetPhoneNumberValue(const AutofillField& field, - const base::string16& number, - const FormFieldData& field_data); + // might be |number|, or |phone_home_city_and_number|, or could possibly be a + // meaningful subset |number|, if that's appropriate for the field. + static std::u16string GetPhoneNumberValue( + const AutofillField& field, + const std::u16string& number, + const std::u16string& phone_home_city_and_number, + const FormFieldData& field_data); // Returns the index of the shortest entry in the given select field of which // |value| is a substring. Returns -1 if no such entry exists. - static int FindShortestSubstringMatchInSelect(const base::string16& value, + static int FindShortestSubstringMatchInSelect(const std::u16string& value, bool ignore_whitespace, const FormFieldData* field); diff --git a/chromium/components/autofill/core/browser/field_filler_unittest.cc b/chromium/components/autofill/core/browser/field_filler_unittest.cc index 1d32da08cfc..f550a9c6202 100644 --- a/chromium/components/autofill/core/browser/field_filler_unittest.cc +++ b/chromium/components/autofill/core/browser/field_filler_unittest.cc @@ -72,8 +72,8 @@ const std::vector<const char*> NotNumericMonthsContentsWithPlaceholder() { } // Returns the index of |value| in |values|. -void GetIndexOfValue(const std::vector<base::string16>& values, - const base::string16& value, +void GetIndexOfValue(const std::vector<std::u16string>& values, + const std::u16string& value, size_t* index) { for (size_t i = 0; i < values.size(); ++i) { if (values[i] == value) { @@ -101,19 +101,19 @@ void TestFillingExpirationMonth(const std::vector<const char*>& values, // Try a single-digit month. CreditCard card = test::GetCreditCard(); card.SetExpirationMonth(3); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); GetIndexOfValue(field.option_values, field.value, &content_index); - EXPECT_EQ(ASCIIToUTF16("Mar"), field.option_contents[content_index]); + EXPECT_EQ(u"Mar", field.option_contents[content_index]); // Try a two-digit month. card.SetExpirationMonth(11); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); GetIndexOfValue(field.option_values, field.value, &content_index); - EXPECT_EQ(ASCIIToUTF16("Nov"), field.option_contents[content_index]); + EXPECT_EQ(u"Nov", field.option_contents[content_index]); } -void TestFillingInvalidFields(const base::string16& state, - const base::string16& city) { +void TestFillingInvalidFields(const std::u16string& state, + const std::u16string& city) { AutofillProfile profile = test::GetFullProfile(); profile.SetValidityState(ADDRESS_HOME_STATE, AutofillProfile::INVALID, AutofillProfile::SERVER); @@ -127,11 +127,11 @@ void TestFillingInvalidFields(const base::string16& state, FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); filler.FillFormField(field_state, &profile, &field_state, - /*cvc=*/base::string16()); + /*cvc=*/std::u16string()); EXPECT_EQ(state, field_state.value); filler.FillFormField(field_city, &profile, &field_city, - /*cvc=*/base::string16()); + /*cvc=*/std::u16string()); EXPECT_EQ(city, field_city.value); } @@ -292,26 +292,26 @@ TEST_F(AutofillFieldFillerTest, TEST_F(AutofillFieldFillerTest, IsEmpty) { AutofillField field; - ASSERT_EQ(base::string16(), field.value); + ASSERT_EQ(std::u16string(), field.value); // Field value is empty. EXPECT_TRUE(field.IsEmpty()); // Field value is non-empty. - field.value = ASCIIToUTF16("Value"); + field.value = u"Value"; EXPECT_FALSE(field.IsEmpty()); } TEST_F(AutofillFieldFillerTest, FieldSignatureAsStr) { AutofillField field; - ASSERT_EQ(base::string16(), field.name); + ASSERT_EQ(std::u16string(), field.name); ASSERT_EQ(std::string(), field.form_control_type); // Signature is empty. EXPECT_EQ("2085434232", field.FieldSignatureAsStr()); // Field name is set. - field.name = ASCIIToUTF16("Name"); + field.name = u"Name"; EXPECT_EQ("1606968241", field.FieldSignatureAsStr()); // Field form control type is set. @@ -364,12 +364,12 @@ TEST_F(AutofillFieldFillerTest, field.set_heuristic_type(NAME_FIRST); // Non credit card related field. - address()->SetRawInfo(NAME_FIRST, ASCIIToUTF16("Test")); + address()->SetRawInfo(NAME_FIRST, u"Test"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, address(), &field, /*cvc=*/base::string16()); + filler.FillFormField(field, address(), &field, /*cvc=*/std::u16string()); // Verify that the field is filled in all circumstances. - EXPECT_EQ(ASCIIToUTF16("Test"), field.value); + EXPECT_EQ(u"Test", field.value); } // Verify that credit card related fields with the autocomplete attribute @@ -380,12 +380,12 @@ TEST_F(AutofillFieldFillerTest, FillFormField_AutocompleteOff_CreditCardField) { field.set_heuristic_type(CREDIT_CARD_NUMBER); // Credit card related field. - credit_card()->SetNumber(ASCIIToUTF16("4111111111111111")); + credit_card()->SetNumber(u"4111111111111111"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, credit_card(), &field, /*cvc=*/base::string16()); + filler.FillFormField(field, credit_card(), &field, /*cvc=*/std::u16string()); // Verify that the field is filled. - EXPECT_EQ(ASCIIToUTF16("4111111111111111"), field.value); + EXPECT_EQ(u"4111111111111111", field.value); } // Verify that the correct value is returned if the maximum length of the credit @@ -398,13 +398,13 @@ TEST_F(AutofillFieldFillerTest, field.set_heuristic_type(CREDIT_CARD_NUMBER); // Credit card related field. - credit_card()->SetNumber(ASCIIToUTF16("0123456789999999")); + credit_card()->SetNumber(u"0123456789999999"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, credit_card(), &field, /*cvc=*/base::string16()); + filler.FillFormField(field, credit_card(), &field, /*cvc=*/std::u16string()); // Verify that the field is filled with the fourth digit of the credit card // number. - EXPECT_EQ(ASCIIToUTF16("23456789999999"), field.value); + EXPECT_EQ(u"23456789999999", field.value); } // Verify that the full credit card number is returned if the offset exceeds the @@ -417,12 +417,12 @@ TEST_F(AutofillFieldFillerTest, field.set_heuristic_type(CREDIT_CARD_NUMBER); // Credit card related field. - credit_card()->SetNumber(ASCIIToUTF16("0123456789999999")); + credit_card()->SetNumber(u"0123456789999999"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, credit_card(), &field, /*cvc=*/base::string16()); + filler.FillFormField(field, credit_card(), &field, /*cvc=*/std::u16string()); // Verify that the field is filled with the full credit card number. - EXPECT_EQ(ASCIIToUTF16("0123456789999999"), field.value); + EXPECT_EQ(u"0123456789999999", field.value); } // Verify that only the truncated and offsetted value of the credit card number @@ -435,13 +435,13 @@ TEST_F(AutofillFieldFillerTest, field.set_heuristic_type(CREDIT_CARD_NUMBER); // Credit card related field. - credit_card()->SetNumber(ASCIIToUTF16("0123456789999999")); + credit_card()->SetNumber(u"0123456789999999"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, credit_card(), &field, /*cvc=*/base::string16()); + filler.FillFormField(field, credit_card(), &field, /*cvc=*/std::u16string()); // Verify that the field is filled with the third digit of the credit card // number. - EXPECT_EQ(ASCIIToUTF16("3"), field.value); + EXPECT_EQ(u"3", field.value); } // Verify that only the truncated value of the credit card number is set. @@ -451,13 +451,13 @@ TEST_F(AutofillFieldFillerTest, FillFormField_MaxLength_CreditCardField) { field.set_heuristic_type(CREDIT_CARD_NUMBER); // Credit card related field. - credit_card()->SetNumber(ASCIIToUTF16("4111111111111111")); + credit_card()->SetNumber(u"4111111111111111"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, credit_card(), &field, /*cvc=*/base::string16()); + filler.FillFormField(field, credit_card(), &field, /*cvc=*/std::u16string()); // Verify that the field is filled with only the first digit of the credit // card number. - EXPECT_EQ(ASCIIToUTF16("4"), field.value); + EXPECT_EQ(u"4", field.value); } // Verify that when the relevant feature is enabled, the invalid fields don't @@ -469,8 +469,8 @@ TEST_F(AutofillFieldFillerTest, FillFormField_Validity_ServerClient) { features::kAutofillProfileClientValidation}, /*disabled_features=*/{}); // State's validity is set by server and city's validity by client. - TestFillingInvalidFields(/*state=*/base::string16(), - /*city=*/base::string16()); + TestFillingInvalidFields(/*state=*/std::u16string(), + /*city=*/std::u16string()); } TEST_F(AutofillFieldFillerTest, FillFormField_Validity_OnlyServer) { @@ -479,8 +479,8 @@ TEST_F(AutofillFieldFillerTest, FillFormField_Validity_OnlyServer) { /*enabled_features=*/{features::kAutofillProfileServerValidation}, /*disabled_features=*/{features::kAutofillProfileClientValidation}); // State's validity is set by server and city's validity by client. - TestFillingInvalidFields(/*state=*/base::string16(), - /*city=*/ASCIIToUTF16("Elysium")); + TestFillingInvalidFields(/*state=*/std::u16string(), + /*city=*/u"Elysium"); } TEST_F(AutofillFieldFillerTest, FillFormField_Validity_OnlyClient) { @@ -489,8 +489,8 @@ TEST_F(AutofillFieldFillerTest, FillFormField_Validity_OnlyClient) { /*enabled_features=*/{features::kAutofillProfileClientValidation}, /*disabled_features=*/{features::kAutofillProfileServerValidation}); // State's validity is set by server and city's validity by client. - TestFillingInvalidFields(/*state=*/ASCIIToUTF16("CA"), - /*city=*/base::string16()); + TestFillingInvalidFields(/*state=*/u"CA", + /*city=*/std::u16string()); } TEST_F(AutofillFieldFillerTest, FillFormField_NoValidity) { @@ -500,8 +500,8 @@ TEST_F(AutofillFieldFillerTest, FillFormField_NoValidity) { /*disabled_features=*/{features::kAutofillProfileServerValidation, features::kAutofillProfileClientValidation}); // State's validity is set by server and city's validity by client. - TestFillingInvalidFields(/*state=*/ASCIIToUTF16("CA"), - /*city=*/ASCIIToUTF16("Elysium")); + TestFillingInvalidFields(/*state=*/u"CA", + /*city=*/u"Elysium"); } // Tests that using only client side validation, if the country is empty, the @@ -512,7 +512,7 @@ TEST_F(AutofillFieldFillerTest, FillFormField_Validity_CountryEmpty) { /*enabled_features=*/{features::kAutofillProfileClientValidation}, /*disabled_features=*/{features::kAutofillProfileServerValidation}); AutofillProfile profile = test::GetFullProfile(); - profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("")); + profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u""); profile.SetValidityState(ADDRESS_HOME_STATE, AutofillProfile::INVALID, AutofillProfile::CLIENT); profile.SetValidityState(EMAIL_ADDRESS, AutofillProfile::INVALID, @@ -526,24 +526,44 @@ TEST_F(AutofillFieldFillerTest, FillFormField_Validity_CountryEmpty) { FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); // State is filled, because it's an address field. filler.FillFormField(field_state, &profile, &field_state, - /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("CA"), field_state.value); + /*cvc=*/std::u16string()); + EXPECT_EQ(u"CA", field_state.value); // Email is not filled, because it's not an address field, and it doesn't // depend on the country. filler.FillFormField(field_email, &profile, &field_email, - /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16(""), field_email.value); + /*cvc=*/std::u16string()); + EXPECT_EQ(u"", field_email.value); } struct AutofillFieldFillerTestCase { HtmlFieldType field_type; size_t field_max_length; std::string expected_value; + + AutofillFieldFillerTestCase(HtmlFieldType field_type, + size_t field_max_length, + std::string expected_value) + : field_type(field_type), + field_max_length(field_max_length), + expected_value(expected_value) {} +}; + +struct AutofillPhoneFieldFillerTestCase : public AutofillFieldFillerTestCase { + std::string phone_home_whole_number_value; + + AutofillPhoneFieldFillerTestCase(HtmlFieldType field_type, + size_t field_max_length, + std::string expected_value, + std::string phone_home_whole_number_value) + : AutofillFieldFillerTestCase(field_type, + field_max_length, + expected_value), + phone_home_whole_number_value(phone_home_whole_number_value) {} }; class PhoneNumberTest - : public testing::TestWithParam<AutofillFieldFillerTestCase> { + : public testing::TestWithParam<AutofillPhoneFieldFillerTestCase> { public: PhoneNumberTest() { CountryNames::SetLocaleString("en-US"); } }; @@ -555,9 +575,10 @@ TEST_P(PhoneNumberTest, FillPhoneNumber) { field.max_length = test_case.field_max_length; AutofillProfile address; - address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("+15145554578")); + address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, + ASCIIToUTF16(test_case.phone_home_whole_number_value)); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); EXPECT_EQ(ASCIIToUTF16(test_case.expected_value), field.value); } @@ -566,30 +587,44 @@ INSTANTIATE_TEST_SUITE_P( PhoneNumberTest, testing::Values( // Filling a prefix type field should just fill the prefix. - AutofillFieldFillerTestCase{HTML_TYPE_TEL_LOCAL_PREFIX, - /*max_length=*/0, "555"}, + AutofillPhoneFieldFillerTestCase{HTML_TYPE_TEL_LOCAL_PREFIX, + /*field_max_length=*/0, "555", + "+15145554578"}, // Filling a suffix type field with a phone number of 7 digits should // just fill the suffix. - AutofillFieldFillerTestCase{HTML_TYPE_TEL_LOCAL_SUFFIX, - /*max_length=*/0, "4578"}, + AutofillPhoneFieldFillerTestCase{HTML_TYPE_TEL_LOCAL_SUFFIX, + /*field_max_length=*/0, "4578", + "+15145554578"}, // Filling a phone type field with a max length of 3 should fill only // the prefix. - AutofillFieldFillerTestCase{HTML_TYPE_TEL_LOCAL, /*max_length=*/3, - "555"}, + AutofillPhoneFieldFillerTestCase{HTML_TYPE_TEL_LOCAL, + /*field_max_length=*/3, "555", + "+15145554578"}, // TODO(crbug.com/581485): There should be a test case where the full - // number is requested (HTML_TYPE_TEL) but a max_length of 3 would fill - // the prefix. + // number is requested (HTML_TYPE_TEL) but a field_max_length of 3 would + // fill the prefix. // Filling a phone type field with a max length of 4 should fill only // the suffix. - AutofillFieldFillerTestCase{HTML_TYPE_TEL, /*max_length=*/4, "4578"}, + AutofillPhoneFieldFillerTestCase{HTML_TYPE_TEL, + /*field_max_length=*/4, "4578", + "+15145554578"}, // Filling a phone type field with a max length of 10 with a phone // number including the country code should fill the phone number // without the country code. - AutofillFieldFillerTestCase{HTML_TYPE_TEL, /*max_length=*/10, - "5145554578"}, + AutofillPhoneFieldFillerTestCase{HTML_TYPE_TEL, + /*field_max_length=*/10, "5145554578", + "+15145554578"}, // Filling a phone type field with a max length of 5 with a phone number // should fill with the last 5 digits of that phone number. - AutofillFieldFillerTestCase{HTML_TYPE_TEL, /*max_length=*/5, "54578"})); + AutofillPhoneFieldFillerTestCase{HTML_TYPE_TEL, + /*field_max_length=*/5, "54578", + "+15145554578"}, + // Filling a phone type field with a max length of 10 with a phone + // number including the country code should fill the phone number + // without the country code. + AutofillPhoneFieldFillerTestCase{HTML_TYPE_TEL, + /*field_max_length=*/10, "123456789", + "+886123456789"})); class ExpirationYearTest : public testing::TestWithParam<AutofillFieldFillerTestCase> { @@ -605,9 +640,9 @@ TEST_P(ExpirationYearTest, FillExpirationYearInput) { field.max_length = test_case.field_max_length; CreditCard card = test::GetCreditCard(); - card.SetExpirationDateFromString(ASCIIToUTF16("12/2023")); + card.SetExpirationDateFromString(u"12/2023"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); EXPECT_EQ(ASCIIToUTF16(test_case.expected_value), field.value); } @@ -667,10 +702,10 @@ TEST_P(ExpirationDateTest, FillExpirationDateInput) { field.max_length = test_case.field_max_length; CreditCard card = test::GetCreditCard(); - card.SetExpirationDateFromString(ASCIIToUTF16("03/2022")); + card.SetExpirationDateFromString(u"03/2022"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); bool response = - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); EXPECT_EQ(ASCIIToUTF16(test_case.expected_value), field.value); EXPECT_EQ(response, test_case.expected_response); } @@ -758,10 +793,10 @@ TEST_F(AutofillFieldFillerTest, FillSelectControlByValue) { for (size_t i = 0; i < field.option_contents.size(); ++i) field.option_contents[i] = base::NumberToString16(i); - address()->SetRawInfo(NAME_FIRST, ASCIIToUTF16("Meenie")); + address()->SetRawInfo(NAME_FIRST, u"Meenie"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, address(), &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("Meenie"), field.value); + filler.FillFormField(field, address(), &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"Meenie", field.value); } TEST_F(AutofillFieldFillerTest, FillSelectControlByContents) { @@ -780,10 +815,10 @@ TEST_F(AutofillFieldFillerTest, FillSelectControlByContents) { for (size_t i = 0; i < field.option_values.size(); ++i) field.option_values[i] = base::NumberToString16(i); - address()->SetRawInfo(NAME_FIRST, ASCIIToUTF16("Miney")); + address()->SetRawInfo(NAME_FIRST, u"Miney"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, address(), &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("2"), field.value); // Corresponds to "Miney". + filler.FillFormField(field, address(), &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"2", field.value); // Corresponds to "Miney". } struct FillSelectTestCase { @@ -847,7 +882,7 @@ TEST_P(AutofillSelectWithStatesTest, FillSelectWithStates) { AutofillProfile address = test::GetFullProfile(); address.SetRawInfo(ADDRESS_HOME_STATE, UTF8ToUTF16(test_case.input_value)); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); // nullptr means we expect them not to match without normalization. if (test_case.expected_value_without_normalization != nullptr) { EXPECT_EQ(UTF8ToUTF16(test_case.expected_value_without_normalization), @@ -861,7 +896,7 @@ TEST_P(AutofillSelectWithStatesTest, FillSelectWithStates) { // Fill a first time without loading the rules for the region. FieldFiller canadian_filler(/*app_locale=*/"en-US", normalizer()); canadian_filler.FillFormField(field, &canadian_address, &field, - /*cvc=*/base::string16()); + /*cvc=*/std::u16string()); // If the expectation with normalization is nullptr, this means that the same // result than without a normalizer is expected. if (test_case.expected_value_with_normalization == nullptr) { @@ -876,7 +911,7 @@ TEST_P(AutofillSelectWithStatesTest, FillSelectWithStates) { // Load the rules and try again. normalizer()->LoadRulesForRegion("CA"); canadian_filler.FillFormField(field, &canadian_address, &field, - /*cvc=*/base::string16()); + /*cvc=*/std::u16string()); EXPECT_EQ(UTF8ToUTF16(test_case.expected_value_with_normalization), field.value); } @@ -942,10 +977,10 @@ TEST_F(AutofillFieldFillerTest, FillSelectWithCountries) { field.set_heuristic_type(ADDRESS_HOME_COUNTRY); AutofillProfile address = test::GetFullProfile(); - address.SetRawInfo(ADDRESS_HOME_COUNTRY, UTF8ToUTF16("CA")); + address.SetRawInfo(ADDRESS_HOME_COUNTRY, u"CA"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(UTF8ToUTF16("Canada"), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"Canada", field.value); } struct FillWithExpirationMonthTestCase { @@ -1070,8 +1105,8 @@ TEST_F(AutofillFieldFillerTest, FillSelectControlWithAbbreviatedMonthName) { CreditCard card = test::GetCreditCard(); card.SetExpirationMonth(4); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("Apr"), field.value); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"Apr", field.value); } TEST_F(AutofillFieldFillerTest, FillSelectControlWithMonthName) { @@ -1086,8 +1121,8 @@ TEST_F(AutofillFieldFillerTest, FillSelectControlWithMonthName) { CreditCard card = test::GetCreditCard(); card.SetExpirationMonth(4); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("April"), field.value); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"April", field.value); } TEST_F(AutofillFieldFillerTest, FillSelectControlWithMonthNameAndDigits) { @@ -1103,8 +1138,8 @@ TEST_F(AutofillFieldFillerTest, FillSelectControlWithMonthNameAndDigits) { CreditCard card = test::GetCreditCard(); card.SetExpirationMonth(4); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("April (04)"), field.value); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"April (04)", field.value); } TEST_F(AutofillFieldFillerTest, @@ -1130,11 +1165,11 @@ TEST_F(AutofillFieldFillerTest, CreditCard card = test::GetCreditCard(); card.SetExpirationMonth(8); FieldFiller filler(/*app_locale=*/"fr-FR", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(UTF8ToUTF16("08 - AOÛT"), field.value); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"08 - AOÛT", field.value); card.SetExpirationMonth(12); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(UTF8ToUTF16("12 - DECEMBRE"), field.value); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"12 - DECEMBRE", field.value); } TEST_F(AutofillFieldFillerTest, FillSelectControlWithMonthName_French) { @@ -1147,16 +1182,16 @@ TEST_F(AutofillFieldFillerTest, FillSelectControlWithMonthName_French) { CreditCard card = test::GetCreditCard(); card.SetExpirationMonth(2); FieldFiller filler(/*app_locale=*/"fr-FR", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(UTF8ToUTF16("FÉVR."), field.value); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"FÉVR.", field.value); card.SetExpirationMonth(1); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(UTF8ToUTF16("JANV"), field.value); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"JANV", field.value); card.SetExpirationMonth(12); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(UTF8ToUTF16("décembre"), field.value); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"décembre", field.value); } TEST_F(AutofillFieldFillerTest, @@ -1171,8 +1206,8 @@ TEST_F(AutofillFieldFillerTest, CreditCard card = test::GetCreditCard(); card.SetExpirationMonth(4); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("4"), field.value); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"4", field.value); } TEST_F(AutofillFieldFillerTest, FillSelectControlWithTwoDigitCreditCardYear) { @@ -1185,8 +1220,8 @@ TEST_F(AutofillFieldFillerTest, FillSelectControlWithTwoDigitCreditCardYear) { CreditCard card = test::GetCreditCard(); card.SetExpirationYear(2017); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("17"), field.value); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"17", field.value); } TEST_F(AutofillFieldFillerTest, FillSelectControlWithCreditCardType) { @@ -1199,24 +1234,24 @@ TEST_F(AutofillFieldFillerTest, FillSelectControlWithCreditCardType) { FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); // Normal case: - card.SetNumber(ASCIIToUTF16("4111111111111111")); // Visa number. - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("Visa"), field.value); + card.SetNumber(u"4111111111111111"); // Visa number. + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"Visa", field.value); // Filling should be able to handle intervening whitespace: - card.SetNumber(ASCIIToUTF16("5555555555554444")); // MC number. - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("Mastercard"), field.value); + card.SetNumber(u"5555555555554444"); // MC number. + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"Mastercard", field.value); // American Express is sometimes abbreviated as AmEx: - card.SetNumber(ASCIIToUTF16("378282246310005")); // Amex number. - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("AmEx"), field.value); + card.SetNumber(u"378282246310005"); // Amex number. + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"AmEx", field.value); // Case insensitivity: - card.SetNumber(ASCIIToUTF16("6011111111111117")); // Discover number. - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("discover"), field.value); + card.SetNumber(u"6011111111111117"); // Discover number. + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"discover", field.value); } TEST_F(AutofillFieldFillerTest, FillMonthControl) { @@ -1227,14 +1262,14 @@ TEST_F(AutofillFieldFillerTest, FillMonthControl) { // Try a month with two digits. CreditCard card = test::GetCreditCard(); - card.SetExpirationDateFromString(ASCIIToUTF16("12/2017")); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("2017-12"), field.value); + card.SetExpirationDateFromString(u"12/2017"); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"2017-12", field.value); // Try a month with a leading zero. - card.SetExpirationDateFromString(ASCIIToUTF16("03/2019")); - filler.FillFormField(field, &card, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("2019-03"), field.value); + card.SetExpirationDateFromString(u"03/2019"); + filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"2019-03", field.value); } TEST_F(AutofillFieldFillerTest, FillStreetAddressTextArea) { @@ -1243,20 +1278,20 @@ TEST_F(AutofillFieldFillerTest, FillStreetAddressTextArea) { FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); field.set_heuristic_type(ADDRESS_HOME_STREET_ADDRESS); - base::string16 value = ASCIIToUTF16( + std::u16string value = ASCIIToUTF16( "123 Fake St.\n" "Apt. 42"); address()->SetInfo(AutofillType(ADDRESS_HOME_STREET_ADDRESS), value, "en-US"); - filler.FillFormField(field, address(), &field, /*cvc=*/base::string16()); + filler.FillFormField(field, address(), &field, /*cvc=*/std::u16string()); EXPECT_EQ(value, field.value); - base::string16 ja_value = UTF8ToUTF16( + std::u16string ja_value = UTF8ToUTF16( "桜丘町26-1\n" "セルリアンタワー6階"); address()->SetInfo(AutofillType(ADDRESS_HOME_STREET_ADDRESS), ja_value, "ja-JP"); address()->set_language_code("ja-JP"); - filler.FillFormField(field, address(), &field, /*cvc=*/base::string16()); + filler.FillFormField(field, address(), &field, /*cvc=*/std::u16string()); EXPECT_EQ(ja_value, field.value); } @@ -1266,21 +1301,21 @@ TEST_F(AutofillFieldFillerTest, FillStreetAddressTextField) { field.set_server_type(ADDRESS_HOME_STREET_ADDRESS); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - base::string16 value = ASCIIToUTF16( + std::u16string value = ASCIIToUTF16( "123 Fake St.\n" "Apt. 42"); address()->SetInfo(AutofillType(ADDRESS_HOME_STREET_ADDRESS), value, "en-US"); - filler.FillFormField(field, address(), &field, /*cvc=*/base::string16()); - EXPECT_EQ(UTF8ToUTF16("123 Fake St., Apt. 42"), field.value); + filler.FillFormField(field, address(), &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"123 Fake St., Apt. 42", field.value); - base::string16 ja_value = UTF8ToUTF16( + std::u16string ja_value = UTF8ToUTF16( "桜丘町26-1\n" "セルリアンタワー6階"); address()->SetInfo(AutofillType(ADDRESS_HOME_STREET_ADDRESS), ja_value, "ja-JP"); address()->set_language_code("ja-JP"); - filler.FillFormField(field, address(), &field, /*cvc=*/base::string16()); - EXPECT_EQ(UTF8ToUTF16("桜丘町26-1セルリアンタワー6階"), field.value); + filler.FillFormField(field, address(), &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"桜丘町26-1セルリアンタワー6階", field.value); } TEST_F(AutofillFieldFillerTest, FillCreditCardNumberWithoutSplits) { @@ -1288,13 +1323,13 @@ TEST_F(AutofillFieldFillerTest, FillCreditCardNumberWithoutSplits) { AutofillField cc_number_full; cc_number_full.set_heuristic_type(CREDIT_CARD_NUMBER); - credit_card()->SetNumber(ASCIIToUTF16("41111111111111111")); + credit_card()->SetNumber(u"41111111111111111"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); filler.FillFormField(cc_number_full, credit_card(), &cc_number_full, - /*cvc=*/base::string16()); + /*cvc=*/std::u16string()); // Verify that full card-number shall get filled properly. - EXPECT_EQ(ASCIIToUTF16("41111111111111111"), cc_number_full.value); + EXPECT_EQ(u"41111111111111111", cc_number_full.value); EXPECT_EQ(0U, cc_number_full.credit_card_number_offset()); } @@ -1319,7 +1354,7 @@ TEST_F(AutofillFieldFillerTest, FillCreditCardNumberWithEqualSizeSplits) { // Fill with a card-number; should fill just the card_number_part. credit_card()->SetNumber(ASCIIToUTF16(test.card_number_)); filler.FillFormField(cc_number_part, credit_card(), &cc_number_part, - /*cvc=*/base::string16()); + /*cvc=*/std::u16string()); // Verify for expected results. EXPECT_EQ(ASCIIToUTF16(test.expected_results_[i]), @@ -1333,7 +1368,7 @@ TEST_F(AutofillFieldFillerTest, FillCreditCardNumberWithEqualSizeSplits) { credit_card()->SetNumber(ASCIIToUTF16(test.card_number_)); filler.FillFormField(cc_number_full, credit_card(), &cc_number_full, - /*cvc=*/base::string16()); + /*cvc=*/std::u16string()); // Verify for expected results. EXPECT_EQ(ASCIIToUTF16(test.card_number_), cc_number_full.value); @@ -1362,7 +1397,7 @@ TEST_F(AutofillFieldFillerTest, FillCreditCardNumberWithUnequalSizeSplits) { // Fill with a card-number; should fill just the card_number_part. credit_card()->SetNumber(ASCIIToUTF16(test.card_number_)); filler.FillFormField(cc_number_part, credit_card(), &cc_number_part, - /*cvc=*/base::string16()); + /*cvc=*/std::u16string()); // Verify for expected results. EXPECT_EQ(ASCIIToUTF16(test.expected_results_[i]), @@ -1376,7 +1411,7 @@ TEST_F(AutofillFieldFillerTest, FillCreditCardNumberWithUnequalSizeSplits) { cc_number_full.set_heuristic_type(CREDIT_CARD_NUMBER); credit_card()->SetNumber(ASCIIToUTF16(test.card_number_)); filler.FillFormField(cc_number_full, credit_card(), &cc_number_full, - /*cvc=*/base::string16()); + /*cvc=*/std::u16string()); // Verify for expected results. EXPECT_EQ(ASCIIToUTF16(test.card_number_), cc_number_full.value); @@ -1389,38 +1424,38 @@ TEST_F(AutofillFieldFillerTest, FindShortestSubstringMatchInSelect) { FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); // Case 1: Exact match - int ret = FieldFiller::FindShortestSubstringMatchInSelect( - ASCIIToUTF16("Canada"), false, &field); + int ret = + FieldFiller::FindShortestSubstringMatchInSelect(u"Canada", false, &field); EXPECT_EQ(1, ret); // Case 2: Case-insensitive - ret = FieldFiller::FindShortestSubstringMatchInSelect(ASCIIToUTF16("CANADA"), - false, &field); + ret = + FieldFiller::FindShortestSubstringMatchInSelect(u"CANADA", false, &field); EXPECT_EQ(1, ret); // Case 3: Proper substring - ret = FieldFiller::FindShortestSubstringMatchInSelect(UTF8ToUTF16("États"), - false, &field); + ret = + FieldFiller::FindShortestSubstringMatchInSelect(u"États", false, &field); EXPECT_EQ(0, ret); // Case 4: Accent-insensitive - ret = FieldFiller::FindShortestSubstringMatchInSelect( - UTF8ToUTF16("Etats-Unis"), false, &field); + ret = FieldFiller::FindShortestSubstringMatchInSelect(u"Etats-Unis", false, + &field); EXPECT_EQ(0, ret); // Case 5: Whitespace-insensitive - ret = FieldFiller::FindShortestSubstringMatchInSelect( - ASCIIToUTF16("Ca na da"), true, &field); + ret = FieldFiller::FindShortestSubstringMatchInSelect(u"Ca na da", true, + &field); EXPECT_EQ(1, ret); // Case 6: No match (whitespace-sensitive) - ret = FieldFiller::FindShortestSubstringMatchInSelect( - ASCIIToUTF16("Ca Na Da"), false, &field); + ret = FieldFiller::FindShortestSubstringMatchInSelect(u"Ca Na Da", false, + &field); EXPECT_EQ(-1, ret); // Case 7: No match (not present) - ret = FieldFiller::FindShortestSubstringMatchInSelect(ASCIIToUTF16("Canadia"), - true, &field); + ret = + FieldFiller::FindShortestSubstringMatchInSelect(u"Canadia", true, &field); EXPECT_EQ(-1, ret); } @@ -1450,7 +1485,7 @@ TEST_P(AutofillStateTextTest, FillStateText) { AutofillProfile address = test::GetFullProfile(); address.SetRawInfo(ADDRESS_HOME_STATE, UTF8ToUTF16(test_case.value_to_fill)); bool has_filled = - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); EXPECT_EQ(test_case.should_fill, has_filled); EXPECT_EQ(ASCIIToUTF16(test_case.expected_value), field.value); @@ -1502,10 +1537,10 @@ TEST_F(AutofillFieldFillerTest, field.set_heuristic_type(PHONE_HOME_COUNTRY_CODE); AutofillProfile address; - address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("+15145554578")); + address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"+15145554578"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("1"), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"1", field.value); } // Tests that the correct option is chosen in the selection box when the options @@ -1523,10 +1558,10 @@ TEST_F(AutofillFieldFillerTest, field.set_heuristic_type(PHONE_HOME_COUNTRY_CODE); AutofillProfile address; - address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("+918890888888")); + address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"+918890888888"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("+91"), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"+91", field.value); } // Tests that the correct option is chosen in the selection box when the options @@ -1544,10 +1579,10 @@ TEST_F(AutofillFieldFillerTest, field.set_heuristic_type(PHONE_HOME_COUNTRY_CODE); AutofillProfile address; - address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("+918890888888")); + address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"+918890888888"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("0091"), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"0091", field.value); } // Tests that the correct option is chosen in the selection box when the options @@ -1565,10 +1600,10 @@ TEST_F(AutofillFieldFillerTest, FillSelectControlAugmentedPhoneCountryCode) { field.set_heuristic_type(PHONE_HOME_COUNTRY_CODE); AutofillProfile address; - address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("+49151669087345")); + address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"+49151669087345"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("+49 (Germany)"), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"+49 (Germany)", field.value); } // Tests that the correct option is chosen in the selection box when the options @@ -1587,10 +1622,10 @@ TEST_F(AutofillFieldFillerTest, field.set_heuristic_type(PHONE_HOME_COUNTRY_CODE); AutofillProfile address; - address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("+49151669087345")); + address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"+49151669087345"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("(00 49) Germany"), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"(00 49) Germany", field.value); } // Tests that the correct option is chosen in the selection box when the options @@ -1610,10 +1645,10 @@ TEST_F(AutofillFieldFillerTest, field.set_heuristic_type(PHONE_HOME_COUNTRY_CODE); AutofillProfile address; - address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("+49151669087345")); + address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"+49151669087345"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("(0049) Germany"), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"(0049) Germany", field.value); } // Tests that the abbreviated state names are selected correctly. @@ -1630,12 +1665,12 @@ TEST_F(AutofillFieldFillerTest, FillSelectAbbreviatedState) { field.set_heuristic_type(ADDRESS_HOME_STATE); AutofillProfile address; - address.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("Bavaria")); - address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE")); + address.SetRawInfo(ADDRESS_HOME_STATE, u"Bavaria"); + address.SetRawInfo(ADDRESS_HOME_COUNTRY, u"DE"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("BY"), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"BY", field.value); } // Tests that the localized state names are selected correctly. @@ -1653,12 +1688,12 @@ TEST_F(AutofillFieldFillerTest, FillSelectLocalizedState) { field.set_heuristic_type(ADDRESS_HOME_STATE); AutofillProfile address; - address.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("Bavaria")); - address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE")); + address.SetRawInfo(ADDRESS_HOME_STATE, u"Bavaria"); + address.SetRawInfo(ADDRESS_HOME_COUNTRY, u"DE"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("Bayern"), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"Bayern", field.value); } // Tests that the state names are selected correctly when the state name exists @@ -1676,12 +1711,12 @@ TEST_F(AutofillFieldFillerTest, FillSelectLocalizedStateSubstring) { field.set_heuristic_type(ADDRESS_HOME_STATE); AutofillProfile address; - address.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("Bavaria")); - address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE")); + address.SetRawInfo(ADDRESS_HOME_STATE, u"Bavaria"); + address.SetRawInfo(ADDRESS_HOME_COUNTRY, u"DE"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("Bavaria Has Munich"), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"Bavaria Has Munich", field.value); } // Tests that the state abbreviations are filled in the text field when the @@ -1699,12 +1734,12 @@ TEST_F(AutofillFieldFillerTest, FillStateAbbreviationInTextField) { field.max_length = 4; AutofillProfile address; - address.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("Bavaria")); - address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE")); + address.SetRawInfo(ADDRESS_HOME_STATE, u"Bavaria"); + address.SetRawInfo(ADDRESS_HOME_COUNTRY, u"DE"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("BY"), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"BY", field.value); } // Tests that the state names are selected correctly even though the state @@ -1722,12 +1757,12 @@ TEST_F(AutofillFieldFillerTest, FillStateFieldWithSavedValueInProfile) { field.set_heuristic_type(ADDRESS_HOME_STATE); AutofillProfile address; - address.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("Bavari")); - address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE")); + address.SetRawInfo(ADDRESS_HOME_STATE, u"Bavari"); + address.SetRawInfo(ADDRESS_HOME_COUNTRY, u"DE"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("Bavari"), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"Bavari", field.value); } // Tests that Autofill does not wrongly fill the state when the appropriate @@ -1750,12 +1785,12 @@ TEST_F(AutofillFieldFillerTest, FillStateFieldWhenStateIsNotInOptions) { field.set_heuristic_type(ADDRESS_HOME_STATE); AutofillProfile address; - address.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CO")); - address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); + address.SetRawInfo(ADDRESS_HOME_STATE, u"CO"); + address.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16(""), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"", field.value); } // Tests that Autofill uses the static states data of US as a fallback mechanism @@ -1773,12 +1808,12 @@ TEST_F(AutofillFieldFillerTest, field.set_heuristic_type(ADDRESS_HOME_STATE); AutofillProfile address; - address.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CO")); - address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); + address.SetRawInfo(ADDRESS_HOME_STATE, u"CO"); + address.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("Colorado"), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"Colorado", field.value); } // Tests that Autofill fills upper case abbreviation in the input field when @@ -1799,12 +1834,12 @@ TEST_F(AutofillFieldFillerTest, FillUpperCaseAbbreviationInStateTextField) { field.max_length = 4; AutofillProfile address; - address.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("Bavaria")); - address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE")); + address.SetRawInfo(ADDRESS_HOME_STATE, u"Bavaria"); + address.SetRawInfo(ADDRESS_HOME_COUNTRY, u"DE"); FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); - filler.FillFormField(field, &address, &field, /*cvc=*/base::string16()); - EXPECT_EQ(ASCIIToUTF16("BY"), field.value); + filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string()); + EXPECT_EQ(u"BY", field.value); } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/field_types.cc b/chromium/components/autofill/core/browser/field_types.cc index 78e6b52c81f..79283d6f3f4 100644 --- a/chromium/components/autofill/core/browser/field_types.cc +++ b/chromium/components/autofill/core/browser/field_types.cc @@ -99,6 +99,10 @@ bool IsFillableFieldType(ServerFieldType field_type) { case COMPANY_NAME: return true; + case MERCHANT_PROMO_CODE: + // TODO(crbug/1190334): Create flag for this and use flag value instead. + return false; + // Fillable credential fields. case USERNAME: case PASSWORD: @@ -130,7 +134,6 @@ bool IsFillableFieldType(ServerFieldType field_type) { case PHONE_FAX_WHOLE_NUMBER: case FIELD_WITH_DEFAULT_VALUE: case MERCHANT_EMAIL_SIGNUP: - case MERCHANT_PROMO_CODE: case PRICE: case SEARCH_TERM: case UNKNOWN_TYPE: diff --git a/chromium/components/autofill/core/browser/field_types.h b/chromium/components/autofill/core/browser/field_types.h index 52f3cfab947..a0feacceb22 100644 --- a/chromium/components/autofill/core/browser/field_types.h +++ b/chromium/components/autofill/core/browser/field_types.h @@ -7,8 +7,8 @@ #include <map> #include <set> +#include <string> -#include "base/strings/string16.h" #include "base/strings/string_piece_forward.h" #include "components/autofill/core/common/dense_set.h" @@ -106,6 +106,8 @@ enum ServerFieldType { // these are likely to be filled out differently on a case by case basis, // they are here primarily for use by Autocheckout. MERCHANT_EMAIL_SIGNUP = 73, + // A promo/gift/coupon code, usually entered during checkout on a commerce web + // site to reduce the cost of a purchase. MERCHANT_PROMO_CODE = 74, // Field types for the password fields. PASSWORD is the default type for all diff --git a/chromium/components/autofill/core/browser/form_data_importer.cc b/chromium/components/autofill/core/browser/form_data_importer.cc index a81a2586b53..a074a6d95f7 100644 --- a/chromium/components/autofill/core/browser/form_data_importer.cc +++ b/chromium/components/autofill/core/browser/form_data_importer.cc @@ -12,10 +12,10 @@ #include <map> #include <memory> #include <set> +#include <string> #include <utility> #include "base/bind.h" -#include "base/strings/string16.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" @@ -54,7 +54,7 @@ using AddressImportRequirement = // of importing a form. bool IsValidFieldTypeAndValue(const ServerFieldTypeSet types_seen, ServerFieldType field_type, - const base::string16& value, + const std::u16string& value, LogBuffer* import_log_buffer) { // Abandon the import if two fields of the same type are encountered. // This indicates ambiguous data or miscategorization of types. @@ -293,6 +293,13 @@ void FormDataImporter::ImportFormData(const FormStructure& submitted_form, return; } + // Do not offer credit card save at all if Autofill Assistant is running. + if (base::FeatureList::IsEnabled( + features::kAutofillSuppressCreditCardSaveForAssistant) && + client_->IsAutofillAssistantShowing()) { + return; + } + #if !defined(OS_ANDROID) && !defined(OS_IOS) // A credit card was successfully imported, but it's possible it is already a // local or server card. First, check to see if we should offer local card @@ -359,7 +366,7 @@ bool FormDataImporter::IsValidLearnableProfile( // Check that the email address is valid if it is supplied. bool is_email_invalid = false; - base::string16 email = profile.GetRawInfo(EMAIL_ADDRESS); + std::u16string email = profile.GetRawInfo(EMAIL_ADDRESS); if (!email.empty() && !IsValidEmailAddress(email)) { if (import_log_buffer) { *import_log_buffer << LogMessage::kImportAddressProfileFromFormFailed @@ -555,7 +562,7 @@ bool FormDataImporter::ImportAddressProfileForSection( if (field->section != section && !section.empty()) continue; - base::string16 value; + std::u16string value; base::TrimWhitespace(field->value, base::TRIM_ALL, &value); // If we don't know the type of the field, or the user hasn't entered any @@ -658,7 +665,7 @@ bool FormDataImporter::ImportAddressProfileForSection( // Construct the phone number. Reject the whole profile if the number is // invalid. if (!combined_phone.IsEmpty()) { - base::string16 constructed_number; + std::u16string constructed_number; if (!combined_phone.ParseNumber(candidate_profile, app_locale_, &constructed_number) || !candidate_profile.SetInfoWithVerificationStatus( @@ -855,7 +862,7 @@ CreditCard FormDataImporter::ExtractCreditCardFromForm( ServerFieldTypeSet types_seen; for (const auto& field : form) { - base::string16 value; + std::u16string value; base::TrimWhitespace(field->value, base::TRIM_ALL, &value); // If we don't know the type of the field, or the user hasn't entered any diff --git a/chromium/components/autofill/core/browser/form_data_importer_unittest.cc b/chromium/components/autofill/core/browser/form_data_importer_unittest.cc index 8a51f0634dc..15c03e94c12 100644 --- a/chromium/components/autofill/core/browser/form_data_importer_unittest.cc +++ b/chromium/components/autofill/core/browser/form_data_importer_unittest.cc @@ -118,7 +118,7 @@ class FormDataImporterTestBase { FormDataImporterTestBase() : autofill_table_(nullptr) {} void ResetPersonalDataManager(UserMode user_mode) { - personal_data_manager_.reset(new PersonalDataManager("en", "US")); + personal_data_manager_ = std::make_unique<PersonalDataManager>("en", "US"); personal_data_manager_->Init( scoped_refptr<AutofillWebDataService>(autofill_database_service_), /*account_database=*/nullptr, @@ -269,10 +269,10 @@ class FormDataImporterTest test::DisableSystemServices(prefs_.get()); ResetPersonalDataManager(USER_MODE_NORMAL); - form_data_importer_.reset( - new FormDataImporter(autofill_client_.get(), - /*payments::PaymentsClient=*/nullptr, - personal_data_manager_.get(), "en")); + form_data_importer_ = + std::make_unique<FormDataImporter>(autofill_client_.get(), + /*payments::PaymentsClient=*/nullptr, + personal_data_manager_.get(), "en"); // Reset the deduping pref to its default value. personal_data_manager_->pref_service_->SetInteger( @@ -358,12 +358,10 @@ TEST_P(FormDataImporterTest, ImportStructuredNameProfile) { personal_data_manager_->GetProfiles(); ASSERT_EQ(1U, results.size()); - EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), - base::ASCIIToUTF16("21")); - EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_STREET_NAME), - base::ASCIIToUTF16("Laussat St")); + EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), u"21"); + EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_STREET_NAME), u"Laussat St"); EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_STREET_ADDRESS), - base::ASCIIToUTF16("21 Laussat St")); + u"21 Laussat St"); EXPECT_EQ(results[0]->GetVerificationStatus(ADDRESS_HOME_HOUSE_NUMBER), structured_address::VerificationStatus::kParsed); @@ -410,12 +408,10 @@ TEST_P(FormDataImporterTest, personal_data_manager_->GetProfiles(); ASSERT_EQ(1U, results.size()); - EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), - base::ASCIIToUTF16("21")); - EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_STREET_NAME), - base::ASCIIToUTF16("Laussat St")); + EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), u"21"); + EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_STREET_NAME), u"Laussat St"); EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_STREET_ADDRESS), - base::ASCIIToUTF16("21 Laussat St")); + u"21 Laussat St"); EXPECT_EQ(results[0]->GetVerificationStatus(ADDRESS_HOME_HOUSE_NUMBER), structured_address::VerificationStatus::kObserved); @@ -469,14 +465,11 @@ TEST_P( personal_data_manager_->GetProfiles(); ASSERT_EQ(1U, results.size()); - EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), - base::ASCIIToUTF16("21")); - EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_STREET_NAME), - base::ASCIIToUTF16("Laussat St")); + EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), u"21"); + EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_STREET_NAME), u"Laussat St"); EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_STREET_ADDRESS), - base::ASCIIToUTF16("21 Laussat St APT 101")); - EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_APT_NUM), - base::ASCIIToUTF16("101")); + u"21 Laussat St APT 101"); + EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_APT_NUM), u"101"); EXPECT_EQ(results[0]->GetVerificationStatus(ADDRESS_HOME_HOUSE_NUMBER), structured_address::VerificationStatus::kObserved); EXPECT_EQ(results[0]->GetVerificationStatus(ADDRESS_HOME_STREET_NAME), @@ -521,12 +514,11 @@ TEST_P(FormDataImporterTest, personal_data_manager_->GetProfiles(); ASSERT_EQ(1U, results.size()); - EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), - base::ASCIIToUTF16("23")); + EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), u"23"); EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_STREET_NAME), - base::ASCIIToUTF16("Hermann Strasse")); + u"Hermann Strasse"); EXPECT_EQ(results[0]->GetRawInfo(ADDRESS_HOME_STREET_ADDRESS), - base::ASCIIToUTF16("Hermann Strasse 23")); + u"Hermann Strasse 23"); EXPECT_EQ(results[0]->GetVerificationStatus(ADDRESS_HOME_HOUSE_NUMBER), structured_address::VerificationStatus::kObserved); @@ -569,19 +561,13 @@ TEST_P(FormDataImporterTest, ImportStructuredNameAddressProfile) { personal_data_manager_->GetProfiles(); ASSERT_EQ(1U, results.size()); - EXPECT_EQ(results[0]->GetRawInfo(NAME_FULL), - base::ASCIIToUTF16("Pablo Diego Ruiz y Picasso")); - EXPECT_EQ(results[0]->GetRawInfo(NAME_FIRST), - base::ASCIIToUTF16("Pablo Diego")); - EXPECT_EQ(results[0]->GetRawInfo(NAME_MIDDLE), base::ASCIIToUTF16("")); - EXPECT_EQ(results[0]->GetRawInfo(NAME_LAST), - base::ASCIIToUTF16("Ruiz y Picasso")); - EXPECT_EQ(results[0]->GetRawInfo(NAME_LAST_FIRST), - base::ASCIIToUTF16("Ruiz")); - EXPECT_EQ(results[0]->GetRawInfo(NAME_LAST_CONJUNCTION), - base::ASCIIToUTF16("y")); - EXPECT_EQ(results[0]->GetRawInfo(NAME_LAST_SECOND), - base::ASCIIToUTF16("Picasso")); + EXPECT_EQ(results[0]->GetRawInfo(NAME_FULL), u"Pablo Diego Ruiz y Picasso"); + EXPECT_EQ(results[0]->GetRawInfo(NAME_FIRST), u"Pablo Diego"); + EXPECT_EQ(results[0]->GetRawInfo(NAME_MIDDLE), u""); + EXPECT_EQ(results[0]->GetRawInfo(NAME_LAST), u"Ruiz y Picasso"); + EXPECT_EQ(results[0]->GetRawInfo(NAME_LAST_FIRST), u"Ruiz"); + EXPECT_EQ(results[0]->GetRawInfo(NAME_LAST_CONJUNCTION), u"y"); + EXPECT_EQ(results[0]->GetRawInfo(NAME_LAST_SECOND), u"Picasso"); } TEST_P(FormDataImporterTest, ImportAddressProfiles) { @@ -1506,11 +1492,10 @@ TEST_P(FormDataImporterTest, ImportAddressProfiles_SameProfileWithConflict) { // Full name, phone formatting and country are updated. if (!StructuredNames()) - expected.SetRawInfo(NAME_FULL, base::ASCIIToUTF16("George Washington")); - expected.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::ASCIIToUTF16("+1 650-555-6666")); + expected.SetRawInfo(NAME_FULL, u"George Washington"); + expected.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"+1 650-555-6666"); expected.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_COUNTRY, base::ASCIIToUTF16("US"), + ADDRESS_HOME_COUNTRY, u"US", structured_address::VerificationStatus::kObserved); ASSERT_EQ(1U, results2.size()); EXPECT_EQ(0, expected.Compare(*results2[0])); @@ -1590,7 +1575,7 @@ TEST_P(FormDataImporterTest, ImportAddressProfiles_MissingInfoInOld) { if (StructuredNames()) expected2.FinalizeAfterImport(); else - expected2.SetRawInfo(NAME_FULL, base::ASCIIToUTF16("George Washington")); + expected2.SetRawInfo(NAME_FULL, u"George Washington"); ASSERT_EQ(1U, results2.size()); EXPECT_EQ(0, expected2.Compare(*results2[0])); } @@ -1673,7 +1658,7 @@ TEST_P(FormDataImporterTest, ImportAddressProfiles_MissingInfoInNew) { if (StructuredNames()) expected.FinalizeAfterImport(); else - expected.SetRawInfo(NAME_FULL, base::ASCIIToUTF16("George Washington")); + expected.SetRawInfo(NAME_FULL, u"George Washington"); ASSERT_EQ(1U, results2.size()); EXPECT_EQ(0, expected.Compare(*results2[0])); } @@ -1802,10 +1787,9 @@ TEST_P(FormDataImporterTest, // Set the verification status for the first and middle name to parsed. profile.SetRawInfoWithVerificationStatus( - NAME_FIRST, base::ASCIIToUTF16("Marion"), - structured_address::VerificationStatus::kParsed); + NAME_FIRST, u"Marion", structured_address::VerificationStatus::kParsed); profile.SetRawInfoWithVerificationStatus( - NAME_MIDDLE, base::ASCIIToUTF16("Mitchell"), + NAME_MIDDLE, u"Mitchell", structured_address::VerificationStatus::kParsed); base::RunLoop run_loop; @@ -1845,13 +1829,12 @@ TEST_P(FormDataImporterTest, // The form submission should result in a change of name structure. profile.SetRawInfoWithVerificationStatus( - NAME_FIRST, base::ASCIIToUTF16("Marion Mitchell"), + NAME_FIRST, u"Marion Mitchell", structured_address::VerificationStatus::kObserved); profile.SetRawInfoWithVerificationStatus( - NAME_MIDDLE, base::ASCIIToUTF16(""), - structured_address::VerificationStatus::kNoStatus); + NAME_MIDDLE, u"", structured_address::VerificationStatus::kNoStatus); profile.SetRawInfoWithVerificationStatus( - NAME_LAST, base::ASCIIToUTF16("Morrison"), + NAME_LAST, u"Morrison", structured_address::VerificationStatus::kObserved); // Expect that no new profile is saved. @@ -1894,13 +1877,13 @@ TEST_P(FormDataImporterTest, // Reset the structured address to emulate a failed parsing attempt. profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_HOUSE_NUMBER, base::ASCIIToUTF16(""), + ADDRESS_HOME_HOUSE_NUMBER, u"", structured_address::VerificationStatus::kNoStatus); profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_NAME, base::ASCIIToUTF16(""), + ADDRESS_HOME_STREET_NAME, u"", structured_address::VerificationStatus::kNoStatus); profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_AND_DEPENDENT_STREET_NAME, base::ASCIIToUTF16(""), + ADDRESS_HOME_STREET_AND_DEPENDENT_STREET_NAME, u"", structured_address::VerificationStatus::kNoStatus); base::RunLoop run_loop; @@ -1944,14 +1927,13 @@ TEST_P(FormDataImporterTest, // The form submission should result in a change of the address structure. profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_AND_DEPENDENT_STREET_NAME, - base::ASCIIToUTF16("Zoo St."), + ADDRESS_HOME_STREET_AND_DEPENDENT_STREET_NAME, u"Zoo St.", structured_address::VerificationStatus::kFormatted); profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_NAME, base::ASCIIToUTF16("Zoo St."), + ADDRESS_HOME_STREET_NAME, u"Zoo St.", structured_address::VerificationStatus::kObserved); profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_HOUSE_NUMBER, base::ASCIIToUTF16("123"), + ADDRESS_HOME_HOUSE_NUMBER, u"123", structured_address::VerificationStatus::kObserved); // Expect that no new profile is saved. @@ -2257,15 +2239,15 @@ TEST_P(FormDataImporterTest, ImportCreditCard_MonthSelectInvalidText) { AddFullCreditCardForm(&form, "Biggie Smalls", "4111-1111-1111-1111", "Feb (2)", "2999"); // Add option values and contents to the expiration month field. - ASSERT_EQ(base::ASCIIToUTF16("exp_month"), form.fields[2].name); - std::vector<base::string16> values; - values.push_back(base::ASCIIToUTF16("1")); - values.push_back(base::ASCIIToUTF16("2")); - values.push_back(base::ASCIIToUTF16("3")); - std::vector<base::string16> contents; - contents.push_back(base::ASCIIToUTF16("Jan (1)")); - contents.push_back(base::ASCIIToUTF16("Feb (2)")); - contents.push_back(base::ASCIIToUTF16("Mar (3)")); + ASSERT_EQ(u"exp_month", form.fields[2].name); + std::vector<std::u16string> values; + values.push_back(u"1"); + values.push_back(u"2"); + values.push_back(u"3"); + std::vector<std::u16string> contents; + contents.push_back(u"Jan (1)"); + contents.push_back(u"Feb (2)"); + contents.push_back(u"Mar (3)"); form.fields[2].option_values = values; form.fields[2].option_contents = contents; diff --git a/chromium/components/autofill/core/browser/form_parsing/address_field.cc b/chromium/components/autofill/core/browser/form_parsing/address_field.cc index e9e494e023a..ba396bf8d3c 100644 --- a/chromium/components/autofill/core/browser/form_parsing/address_field.cc +++ b/chromium/components/autofill/core/browser/form_parsing/address_field.cc @@ -7,20 +7,17 @@ #include <stddef.h> #include <memory> +#include <string> #include <utility> #include "base/check.h" -#include "base/strings/string16.h" #include "base/strings/string_util.h" -#include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_field.h" #include "components/autofill/core/browser/autofill_regex_constants.h" #include "components/autofill/core/browser/field_types.h" #include "components/autofill/core/browser/form_parsing/autofill_scanner.h" #include "components/autofill/core/common/autofill_features.h" -using base::UTF8ToUTF16; - namespace autofill { namespace { @@ -59,9 +56,6 @@ std::unique_ptr<FormField> AddressField::Parse( const AutofillField* const initial_field = scanner->Cursor(); size_t saved_cursor = scanner->SaveCursor(); - base::string16 attention_ignored = UTF8ToUTF16(kAttentionIgnoredRe); - base::string16 region_ignored = UTF8ToUTF16(kRegionIgnoredRe); - const std::vector<MatchingPattern>& email_patterns = PatternProvider::GetInstance().GetMatchPatterns("EMAIL_ADDRESS", page_language); @@ -88,19 +82,16 @@ std::unique_ptr<FormField> AddressField::Parse( while (!scanner->IsEnd()) { const size_t cursor = scanner->SaveCursor(); // Ignore "Address Lookup" field. http://crbug.com/427622 - if (ParseField(scanner, base::UTF8ToUTF16(kAddressLookupRe), - address_patterns, nullptr, + if (ParseField(scanner, kAddressLookupRe, address_patterns, nullptr, {log_manager, "kAddressLookupRe"}) || - ParseField(scanner, base::UTF8ToUTF16(kAddressNameIgnoredRe), - address_ignore_patterns, nullptr, - {log_manager, "kAddressNameIgnoreRe"})) { + ParseField(scanner, kAddressNameIgnoredRe, address_ignore_patterns, + nullptr, {log_manager, "kAddressNameIgnoreRe"})) { continue; // Ignore email addresses. - } else if (ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kEmailRe), - MATCH_DEFAULT | MATCH_TEXT_AREA, - email_patterns, nullptr, - {log_manager, "kEmailRe"}, - {.augment_types = MATCH_TEXT_AREA})) { + } else if (ParseFieldSpecifics( + scanner, kEmailRe, MATCH_DEFAULT | MATCH_TEXT_AREA, + email_patterns, nullptr, {log_manager, "kEmailRe"}, + {.augment_types = MATCH_TEXT_AREA})) { continue; } else if (address_field->ParseAddress(scanner, page_language) || address_field->ParseDependentLocalityCityStateCountryZipCode( @@ -108,9 +99,10 @@ std::unique_ptr<FormField> AddressField::Parse( address_field->ParseCompany(scanner, page_language)) { has_trailing_non_labeled_fields = false; continue; - } else if (ParseField(scanner, attention_ignored, attention_ignore_patterns, - nullptr, {log_manager, "kAttentionIgnoredRe"}) || - ParseField(scanner, region_ignored, region_ignore_patterns, + } else if (ParseField(scanner, kAttentionIgnoredRe, + attention_ignore_patterns, nullptr, + {log_manager, "kAttentionIgnoredRe"}) || + ParseField(scanner, kRegionIgnoredRe, region_ignore_patterns, nullptr, {log_manager, "kRegionIgnoredRe"})) { // We ignore the following: // * Attention. @@ -205,8 +197,8 @@ bool AddressField::ParseCompany(AutofillScanner* scanner, PatternProvider::GetInstance().GetMatchPatterns("COMPANY_NAME", page_language); - return ParseField(scanner, UTF8ToUTF16(kCompanyRe), company_patterns, - &company_, {log_manager_, "kCompanyRe"}); + return ParseField(scanner, kCompanyRe, company_patterns, &company_, + {log_manager_, "kCompanyRe"}); } bool AddressField::ParseAddressFieldSequence( @@ -237,13 +229,13 @@ bool AddressField::ParseAddressFieldSequence( while (!scanner->IsEnd()) { if (!street_name_ && - ParseFieldSpecifics(scanner, UTF8ToUTF16(kStreetNameRe), MATCH_DEFAULT, + ParseFieldSpecifics(scanner, kStreetNameRe, MATCH_DEFAULT, street_name_patterns, &street_name_, {log_manager_, "kStreetNameRe"})) { continue; } if (!house_number_ && - ParseFieldSpecifics(scanner, UTF8ToUTF16(kHouseNumberRe), + ParseFieldSpecifics(scanner, kHouseNumberRe, MATCH_DEFAULT | MATCH_NUMBER | MATCH_TELEPHONE, house_number_patterns, &house_number_, {log_manager_, "kHouseNumberRe"})) { @@ -254,7 +246,7 @@ bool AddressField::ParseAddressFieldSequence( if (base::FeatureList::IsEnabled( features::kAutofillEnableSupportForApartmentNumbers) && !apartment_number_ && - ParseFieldSpecifics(scanner, UTF8ToUTF16(kApartmentNumberRe), + ParseFieldSpecifics(scanner, kApartmentNumberRe, MATCH_DEFAULT | MATCH_NUMBER | MATCH_TELEPHONE, apartment_number_patterns, &apartment_number_, {log_manager_, "kApartmentNumberRe"})) { @@ -299,8 +291,8 @@ bool AddressField::ParseAddressLines(AutofillScanner* scanner, if (address1_ || street_address_) return false; - base::string16 pattern = UTF8ToUTF16(kAddressLine1Re); - base::string16 label_pattern = UTF8ToUTF16(kAddressLine1LabelRe); + std::u16string pattern = kAddressLine1Re; + std::u16string label_pattern = kAddressLine1LabelRe; const std::vector<MatchingPattern>& address_line1_patterns = PatternProvider::GetInstance().GetMatchPatterns("ADDRESS_LINE_1", @@ -329,8 +321,8 @@ bool AddressField::ParseAddressLines(AutofillScanner* scanner, // This code may not pick up pages that have an address field consisting of a // sequence of unlabeled address fields. If we need to add this, see // discussion on https://codereview.chromium.org/741493003/ - pattern = UTF8ToUTF16(kAddressLine2Re); - label_pattern = UTF8ToUTF16(kAddressLine2LabelRe); + pattern = kAddressLine2Re; + label_pattern = kAddressLine2LabelRe; const std::vector<MatchingPattern>& address_line2_patterns = PatternProvider::GetInstance().GetMatchPatterns("ADDRESS_LINE_2", @@ -349,7 +341,7 @@ bool AddressField::ParseAddressLines(AutofillScanner* scanner, // Optionally parse address line 3. This uses the same label regexp as // address 2 above. - pattern = UTF8ToUTF16(kAddressLinesExtraRe); + pattern = kAddressLinesExtraRe; if (!ParseField(scanner, pattern, address_line_extra_patterns, &address3_, {log_manager_, "kAddressLinesExtraRe"}) && !ParseFieldSpecifics(scanner, label_pattern, MATCH_LABEL | MATCH_TEXT, @@ -362,7 +354,7 @@ bool AddressField::ParseAddressLines(AutofillScanner* scanner, // // Since these are rare, don't bother considering unlabeled lines as extra // address lines. - pattern = UTF8ToUTF16(kAddressLinesExtraRe); + pattern = kAddressLinesExtraRe; while (ParseField(scanner, pattern, address_line_extra_patterns, nullptr, {log_manager_, "kAddressLinesExtraRe"})) { // Consumed a surplus line, try for another. @@ -382,10 +374,9 @@ bool AddressField::ParseCountry(AutofillScanner* scanner, page_language); scanner->SaveCursor(); - if (ParseFieldSpecifics(scanner, UTF8ToUTF16(kCountryRe), - MATCH_DEFAULT | MATCH_SELECT | MATCH_SEARCH, - country_patterns, &country_, - {log_manager_, "kCountryRe"})) { + if (ParseFieldSpecifics( + scanner, kCountryRe, MATCH_DEFAULT | MATCH_SELECT | MATCH_SEARCH, + country_patterns, &country_, {log_manager_, "kCountryRe"})) { return true; } @@ -393,7 +384,7 @@ bool AddressField::ParseCountry(AutofillScanner* scanner, // "location". However, this only makes sense for select tags. scanner->Rewind(); return ParseFieldSpecifics( - scanner, UTF8ToUTF16(kCountryLocationRe), + scanner, kCountryLocationRe, MATCH_LABEL | MATCH_NAME | MATCH_SELECT | MATCH_SEARCH, country_patternsl, &country_, {log_manager_, "kCountryLocationRe"}); } @@ -409,7 +400,7 @@ bool AddressField::ParseZipCode(AutofillScanner* scanner, const std::vector<MatchingPattern>& four_digit_zip_code_patterns = PatternProvider::GetInstance().GetMatchPatterns("ZIP_4", page_language); - if (!ParseFieldSpecifics(scanner, UTF8ToUTF16(kZipCodeRe), kZipCodeMatchType, + if (!ParseFieldSpecifics(scanner, kZipCodeRe, kZipCodeMatchType, zip_code_patterns, &zip_, {log_manager_, "kZipCodeRe"})) { return false; @@ -417,7 +408,7 @@ bool AddressField::ParseZipCode(AutofillScanner* scanner, // Look for a zip+4, whose field name will also often contain // the substring "zip". - ParseFieldSpecifics(scanner, UTF8ToUTF16(kZip4Re), kZipCodeMatchType, + ParseFieldSpecifics(scanner, kZip4Re, kZipCodeMatchType, four_digit_zip_code_patterns, &zip4_, {log_manager_, "kZip4Re"}); return true; @@ -435,7 +426,7 @@ bool AddressField::ParseDependentLocality(AutofillScanner* scanner, const std::vector<MatchingPattern>& dependent_locality_patterns = PatternProvider::GetInstance().GetMatchPatterns( "ADDRESS_HOME_DEPENDENT_LOCALITY", page_language); - return ParseFieldSpecifics(scanner, UTF8ToUTF16(kDependentLocalityRe), + return ParseFieldSpecifics(scanner, kDependentLocalityRe, kDependentLocalityMatchType, dependent_locality_patterns, &dependent_locality_, {log_manager_, "kDependentLocalityRe"}); @@ -448,8 +439,8 @@ bool AddressField::ParseCity(AutofillScanner* scanner, const std::vector<MatchingPattern>& city_patterns = PatternProvider::GetInstance().GetMatchPatterns("CITY", page_language); - return ParseFieldSpecifics(scanner, UTF8ToUTF16(kCityRe), kCityMatchType, - city_patterns, &city_, {log_manager_, "kCityRe"}); + return ParseFieldSpecifics(scanner, kCityRe, kCityMatchType, city_patterns, + &city_, {log_manager_, "kCityRe"}); } bool AddressField::ParseState(AutofillScanner* scanner, @@ -459,14 +450,13 @@ bool AddressField::ParseState(AutofillScanner* scanner, const std::vector<MatchingPattern>& patterns_state = PatternProvider::GetInstance().GetMatchPatterns("STATE", page_language); - return ParseFieldSpecifics(scanner, UTF8ToUTF16(kStateRe), kStateMatchType, - patterns_state, &state_, - {log_manager_, "kStateRe"}); + return ParseFieldSpecifics(scanner, kStateRe, kStateMatchType, patterns_state, + &state_, {log_manager_, "kStateRe"}); } AddressField::ParseNameLabelResult AddressField::ParseNameAndLabelSeparately( AutofillScanner* scanner, - const base::string16& pattern, + const std::u16string& pattern, int match_type, const std::vector<MatchingPattern>& patterns, AutofillField** match, @@ -619,8 +609,8 @@ AddressField::ParseNameLabelResult AddressField::ParseNameAndLabelForZipCode( PatternProvider::GetInstance().GetMatchPatterns("ZIP_4", page_language); ParseNameLabelResult result = ParseNameAndLabelSeparately( - scanner, UTF8ToUTF16(kZipCodeRe), kZipCodeMatchType, zip_code_patterns, - &zip_, {log_manager_, "kZipCodeRe"}); + scanner, kZipCodeRe, kZipCodeMatchType, zip_code_patterns, &zip_, + {log_manager_, "kZipCodeRe"}); if (result != RESULT_MATCH_NAME_LABEL || scanner->IsEnd()) return result; @@ -640,7 +630,7 @@ AddressField::ParseNameLabelResult AddressField::ParseNameAndLabelForZipCode( if (!found_non_zip4) { // Look for a zip+4, whose field name will also often contain // the substring "zip". - ParseFieldSpecifics(scanner, UTF8ToUTF16(kZip4Re), kZipCodeMatchType, + ParseFieldSpecifics(scanner, kZip4Re, kZipCodeMatchType, four_digit_zip_code_patterns, &zip4_, {log_manager_, "kZip4Re"}); } @@ -662,7 +652,7 @@ AddressField::ParseNameAndLabelForDependentLocality( PatternProvider::GetInstance().GetMatchPatterns( "ADDRESS_HOME_DEPENDENT_LOCALITY", page_language); return ParseNameAndLabelSeparately( - scanner, UTF8ToUTF16(kDependentLocalityRe), kDependentLocalityMatchType, + scanner, kDependentLocalityRe, kDependentLocalityMatchType, dependent_locality_patterns, &dependent_locality_, {log_manager_, "kDependentLocalityRe"}); } @@ -675,8 +665,8 @@ AddressField::ParseNameLabelResult AddressField::ParseNameAndLabelForCity( const std::vector<MatchingPattern>& city_patterns = PatternProvider::GetInstance().GetMatchPatterns("CITY", page_language); - return ParseNameAndLabelSeparately(scanner, UTF8ToUTF16(kCityRe), - kCityMatchType, city_patterns, &city_, + return ParseNameAndLabelSeparately(scanner, kCityRe, kCityMatchType, + city_patterns, &city_, {log_manager_, "kCityRe"}); } @@ -688,8 +678,8 @@ AddressField::ParseNameLabelResult AddressField::ParseNameAndLabelForState( const std::vector<MatchingPattern>& patterns_state = PatternProvider::GetInstance().GetMatchPatterns("STATE", page_language); - return ParseNameAndLabelSeparately(scanner, UTF8ToUTF16(kStateRe), - kStateMatchType, patterns_state, &state_, + return ParseNameAndLabelSeparately(scanner, kStateRe, kStateMatchType, + patterns_state, &state_, {log_manager_, "kStateRe"}); } @@ -707,16 +697,15 @@ AddressField::ParseNameLabelResult AddressField::ParseNameAndLabelForCountry( page_language); ParseNameLabelResult country_result = ParseNameAndLabelSeparately( - scanner, UTF8ToUTF16(kCountryRe), - MATCH_DEFAULT | MATCH_SELECT | MATCH_SEARCH, country_patterns, &country_, - {log_manager_, "kCountryRe"}); + scanner, kCountryRe, MATCH_DEFAULT | MATCH_SELECT | MATCH_SEARCH, + country_patterns, &country_, {log_manager_, "kCountryRe"}); if (country_result != RESULT_MATCH_NONE) return country_result; // The occasional page (e.g. google account registration page) calls this a // "location". However, this only makes sense for select tags. return ParseNameAndLabelSeparately( - scanner, UTF8ToUTF16(kCountryLocationRe), + scanner, kCountryLocationRe, MATCH_LABEL | MATCH_NAME | MATCH_SELECT | MATCH_SEARCH, country_location_patterns, &country_, {log_manager_, "kCountryLocationRe"}); diff --git a/chromium/components/autofill/core/browser/form_parsing/address_field.h b/chromium/components/autofill/core/browser/form_parsing/address_field.h index 820ac0b2f11..a360a30022d 100644 --- a/chromium/components/autofill/core/browser/form_parsing/address_field.h +++ b/chromium/components/autofill/core/browser/form_parsing/address_field.h @@ -6,12 +6,12 @@ #define COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_PARSING_ADDRESS_FIELD_H_ #include <memory> +#include <string> #include <vector> #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/autofill_type.h" #include "components/autofill/core/browser/form_parsing/form_field.h" #include "components/autofill/core/browser/pattern_provider/pattern_provider.h" @@ -88,7 +88,7 @@ class AddressField : public FormField { // change. ParseNameLabelResult ParseNameAndLabelSeparately( AutofillScanner* scanner, - const base::string16& pattern, + const std::u16string& pattern, int match_type, const std::vector<MatchingPattern>& patterns, AutofillField** match, diff --git a/chromium/components/autofill/core/browser/form_parsing/autofill_parsing_utils.h b/chromium/components/autofill/core/browser/form_parsing/autofill_parsing_utils.h index 1a4160c01aa..b6890a13bd4 100644 --- a/chromium/components/autofill/core/browser/form_parsing/autofill_parsing_utils.h +++ b/chromium/components/autofill/core/browser/form_parsing/autofill_parsing_utils.h @@ -5,9 +5,9 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_PARSING_AUTOFILL_PARSING_UTILS_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_PARSING_AUTOFILL_PARSING_UTILS_H_ -#include <base/optional.h> #include <string> +#include "base/optional.h" #include "components/autofill/core/common/language_code.h" namespace autofill { @@ -54,8 +54,8 @@ struct MatchingPattern { ~MatchingPattern(); LanguageCode language; - std::string positive_pattern; - std::string negative_pattern; + std::u16string positive_pattern; + std::u16string negative_pattern; float positive_score = 1.1; uint8_t match_field_attributes; uint16_t match_field_input_types; diff --git a/chromium/components/autofill/core/browser/form_parsing/autofill_scanner.h b/chromium/components/autofill/core/browser/form_parsing/autofill_scanner.h index 2d24f418726..53179b4b1c6 100644 --- a/chromium/components/autofill/core/browser/form_parsing/autofill_scanner.h +++ b/chromium/components/autofill/core/browser/form_parsing/autofill_scanner.h @@ -8,10 +8,10 @@ #include <stddef.h> #include <memory> +#include <string> #include <vector> #include "base/macros.h" -#include "base/strings/string16.h" namespace autofill { diff --git a/chromium/components/autofill/core/browser/form_parsing/credit_card_field.cc b/chromium/components/autofill/core/browser/form_parsing/credit_card_field.cc index cb1ab38fd8d..f7b3944780d 100644 --- a/chromium/components/autofill/core/browser/form_parsing/credit_card_field.cc +++ b/chromium/components/autofill/core/browser/form_parsing/credit_card_field.cc @@ -7,14 +7,13 @@ #include <stddef.h> #include <memory> +#include <string> #include <utility> #include "base/memory/ptr_util.h" #include "base/stl_util.h" -#include "base/strings/string16.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_field.h" #include "components/autofill/core/browser/autofill_regex_constants.h" @@ -38,8 +37,8 @@ const size_t kMaxValidCardNumberSize = 19; // Look for the vector |regex_needles| in |haystack|. Returns true if a // consecutive section of |haystack| matches |regex_needles|. -bool FindConsecutiveStrings(const std::vector<base::string16>& regex_needles, - const std::vector<base::string16>& haystack) { +bool FindConsecutiveStrings(const std::vector<std::u16string>& regex_needles, + const std::vector<std::u16string>& haystack) { if (regex_needles.empty() || haystack.empty() || (haystack.size() < regex_needles.size())) return false; @@ -119,8 +118,8 @@ std::unique_ptr<FormField> CreditCardField::Parse( break; if (!credit_card_field->cardholder_) { - if (ParseField(scanner, base::UTF8ToUTF16(kNameOnCardRe), - name_on_card_patterns, &credit_card_field->cardholder_, + if (ParseField(scanner, kNameOnCardRe, name_on_card_patterns, + &credit_card_field->cardholder_, {log_manager, "kNameOnCardRe"})) { continue; } @@ -133,7 +132,7 @@ std::unique_ptr<FormField> CreditCardField::Parse( // expiration date (which usually appears at the end). if (fields > 0 && !credit_card_field->expiration_month_ && - ParseField(scanner, base::UTF8ToUTF16(kNameOnCardContextualRe), + ParseField(scanner, kNameOnCardContextualRe, name_on_card_contextual_patterns, &credit_card_field->cardholder_, {log_manager, "kNameOnCardContextualRe"})) { @@ -146,8 +145,8 @@ std::unique_ptr<FormField> CreditCardField::Parse( // and haven't yet parsed the expiration date (which usually appears at // the end). if (!credit_card_field->expiration_month_ && - ParseField(scanner, base::UTF8ToUTF16(kLastNameRe), - last_name_patterns, &credit_card_field->cardholder_last_, + ParseField(scanner, kLastNameRe, last_name_patterns, + &credit_card_field->cardholder_last_, {log_manager, "kLastNameRe"})) { continue; } @@ -173,9 +172,8 @@ std::unique_ptr<FormField> CreditCardField::Parse( MATCH_DEFAULT | MATCH_NUMBER | MATCH_TELEPHONE | MATCH_PASSWORD; if (!credit_card_field->verification_ && - ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kCardCvcRe), - kMatchNumTelAndPwd, cvc_patterns, - &credit_card_field->verification_, + ParseFieldSpecifics(scanner, kCardCvcRe, kMatchNumTelAndPwd, + cvc_patterns, &credit_card_field->verification_, {log_manager, "kCardCvcRe"})) { // A couple of sites have multiple verification codes right after another. // Allow the classification of these codes one by one. @@ -189,9 +187,8 @@ std::unique_ptr<FormField> CreditCardField::Parse( // Check if the previous field was a verification code. scanner->RewindTo(scanner->SaveCursor() - 2); - if (ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kCardCvcRe), - kMatchNumTelAndPwd, cvc_patterns, - &credit_card_field->verification_, + if (ParseFieldSpecifics(scanner, kCardCvcRe, kMatchNumTelAndPwd, + cvc_patterns, &credit_card_field->verification_, {log_manager, "kCardCvcRe"})) { // Reset the current cvv (The verification parse overwrote it). credit_card_field->verification_ = saved_cvv; @@ -216,8 +213,8 @@ std::unique_ptr<FormField> CreditCardField::Parse( const std::vector<MatchingPattern>& patterns = PatternProvider::GetInstance().GetMatchPatterns(CREDIT_CARD_NUMBER, page_language); - if (ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kCardNumberRe), - kMatchNumTelAndPwd, patterns, ¤t_number_field, + if (ParseFieldSpecifics(scanner, kCardNumberRe, kMatchNumTelAndPwd, + patterns, ¤t_number_field, {log_manager, "kCardNumberRe"})) { // Avoid autofilling any credit card number field having very low or high // |start_index| on the HTML form. @@ -324,8 +321,7 @@ bool CreditCardField::LikelyCardMonthSelectField(AutofillScanner* scanner) { return false; // Filter out years. - const base::string16 kNumericalYearRe = - base::ASCIIToUTF16("[1-9][0-9][0-9][0-9]"); + const std::u16string kNumericalYearRe = u"[1-9][0-9][0-9][0-9]"; for (const auto& value : field->option_values) { if (MatchesPattern(value, kNumericalYearRe)) return false; @@ -336,7 +332,7 @@ bool CreditCardField::LikelyCardMonthSelectField(AutofillScanner* scanner) { } // Look for numerical months. - const base::string16 kNumericalMonthRe = base::ASCIIToUTF16("12"); + const std::u16string kNumericalMonthRe = u"12"; if (MatchesPattern(field->option_values.back(), kNumericalMonthRe) || MatchesPattern(field->option_contents.back(), kNumericalMonthRe)) { return true; @@ -363,7 +359,7 @@ bool CreditCardField::LikelyCardYearSelectField( // Filter out days - elements for date entries would have // numbers 1 to 9 as well in them, which we can filter on. - const base::string16 kSingleDigitDateRe = base::ASCIIToUTF16("\\b[1-9]\\b"); + const std::u16string kSingleDigitDateRe = u"\\b[1-9]\\b"; for (const auto& value : field->option_contents) { if (MatchesPattern(value, kSingleDigitDateRe)) { return false; @@ -373,7 +369,7 @@ bool CreditCardField::LikelyCardYearSelectField( // Another way to eliminate days - filter out 'day' fields. const std::vector<MatchingPattern>& day_patterns = PatternProvider::GetInstance().GetMatchPatterns("DAY", page_language); - if (FormField::ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kDayRe), + if (FormField::ParseFieldSpecifics(scanner, kDayRe, MATCH_DEFAULT | MATCH_SELECT, day_patterns, nullptr, {log_manager, "kDayRe"})) { return false; @@ -381,7 +377,7 @@ bool CreditCardField::LikelyCardYearSelectField( // Filter out birth years - a website would not offer 1999 as a credit card // expiration year, but show it in the context of a birth year selector. - const base::string16 kBirthYearRe = base::ASCIIToUTF16("(1999|99)"); + const std::u16string kBirthYearRe = u"(1999|99)"; for (const auto& value : field->option_contents) { if (MatchesPattern(value, kBirthYearRe)) { return false; @@ -393,8 +389,8 @@ bool CreditCardField::LikelyCardYearSelectField( time_now.UTCExplode(&time_exploded); const int kYearsToMatch = 3; - std::vector<base::string16> years_to_check_4_digit; - std::vector<base::string16> years_to_check_2_digit; + std::vector<std::u16string> years_to_check_4_digit; + std::vector<std::u16string> years_to_check_2_digit; for (int year = time_exploded.year; year < time_exploded.year + kYearsToMatch; ++year) { years_to_check_4_digit.push_back(base::NumberToString16(year)); @@ -452,21 +448,21 @@ bool CreditCardField::IsGiftCardField(AutofillScanner* scanner, PatternProvider::GetInstance().GetMatchPatterns("GIFT_CARD", page_language); - if (ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kDebitCardRe), - kMatchFieldTypes, debit_cards_patterns, nullptr, + if (ParseFieldSpecifics(scanner, kDebitCardRe, kMatchFieldTypes, + debit_cards_patterns, nullptr, {log_manager, "kDebitCardRe"})) { scanner->RewindTo(saved_cursor); return false; } - if (ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kDebitGiftCardRe), - kMatchFieldTypes, debit_gift_card_patterns, nullptr, + if (ParseFieldSpecifics(scanner, kDebitGiftCardRe, kMatchFieldTypes, + debit_gift_card_patterns, nullptr, {log_manager, "kDebitGiftCardRe"})) { scanner->RewindTo(saved_cursor); return false; } - return ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kGiftCardRe), - kMatchFieldTypes, gift_card_patterns, nullptr, + return ParseFieldSpecifics(scanner, kGiftCardRe, kMatchFieldTypes, + gift_card_patterns, nullptr, {log_manager, "kGiftCardRe"}); } @@ -574,24 +570,23 @@ bool CreditCardField::ParseExpirationDate(AutofillScanner* scanner, PatternProvider::GetInstance().GetMatchPatterns( "CREDIT_CARD_EXP_YEAR_AFTER_MONTH", page_language); - if (ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kExpirationMonthRe), - kMatchCCType, cc_exp_month_patterns, - &expiration_month_, + if (ParseFieldSpecifics(scanner, kExpirationMonthRe, kMatchCCType, + cc_exp_month_patterns, &expiration_month_, {log_manager_, "kExpirationMonthRe"}) && - ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kExpirationYearRe), - kMatchCCType, cc_exp_year_patterns, &expiration_year_, + ParseFieldSpecifics(scanner, kExpirationYearRe, kMatchCCType, + cc_exp_year_patterns, &expiration_year_, {log_manager_, "kExpirationYearRe"})) { return true; } // If that fails, look for just MM and/or YY(YY). scanner->RewindTo(month_year_saved_cursor); - if (ParseFieldSpecifics(scanner, base::ASCIIToUTF16("^mm$"), kMatchCCType, + if (ParseFieldSpecifics(scanner, u"^mm$", kMatchCCType, cc_exp_month_before_year_patterns, &expiration_month_, {log_manager_, "^mm$"}) && - ParseFieldSpecifics(scanner, base::ASCIIToUTF16("^(yy|yyyy)$"), - kMatchCCType, cc_exp_year_after_month_patterns, - &expiration_year_, {log_manager_, "^(yy|yyyy)$"})) { + ParseFieldSpecifics(scanner, u"^(yy|yyyy)$", kMatchCCType, + cc_exp_year_after_month_patterns, &expiration_year_, + {log_manager_, "^(yy|yyyy)$"})) { return true; } @@ -609,10 +604,9 @@ bool CreditCardField::ParseExpirationDate(AutofillScanner* scanner, const std::vector<MatchingPattern>& cc_exp_2digit_year_patterns = PatternProvider::GetInstance().GetMatchPatterns( CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, page_language); - if (ParseFieldSpecifics( - scanner, base::UTF8ToUTF16(kExpirationDate2DigitYearRe), kMatchCCType, - cc_exp_2digit_year_patterns, &expiration_date_, - {log_manager_, "kExpirationDate2DigitYearRe"})) { + if (ParseFieldSpecifics(scanner, kExpirationDate2DigitYearRe, kMatchCCType, + cc_exp_2digit_year_patterns, &expiration_date_, + {log_manager_, "kExpirationDate2DigitYearRe"})) { exp_year_type_ = CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR; expiration_month_ = nullptr; return true; @@ -622,8 +616,8 @@ bool CreditCardField::ParseExpirationDate(AutofillScanner* scanner, const std::vector<MatchingPattern>& cc_exp_date_patterns = PatternProvider::GetInstance().GetMatchPatterns("CREDIT_CARD_EXP_DATE", page_language); - if (ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kExpirationDateRe), - kMatchCCType, cc_exp_date_patterns, &expiration_date_, + if (ParseFieldSpecifics(scanner, kExpirationDateRe, kMatchCCType, + cc_exp_date_patterns, &expiration_date_, {log_manager_, "kExpirationDateRe"})) { // If such a field exists, but it cannot fit a 4-digit year expiration // date, then the likely possibility is that it is a 2-digit year expiration @@ -642,10 +636,9 @@ bool CreditCardField::ParseExpirationDate(AutofillScanner* scanner, CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, page_language); if (FieldCanFitDataForFieldType(current_field_max_length, CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR) && - ParseFieldSpecifics( - scanner, base::UTF8ToUTF16(kExpirationDate4DigitYearRe), kMatchCCType, - cc_exp_date_4_digit_year_patterns, &expiration_date_, - {log_manager_, "kExpirationDate4DigitYearRe"})) { + ParseFieldSpecifics(scanner, kExpirationDate4DigitYearRe, kMatchCCType, + cc_exp_date_4_digit_year_patterns, &expiration_date_, + {log_manager_, "kExpirationDate4DigitYearRe"})) { expiration_month_ = nullptr; return true; } diff --git a/chromium/components/autofill/core/browser/form_parsing/email_field.cc b/chromium/components/autofill/core/browser/form_parsing/email_field.cc index 655749affc6..00498313fe8 100644 --- a/chromium/components/autofill/core/browser/form_parsing/email_field.cc +++ b/chromium/components/autofill/core/browser/form_parsing/email_field.cc @@ -4,7 +4,6 @@ #include "components/autofill/core/browser/form_parsing/email_field.h" -#include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_regex_constants.h" #include "components/autofill/core/browser/form_parsing/autofill_scanner.h" @@ -18,9 +17,8 @@ std::unique_ptr<FormField> EmailField::Parse(AutofillScanner* scanner, const std::vector<MatchingPattern>& email_patterns = PatternProvider::GetInstance().GetMatchPatterns("EMAIL_ADDRESS", page_language); - if (ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kEmailRe), - MATCH_DEFAULT | MATCH_EMAIL, email_patterns, &field, - {log_manager, "kEmailRe"})) { + if (ParseFieldSpecifics(scanner, kEmailRe, MATCH_DEFAULT | MATCH_EMAIL, + email_patterns, &field, {log_manager, "kEmailRe"})) { return std::make_unique<EmailField>(field); } diff --git a/chromium/components/autofill/core/browser/form_parsing/field_candidates.h b/chromium/components/autofill/core/browser/form_parsing/field_candidates.h index 4cf3c6d7204..6907bb9a1a1 100644 --- a/chromium/components/autofill/core/browser/form_parsing/field_candidates.h +++ b/chromium/components/autofill/core/browser/form_parsing/field_candidates.h @@ -9,7 +9,7 @@ #include "base/containers/flat_map.h" #include "components/autofill/core/browser/field_types.h" -#include "components/autofill/core/common/renderer_id.h" +#include "components/autofill/core/common/unique_ids.h" namespace autofill { @@ -50,8 +50,8 @@ class FieldCandidates { std::vector<FieldCandidate> field_candidates_; }; -// A map from the field's unique name to its possible candidates. -using FieldCandidatesMap = base::flat_map<FieldRendererId, FieldCandidates>; +// A map from the field's global ID to its possible candidates. +using FieldCandidatesMap = base::flat_map<FieldGlobalId, FieldCandidates>; } // namespace autofill diff --git a/chromium/components/autofill/core/browser/form_parsing/form_field.cc b/chromium/components/autofill/core/browser/form_parsing/form_field.cc index 696b422b450..f816d1b1c12 100644 --- a/chromium/components/autofill/core/browser/form_parsing/form_field.cc +++ b/chromium/components/autofill/core/browser/form_parsing/form_field.cc @@ -15,7 +15,6 @@ #include "base/strings/string_piece.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" -#include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_field.h" #include "components/autofill/core/browser/autofill_regexes.h" #include "components/autofill/core/browser/autofill_type.h" @@ -23,6 +22,7 @@ #include "components/autofill/core/browser/form_parsing/autofill_scanner.h" #include "components/autofill/core/browser/form_parsing/credit_card_field.h" #include "components/autofill/core/browser/form_parsing/email_field.h" +#include "components/autofill/core/browser/form_parsing/merchant_promo_code_field.h" #include "components/autofill/core/browser/form_parsing/name_field.h" #include "components/autofill/core/browser/form_parsing/phone_field.h" #include "components/autofill/core/browser/form_parsing/price_field.h" @@ -40,7 +40,7 @@ namespace autofill { // There's an implicit precedence determined by the values assigned here. Email // is currently the most important followed by Phone, Travel, Address, -// Credit Card, Name, and Search. +// Credit Card, Price, Name, Merchant promo code, and Search. const float FormField::kBaseEmailParserScore = 1.4f; const float FormField::kBasePhoneParserScore = 1.3f; const float FormField::kBaseTravelParserScore = 1.2f; @@ -48,6 +48,7 @@ const float FormField::kBaseAddressParserScore = 1.1f; const float FormField::kBaseCreditCardParserScore = 1.0f; const float FormField::kBasePriceParserScore = 0.95f; const float FormField::kBaseNameParserScore = 0.9f; +const float FormField::kBaseMerchantPromoCodeParserScore = 0.85f; const float FormField::kBaseSearchParserScore = 0.8f; // static @@ -103,6 +104,10 @@ FieldCandidatesMap FormField::ParseFormFields( ParseFormFieldsPass(NameField::Parse, processed_fields, &field_candidates, page_language, log_manager); + // Merchant promo code pass. + ParseFormFieldsPass(MerchantPromoCodeField::Parse, processed_fields, + &field_candidates, page_language, log_manager); + // Search pass. ParseFormFieldsPass(SearchField::Parse, processed_fields, &field_candidates, page_language, log_manager); @@ -133,7 +138,7 @@ FieldCandidatesMap FormField::ParseFormFields( } for (const auto& candidate : field_candidates) { LogBuffer name; - name << "Type candidate for renderer ID: " << candidate.first.value(); + name << "Type candidate for frame and renderer ID: " << candidate.first; LogBuffer description; ServerFieldType field_type = candidate.second.BestHeuristicType(); description << "BestHeuristicType: " @@ -155,7 +160,7 @@ FieldCandidatesMap FormField::ParseFormFields( // static bool FormField::ParseField(AutofillScanner* scanner, - const base::string16& pattern, + base::StringPiece16 pattern, AutofillField** match, const RegExLogging& logging) { return ParseFieldSpecifics(scanner, pattern, MATCH_DEFAULT, match, logging); @@ -169,7 +174,7 @@ bool FormField::ParseField(AutofillScanner* scanner, } bool FormField::ParseField(AutofillScanner* scanner, - const base::string16& pattern, + base::StringPiece16 pattern, const std::vector<MatchingPattern>& patterns, AutofillField** match, const RegExLogging& logging) { @@ -184,7 +189,7 @@ bool FormField::ParseField(AutofillScanner* scanner, } bool FormField::ParseFieldSpecifics(AutofillScanner* scanner, - const base::string16& pattern, + base::StringPiece16 pattern, int match_field_attributes, int match_field_input_types, AutofillField** match, @@ -222,7 +227,7 @@ bool FormField::ParseFieldSpecifics( if (base::FeatureList::IsEnabled( features::kAutofillParsingPatternsNegativeMatching)) { if (!pattern.negative_pattern.empty() && - FormField::Match(field, base::UTF8ToUTF16(pattern.negative_pattern), + FormField::Match(field, pattern.negative_pattern, pattern.match_field_attributes, pattern.match_field_input_types, logging)) { continue; @@ -230,7 +235,7 @@ bool FormField::ParseFieldSpecifics( } if (!pattern.positive_pattern.empty() && - MatchAndAdvance(scanner, base::UTF8ToUTF16(pattern.positive_pattern), + MatchAndAdvance(scanner, pattern.positive_pattern, pattern.match_field_attributes, pattern.match_field_input_types, match, logging)) { return true; @@ -241,7 +246,7 @@ bool FormField::ParseFieldSpecifics( // static bool FormField::ParseFieldSpecifics(AutofillScanner* scanner, - const base::string16& pattern, + base::StringPiece16 pattern, int match_type, AutofillField** match, const RegExLogging& logging) { @@ -254,7 +259,7 @@ bool FormField::ParseFieldSpecifics(AutofillScanner* scanner, bool FormField::ParseFieldSpecifics( AutofillScanner* scanner, - const base::string16& pattern, + base::StringPiece16 pattern, int match_type, const std::vector<MatchingPattern>& patterns, AutofillField** match, @@ -284,8 +289,8 @@ bool FormField::ParseFieldSpecifics( // static bool FormField::ParseEmptyLabel(AutofillScanner* scanner, AutofillField** match) { - return ParseFieldSpecifics(scanner, base::ASCIIToUTF16("^$"), - MATCH_LABEL | MATCH_ALL_INPUTS, match); + return ParseFieldSpecifics(scanner, u"^$", MATCH_LABEL | MATCH_ALL_INPUTS, + match); } // static @@ -297,12 +302,12 @@ void FormField::AddClassification(const AutofillField* field, if (field == nullptr) return; - FieldCandidates& candidates = (*field_candidates)[field->unique_renderer_id]; + FieldCandidates& candidates = (*field_candidates)[field->global_id()]; candidates.AddFieldCandidate(type, score); } bool FormField::MatchAndAdvance(AutofillScanner* scanner, - const base::string16& pattern, + base::StringPiece16 pattern, int match_field_attributes, int match_field_input_types, AutofillField** match, @@ -321,7 +326,7 @@ bool FormField::MatchAndAdvance(AutofillScanner* scanner, // static bool FormField::MatchAndAdvance(AutofillScanner* scanner, - const base::string16& pattern, + base::StringPiece16 pattern, int match_type, AutofillField** match, const RegExLogging& logging) { @@ -333,23 +338,23 @@ bool FormField::MatchAndAdvance(AutofillScanner* scanner, } bool FormField::Match(const AutofillField* field, - const base::string16& pattern, + base::StringPiece16 pattern, int match_field_attributes, int match_field_input_types, const RegExLogging& logging) { bool found_match = false; base::StringPiece match_type_string; base::StringPiece16 value; - base::string16 match; + std::u16string match; // TODO(crbug/1165780): Remove once shared labels are launched. - const base::string16& label = + const std::u16string& label = base::FeatureList::IsEnabled( features::kAutofillEnableSupportForParsingWithSharedLabels) ? field->parseable_label() : field->label; - const base::string16& name = field->parseable_name(); + const std::u16string& name = field->parseable_name(); if ((match_field_attributes & MATCH_LABEL) && MatchesPattern(label, pattern, &match)) { @@ -381,7 +386,7 @@ bool FormField::Match(const AutofillField* field, // static bool FormField::Match(const AutofillField* field, - const base::string16& pattern, + base::StringPiece16 pattern, int match_type, const RegExLogging& logging) { int match_field_attributes = match_type & 0b11; diff --git a/chromium/components/autofill/core/browser/form_parsing/form_field.h b/chromium/components/autofill/core/browser/form_parsing/form_field.h index 904c373e517..20753be3894 100644 --- a/chromium/components/autofill/core/browser/form_parsing/form_field.h +++ b/chromium/components/autofill/core/browser/form_parsing/form_field.h @@ -6,11 +6,12 @@ #define COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_PARSING_FORM_FIELD_H_ #include <memory> +#include <string> #include <vector> #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "base/strings/string16.h" +#include "base/strings/string_piece.h" #include "components/autofill/core/browser/field_types.h" #include "components/autofill/core/browser/form_parsing/autofill_parsing_utils.h" #include "components/autofill/core/browser/form_parsing/field_candidates.h" @@ -64,6 +65,7 @@ class FormField { static const float kBaseCreditCardParserScore; static const float kBasePriceParserScore; static const float kBaseNameParserScore; + static const float kBaseMerchantPromoCodeParserScore; static const float kBaseSearchParserScore; // Only derived classes may instantiate. @@ -72,7 +74,7 @@ class FormField { // Attempts to parse a form field with the given pattern. Returns true on // success and fills |match| with a pointer to the field. static bool ParseField(AutofillScanner* scanner, - const base::string16& pattern, + base::StringPiece16 pattern, AutofillField** match, const RegExLogging& logging = {}); @@ -82,7 +84,7 @@ class FormField { const RegExLogging& logging = {}); static bool ParseField(AutofillScanner* scanner, - const base::string16& pattern, + base::StringPiece16 pattern, const std::vector<MatchingPattern>& patterns, AutofillField** match, const RegExLogging& logging = {}); @@ -93,7 +95,7 @@ class FormField { // field, and the scanner would advance by one step. A |true| result is // returned in the case of a successful match, false otherwise. static bool ParseFieldSpecifics(AutofillScanner* scanner, - const base::string16& pattern, + base::StringPiece16 pattern, int match_type, AutofillField** match, const RegExLogging& logging = {}); @@ -106,7 +108,7 @@ class FormField { // The same as ParseFieldSpecifics but with splitted match_types into // MatchAttributes and MatchFieldTypes. static bool ParseFieldSpecifics(AutofillScanner* scanner, - const base::string16& pattern, + base::StringPiece16 pattern, int match_field_attributes, int match_field_input_types, AutofillField** match, @@ -118,7 +120,7 @@ class FormField { }; static bool ParseFieldSpecifics(AutofillScanner* scanner, - const base::string16& pattern, + base::StringPiece16 pattern, int match_type, const std::vector<MatchingPattern>& patterns, AutofillField** match, @@ -165,7 +167,7 @@ class FormField { // Returns |true| if a match is found according to |match_type|, and |false| // otherwise. static bool MatchAndAdvance(AutofillScanner* scanner, - const base::string16& pattern, + base::StringPiece16 pattern, int match_type, AutofillField** match, const RegExLogging& logging = {}); @@ -173,7 +175,7 @@ class FormField { // The same as MatchAndAdvance but with splitted match_types into // MatchAttributes and MatchFieldTypes. static bool MatchAndAdvance(AutofillScanner* scanner, - const base::string16& pattern, + base::StringPiece16 pattern, int match_field_attributes, int match_field_input_types, AutofillField** match, @@ -182,14 +184,14 @@ class FormField { // Matches the regular expression |pattern| against the components of // |field| as specified in the |match_type| bit field (see |MatchType|). static bool Match(const AutofillField* field, - const base::string16& pattern, + base::StringPiece16 pattern, int match_type, const RegExLogging& logging = {}); // The same as Match but with splitted match_types into MatchAttributes // and MatchFieldTypes. static bool Match(const AutofillField* field, - const base::string16& pattern, + base::StringPiece16 pattern, int match_field_attributes, int match_field_input_types, const RegExLogging& logging = {}); diff --git a/chromium/components/autofill/core/browser/form_parsing/form_field_unittest.cc b/chromium/components/autofill/core/browser/form_parsing/form_field_unittest.cc index 1d41fdeea2d..54e0c2e6524 100644 --- a/chromium/components/autofill/core/browser/form_parsing/form_field_unittest.cc +++ b/chromium/components/autofill/core/browser/form_parsing/form_field_unittest.cc @@ -3,9 +3,9 @@ // found in the LICENSE file. #include <memory> +#include <string> #include <vector> -#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_field.h" @@ -37,91 +37,80 @@ TEST(FormFieldTest, Match) { AutofillField field; // Empty strings match. - EXPECT_TRUE(FormField::Match(&field, base::string16(), MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, std::u16string(), MATCH_LABEL)); // Empty pattern matches non-empty string. SetFieldLabels(&field, "a"); - EXPECT_TRUE(FormField::Match(&field, base::string16(), MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, std::u16string(), MATCH_LABEL)); // Strictly empty pattern matches empty string. SetFieldLabels(&field, ""); - EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^$"), MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"^$", MATCH_LABEL)); // Strictly empty pattern does not match non-empty string. SetFieldLabels(&field, "a"); - EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^$"), MATCH_LABEL)); + EXPECT_FALSE(FormField::Match(&field, u"^$", MATCH_LABEL)); // Non-empty pattern doesn't match empty string. SetFieldLabels(&field, ""); - EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("a"), MATCH_LABEL)); + EXPECT_FALSE(FormField::Match(&field, u"a", MATCH_LABEL)); // Beginning of line. SetFieldLabels(&field, "head_tail"); - EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^head"), MATCH_LABEL)); - EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^tail"), MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"^head", MATCH_LABEL)); + EXPECT_FALSE(FormField::Match(&field, u"^tail", MATCH_LABEL)); // End of line. SetFieldLabels(&field, "head_tail"); - EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("head$"), MATCH_LABEL)); - EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("tail$"), MATCH_LABEL)); + EXPECT_FALSE(FormField::Match(&field, u"head$", MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"tail$", MATCH_LABEL)); // Exact. SetFieldLabels(&field, "head_tail"); - EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^head$"), MATCH_LABEL)); - EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^tail$"), MATCH_LABEL)); - EXPECT_TRUE( - FormField::Match(&field, ASCIIToUTF16("^head_tail$"), MATCH_LABEL)); + EXPECT_FALSE(FormField::Match(&field, u"^head$", MATCH_LABEL)); + EXPECT_FALSE(FormField::Match(&field, u"^tail$", MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"^head_tail$", MATCH_LABEL)); // Escaped dots. SetFieldLabels(&field, "m.i."); // Note: This pattern is misleading as the "." characters are wild cards. - EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("m.i."), MATCH_LABEL)); - EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("m\\.i\\."), MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"m.i.", MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"m\\.i\\.", MATCH_LABEL)); SetFieldLabels(&field, "mXiX"); - EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("m.i."), MATCH_LABEL)); - EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("m\\.i\\."), MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"m.i.", MATCH_LABEL)); + EXPECT_FALSE(FormField::Match(&field, u"m\\.i\\.", MATCH_LABEL)); // Repetition. SetFieldLabels(&field, "headtail"); - EXPECT_TRUE( - FormField::Match(&field, ASCIIToUTF16("head.*tail"), MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"head.*tail", MATCH_LABEL)); SetFieldLabels(&field, "headXtail"); - EXPECT_TRUE( - FormField::Match(&field, ASCIIToUTF16("head.*tail"), MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"head.*tail", MATCH_LABEL)); SetFieldLabels(&field, "headXXXtail"); - EXPECT_TRUE( - FormField::Match(&field, ASCIIToUTF16("head.*tail"), MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"head.*tail", MATCH_LABEL)); SetFieldLabels(&field, "headtail"); - EXPECT_FALSE( - FormField::Match(&field, ASCIIToUTF16("head.+tail"), MATCH_LABEL)); + EXPECT_FALSE(FormField::Match(&field, u"head.+tail", MATCH_LABEL)); SetFieldLabels(&field, "headXtail"); - EXPECT_TRUE( - FormField::Match(&field, ASCIIToUTF16("head.+tail"), MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"head.+tail", MATCH_LABEL)); SetFieldLabels(&field, "headXXXtail"); - EXPECT_TRUE( - FormField::Match(&field, ASCIIToUTF16("head.+tail"), MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"head.+tail", MATCH_LABEL)); // Alternation. SetFieldLabels(&field, "head_tail"); - EXPECT_TRUE( - FormField::Match(&field, ASCIIToUTF16("head|other"), MATCH_LABEL)); - EXPECT_TRUE( - FormField::Match(&field, ASCIIToUTF16("tail|other"), MATCH_LABEL)); - EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("bad|good"), MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"head|other", MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"tail|other", MATCH_LABEL)); + EXPECT_FALSE(FormField::Match(&field, u"bad|good", MATCH_LABEL)); // Case sensitivity. SetFieldLabels(&field, "xxxHeAd_tAiLxxx"); - EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head_tail"), MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"head_tail", MATCH_LABEL)); // Word boundaries. SetFieldLabels(&field, "contains word:"); - EXPECT_TRUE( - FormField::Match(&field, ASCIIToUTF16("\\bword\\b"), MATCH_LABEL)); - EXPECT_FALSE( - FormField::Match(&field, ASCIIToUTF16("\\bcon\\b"), MATCH_LABEL)); + EXPECT_TRUE(FormField::Match(&field, u"\\bword\\b", MATCH_LABEL)); + EXPECT_FALSE(FormField::Match(&field, u"\\bcon\\b", MATCH_LABEL)); // Make sure the circumflex in 'crepe' is not treated as a word boundary. field.label = base::UTF8ToUTF16("cr\xC3\xAApe"); - EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("\\bcr\\b"), MATCH_LABEL)); + EXPECT_FALSE(FormField::Match(&field, u"\\bcr\\b", MATCH_LABEL)); } // Test that we ignore checkable elements. @@ -131,7 +120,7 @@ TEST(FormFieldTest, ParseFormFields) { field_data.form_control_type = "text"; field_data.check_status = FormFieldData::CheckStatus::kCheckableButUnchecked; - field_data.label = ASCIIToUTF16("Is PO Box"); + field_data.label = u"Is PO Box"; field_data.unique_renderer_id = MakeFieldRendererId(); fields.push_back(std::make_unique<AutofillField>(field_data)); @@ -143,7 +132,7 @@ TEST(FormFieldTest, ParseFormFields) { // reset |is_checkable| to false. field_data.check_status = FormFieldData::CheckStatus::kNotCheckable; - field_data.label = ASCIIToUTF16("Address line1"); + field_data.label = u"Address line1"; field_data.unique_renderer_id = MakeFieldRendererId(); fields.push_back(std::make_unique<AutofillField>(field_data)); @@ -152,7 +141,7 @@ TEST(FormFieldTest, ParseFormFields) { FormField::ParseFormFields(fields, LanguageCode(""), true).size()); // Parses address line 1 and 2. - field_data.label = ASCIIToUTF16("Address line2"); + field_data.label = u"Address line2"; field_data.unique_renderer_id = MakeFieldRendererId(); fields.push_back(std::make_unique<AutofillField>(field_data)); @@ -169,11 +158,11 @@ TEST(FormFieldTest, ParseFormFieldEnforceMinFillableFields) { FormFieldData field_data; field_data.form_control_type = "text"; - field_data.label = ASCIIToUTF16("Address line 1"); + field_data.label = u"Address line 1"; field_data.unique_renderer_id = MakeFieldRendererId(); fields.push_back(std::make_unique<AutofillField>(field_data)); - field_data.label = ASCIIToUTF16("Address line 2"); + field_data.label = u"Address line 2"; field_data.unique_renderer_id = MakeFieldRendererId(); fields.push_back(std::make_unique<AutofillField>(field_data)); @@ -183,7 +172,7 @@ TEST(FormFieldTest, ParseFormFieldEnforceMinFillableFields) { EXPECT_EQ(0u, FormField::ParseFormFields(fields, LanguageCode(""), true).size()); - field_data.label = ASCIIToUTF16("Search"); + field_data.label = u"Search"; field_data.unique_renderer_id = MakeFieldRendererId(); fields.push_back(std::make_unique<AutofillField>(field_data)); @@ -217,23 +206,23 @@ TEST(FormFieldTest, TestParseableLabels) { FormFieldData field_data; field_data.form_control_type = "text"; - field_data.label = ASCIIToUTF16("not a parseable label"); + field_data.label = u"not a parseable label"; field_data.unique_renderer_id = MakeFieldRendererId(); auto autofill_field = std::make_unique<AutofillField>(field_data); - autofill_field->set_parseable_label(ASCIIToUTF16("First Name")); + autofill_field->set_parseable_label(u"First Name"); { base::test::ScopedFeatureList feature_list; feature_list.InitAndEnableFeature( features::kAutofillEnableSupportForParsingWithSharedLabels); - EXPECT_TRUE(FormField::Match(autofill_field.get(), - ASCIIToUTF16("First Name"), MATCH_LABEL)); + EXPECT_TRUE( + FormField::Match(autofill_field.get(), u"First Name", MATCH_LABEL)); } { base::test::ScopedFeatureList feature_list; feature_list.InitAndDisableFeature( features::kAutofillEnableSupportForParsingWithSharedLabels); - EXPECT_FALSE(FormField::Match(autofill_field.get(), - ASCIIToUTF16("First Name"), MATCH_LABEL)); + EXPECT_FALSE( + FormField::Match(autofill_field.get(), u"First Name", MATCH_LABEL)); } } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/form_parsing/merchant_promo_code_field.cc b/chromium/components/autofill/core/browser/form_parsing/merchant_promo_code_field.cc new file mode 100644 index 00000000000..4d7653c699d --- /dev/null +++ b/chromium/components/autofill/core/browser/form_parsing/merchant_promo_code_field.cc @@ -0,0 +1,48 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/autofill/core/browser/form_parsing/merchant_promo_code_field.h" + +#include "components/autofill/core/browser/autofill_field.h" +#include "components/autofill/core/browser/autofill_regex_constants.h" +#include "components/autofill/core/browser/form_parsing/autofill_scanner.h" +#include "components/autofill/core/common/autofill_payments_features.h" + +namespace autofill { + +// static +std::unique_ptr<FormField> MerchantPromoCodeField::Parse( + AutofillScanner* scanner, + const LanguageCode& page_language, + LogManager* log_manager) { + if (!base::FeatureList::IsEnabled( + features::kAutofillParseMerchantPromoCodeFields)) { + return nullptr; + } + + AutofillField* field; + const std::vector<MatchingPattern>& merchant_promo_code_patterns = + PatternProvider::GetInstance().GetMatchPatterns("MERCHANT_PROMO_CODE", + page_language); + + if (ParseFieldSpecifics(scanner, kMerchantPromoCodeRe, + MATCH_DEFAULT | MATCH_NUMBER | MATCH_TEXT_AREA, + merchant_promo_code_patterns, &field, + {log_manager, "kMerchantPromoCodeRe"})) { + return std::make_unique<MerchantPromoCodeField>(field); + } + + return nullptr; +} + +MerchantPromoCodeField::MerchantPromoCodeField(const AutofillField* field) + : field_(field) {} + +void MerchantPromoCodeField::AddClassifications( + FieldCandidatesMap* field_candidates) const { + AddClassification(field_, MERCHANT_PROMO_CODE, + kBaseMerchantPromoCodeParserScore, field_candidates); +} + +} // namespace autofill diff --git a/chromium/components/autofill/core/browser/form_parsing/merchant_promo_code_field.h b/chromium/components/autofill/core/browser/form_parsing/merchant_promo_code_field.h new file mode 100644 index 00000000000..02369ac9dfd --- /dev/null +++ b/chromium/components/autofill/core/browser/form_parsing/merchant_promo_code_field.h @@ -0,0 +1,49 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_PARSING_MERCHANT_PROMO_CODE_FIELD_H_ +#define COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_PARSING_MERCHANT_PROMO_CODE_FIELD_H_ + +#include <memory> + +#include "base/compiler_specific.h" +#include "base/macros.h" +#include "components/autofill/core/browser/form_parsing/form_field.h" +#include "components/autofill/core/browser/pattern_provider/pattern_provider.h" +#include "components/autofill/core/common/language_code.h" + +namespace autofill { + +class AutofillField; +class AutofillScanner; +class LogManager; + +// A form field that accepts promo/gift/coupon codes during checkout on a +// merchant's web site. +class MerchantPromoCodeField : public FormField { + public: + static std::unique_ptr<FormField> Parse(AutofillScanner* scanner, + const LanguageCode& page_language, + LogManager* log_manager); + explicit MerchantPromoCodeField(const AutofillField* field); + + MerchantPromoCodeField(const MerchantPromoCodeField&) = delete; + MerchantPromoCodeField& operator=(const MerchantPromoCodeField&) = delete; + + protected: + void AddClassifications(FieldCandidatesMap* field_candidates) const override; + + private: + FRIEND_TEST_ALL_PREFIXES(MerchantPromoCodeFieldTest, ParsePromoCode); + FRIEND_TEST_ALL_PREFIXES(MerchantPromoCodeFieldTest, ParseCouponCode); + FRIEND_TEST_ALL_PREFIXES(MerchantPromoCodeFieldTest, ParseGiftCode); + FRIEND_TEST_ALL_PREFIXES(MerchantPromoCodeFieldTest, ParseNonPromoCode); + FRIEND_TEST_ALL_PREFIXES(MerchantPromoCodeFieldTest, ParsePromoCodeFlagOff); + + const AutofillField* field_; +}; + +} // namespace autofill + +#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_PARSING_MERCHANT_PROMO_CODE_FIELD_H_ diff --git a/chromium/components/autofill/core/browser/form_parsing/merchant_promo_code_field_unittest.cc b/chromium/components/autofill/core/browser/form_parsing/merchant_promo_code_field_unittest.cc new file mode 100644 index 00000000000..fc90673eb0d --- /dev/null +++ b/chromium/components/autofill/core/browser/form_parsing/merchant_promo_code_field_unittest.cc @@ -0,0 +1,81 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/autofill/core/browser/form_parsing/merchant_promo_code_field.h" + +#include "base/test/scoped_feature_list.h" +#include "components/autofill/core/browser/form_parsing/parsing_test_utils.h" +#include "components/autofill/core/common/autofill_payments_features.h" + +using base::ASCIIToUTF16; + +namespace autofill { + +class MerchantPromoCodeFieldTest : public FormFieldTest { + public: + MerchantPromoCodeFieldTest() = default; + MerchantPromoCodeFieldTest(const MerchantPromoCodeFieldTest&) = delete; + MerchantPromoCodeFieldTest& operator=(const MerchantPromoCodeFieldTest&) = + delete; + + protected: + std::unique_ptr<FormField> Parse( + AutofillScanner* scanner, + const LanguageCode& page_language = LanguageCode("en")) override { + return MerchantPromoCodeField::Parse(scanner, page_language, nullptr); + } +}; + +TEST_F(MerchantPromoCodeFieldTest, ParsePromoCode) { + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitAndEnableFeature( + features::kAutofillParseMerchantPromoCodeFields); + AddTextFormFieldData("Enter promo code here", "promoCodeField", + MERCHANT_PROMO_CODE); + + ClassifyAndVerify(ParseResult::PARSED); +} + +TEST_F(MerchantPromoCodeFieldTest, ParseCouponCode) { + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitAndEnableFeature( + features::kAutofillParseMerchantPromoCodeFields); + AddTextFormFieldData("Enter coupon code", "couponCodeField", + MERCHANT_PROMO_CODE); + + ClassifyAndVerify(ParseResult::PARSED); +} + +TEST_F(MerchantPromoCodeFieldTest, ParseGiftCode) { + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitAndEnableFeature( + features::kAutofillParseMerchantPromoCodeFields); + AddTextFormFieldData("Check out with gift code", "giftCodeField", + MERCHANT_PROMO_CODE); + + ClassifyAndVerify(ParseResult::PARSED); +} + +TEST_F(MerchantPromoCodeFieldTest, ParseNonPromoCode) { + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitAndEnableFeature( + features::kAutofillParseMerchantPromoCodeFields); + // Regex relies on "promo/coupon/gift" + "code" together. + AddTextFormFieldData("Field for gift card or promo details", "otherField", + UNKNOWN_TYPE); + + ClassifyAndVerify(ParseResult::NOT_PARSED); +} + +TEST_F(MerchantPromoCodeFieldTest, ParsePromoCodeFlagOff) { + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitAndDisableFeature( + features::kAutofillParseMerchantPromoCodeFields); + AddTextFormFieldData("Enter promo code here", "promoCodeField", + MERCHANT_PROMO_CODE); + + ClassifyAndVerify(ParseResult::NOT_PARSED); +} + +} // namespace autofill diff --git a/chromium/components/autofill/core/browser/form_parsing/name_field.cc b/chromium/components/autofill/core/browser/form_parsing/name_field.cc index 1e3bf74d083..f52c936aa3f 100644 --- a/chromium/components/autofill/core/browser/form_parsing/name_field.cc +++ b/chromium/components/autofill/core/browser/form_parsing/name_field.cc @@ -9,14 +9,11 @@ #include "base/feature_list.h" #include "base/macros.h" #include "base/strings/string_util.h" -#include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_regex_constants.h" #include "components/autofill/core/browser/autofill_type.h" #include "components/autofill/core/browser/form_parsing/autofill_scanner.h" #include "components/autofill/core/common/autofill_features.h" -using base::UTF8ToUTF16; - namespace autofill { namespace { @@ -137,11 +134,10 @@ std::unique_ptr<FullNameField> FullNameField::Parse( PatternProvider::GetInstance().GetMatchPatterns("ADDRESS_NAME_IGNORED", page_language); bool should_ignore = - ParseField(scanner, UTF8ToUTF16(kNameIgnoredRe), name_ignored_patterns, - nullptr, {log_manager, "kNameIgnoredRe"}) || - ParseField(scanner, UTF8ToUTF16(kAddressNameIgnoredRe), - address_name_ignored_patterns, nullptr, - {log_manager, "kAddressNameIgnoredRe"}); + ParseField(scanner, kNameIgnoredRe, name_ignored_patterns, nullptr, + {log_manager, "kNameIgnoredRe"}) || + ParseField(scanner, kAddressNameIgnoredRe, address_name_ignored_patterns, + nullptr, {log_manager, "kAddressNameIgnoredRe"}); scanner->Rewind(); if (should_ignore) return nullptr; @@ -154,7 +150,7 @@ std::unique_ptr<FullNameField> FullNameField::Parse( const std::vector<MatchingPattern>& name_patterns = PatternProvider::GetInstance().GetMatchPatterns("FULL_NAME", page_language); - if (ParseField(scanner, UTF8ToUTF16(kNameRe), name_patterns, &field, + if (ParseField(scanner, kNameRe, name_patterns, &field, {log_manager, "kNameRe"})) return std::make_unique<FullNameField>(field); @@ -212,9 +208,9 @@ FirstTwoLastNamesField::ParseComponentNames(AutofillScanner* scanner, while (!scanner->IsEnd()) { // Skip over address label fields, which can have misleading names // e.g. "title" or "name". - if (ParseFieldSpecifics(scanner, UTF8ToUTF16(kAddressNameIgnoredRe), - MATCH_DEFAULT, address_name_ignored_patterns, - nullptr, {log_manager, "kAddressNameIgnoredRe"})) { + if (ParseFieldSpecifics(scanner, kAddressNameIgnoredRe, MATCH_DEFAULT, + address_name_ignored_patterns, nullptr, + {log_manager, "kAddressNameIgnoredRe"})) { continue; } @@ -224,14 +220,14 @@ FirstTwoLastNamesField::ParseComponentNames(AutofillScanner* scanner, // TODO(crbug.com/1098943): Remove check once feature is launched or // removed. if (!v->honorific_prefix_ && - ParseField(scanner, UTF8ToUTF16(kHonorificPrefixRe), - honorific_prefix_patterns, &v->honorific_prefix_, + ParseField(scanner, kHonorificPrefixRe, honorific_prefix_patterns, + &v->honorific_prefix_, {log_manager, "kHonorificPrefixRe"})) { continue; } // Skip over any unrelated fields, e.g. "username" or "nickname". - if (ParseFieldSpecifics(scanner, UTF8ToUTF16(kNameIgnoredRe), + if (ParseFieldSpecifics(scanner, kNameIgnoredRe, MATCH_DEFAULT | MATCH_SELECT | MATCH_SEARCH, name_ignored_patterns, nullptr, {log_manager, "kNameIgnoredRe"})) { @@ -239,27 +235,26 @@ FirstTwoLastNamesField::ParseComponentNames(AutofillScanner* scanner, } if (!v->first_name_ && - ParseField(scanner, UTF8ToUTF16(kFirstNameRe), first_name_patterns, - &v->first_name_, {log_manager, "kFirstNameRe"})) { + ParseField(scanner, kFirstNameRe, first_name_patterns, &v->first_name_, + {log_manager, "kFirstNameRe"})) { continue; } if (!v->middle_name_ && - ParseField(scanner, UTF8ToUTF16(kMiddleNameRe), middle_name_patterns, + ParseField(scanner, kMiddleNameRe, middle_name_patterns, &v->middle_name_, {log_manager, "kMiddleNameRe"})) { continue; } if (!v->first_last_name_ && - ParseField(scanner, UTF8ToUTF16(kNameLastFirstRe), - first_last_name_patterns, &v->first_last_name_, - {log_manager, "kNameLastFirstRe"})) { + ParseField(scanner, kNameLastFirstRe, first_last_name_patterns, + &v->first_last_name_, {log_manager, "kNameLastFirstRe"})) { continue; } if (!v->second_last_name_ && - ParseField(scanner, UTF8ToUTF16(kNameLastSecondRe), - second_last_name_patterns, &v->second_last_name_, + ParseField(scanner, kNameLastSecondRe, second_last_name_patterns, + &v->second_last_name_, {log_manager, "kNameLastSecondtRe"})) { continue; } @@ -305,7 +300,7 @@ std::unique_ptr<FirstLastNameField> FirstLastNameField::ParseSpecificName( PatternProvider::GetInstance().GetMatchPatterns("NAME_SPECIFIC", page_language); - if (ParseField(scanner, UTF8ToUTF16(kNameSpecificRe), name_specific_patterns, + if (ParseField(scanner, kNameSpecificRe, name_specific_patterns, &v->first_name_, {log_manager, "kNameSpecificRe"}) && ParseEmptyLabel(scanner, &next)) { if (ParseEmptyLabel(scanner, &v->last_name_)) { @@ -369,9 +364,9 @@ std::unique_ptr<FirstLastNameField> FirstLastNameField::ParseComponentNames( while (!scanner->IsEnd()) { // Skip over address label fields, which can have misleading names // e.g. "title" or "name". - if (ParseFieldSpecifics(scanner, UTF8ToUTF16(kAddressNameIgnoredRe), - MATCH_DEFAULT, address_name_ignored_patterns, - nullptr, {log_manager, "kAddressNameIgnoredRe"})) { + if (ParseFieldSpecifics(scanner, kAddressNameIgnoredRe, MATCH_DEFAULT, + address_name_ignored_patterns, nullptr, + {log_manager, "kAddressNameIgnoredRe"})) { continue; } @@ -383,15 +378,15 @@ std::unique_ptr<FirstLastNameField> FirstLastNameField::ParseComponentNames( if (base::FeatureList::IsEnabled( features::kAutofillEnableSupportForMoreStructureInNames)) { if (!v->honorific_prefix_ && - ParseField(scanner, UTF8ToUTF16(kHonorificPrefixRe), - honorific_prefix_patterns, &v->honorific_prefix_, + ParseField(scanner, kHonorificPrefixRe, honorific_prefix_patterns, + &v->honorific_prefix_, {log_manager, "kHonorificPrefixRe"})) { continue; } } // Skip over any unrelated name fields, e.g. "username" or "nickname". - if (ParseFieldSpecifics(scanner, UTF8ToUTF16(kNameIgnoredRe), + if (ParseFieldSpecifics(scanner, kNameIgnoredRe, MATCH_DEFAULT | MATCH_SELECT | MATCH_SEARCH, name_ignored_patterns, nullptr, {log_manager, "kNameIgnoredRe"})) { @@ -399,8 +394,8 @@ std::unique_ptr<FirstLastNameField> FirstLastNameField::ParseComponentNames( } if (!v->first_name_ && - ParseField(scanner, UTF8ToUTF16(kFirstNameRe), first_name_patterns, - &v->first_name_, {log_manager, "kFirstNameRe"})) { + ParseField(scanner, kFirstNameRe, first_name_patterns, &v->first_name_, + {log_manager, "kFirstNameRe"})) { continue; } @@ -410,22 +405,21 @@ std::unique_ptr<FirstLastNameField> FirstLastNameField::ParseComponentNames( // "txtmiddlename"); such a field probably actually represents a // middle initial. if (!v->middle_name_ && - ParseField(scanner, UTF8ToUTF16(kMiddleInitialRe), - middle_name_initial_patterns, &v->middle_name_, - {log_manager, "kMiddleInitialRe"})) { + ParseField(scanner, kMiddleInitialRe, middle_name_initial_patterns, + &v->middle_name_, {log_manager, "kMiddleInitialRe"})) { v->middle_initial_ = true; continue; } if (!v->middle_name_ && - ParseField(scanner, UTF8ToUTF16(kMiddleNameRe), middle_name_patterns, + ParseField(scanner, kMiddleNameRe, middle_name_patterns, &v->middle_name_, {log_manager, "kMiddleNameRe"})) { continue; } if (!v->last_name_ && - ParseField(scanner, UTF8ToUTF16(kLastNameRe), last_name_patterns, - &v->last_name_, {log_manager, "kLastNameRe"})) { + ParseField(scanner, kLastNameRe, last_name_patterns, &v->last_name_, + {log_manager, "kLastNameRe"})) { continue; } diff --git a/chromium/components/autofill/core/browser/form_parsing/name_field_unittest.cc b/chromium/components/autofill/core/browser/form_parsing/name_field_unittest.cc index af7fdf56732..c886303f4ab 100644 --- a/chromium/components/autofill/core/browser/form_parsing/name_field_unittest.cc +++ b/chromium/components/autofill/core/browser/form_parsing/name_field_unittest.cc @@ -7,7 +7,6 @@ #include <memory> #include <vector> -#include "base/strings/utf_string_conversions.h" #include "base/test/scoped_feature_list.h" #include "components/autofill/core/browser/autofill_regex_constants.h" #include "components/autofill/core/browser/autofill_regexes.h" @@ -15,8 +14,6 @@ #include "components/autofill/core/common/autofill_features.h" #include "components/autofill/core/common/form_field_data.h" -using base::ASCIIToUTF16; - namespace autofill { class NameFieldTest : public FormFieldTest { @@ -166,38 +163,34 @@ TEST_F(NameFieldTest, MiddleInitialAtEnd) { // Test the coverage of all found strings for first and second last names. TEST_F(NameFieldTest, HispanicLastNameRegexConverage) { - std::vector<std::string> first_last_name_strings = { - "Primer apellido", "apellidoPaterno", "apellido_paterno", - "first_surname", "first surname", "apellido1"}; + std::vector<std::u16string> first_last_name_strings = { + u"Primer apellido", u"apellidoPaterno", u"apellido_paterno", + u"first_surname", u"first surname", u"apellido1"}; - std::vector<std::string> second_last_name_strings = { - "Segundo apellido", "apellidoMaterno", "apellido_materno", - "apellido2", "second_surname", "second surname", + std::vector<std::u16string> second_last_name_strings = { + u"Segundo apellido", u"apellidoMaterno", u"apellido_materno", + u"apellido2", u"second_surname", u"second surname", }; - std::vector<std::string> neither_first_or_second_last_name_strings = { - "apellido", - "apellidos", + std::vector<std::u16string> neither_first_or_second_last_name_strings = { + u"apellido", + u"apellidos", }; for (const auto& string : first_last_name_strings) { SCOPED_TRACE(string); - EXPECT_TRUE(MatchesPattern(ASCIIToUTF16(string), - ASCIIToUTF16(kNameLastFirstRe), nullptr)); + EXPECT_TRUE(MatchesPattern(string, kNameLastFirstRe, nullptr)); } for (const auto& string : second_last_name_strings) { SCOPED_TRACE(string); - EXPECT_TRUE(MatchesPattern(ASCIIToUTF16(string), - ASCIIToUTF16(kNameLastSecondRe), nullptr)); + EXPECT_TRUE(MatchesPattern(string, kNameLastSecondRe, nullptr)); } for (const auto& string : neither_first_or_second_last_name_strings) { SCOPED_TRACE(string); - EXPECT_FALSE(MatchesPattern(ASCIIToUTF16(string), - ASCIIToUTF16(kNameLastFirstRe), nullptr)); - EXPECT_FALSE(MatchesPattern(ASCIIToUTF16(string), - ASCIIToUTF16(kNameLastSecondRe), nullptr)); + EXPECT_FALSE(MatchesPattern(string, kNameLastFirstRe, nullptr)); + EXPECT_FALSE(MatchesPattern(string, kNameLastSecondRe, nullptr)); } } diff --git a/chromium/components/autofill/core/browser/form_parsing/parsing_test_utils.cc b/chromium/components/autofill/core/browser/form_parsing/parsing_test_utils.cc index 93fc4be0625..1364df0f270 100644 --- a/chromium/components/autofill/core/browser/form_parsing/parsing_test_utils.cc +++ b/chromium/components/autofill/core/browser/form_parsing/parsing_test_utils.cc @@ -31,7 +31,7 @@ void FormFieldTestBase::AddFormFieldDataWithLength( field_data.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field_data)); expected_classifications_.insert( - std::make_pair(field_data.unique_renderer_id, expected_type)); + std::make_pair(field_data.global_id(), expected_type)); } void FormFieldTestBase::AddSelectOneFormFieldData( @@ -92,29 +92,29 @@ void FormFieldTestBase::ClassifyAndVerify(ParseResult parse_result, } void FormFieldTestBase::TestClassificationExpectations() { - for (const std::pair<FieldRendererId, ServerFieldType> it : + for (const std::pair<FieldGlobalId, ServerFieldType> p : expected_classifications_) { - if (it.second != UNKNOWN_TYPE) { + if (p.second != UNKNOWN_TYPE) { SCOPED_TRACE(testing::Message() << "Found type " << AutofillType::ServerFieldTypeToString( - field_candidates_map_[it.first].BestHeuristicType()) + field_candidates_map_[p.first].BestHeuristicType()) << ", expected type " - << AutofillType::ServerFieldTypeToString(it.second)); + << AutofillType::ServerFieldTypeToString(p.second)); - ASSERT_TRUE(field_candidates_map_.find(it.first) != + ASSERT_TRUE(field_candidates_map_.find(p.first) != field_candidates_map_.end()); - EXPECT_EQ(it.second, field_candidates_map_[it.first].BestHeuristicType()); + EXPECT_EQ(p.second, field_candidates_map_[p.first].BestHeuristicType()); } else { SCOPED_TRACE( testing::Message() << "Expected type UNKNOWN_TYPE but got " << AutofillType::ServerFieldTypeToString( - field_candidates_map_.find(it.first) != + field_candidates_map_.find(p.first) != field_candidates_map_.end() - ? field_candidates_map_[it.first].BestHeuristicType() + ? field_candidates_map_[p.first].BestHeuristicType() : UNKNOWN_TYPE)); - EXPECT_EQ(field_candidates_map_.find(it.first), + EXPECT_EQ(field_candidates_map_.find(p.first), field_candidates_map_.end()); } } diff --git a/chromium/components/autofill/core/browser/form_parsing/parsing_test_utils.h b/chromium/components/autofill/core/browser/form_parsing/parsing_test_utils.h index df5d271565f..bf056c6138d 100644 --- a/chromium/components/autofill/core/browser/form_parsing/parsing_test_utils.h +++ b/chromium/components/autofill/core/browser/form_parsing/parsing_test_utils.h @@ -6,10 +6,10 @@ #define COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_PARSING_PARSING_TEST_UTILS_H_ #include <memory> +#include <string> #include <vector> #include "base/macros.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_field.h" #include "components/autofill/core/browser/field_types.h" @@ -93,7 +93,7 @@ class FormFieldTestBase { std::vector<std::unique_ptr<AutofillField>> list_; std::unique_ptr<FormField> field_; FieldCandidatesMap field_candidates_map_; - std::map<FieldRendererId, ServerFieldType> expected_classifications_; + std::map<FieldGlobalId, ServerFieldType> expected_classifications_; private: uint64_t id_counter_ = 0; diff --git a/chromium/components/autofill/core/browser/form_parsing/phone_field.cc b/chromium/components/autofill/core/browser/form_parsing/phone_field.cc index 451ca2c75d6..ce8f5b103f2 100644 --- a/chromium/components/autofill/core/browser/form_parsing/phone_field.cc +++ b/chromium/components/autofill/core/browser/form_parsing/phone_field.cc @@ -7,14 +7,14 @@ #include <string.h> #include <memory> +#include <string> #include <utility> #include "base/check.h" #include "base/notreached.h" #include "base/stl_util.h" -#include "base/strings/string16.h" +#include "base/strings/strcat.h" #include "base/strings/string_util.h" -#include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_field.h" #include "components/autofill/core/browser/autofill_regex_constants.h" #include "components/autofill/core/browser/autofill_regexes.h" @@ -45,11 +45,8 @@ constexpr int kMinCandidatePercentageForCountryCode = 90; constexpr int kHeuristicThresholdForCountryCode = 10; // This string includes all area code separators, including NoText. -std::string GetAreaRegex() { - std::string area_code = kAreaCodeRe; - area_code.append("|"); // Regexp separator. - area_code.append(kAreaCodeNotextRe); - return area_code; +std::u16string GetAreaRegex() { + return base::StrCat({kAreaCodeRe, u"|", kAreaCodeNotextRe}); } } // namespace @@ -183,8 +180,7 @@ bool PhoneField::LikelyAugmentedPhoneCountryCode( int total_positive_options = 0; for (const auto& option : field->option_contents) { - if (MatchesPattern(option, - base::ASCIIToUTF16(kAugmentedPhoneCountryCodeRe))) + if (MatchesPattern(option, kAugmentedPhoneCountryCodeRe)) total_positive_options++; } @@ -365,7 +361,7 @@ PhoneField::PhoneField() { } // static -std::string PhoneField::GetRegExp(RegexType regex_id) { +std::u16string PhoneField::GetRegExp(RegexType regex_id) { switch (regex_id) { case REGEX_COUNTRY: return kCountryCodeRe; @@ -389,7 +385,7 @@ std::string PhoneField::GetRegExp(RegexType regex_id) { NOTREACHED(); break; } - return std::string(); + return std::u16string(); } // static @@ -451,7 +447,7 @@ std::string PhoneField::GetJSONFieldType(RegexType phonetype_id) { // static bool PhoneField::ParsePhoneField(AutofillScanner* scanner, - const std::string& regex, + base::StringPiece16 regex, AutofillField** field, const RegExLogging& logging, const bool is_country_code_field, @@ -466,8 +462,8 @@ bool PhoneField::ParsePhoneField(AutofillScanner* scanner, PatternProvider::GetInstance().GetMatchPatterns(json_field_type, page_language); - return ParseFieldSpecifics(scanner, base::UTF8ToUTF16(regex), match_type, - patterns, field, logging); + return ParseFieldSpecifics(scanner, regex, match_type, patterns, field, + logging); } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/form_parsing/phone_field.h b/chromium/components/autofill/core/browser/form_parsing/phone_field.h index 1b3bf5d7fde..6408914d30c 100644 --- a/chromium/components/autofill/core/browser/form_parsing/phone_field.h +++ b/chromium/components/autofill/core/browser/form_parsing/phone_field.h @@ -14,6 +14,7 @@ #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/macros.h" +#include "base/strings/string_piece.h" #include "components/autofill/core/browser/autofill_type.h" #include "components/autofill/core/browser/data_model/phone_number.h" #include "components/autofill/core/browser/form_parsing/form_field.h" @@ -92,7 +93,7 @@ class PhoneField : public FormField { PhoneField(); // Returns the regular expression string corresponding to |regex_id| - static std::string GetRegExp(RegexType regex_id); + static std::u16string GetRegExp(RegexType regex_id); // Returns the constant name of the regex corresponding to |regex_id|. // This is useful for logging purposes. @@ -104,7 +105,7 @@ class PhoneField : public FormField { // Convenient wrapper for ParseFieldSpecifics(). static bool ParsePhoneField(AutofillScanner* scanner, - const std::string& regex, + base::StringPiece16 regex, AutofillField** field, const RegExLogging& logging, const bool is_country_code_field, diff --git a/chromium/components/autofill/core/browser/form_parsing/phone_field_unittest.cc b/chromium/components/autofill/core/browser/form_parsing/phone_field_unittest.cc index 1257ba01c13..ac079ce24ca 100644 --- a/chromium/components/autofill/core/browser/form_parsing/phone_field_unittest.cc +++ b/chromium/components/autofill/core/browser/form_parsing/phone_field_unittest.cc @@ -57,8 +57,7 @@ class PhoneFieldTest : public testing::Test { field_candidates_map_.clear(); } - void CheckField(const FieldRendererId id, - ServerFieldType expected_type) const { + void CheckField(const FieldGlobalId id, ServerFieldType expected_type) const { auto it = field_candidates_map_.find(id); ASSERT_TRUE(it != field_candidates_map_.end()); EXPECT_EQ(expected_type, it->second.BestHeuristicType()); @@ -73,7 +72,7 @@ class PhoneFieldTest : public testing::Test { field->name = ASCIIToUTF16(name); field->form_control_type = "select-one"; - std::vector<base::string16> contents16; + std::vector<std::u16string> contents16; for (auto* const element : contents) contents16.push_back(base::UTF8ToUTF16(element)); @@ -112,11 +111,11 @@ TEST_F(PhoneFieldTest, ParseOneLinePhone) { Clear(); field.form_control_type = field_type; - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("phone"); + field.label = u"Phone"; + field.name = u"phone"; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId phone1 = list_.back()->unique_renderer_id; + FieldGlobalId phone1 = list_.back()->global_id(); AutofillScanner scanner(list_); field_ = Parse(&scanner); @@ -133,17 +132,17 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhone) { Clear(); field.form_control_type = field_type; - field.label = ASCIIToUTF16("Area Code"); - field.name = ASCIIToUTF16("area code"); + field.label = u"Area Code"; + field.name = u"area code"; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId areacode1 = list_.back()->unique_renderer_id; + FieldGlobalId areacode1 = list_.back()->global_id(); - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("phone"); + field.label = u"Phone"; + field.name = u"phone"; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId phone2 = list_.back()->unique_renderer_id; + FieldGlobalId phone2 = list_.back()->global_id(); AutofillScanner scanner(list_); field_ = Parse(&scanner); @@ -166,33 +165,33 @@ TEST_F(PhoneFieldTest, ThreePartPhoneNumber) { Clear(); field.form_control_type = field_type; - field.label = ASCIIToUTF16("Phone:"); - field.name = ASCIIToUTF16("dayphone1"); + field.label = u"Phone:"; + field.name = u"dayphone1"; field.max_length = 0; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId areacode1 = list_.back()->unique_renderer_id; + FieldGlobalId areacode1 = list_.back()->global_id(); - field.label = ASCIIToUTF16("-"); - field.name = ASCIIToUTF16("dayphone2"); + field.label = u"-"; + field.name = u"dayphone2"; field.max_length = 3; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId prefix2 = list_.back()->unique_renderer_id; + FieldGlobalId prefix2 = list_.back()->global_id(); - field.label = ASCIIToUTF16("-"); - field.name = ASCIIToUTF16("dayphone3"); + field.label = u"-"; + field.name = u"dayphone3"; field.max_length = 4; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId suffix3 = list_.back()->unique_renderer_id; + FieldGlobalId suffix3 = list_.back()->global_id(); - field.label = ASCIIToUTF16("ext.:"); - field.name = ASCIIToUTF16("dayphone4"); + field.label = u"ext.:"; + field.name = u"dayphone4"; field.max_length = 0; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId ext4 = list_.back()->unique_renderer_id; + FieldGlobalId ext4 = list_.back()->global_id(); AutofillScanner scanner(list_); field_ = Parse(&scanner); @@ -215,23 +214,23 @@ TEST_F(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix) { Clear(); field.form_control_type = field_type; - field.label = ASCIIToUTF16("Phone:"); - field.name = ASCIIToUTF16("area"); + field.label = u"Phone:"; + field.name = u"area"; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId areacode1 = list_.back()->unique_renderer_id; + FieldGlobalId areacode1 = list_.back()->global_id(); - field.label = base::string16(); - field.name = ASCIIToUTF16("prefix"); + field.label = std::u16string(); + field.name = u"prefix"; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId prefix2 = list_.back()->unique_renderer_id; + FieldGlobalId prefix2 = list_.back()->global_id(); - field.label = base::string16(); - field.name = ASCIIToUTF16("suffix"); + field.label = std::u16string(); + field.name = u"suffix"; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId suffix3 = list_.back()->unique_renderer_id; + FieldGlobalId suffix3 = list_.back()->global_id(); AutofillScanner scanner(list_); field_ = Parse(&scanner); @@ -250,26 +249,26 @@ TEST_F(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix2) { Clear(); field.form_control_type = field_type; - field.label = ASCIIToUTF16("("); - field.name = ASCIIToUTF16("phone1"); + field.label = u"("; + field.name = u"phone1"; field.max_length = 3; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId phone1 = list_.back()->unique_renderer_id; + FieldGlobalId phone1 = list_.back()->global_id(); - field.label = ASCIIToUTF16(")"); - field.name = ASCIIToUTF16("phone2"); + field.label = u")"; + field.name = u"phone2"; field.max_length = 3; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId phone2 = list_.back()->unique_renderer_id; + FieldGlobalId phone2 = list_.back()->global_id(); - field.label = base::string16(); - field.name = ASCIIToUTF16("phone3"); + field.label = std::u16string(); + field.name = u"phone3"; field.max_length = 4; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId phone3 = list_.back()->unique_renderer_id; + FieldGlobalId phone3 = list_.back()->global_id(); AutofillScanner scanner(list_); field_ = Parse(&scanner); @@ -290,19 +289,19 @@ TEST_F(PhoneFieldTest, CountryAndCityAndPhoneNumber) { Clear(); field.form_control_type = field_type; - field.label = ASCIIToUTF16("Phone Number"); - field.name = ASCIIToUTF16("CountryCode"); + field.label = u"Phone Number"; + field.name = u"CountryCode"; field.max_length = 3; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId country = list_.back()->unique_renderer_id; + FieldGlobalId country = list_.back()->global_id(); - field.label = ASCIIToUTF16("Phone Number"); - field.name = ASCIIToUTF16("PhoneNumber"); + field.label = u"Phone Number"; + field.name = u"PhoneNumber"; field.max_length = 10; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId phone = list_.back()->unique_renderer_id; + FieldGlobalId phone = list_.back()->global_id(); AutofillScanner scanner(list_); field_ = Parse(&scanner); @@ -322,21 +321,21 @@ TEST_F(PhoneFieldTest, CountryAndCityAndPhoneNumberWithLongerMaxLength) { Clear(); field.form_control_type = field_type; - field.label = ASCIIToUTF16("Phone Number"); - field.name = ASCIIToUTF16("CountryCode"); + field.label = u"Phone Number"; + field.name = u"CountryCode"; field.max_length = 3; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId country = list_.back()->unique_renderer_id; + FieldGlobalId country = list_.back()->global_id(); // Verify if websites expect a longer formatted number like: // (514)-123-1234, autofill is able to classify correctly. - field.label = ASCIIToUTF16("Phone Number"); - field.name = ASCIIToUTF16("PhoneNumber"); + field.label = u"Phone Number"; + field.name = u"PhoneNumber"; field.max_length = 14; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId phone = list_.back()->unique_renderer_id; + FieldGlobalId phone = list_.back()->global_id(); AutofillScanner scanner(list_); field_ = Parse(&scanner); @@ -352,27 +351,27 @@ TEST_F(PhoneFieldTest, CountryAndCityAndPhoneNumberWithLongerMaxLength) { TEST_F(PhoneFieldTest, CountryCodeIsSelectElement) { FormFieldData field; - field.label = ASCIIToUTF16("Phone Country Code"); - field.name = ASCIIToUTF16("ccode"); + field.label = u"Phone Country Code"; + field.name = u"ccode"; field.form_control_type = "select-one"; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId country_code = list_.back()->unique_renderer_id; + FieldGlobalId country_code = list_.back()->global_id(); - field.label = ASCIIToUTF16("Phone City Code"); - field.name = ASCIIToUTF16("areacode"); + field.label = u"Phone City Code"; + field.name = u"areacode"; field.form_control_type = "text"; field.max_length = 3; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId cityCode = list_.back()->unique_renderer_id; + FieldGlobalId cityCode = list_.back()->global_id(); - field.label = ASCIIToUTF16("Phone Number"); - field.name = ASCIIToUTF16("phonenumber"); + field.label = u"Phone Number"; + field.name = u"phonenumber"; field.max_length = 0; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId phoneNumber = list_.back()->unique_renderer_id; + FieldGlobalId phoneNumber = list_.back()->global_id(); AutofillScanner scanner(list_); field_ = Parse(&scanner); @@ -400,22 +399,22 @@ TEST_F(PhoneFieldTest, CountryCodeWithOptions) { CreateTestSelectField("PC", "PC", augmented_field_options_list, &field); field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId country_code = list_.back()->unique_renderer_id; + FieldGlobalId country_code = list_.back()->global_id(); - field.label = ASCIIToUTF16("Phone City Code"); - field.name = ASCIIToUTF16("areacode"); + field.label = u"Phone City Code"; + field.name = u"areacode"; field.form_control_type = "text"; field.max_length = 3; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId cityCode = list_.back()->unique_renderer_id; + FieldGlobalId cityCode = list_.back()->global_id(); - field.label = ASCIIToUTF16("Phone Number"); - field.name = ASCIIToUTF16("phonenumber"); + field.label = u"Phone Number"; + field.name = u"phonenumber"; field.max_length = 0; field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId phoneNumber = list_.back()->unique_renderer_id; + FieldGlobalId phoneNumber = list_.back()->global_id(); AutofillScanner scanner(list_); field_ = Parse(&scanner); @@ -496,10 +495,10 @@ TEST_F(PhoneFieldTest, IsPhoneCountryCodeField) { CreateTestSelectField("PC", "PC", options_list, &field); field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - FieldRendererId country_code = list_.back()->unique_renderer_id; + FieldGlobalId country_code = list_.back()->global_id(); - field.label = ASCIIToUTF16("Phone Number"); - field.name = ASCIIToUTF16("phonenumber"); + field.label = u"Phone Number"; + field.name = u"phonenumber"; field.max_length = 14; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); @@ -536,8 +535,8 @@ TEST_F(PhoneFieldTest, IsMonthField) { field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - field.label = ASCIIToUTF16("Phone Number"); - field.name = ASCIIToUTF16("phonenumber"); + field.label = u"Phone Number"; + field.name = u"phonenumber"; field.max_length = 14; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); @@ -602,8 +601,8 @@ TEST_F(PhoneFieldTest, IsDayField) { field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - field.label = ASCIIToUTF16("Phone Number"); - field.name = ASCIIToUTF16("phonenumber"); + field.label = u"Phone Number"; + field.name = u"phonenumber"; field.max_length = 14; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); @@ -654,8 +653,8 @@ TEST_F(PhoneFieldTest, IsYearField) { field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - field.label = ASCIIToUTF16("Phone Number"); - field.name = ASCIIToUTF16("phonenumber"); + field.label = u"Phone Number"; + field.name = u"phonenumber"; field.max_length = 14; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); @@ -692,8 +691,8 @@ TEST_F(PhoneFieldTest, IsTimeZoneField) { field.unique_renderer_id = MakeFieldRendererId(); list_.push_back(std::make_unique<AutofillField>(field)); - field.label = ASCIIToUTF16("Phone Number"); - field.name = ASCIIToUTF16("phonenumber"); + field.label = u"Phone Number"; + field.name = u"phonenumber"; field.max_length = 14; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); diff --git a/chromium/components/autofill/core/browser/form_parsing/price_field.cc b/chromium/components/autofill/core/browser/form_parsing/price_field.cc index bc1fed93b86..84704eb7c45 100644 --- a/chromium/components/autofill/core/browser/form_parsing/price_field.cc +++ b/chromium/components/autofill/core/browser/form_parsing/price_field.cc @@ -4,7 +4,6 @@ #include "components/autofill/core/browser/form_parsing/price_field.h" -#include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_field.h" #include "components/autofill/core/browser/autofill_regex_constants.h" #include "components/autofill/core/browser/form_parsing/autofill_scanner.h" @@ -19,10 +18,10 @@ std::unique_ptr<FormField> PriceField::Parse(AutofillScanner* scanner, const std::vector<MatchingPattern>& price_patterns = PatternProvider::GetInstance().GetMatchPatterns("PRICE", page_language); - if (ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kPriceRe), + if (ParseFieldSpecifics(scanner, kPriceRe, MATCH_DEFAULT | MATCH_NUMBER | MATCH_SELECT | MATCH_TEXT_AREA | MATCH_SEARCH, - price_patterns, &field, {log_manager, kPriceRe})) { + price_patterns, &field, {log_manager, "kPriceRe"})) { return std::make_unique<PriceField>(field); } diff --git a/chromium/components/autofill/core/browser/form_parsing/search_field.cc b/chromium/components/autofill/core/browser/form_parsing/search_field.cc index 7ed0724daa4..00ac6dd663e 100644 --- a/chromium/components/autofill/core/browser/form_parsing/search_field.cc +++ b/chromium/components/autofill/core/browser/form_parsing/search_field.cc @@ -4,7 +4,6 @@ #include "components/autofill/core/browser/form_parsing/search_field.h" -#include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_field.h" #include "components/autofill/core/browser/autofill_regex_constants.h" #include "components/autofill/core/browser/form_parsing/autofill_scanner.h" @@ -19,7 +18,7 @@ std::unique_ptr<FormField> SearchField::Parse(AutofillScanner* scanner, auto& patterns = PatternProvider::GetInstance().GetMatchPatterns( SEARCH_TERM, page_language); - if (ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kSearchTermRe), + if (ParseFieldSpecifics(scanner, kSearchTermRe, MATCH_DEFAULT | MATCH_SEARCH | MATCH_TEXT_AREA, patterns, &field, {log_manager, "kSearchTermRe"})) { return std::make_unique<SearchField>(field); diff --git a/chromium/components/autofill/core/browser/form_parsing/travel_field.cc b/chromium/components/autofill/core/browser/form_parsing/travel_field.cc index 0817d6750f4..b92086e962c 100644 --- a/chromium/components/autofill/core/browser/form_parsing/travel_field.cc +++ b/chromium/components/autofill/core/browser/form_parsing/travel_field.cc @@ -7,7 +7,6 @@ #include <memory> #include <utility> -#include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_regex_constants.h" namespace autofill { @@ -34,16 +33,15 @@ std::unique_ptr<FormField> TravelField::Parse(AutofillScanner* scanner, PatternProvider::GetInstance().GetMatchPatterns("FLIGHT", page_language); auto travel_field = std::make_unique<TravelField>(); - if (ParseField(scanner, base::UTF8ToUTF16(kPassportRe), passport_patterns, + if (ParseField(scanner, kPassportRe, passport_patterns, &travel_field->passport_, {log_manager, "kPassportRe"}) || - ParseField(scanner, base::UTF8ToUTF16(kTravelOriginRe), - travel_origin_patterns, &travel_field->origin_, - {log_manager, "kTravelOriginRe"}) || - ParseField(scanner, base::UTF8ToUTF16(kTravelDestinationRe), - travel_destination_patterns, &travel_field->destination_, + ParseField(scanner, kTravelOriginRe, travel_origin_patterns, + &travel_field->origin_, {log_manager, "kTravelOriginRe"}) || + ParseField(scanner, kTravelDestinationRe, travel_destination_patterns, + &travel_field->destination_, {log_manager, "kTravelDestinationRe"}) || - ParseField(scanner, base::UTF8ToUTF16(kFlightRe), flight_patterns, - &travel_field->flight_, {log_manager, "kFlightRe"})) { + ParseField(scanner, kFlightRe, flight_patterns, &travel_field->flight_, + {log_manager, "kFlightRe"})) { // If any regex matches, then we found a travel field. return std::move(travel_field); } diff --git a/chromium/components/autofill/core/browser/form_processing/label_processing_util.cc b/chromium/components/autofill/core/browser/form_processing/label_processing_util.cc index 50e7e56a1b3..6cfc0008ea9 100644 --- a/chromium/components/autofill/core/browser/form_processing/label_processing_util.cc +++ b/chromium/components/autofill/core/browser/form_processing/label_processing_util.cc @@ -17,7 +17,7 @@ const int kMaxNumberOfFieldsToShareALabel = 3; // The maximum length of a label that can be shared among fields. const int kMaxLengthOfShareableLabel = 40; -base::Optional<std::vector<base::string16>> GetParseableLabels( +base::Optional<std::vector<std::u16string>> GetParseableLabels( const LabelPieces& labels) { // Make a copy of the labels. LabelPieces shared_labels = labels; @@ -65,8 +65,7 @@ base::Optional<std::vector<base::string16>> GetParseableLabels( // Otherwise, try to split the label by single character separators. LabelPieces label_components = base::SplitStringPiece( - label, base::ASCIIToUTF16("/,&-"), base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); + label, u"/,&-", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); // If the number of components does not match, try to split by common // separating words. @@ -98,10 +97,10 @@ base::Optional<std::vector<base::string16>> GetParseableLabels( // Otherwise convert the shared label string pieces into strings for memory // safety. - std::vector<base::string16> result; + std::vector<std::u16string> result; result.reserve(shared_labels.size()); base::ranges::transform(shared_labels, std::back_inserter(result), - [](auto& s) { return base::string16(s); }); + [](auto& s) { return std::u16string(s); }); return base::make_optional(std::move(result)); } diff --git a/chromium/components/autofill/core/browser/form_processing/label_processing_util.h b/chromium/components/autofill/core/browser/form_processing/label_processing_util.h index 31e581a5f32..c79fa295720 100644 --- a/chromium/components/autofill/core/browser/form_processing/label_processing_util.h +++ b/chromium/components/autofill/core/browser/form_processing/label_processing_util.h @@ -12,11 +12,11 @@ namespace autofill { // If parseable labels can be derived from |labels|, a vector of -// |base::string16| is return that is aligned with |labels|. +// |std::u16string| is return that is aligned with |labels|. // Parseable labels can be derived by splitting one label between multiple // adjacent fields. If there aren't any changes to the labels, |base::nullopt| // is returned. -base::Optional<std::vector<base::string16>> GetParseableLabels( +base::Optional<std::vector<std::u16string>> GetParseableLabels( const std::vector<base::StringPiece16>& labels); } // namespace autofill diff --git a/chromium/components/autofill/core/browser/form_processing/label_processing_util_unittest.cc b/chromium/components/autofill/core/browser/form_processing/label_processing_util_unittest.cc index f72bdf6d788..6cd10b21b97 100644 --- a/chromium/components/autofill/core/browser/form_processing/label_processing_util_unittest.cc +++ b/chromium/components/autofill/core/browser/form_processing/label_processing_util_unittest.cc @@ -15,7 +15,7 @@ using base::ASCIIToUTF16; namespace { std::vector<base::StringPiece16> StringsToStringPieces( - const std::vector<base::string16>& strings) { + const std::vector<std::u16string>& strings) { std::vector<base::StringPiece16> string_pieces; for (const auto& s : strings) { string_pieces.emplace_back(base::StringPiece16(s)); @@ -28,88 +28,88 @@ std::vector<base::StringPiece16> StringsToStringPieces( namespace autofill { TEST(LabelProcessingUtil, GetParseableNameStringPieces) { - std::vector<base::string16> labels; - labels.push_back(ASCIIToUTF16("City")); - labels.push_back(ASCIIToUTF16("Street & House Number")); - labels.push_back(ASCIIToUTF16("")); - labels.push_back(ASCIIToUTF16("Zip")); - - auto expectation = base::make_optional(std::vector<base::string16>()); - expectation->push_back(ASCIIToUTF16("City")); - expectation->push_back(ASCIIToUTF16("Street")); - expectation->push_back(ASCIIToUTF16("House Number")); - expectation->push_back(ASCIIToUTF16("Zip")); + std::vector<std::u16string> labels; + labels.push_back(u"City"); + labels.push_back(u"Street & House Number"); + labels.push_back(u""); + labels.push_back(u"Zip"); + + auto expectation = base::make_optional(std::vector<std::u16string>()); + expectation->push_back(u"City"); + expectation->push_back(u"Street"); + expectation->push_back(u"House Number"); + expectation->push_back(u"Zip"); EXPECT_EQ(GetParseableLabels(StringsToStringPieces(labels)), expectation); } TEST(LabelProcessingUtil, GetParseableNameStringPieces_ThreeComponents) { - std::vector<base::string16> labels; - labels.push_back(ASCIIToUTF16("City")); - labels.push_back(ASCIIToUTF16("Street & House Number & Floor")); - labels.push_back(ASCIIToUTF16("")); - labels.push_back(ASCIIToUTF16("")); - labels.push_back(ASCIIToUTF16("Zip")); - - auto expectation = base::make_optional(std::vector<base::string16>()); - expectation->push_back(ASCIIToUTF16("City")); - expectation->push_back(ASCIIToUTF16("Street")); - expectation->push_back(ASCIIToUTF16("House Number")); - expectation->push_back(ASCIIToUTF16("Floor")); - expectation->push_back(ASCIIToUTF16("Zip")); + std::vector<std::u16string> labels; + labels.push_back(u"City"); + labels.push_back(u"Street & House Number & Floor"); + labels.push_back(u""); + labels.push_back(u""); + labels.push_back(u"Zip"); + + auto expectation = base::make_optional(std::vector<std::u16string>()); + expectation->push_back(u"City"); + expectation->push_back(u"Street"); + expectation->push_back(u"House Number"); + expectation->push_back(u"Floor"); + expectation->push_back(u"Zip"); EXPECT_EQ(GetParseableLabels(StringsToStringPieces(labels)), expectation); } TEST(LabelProcessingUtil, GetParseableNameStringPieces_TooManyComponents) { - std::vector<base::string16> labels; - labels.push_back(ASCIIToUTF16("City")); - labels.push_back(ASCIIToUTF16("Street & House Number & Floor & Stairs")); - labels.push_back(ASCIIToUTF16("")); - labels.push_back(ASCIIToUTF16("")); - labels.push_back(ASCIIToUTF16("")); - labels.push_back(ASCIIToUTF16("Zip")); - - base::Optional<std::vector<base::string16>> expectation = base::nullopt; + std::vector<std::u16string> labels; + labels.push_back(u"City"); + labels.push_back(u"Street & House Number & Floor & Stairs"); + labels.push_back(u""); + labels.push_back(u""); + labels.push_back(u""); + labels.push_back(u"Zip"); + + base::Optional<std::vector<std::u16string>> expectation = base::nullopt; ; EXPECT_EQ(GetParseableLabels(StringsToStringPieces(labels)), expectation); } TEST(LabelProcessingUtil, GetParseableNameStringPieces_UnmachtingComponents) { - std::vector<base::string16> labels; - labels.push_back(ASCIIToUTF16("City")); - labels.push_back(ASCIIToUTF16("Street & House Number & Floor")); - labels.push_back(ASCIIToUTF16("")); - labels.push_back(ASCIIToUTF16("Zip")); + std::vector<std::u16string> labels; + labels.push_back(u"City"); + labels.push_back(u"Street & House Number & Floor"); + labels.push_back(u""); + labels.push_back(u"Zip"); - base::Optional<std::vector<base::string16>> expectation = base::nullopt; + base::Optional<std::vector<std::u16string>> expectation = base::nullopt; EXPECT_EQ(GetParseableLabels(StringsToStringPieces(labels)), expectation); } TEST(LabelProcessingUtil, GetParseableNameStringPieces_SplitableLabelAtEnd) { - std::vector<base::string16> labels; - labels.push_back(ASCIIToUTF16("City")); - labels.push_back(ASCIIToUTF16("")); - labels.push_back(ASCIIToUTF16("Zip")); - labels.push_back(ASCIIToUTF16("Street & House Number & Floor")); + std::vector<std::u16string> labels; + labels.push_back(u"City"); + labels.push_back(u""); + labels.push_back(u"Zip"); + labels.push_back(u"Street & House Number & Floor"); - base::Optional<std::vector<base::string16>> expectation = base::nullopt; + base::Optional<std::vector<std::u16string>> expectation = base::nullopt; EXPECT_EQ(GetParseableLabels(StringsToStringPieces(labels)), expectation); } TEST(LabelProcessingUtil, GetParseableNameStringPieces_TooLongLabel) { - std::vector<base::string16> labels; - labels.push_back(ASCIIToUTF16("City")); + std::vector<std::u16string> labels; + labels.push_back(u"City"); labels.push_back( ASCIIToUTF16("Street & House Number with a lot of additional text that " "exceeds 40 characters by far")); - labels.push_back(ASCIIToUTF16("")); - labels.push_back(ASCIIToUTF16("Zip")); + labels.push_back(u""); + labels.push_back(u"Zip"); - base::Optional<std::vector<base::string16>> expectation = base::nullopt; + base::Optional<std::vector<std::u16string>> expectation = base::nullopt; EXPECT_EQ(GetParseableLabels(StringsToStringPieces(labels)), expectation); } diff --git a/chromium/components/autofill/core/browser/form_processing/name_processing_util.cc b/chromium/components/autofill/core/browser/form_processing/name_processing_util.cc index 7df75933fd0..29140ba4570 100644 --- a/chromium/components/autofill/core/browser/form_processing/name_processing_util.cc +++ b/chromium/components/autofill/core/browser/form_processing/name_processing_util.cc @@ -84,7 +84,7 @@ size_t FindLongestCommonPrefixLengthInStringsWithMinimalLength( // Returns true if |parseable_name| is a valid parseable_name. Current criterion // is the |autofill::kParseableNameValidationRe| regex. bool IsValidParseableName(const base::StringPiece16 parseable_name) { - static const base::string16 kParseableNameValidationPattern = + static const std::u16string kParseableNameValidationPattern = base::UTF8ToUTF16(kParseableNameValidationRe); return MatchesPattern(parseable_name, kParseableNameValidationPattern); } @@ -204,10 +204,10 @@ OptionalNamePieces RemoveCommonPrefixForNamesWithMinimalLengthIfPossible( kMinCommonNameLongPrefixLength); } -std::vector<base::string16> GetParseableNames(const NamePieces& field_names) { +std::vector<std::u16string> GetParseableNames(const NamePieces& field_names) { OptionalNamePieces parseable_names = base::nullopt; - std::vector<base::string16> result; + std::vector<std::u16string> result; result.reserve(field_names.size()); // If the feature is enabled, try to remove a common affix. If this is not @@ -231,7 +231,7 @@ std::vector<base::string16> GetParseableNames(const NamePieces& field_names) { // field names. base::ranges::transform( parseable_names.has_value() ? parseable_names.value() : field_names, - std::back_inserter(result), [](auto& s) { return base::string16(s); }); + std::back_inserter(result), [](auto& s) { return std::u16string(s); }); return result; } diff --git a/chromium/components/autofill/core/browser/form_processing/name_processing_util.h b/chromium/components/autofill/core/browser/form_processing/name_processing_util.h index 9500b42796a..41cd63f714f 100644 --- a/chromium/components/autofill/core/browser/form_processing/name_processing_util.h +++ b/chromium/components/autofill/core/browser/form_processing/name_processing_util.h @@ -56,7 +56,7 @@ RemoveCommonPrefixForNamesWithMinimalLengthIfPossible( // Beware, this function works on string pieces and therefore, it should not be // called with temporary objects. Also, the underlying strings should not be // modified before the last usage of the result. -std::vector<base::string16> GetParseableNames( +std::vector<std::u16string> GetParseableNames( const std::vector<base::StringPiece16>& field_names); } // namespace autofill diff --git a/chromium/components/autofill/core/browser/form_processing/name_processing_util_unittest.cc b/chromium/components/autofill/core/browser/form_processing/name_processing_util_unittest.cc index 4481d9a0240..8c808ee37d0 100644 --- a/chromium/components/autofill/core/browser/form_processing/name_processing_util_unittest.cc +++ b/chromium/components/autofill/core/browser/form_processing/name_processing_util_unittest.cc @@ -14,7 +14,7 @@ using base::ASCIIToUTF16; namespace { std::vector<base::StringPiece16> StringsToStringPieces( - const std::vector<base::string16>& strings) { + const std::vector<std::u16string>& strings) { std::vector<base::StringPiece16> string_pieces; for (const auto& s : strings) { string_pieces.emplace_back(base::StringPiece16(s)); @@ -28,18 +28,18 @@ namespace autofill { // Tests that the validity of parseable names is determined correctly. TEST(NameProcessingUtil, IsValidParseableName) { // Parseable name should not be empty. - EXPECT_FALSE(IsValidParseableName(ASCIIToUTF16(""))); + EXPECT_FALSE(IsValidParseableName(u"")); // Parseable name should not be solely numerical. - EXPECT_FALSE(IsValidParseableName(ASCIIToUTF16("1265125"))); + EXPECT_FALSE(IsValidParseableName(u"1265125")); // Valid parseable name cases. - EXPECT_TRUE(IsValidParseableName(ASCIIToUTF16("a23"))); - EXPECT_TRUE(IsValidParseableName(ASCIIToUTF16("*)&%@"))); + EXPECT_TRUE(IsValidParseableName(u"a23")); + EXPECT_TRUE(IsValidParseableName(u"*)&%@")); } // Tests that the correct length of prefixes and suffixes are returned. TEST(NameProcessingUtil, FindLongestCommonAffixLength) { - auto String16ToStringPiece16 = [](std::vector<base::string16>& vin, + auto String16ToStringPiece16 = [](std::vector<std::u16string>& vin, std::vector<base::StringPiece16>& vout) { vout.clear(); for (auto& str : vin) @@ -47,54 +47,54 @@ TEST(NameProcessingUtil, FindLongestCommonAffixLength) { }; // Normal prefix case. - std::vector<base::string16> strings; + std::vector<std::u16string> strings; std::vector<base::StringPiece16> stringPieces; - strings.push_back(ASCIIToUTF16("123456XXX123456789")); - strings.push_back(ASCIIToUTF16("12345678XXX012345678_foo")); - strings.push_back(ASCIIToUTF16("1234567890123456")); - strings.push_back(ASCIIToUTF16("1234567XXX901234567890")); + strings.push_back(u"123456XXX123456789"); + strings.push_back(u"12345678XXX012345678_foo"); + strings.push_back(u"1234567890123456"); + strings.push_back(u"1234567XXX901234567890"); String16ToStringPiece16(strings, stringPieces); size_t affixLength = FindLongestCommonAffixLength(stringPieces, false); EXPECT_EQ(ASCIIToUTF16("123456").size(), affixLength); // Normal suffix case. strings.clear(); - strings.push_back(ASCIIToUTF16("black and gold dress")); - strings.push_back(ASCIIToUTF16("work_address")); - strings.push_back(ASCIIToUTF16("123456XXX1234_home_address")); - strings.push_back(ASCIIToUTF16("1234567890123456_city_address")); + strings.push_back(u"black and gold dress"); + strings.push_back(u"work_address"); + strings.push_back(u"123456XXX1234_home_address"); + strings.push_back(u"1234567890123456_city_address"); String16ToStringPiece16(strings, stringPieces); affixLength = FindLongestCommonAffixLength(stringPieces, true); EXPECT_EQ(ASCIIToUTF16("dress").size(), affixLength); // Handles no common prefix. strings.clear(); - strings.push_back(ASCIIToUTF16("1234567890123456")); - strings.push_back(ASCIIToUTF16("4567890123456789")); - strings.push_back(ASCIIToUTF16("7890123456789012")); + strings.push_back(u"1234567890123456"); + strings.push_back(u"4567890123456789"); + strings.push_back(u"7890123456789012"); String16ToStringPiece16(strings, stringPieces); affixLength = FindLongestCommonAffixLength(stringPieces, false); EXPECT_EQ(ASCIIToUTF16("").size(), affixLength); // Handles no common suffix. strings.clear(); - strings.push_back(ASCIIToUTF16("1234567890123456")); - strings.push_back(ASCIIToUTF16("4567890123456789")); - strings.push_back(ASCIIToUTF16("7890123456789012")); + strings.push_back(u"1234567890123456"); + strings.push_back(u"4567890123456789"); + strings.push_back(u"7890123456789012"); String16ToStringPiece16(strings, stringPieces); affixLength = FindLongestCommonAffixLength(stringPieces, true); EXPECT_EQ(ASCIIToUTF16("").size(), affixLength); // Only one string, prefix case. strings.clear(); - strings.push_back(ASCIIToUTF16("1234567890")); + strings.push_back(u"1234567890"); String16ToStringPiece16(strings, stringPieces); affixLength = FindLongestCommonAffixLength(stringPieces, false); EXPECT_EQ(ASCIIToUTF16("1234567890").size(), affixLength); // Only one string, suffix case. strings.clear(); - strings.push_back(ASCIIToUTF16("1234567890")); + strings.push_back(u"1234567890"); String16ToStringPiece16(strings, stringPieces); affixLength = FindLongestCommonAffixLength(stringPieces, true); EXPECT_EQ(ASCIIToUTF16("1234567890").size(), affixLength); @@ -116,11 +116,11 @@ TEST(NameProcessingUtil, FindLongestCommonAffixLength) { // strings with a minimal length. TEST(NameProcessingUtil, FindLongestCommonPrefixLengthForStringsWithMinimalLength) { - std::vector<base::string16> strings; - strings.push_back(ASCIIToUTF16("aabbccddeeff")); - strings.push_back(ASCIIToUTF16("aabbccddeeffgg")); - strings.push_back(ASCIIToUTF16("zzz")); - strings.push_back(ASCIIToUTF16("aabbc___")); + std::vector<std::u16string> strings; + strings.push_back(u"aabbccddeeff"); + strings.push_back(u"aabbccddeeffgg"); + strings.push_back(u"zzz"); + strings.push_back(u"aabbc___"); EXPECT_EQ(FindLongestCommonPrefixLengthInStringsWithMinimalLength( StringsToStringPieces(strings), 4), 5U); @@ -131,11 +131,11 @@ TEST(NameProcessingUtil, // Tests that a |base::nullopt| is returned if no common affix was removed. TEST(NameProcessingUtil, RemoveCommonAffixesIfPossible_NotPossible) { - std::vector<base::string16> strings; - strings.push_back(ASCIIToUTF16("abc")); - strings.push_back(ASCIIToUTF16("def")); - strings.push_back(ASCIIToUTF16("abcd")); - strings.push_back(ASCIIToUTF16("abcdef")); + std::vector<std::u16string> strings; + strings.push_back(u"abc"); + strings.push_back(u"def"); + strings.push_back(u"abcd"); + strings.push_back(u"abcdef"); EXPECT_EQ(RemoveCommonAffixesIfPossible(StringsToStringPieces(strings)), base::nullopt); @@ -143,15 +143,15 @@ TEST(NameProcessingUtil, RemoveCommonAffixesIfPossible_NotPossible) { // Tests that both the prefix and the suffix are removed. TEST(NameProcessingUtil, RemoveCommonAffixesIfPossible) { - std::vector<base::string16> strings; - strings.push_back(ASCIIToUTF16("abcaazzz")); - strings.push_back(ASCIIToUTF16("abcbbzzz")); - strings.push_back(ASCIIToUTF16("abccczzz")); + std::vector<std::u16string> strings; + strings.push_back(u"abcaazzz"); + strings.push_back(u"abcbbzzz"); + strings.push_back(u"abccczzz"); - std::vector<base::string16> expectation; - expectation.push_back(ASCIIToUTF16("aa")); - expectation.push_back(ASCIIToUTF16("bb")); - expectation.push_back(ASCIIToUTF16("cc")); + std::vector<std::u16string> expectation; + expectation.push_back(u"aa"); + expectation.push_back(u"bb"); + expectation.push_back(u"cc"); EXPECT_EQ(RemoveCommonAffixesIfPossible(StringsToStringPieces(strings)), StringsToStringPieces(expectation)); @@ -159,11 +159,11 @@ TEST(NameProcessingUtil, RemoveCommonAffixesIfPossible) { // Tests that a |base::nullopt| is returned if no common prefix was removed. TEST(NameProcessingUtil, RemoveCommonPrefixIfPossible_NotPossible) { - std::vector<base::string16> strings; - strings.push_back(ASCIIToUTF16("abc")); - strings.push_back(ASCIIToUTF16("def")); - strings.push_back(ASCIIToUTF16("abcd")); - strings.push_back(ASCIIToUTF16("abcdef")); + std::vector<std::u16string> strings; + strings.push_back(u"abc"); + strings.push_back(u"def"); + strings.push_back(u"abcd"); + strings.push_back(u"abcdef"); EXPECT_EQ(RemoveCommonPrefixIfPossible(StringsToStringPieces(strings)), base::nullopt); @@ -171,16 +171,16 @@ TEST(NameProcessingUtil, RemoveCommonPrefixIfPossible_NotPossible) { // Tests that prefix is removed correctly. TEST(NameProcessingUtil, RemoveCommonPrefixIfPossible) { - std::vector<base::string16> strings; + std::vector<std::u16string> strings; // The strings contain a long common prefix that can be removed. - strings.push_back(ASCIIToUTF16("ccccccccccccccccaazzz")); - strings.push_back(ASCIIToUTF16("ccccccccccccccccbbzzz")); - strings.push_back(ASCIIToUTF16("cccccccccccccccccczzz")); + strings.push_back(u"ccccccccccccccccaazzz"); + strings.push_back(u"ccccccccccccccccbbzzz"); + strings.push_back(u"cccccccccccccccccczzz"); - std::vector<base::string16> expectation; - expectation.push_back(ASCIIToUTF16("aazzz")); - expectation.push_back(ASCIIToUTF16("bbzzz")); - expectation.push_back(ASCIIToUTF16("cczzz")); + std::vector<std::u16string> expectation; + expectation.push_back(u"aazzz"); + expectation.push_back(u"bbzzz"); + expectation.push_back(u"cczzz"); EXPECT_EQ(RemoveCommonPrefixIfPossible(StringsToStringPieces(strings)), StringsToStringPieces(expectation)); @@ -189,17 +189,17 @@ TEST(NameProcessingUtil, RemoveCommonPrefixIfPossible) { // Tests that prefix is removed correctly for fields with a minimal length. TEST(NameProcessingUtil, RemoveCommonPrefixForFieldsWithMinimalLengthIfPossible) { - std::vector<base::string16> strings; - strings.push_back(ASCIIToUTF16("ccccccccccccccccaazzz")); + std::vector<std::u16string> strings; + strings.push_back(u"ccccccccccccccccaazzz"); // This name is too short to be considered and is skipped both in the // detection of prefixes as well as in the removal. - strings.push_back(ASCIIToUTF16("abc")); - strings.push_back(ASCIIToUTF16("cccccccccccccccccczzz")); + strings.push_back(u"abc"); + strings.push_back(u"cccccccccccccccccczzz"); - std::vector<base::string16> expectation; - expectation.push_back(ASCIIToUTF16("aazzz")); - expectation.push_back(ASCIIToUTF16("abc")); - expectation.push_back(ASCIIToUTF16("cczzz")); + std::vector<std::u16string> expectation; + expectation.push_back(u"aazzz"); + expectation.push_back(u"abc"); + expectation.push_back(u"cczzz"); EXPECT_EQ(RemoveCommonPrefixForNamesWithMinimalLengthIfPossible( StringsToStringPieces(strings)), @@ -208,10 +208,10 @@ TEST(NameProcessingUtil, // Tests that prefix is not removed because it is too short. TEST(NameProcessingUtil, RemoveCommonPrefixIfPossible_TooShort) { - std::vector<base::string16> strings; - strings.push_back(ASCIIToUTF16("abcaazzz")); - strings.push_back(ASCIIToUTF16("abcbbzzz")); - strings.push_back(ASCIIToUTF16("abccczzz")); + std::vector<std::u16string> strings; + strings.push_back(u"abcaazzz"); + strings.push_back(u"abcbbzzz"); + strings.push_back(u"abccczzz"); EXPECT_EQ(RemoveCommonPrefixIfPossible(StringsToStringPieces(strings)), base::nullopt); @@ -219,15 +219,15 @@ TEST(NameProcessingUtil, RemoveCommonPrefixIfPossible_TooShort) { // Tests that the strings are correctly stripped. TEST(NameProcessingUtil, GetStrippedParseableNamesIfValid) { - std::vector<base::string16> strings; - strings.push_back(ASCIIToUTF16("abcaazzz")); - strings.push_back(ASCIIToUTF16("abcbbzzz")); - strings.push_back(ASCIIToUTF16("abccczzz")); + std::vector<std::u16string> strings; + strings.push_back(u"abcaazzz"); + strings.push_back(u"abcbbzzz"); + strings.push_back(u"abccczzz"); - std::vector<base::string16> expectation; - expectation.push_back(ASCIIToUTF16("aaz")); - expectation.push_back(ASCIIToUTF16("bbz")); - expectation.push_back(ASCIIToUTF16("ccz")); + std::vector<std::u16string> expectation; + expectation.push_back(u"aaz"); + expectation.push_back(u"bbz"); + expectation.push_back(u"ccz"); EXPECT_EQ( GetStrippedParseableNamesIfValid(StringsToStringPieces(strings), 3, 2, 1), @@ -237,16 +237,16 @@ TEST(NameProcessingUtil, GetStrippedParseableNamesIfValid) { // Tests that a |base::nullopt| is returned if one of stripped names is not // valid. TEST(NameProcessingUtil, GetStrippedParseableNamesIfValid_NotValid) { - std::vector<base::string16> strings; - strings.push_back(ASCIIToUTF16("abcaazzz")); + std::vector<std::u16string> strings; + strings.push_back(u"abcaazzz"); // This string is not valid because only the "1" is left after stripping. - strings.push_back(ASCIIToUTF16("abc1zz")); - strings.push_back(ASCIIToUTF16("abccczzz")); + strings.push_back(u"abc1zz"); + strings.push_back(u"abccczzz"); - std::vector<base::string16> expectation; - expectation.push_back(ASCIIToUTF16("aaz")); - expectation.push_back(ASCIIToUTF16("bbz")); - expectation.push_back(ASCIIToUTF16("ccz")); + std::vector<std::u16string> expectation; + expectation.push_back(u"aaz"); + expectation.push_back(u"bbz"); + expectation.push_back(u"ccz"); EXPECT_EQ( GetStrippedParseableNamesIfValid(StringsToStringPieces(strings), 3, 2, 1), @@ -255,60 +255,60 @@ TEST(NameProcessingUtil, GetStrippedParseableNamesIfValid_NotValid) { // Tests that the parseable names are returned correctly. TEST(NameProcessingUtil, GetParseableNames_OnlyPrefix) { - std::vector<base::string16> strings; - strings.push_back(ASCIIToUTF16("abcaazzz1")); - strings.push_back(ASCIIToUTF16("abcbbzzz2")); - strings.push_back(ASCIIToUTF16("abccczzz3")); + std::vector<std::u16string> strings; + strings.push_back(u"abcaazzz1"); + strings.push_back(u"abcbbzzz2"); + strings.push_back(u"abccczzz3"); base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitAndEnableFeature( features::kAutofillLabelAffixRemoval); // With the feature turned on, the prefix is removed. - std::vector<base::string16> expectation; - expectation.push_back(ASCIIToUTF16("aazzz1")); - expectation.push_back(ASCIIToUTF16("bbzzz2")); - expectation.push_back(ASCIIToUTF16("cczzz3")); + std::vector<std::u16string> expectation; + expectation.push_back(u"aazzz1"); + expectation.push_back(u"bbzzz2"); + expectation.push_back(u"cczzz3"); EXPECT_EQ(GetParseableNames(StringsToStringPieces(strings)), expectation); } // Tests that the parseable names are returned correctly. TEST(NameProcessingUtil, GetParseableNames_OnlySuffix) { - std::vector<base::string16> strings; - strings.push_back(ASCIIToUTF16("1aazzz")); - strings.push_back(ASCIIToUTF16("2bbzzz")); - strings.push_back(ASCIIToUTF16("3cczzz")); + std::vector<std::u16string> strings; + strings.push_back(u"1aazzz"); + strings.push_back(u"2bbzzz"); + strings.push_back(u"3cczzz"); base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitAndEnableFeature( features::kAutofillLabelAffixRemoval); // With the feature turned on, the suffix is removed. - std::vector<base::string16> expectation; - expectation.push_back(ASCIIToUTF16("1aa")); - expectation.push_back(ASCIIToUTF16("2bb")); - expectation.push_back(ASCIIToUTF16("3cc")); + std::vector<std::u16string> expectation; + expectation.push_back(u"1aa"); + expectation.push_back(u"2bb"); + expectation.push_back(u"3cc"); EXPECT_EQ(GetParseableNames(StringsToStringPieces(strings)), expectation); } // Tests that the parseable names are returned correctly. TEST(NameProcessingUtil, GetParseableNames_Affix) { - std::vector<base::string16> strings; - strings.push_back(ASCIIToUTF16("abcaazzz")); - strings.push_back(ASCIIToUTF16("abcbbzzz")); - strings.push_back(ASCIIToUTF16("abccczzz")); + std::vector<std::u16string> strings; + strings.push_back(u"abcaazzz"); + strings.push_back(u"abcbbzzz"); + strings.push_back(u"abccczzz"); base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitAndEnableFeature( features::kAutofillLabelAffixRemoval); // With the feature turned on, the prefix and affix is removed. - std::vector<base::string16> expectation; - expectation.push_back(ASCIIToUTF16("aa")); - expectation.push_back(ASCIIToUTF16("bb")); - expectation.push_back(ASCIIToUTF16("cc")); + std::vector<std::u16string> expectation; + expectation.push_back(u"aa"); + expectation.push_back(u"bb"); + expectation.push_back(u"cc"); EXPECT_EQ(GetParseableNames(StringsToStringPieces(strings)), expectation); @@ -318,21 +318,21 @@ TEST(NameProcessingUtil, GetParseableNames_Affix) { // With the feature turned off, the names are too short for a prefix removal. expectation.clear(); - expectation.push_back(ASCIIToUTF16("abcaazzz")); - expectation.push_back(ASCIIToUTF16("abcbbzzz")); - expectation.push_back(ASCIIToUTF16("abccczzz")); + expectation.push_back(u"abcaazzz"); + expectation.push_back(u"abcbbzzz"); + expectation.push_back(u"abccczzz"); EXPECT_EQ(GetParseableNames(StringsToStringPieces(strings)), expectation); // But very long prefixes are still removed. strings.clear(); - strings.push_back(ASCIIToUTF16("1234567890ABCDEFGabcaazzz")); - strings.push_back(ASCIIToUTF16("1234567890ABCDEFGabcbbzzz")); - strings.push_back(ASCIIToUTF16("1234567890ABCDEFGabccczzz")); + strings.push_back(u"1234567890ABCDEFGabcaazzz"); + strings.push_back(u"1234567890ABCDEFGabcbbzzz"); + strings.push_back(u"1234567890ABCDEFGabccczzz"); expectation.clear(); - expectation.push_back(ASCIIToUTF16("aazzz")); - expectation.push_back(ASCIIToUTF16("bbzzz")); - expectation.push_back(ASCIIToUTF16("cczzz")); + expectation.push_back(u"aazzz"); + expectation.push_back(u"bbzzz"); + expectation.push_back(u"cczzz"); EXPECT_EQ(GetParseableNames(StringsToStringPieces(strings)), expectation); } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/form_structure.cc b/chromium/components/autofill/core/browser/form_structure.cc index 9a13c2ba9be..18ec46fce12 100644 --- a/chromium/components/autofill/core/browser/form_structure.cc +++ b/chromium/components/autofill/core/browser/form_structure.cc @@ -422,7 +422,7 @@ void EncodeRandomizedValue(const RandomizedEncoder& encoder, encoder.Encode(form_signature, field_signature, data_type, data_value)); if (include_checksum) { DCHECK(data_type == RandomizedEncoder::FORM_URL); - output->set_checksum(StrToHash32Bit(data_value.data())); + output->set_checksum(StrToHash32Bit(data_value)); } } @@ -630,15 +630,12 @@ FormStructure::FormStructure(const FormData& form) target_url_(form.action), main_frame_origin_(form.main_frame_origin), is_form_tag_(form.is_form_tag), - is_formless_checkout_(form.is_formless_checkout), all_fields_are_passwords_(!form.fields.empty()), form_parsed_timestamp_(AutofillTickClock::NowTicks()), - passwords_were_revealed_(false), - password_symbol_vote_(0), - developer_engagement_metrics_(0), + host_frame_(form.host_frame), unique_renderer_id_(form.unique_renderer_id) { // Copy the form fields. - std::map<base::string16, size_t> unique_names; + std::map<std::u16string, size_t> unique_names; for (const FormFieldData& field : form.fields) { if (!ShouldSkipField(field)) ++active_field_count_; @@ -651,9 +648,8 @@ FormStructure::FormStructure(const FormData& form) // Generate a unique name for this field by appending a counter to the name. // Make sure to prepend the counter with a non-numeric digit so that we are // guaranteed to avoid collisions. - base::string16 unique_name = - field.name + base::ASCIIToUTF16("_") + - base::NumberToString16(++unique_names[field.name]); + std::u16string unique_name = + field.name + u"_" + base::NumberToString16(++unique_names[field.name]); fields_.push_back(std::make_unique<AutofillField>(field, unique_name)); } @@ -689,7 +685,7 @@ void FormStructure::DetermineHeuristicTypes( const FieldCandidatesMap field_type_map = FormField::ParseFormFields( fields_, current_page_language_, is_form_tag_, log_manager); for (const auto& field : fields_) { - const auto iter = field_type_map.find(field->unique_renderer_id); + const auto iter = field_type_map.find(field->global_id()); if (iter != field_type_map.end()) { field->set_heuristic_type(iter->second.BestHeuristicType()); } @@ -765,7 +761,7 @@ bool FormStructure::EncodeUploadRequest( } if (is_raw_metadata_uploading_enabled) { - upload->set_action_signature(StrToHash64Bit(target_url_.host())); + upload->set_action_signature(StrToHash64Bit(target_url_.host_piece())); if (!form_name().empty()) upload->set_form_name(base::UTF16ToUTF8(form_name())); for (const ButtonTitleInfo& e : button_titles_) { @@ -1050,10 +1046,8 @@ bool FormStructure::ShouldBeParsed(LogManager* log_manager) const { } // Rule out search forms. - static const base::string16 kUrlSearchActionPattern = - base::UTF8ToUTF16(kUrlSearchActionRe); if (MatchesPattern(base::UTF8ToUTF16(target_url_.path_piece()), - kUrlSearchActionPattern)) { + kUrlSearchActionRe)) { if (log_manager) { log_manager->Log() << LoggingScope::kAbortParsing << LogMessage::kAbortParsingUrlMatchesSearchRegex @@ -1077,10 +1071,7 @@ bool FormStructure::ShouldBeParsed(LogManager* log_manager) const { bool FormStructure::ShouldRunHeuristics() const { return active_field_count() >= kMinRequiredFieldsForHeuristics && - HasAllowedScheme(source_url_) && - (is_form_tag_ || is_formless_checkout_ || - !base::FeatureList::IsEnabled( - features::kAutofillRestrictUnownedFieldsToFormlessCheckout)); + HasAllowedScheme(source_url_); } bool FormStructure::ShouldBeQueried() const { @@ -1098,14 +1089,14 @@ void FormStructure::RetrieveFromCache( const FormStructure& cached_form, const bool should_keep_cached_value, const bool only_server_and_autofill_state) { - std::map<FieldRendererId, const AutofillField*> cached_fields_by_id; + std::map<FieldGlobalId, const AutofillField*> cached_fields_by_id; for (size_t i = 0; i < cached_form.field_count(); ++i) { auto* const field = cached_form.field(i); - cached_fields_by_id[field->unique_renderer_id] = field; + cached_fields_by_id[field->global_id()] = field; } for (auto& field : *this) { const AutofillField* cached_field = nullptr; - const auto& it = cached_fields_by_id.find(field->unique_renderer_id); + const auto& it = cached_fields_by_id.find(field->global_id()); if (it != cached_fields_by_id.end()) cached_field = it->second; @@ -1155,7 +1146,7 @@ void FormStructure::RetrieveFromCache( // default values are equivalent to empty fields. // Since a website can prefill country and state values basedw on // GeoIp, the mechanism is deactivated for state and country fields. - field->value = base::string16(); + field->value = std::u16string(); } } field->set_server_type(cached_field->server_type()); @@ -1454,8 +1445,8 @@ void FormStructure::ParseFieldTypesFromAutocompleteAttributes() { was_parsed_for_autocomplete_attributes_ = true; } -std::set<base::string16> FormStructure::PossibleValues(ServerFieldType type) { - std::set<base::string16> values; +std::set<std::u16string> FormStructure::PossibleValues(ServerFieldType type) { + std::set<std::u16string> values; AutofillType target_type(type); for (const auto& field : fields_) { if (field->Type().GetStorableType() != target_type.GetStorableType() || @@ -1469,12 +1460,12 @@ std::set<base::string16> FormStructure::PossibleValues(ServerFieldType type) { break; } - for (const base::string16& val : field->option_values) { + for (const std::u16string& val : field->option_values) { if (!val.empty()) values.insert(base::i18n::ToUpper(val)); } - for (const base::string16& content : field->option_contents) { + for (const std::u16string& content : field->option_contents) { if (!content.empty()) values.insert(base::i18n::ToUpper(content)); } @@ -1516,8 +1507,8 @@ FormData FormStructure::ToFormData() const { data.action = target_url_; data.main_frame_origin = main_frame_origin_; data.is_form_tag = is_form_tag_; - data.is_formless_checkout = is_formless_checkout_; - data.unique_renderer_id = unique_renderer_id_; + data.host_frame = host_frame(); + data.unique_renderer_id = unique_renderer_id(); for (const auto& field : fields_) { data.fields.push_back(*field); @@ -2099,14 +2090,14 @@ void FormStructure::IdentifySectionsWithNewMethod() { if (base::FeatureList::IsEnabled( features::kAutofillNameSectionsWithRendererIds)) { return base::StrCat( - {field.name, base::ASCIIToUTF16("_"), - base::NumberToString16(field.unique_renderer_id.value())}); + {field.name, u"_", base::ASCIIToUTF16(field.host_frame.ToString()), + u"_", base::NumberToString16(field.unique_renderer_id.value())}); } else { return field.unique_name(); } }; - base::string16 current_section = get_section_name(*fields_.front()); + std::u16string current_section = get_section_name(*fields_.front()); // Keep track of the types we've seen in this section. ServerFieldTypeSet seen_types; @@ -2117,7 +2108,7 @@ void FormStructure::IdentifySectionsWithNewMethod() { bool previous_autocomplete_section_present = false; bool is_hidden_section = false; - base::string16 last_visible_section; + std::u16string last_visible_section; for (const auto& field : fields_) { const ServerFieldType current_type = field->Type().GetStorableType(); // All credit card fields belong to the same section that's different @@ -2281,22 +2272,22 @@ void FormStructure::IdentifySections(bool has_author_specified_sections) { if (base::FeatureList::IsEnabled( features::kAutofillNameSectionsWithRendererIds)) { return base::StrCat( - {field.name, base::ASCIIToUTF16("_"), - base::NumberToString16(field.unique_renderer_id.value())}); + {field.name, u"_", base::ASCIIToUTF16(field.host_frame.ToString()), + u"_", base::NumberToString16(field.unique_renderer_id.value())}); } else { return field.unique_name(); } }; if (!has_author_specified_sections) { - base::string16 current_section = get_section_name(*fields_.front()); + std::u16string current_section = get_section_name(*fields_.front()); // Keep track of the types we've seen in this section. ServerFieldTypeSet seen_types; ServerFieldType previous_type = UNKNOWN_TYPE; bool is_hidden_section = false; - base::string16 last_visible_section; + std::u16string last_visible_section; for (const auto& field : fields_) { const ServerFieldType current_type = field->Type().GetStorableType(); // All credit card fields belong to the same section that's different @@ -2434,7 +2425,7 @@ void FormStructure::ExtractParseableFieldLabels() { } // Determine the parsable labels and write them back. - base::Optional<std::vector<base::string16>> parsable_labels = + base::Optional<std::vector<std::u16string>> parsable_labels = GetParseableLabels(field_labels); // If not single label was split, the function can return, because the // |parsable_label_| is assigned to |label| by default. @@ -2463,7 +2454,7 @@ void FormStructure::ExtractParseableFieldNames() { } // Determine the parseable names and write them into the corresponding field. - std::vector<base::string16> parseable_names = GetParseableNames(names); + std::vector<std::u16string> parseable_names = GetParseableNames(names); DCHECK_EQ(parseable_names.size(), field_count()); size_t idx = 0; for (auto& field : *this) { @@ -2479,14 +2470,14 @@ DenseSet<FormType> FormStructure::GetFormTypes() const { return form_types; } -base::string16 FormStructure::GetIdentifierForRefill() const { +std::u16string FormStructure::GetIdentifierForRefill() const { if (!form_name().empty()) return form_name(); if (field_count() && !field(0)->unique_name().empty()) return field(0)->unique_name(); - return base::string16(); + return std::u16string(); } void FormStructure::set_randomized_encoder( @@ -2525,6 +2516,7 @@ std::ostream& operator<<(std::ostream& buffer, const FormStructure& form) { base::NumberToString( HashFormSignature(form.form_signature()))}); buffer << "\n Form name: " << form.form_name(); + buffer << "\n Host frame: " << form.host_frame().ToString(); buffer << "\n Unique renderer Id: " << form.unique_renderer_id().value(); buffer << "\n Target URL:" << form.target_url(); for (size_t i = 0; i < form.field_count(); ++i) { @@ -2536,6 +2528,7 @@ std::ostream& operator<<(std::ostream& buffer, const FormStructure& form) { " - ", base::NumberToString( HashFieldSignature(field->GetFieldSignature())), + ", host frame: ", field->host_frame.ToString(), ", unique renderer id: ", base::NumberToString(field->unique_renderer_id.value())}); buffer << "\n Name: " << field->parseable_name(); @@ -2555,7 +2548,7 @@ std::ostream& operator<<(std::ostream& buffer, const FormStructure& form) { buffer << "\n Section: " << field->section; constexpr size_t kMaxLabelSize = 100; - const base::string16 truncated_label = + const std::u16string truncated_label = field->label.substr(0, std::min(field->label.length(), kMaxLabelSize)); buffer << "\n Label: " << truncated_label; @@ -2573,6 +2566,7 @@ LogBuffer& operator<<(LogBuffer& buffer, const FormStructure& form) { base::NumberToString( HashFormSignature(form.form_signature()))}); buffer << Tr{} << "Form name:" << form.form_name(); + buffer << Tr{} << "Host frame:" << form.host_frame().ToString(); buffer << Tr{} << "Unique renderer id:" << form.unique_renderer_id().value(); buffer << Tr{} << "Target URL:" << form.target_url(); for (size_t i = 0; i < form.field_count(); ++i) { @@ -2587,6 +2581,7 @@ LogBuffer& operator<<(LogBuffer& buffer, const FormStructure& form) { " - ", base::NumberToString( HashFieldSignature(field->GetFieldSignature())), + ", host frame: ", field->host_frame.ToString(), ", unique renderer id: ", base::NumberToString(field->unique_renderer_id.value())}); buffer << Tr{} << "Name:" << field->parseable_name(); @@ -2606,7 +2601,7 @@ LogBuffer& operator<<(LogBuffer& buffer, const FormStructure& form) { buffer << Tr{} << "Section:" << field->section; constexpr size_t kMaxLabelSize = 100; - const base::string16 truncated_label = + const std::u16string truncated_label = field->label.substr(0, std::min(field->label.length(), kMaxLabelSize)); buffer << Tr{} << "Label:" << truncated_label; diff --git a/chromium/components/autofill/core/browser/form_structure.h b/chromium/components/autofill/core/browser/form_structure.h index 8151d28eb09..1dd3023b975 100644 --- a/chromium/components/autofill/core/browser/form_structure.h +++ b/chromium/components/autofill/core/browser/form_structure.h @@ -27,7 +27,7 @@ #include "components/autofill/core/common/dense_set.h" #include "components/autofill/core/common/language_code.h" #include "components/autofill/core/common/mojom/autofill_types.mojom.h" -#include "components/autofill/core/common/renderer_id.h" +#include "components/autofill/core/common/unique_ids.h" #include "url/gurl.h" #include "url/origin.h" @@ -201,7 +201,7 @@ class FormStructure { // empty set if the form doesn't reference the given type or if all inputs // are accepted (e.g., <input type="text" autocomplete="region">). // All returned values are standardized to upper case. - std::set<base::string16> PossibleValues(ServerFieldType type); + std::set<std::u16string> PossibleValues(ServerFieldType type); // Rationalize phone number fields in a given section, that is only fill // the fields that are considered composing a first complete phone number. @@ -230,11 +230,11 @@ class FormStructure { return fields_.end(); } - const base::string16& form_name() const { return form_name_; } + const std::u16string& form_name() const { return form_name_; } - const base::string16& id_attribute() const { return id_attribute_; } + const std::u16string& id_attribute() const { return id_attribute_; } - const base::string16& name_attribute() const { return name_attribute_; } + const std::u16string& name_attribute() const { return name_attribute_; } const GURL& source_url() const { return source_url_; } @@ -359,7 +359,7 @@ class FormStructure { // empty of these or returns an empty string: // - Form name // - Name for Autofill of first field - base::string16 GetIdentifierForRefill() const; + std::u16string GetIdentifierForRefill() const; int developer_engagement_metrics() const { return developer_engagement_metrics_; @@ -385,6 +385,8 @@ class FormStructure { value_from_dynamic_change_form_ = v; } + FormGlobalId global_id() const { return {host_frame_, unique_renderer_id_}; } + LocalFrameToken host_frame() const { return host_frame_; } FormRendererId unique_renderer_id() const { return unique_renderer_id_; } bool ShouldSkipFieldVisibleForTesting(const FormFieldData& field) const { @@ -532,13 +534,13 @@ class FormStructure { LanguageCode current_page_language_; // The id attribute of the form. - base::string16 id_attribute_; + std::u16string id_attribute_; // The name attribute of the form. - base::string16 name_attribute_; + std::u16string name_attribute_; // The name of the form. - base::string16 form_name_; + std::u16string form_name_; // The titles of form's buttons. ButtonTitleList button_titles_; @@ -597,12 +599,6 @@ class FormStructure { // True if the form is a <form>. bool is_form_tag_ = true; - // True if the form is made of unowned fields (i.e., not within a <form> tag) - // in what appears to be a checkout flow. This attribute is only calculated - // and used if features::kAutofillRestrictUnownedFieldsToFormlessCheckout is - // enabled, to prevent heuristics from running on formless non-checkout. - bool is_formless_checkout_ = false; - // True if all form fields are password fields. bool all_fields_are_passwords_ = false; @@ -651,6 +647,10 @@ class FormStructure { bool value_from_dynamic_change_form_ = false; + // An unique identifier of the fame. + LocalFrameToken host_frame_; + + // An identifier that is unique among the form from the same frame. FormRendererId unique_renderer_id_; DISALLOW_COPY_AND_ASSIGN(FormStructure); diff --git a/chromium/components/autofill/core/browser/form_structure_unittest.cc b/chromium/components/autofill/core/browser/form_structure_unittest.cc index fc22851c9c7..9fb90540051 100644 --- a/chromium/components/autofill/core/browser/form_structure_unittest.cc +++ b/chromium/components/autofill/core/browser/form_structure_unittest.cc @@ -208,8 +208,8 @@ TEST_F(FormStructureTestImpl, IsAutofillable) { // Start with a username field. It should be picked up by the password but // not by autofill. - field.label = ASCIIToUTF16("username"); - field.name = ASCIIToUTF16("username"); + field.label = u"username"; + field.name = u"username"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -219,8 +219,8 @@ TEST_F(FormStructureTestImpl, IsAutofillable) { // Add a password field. The form should be picked up by the password but // not by autofill. - field.label = ASCIIToUTF16("password"); - field.name = ASCIIToUTF16("password"); + field.label = u"password"; + field.name = u"password"; field.form_control_type = "password"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -229,8 +229,8 @@ TEST_F(FormStructureTestImpl, IsAutofillable) { // Add an auto-fillable fields. With just one auto-fillable field, this should // be picked up by autofill only if there is no minimum field enforcement. - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullname"); + field.label = u"Full Name"; + field.name = u"fullname"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -239,8 +239,8 @@ TEST_F(FormStructureTestImpl, IsAutofillable) { // Add an auto-fillable fields. With just one auto-fillable field, this should // be picked up by autofill only if there is no minimum field enforcement. - field.label = ASCIIToUTF16("Address Line 1"); - field.name = ASCIIToUTF16("address1"); + field.label = u"Address Line 1"; + field.name = u"address1"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -248,8 +248,8 @@ TEST_F(FormStructureTestImpl, IsAutofillable) { EXPECT_FALSE(FormIsAutofillable(form)); // We now have three auto-fillable fields. It's always autofillable. - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; field.form_control_type = "email"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -275,7 +275,7 @@ TEST_F(FormStructureTestImpl, ShouldBeParsed) { FormFieldData checkable_field; checkable_field.check_status = FormFieldData::CheckStatus::kCheckableButUnchecked; - checkable_field.name = ASCIIToUTF16("radiobtn"); + checkable_field.name = u"radiobtn"; checkable_field.form_control_type = "radio"; checkable_field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(checkable_field); @@ -284,7 +284,7 @@ TEST_F(FormStructureTestImpl, ShouldBeParsed) { EXPECT_FALSE(FormShouldBeParsed(form)) << "one checkable"; // Add a second checkable field. - checkable_field.name = ASCIIToUTF16("checkbox"); + checkable_field.name = u"checkbox"; checkable_field.form_control_type = "checkbox"; checkable_field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(checkable_field); @@ -294,8 +294,8 @@ TEST_F(FormStructureTestImpl, ShouldBeParsed) { // Add a text field. FormFieldData field; - field.label = ASCIIToUTF16("username"); - field.name = ASCIIToUTF16("username"); + field.label = u"username"; + field.name = u"username"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -305,14 +305,14 @@ TEST_F(FormStructureTestImpl, ShouldBeParsed) { EXPECT_TRUE(FormShouldBeParsed(form)) << "username"; // We now have three text fields, though only two are auto-fillable. - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -332,20 +332,20 @@ TEST_F(FormStructureTestImpl, ShouldBeParsed) { // field. form.fields.clear(); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; field.form_control_type = "email"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; field.form_control_type = "select-one"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.form_control_type = "select-one"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -358,16 +358,16 @@ TEST_F(FormStructureTestImpl, ShouldBeParsed) { // We have only one field, which is password. form.fields.clear(); - field.label = ASCIIToUTF16("Password"); - field.name = ASCIIToUTF16("pw"); + field.label = u"Password"; + field.name = u"pw"; field.form_control_type = "password"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); EXPECT_TRUE(FormShouldBeParsed(form)) << "password"; // We have two fields, which are passwords, should be parsed. - field.label = ASCIIToUTF16("New password"); - field.name = ASCIIToUTF16("new_pw"); + field.label = u"New password"; + field.name = u"new_pw"; field.form_control_type = "password"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -379,22 +379,22 @@ TEST_F(FormStructureTestImpl, ShouldBeParsed_BadScheme) { FormData form; FormFieldData field; - field.label = ASCIIToUTF16("Name"); - field.name = ASCIIToUTF16("name"); + field.label = u"Name"; + field.name = u"name"; field.form_control_type = "text"; field.autocomplete_attribute = "name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; field.form_control_type = "text"; field.autocomplete_attribute = "email"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.form_control_type = "text"; field.autocomplete_attribute = "address-line1"; field.unique_renderer_id = MakeFieldRendererId(); @@ -463,15 +463,15 @@ TEST_F(FormStructureTestImpl, ShouldBeParsed_TwoFields_HasAutocomplete) { form.url = GURL("http://www.foo.com/"); FormFieldData field; - field.label = ASCIIToUTF16("Name"); - field.name = ASCIIToUTF16("name"); + field.label = u"Name"; + field.name = u"name"; field.form_control_type = "name"; field.autocomplete_attribute = "name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("Address"); + field.label = u"Address"; + field.name = u"Address"; field.form_control_type = "select-one"; field.autocomplete_attribute = ""; field.unique_renderer_id = MakeFieldRendererId(); @@ -558,50 +558,6 @@ TEST_F(FormStructureTestImpl, HeuristicsAutocompleteAttribute) { UNKNOWN_TYPE}}}}); } -// // Verify that the heuristics are not run for non checkout formless forms. -TEST_F(FormStructureTestImpl, Heuristics_FormlessNonCheckoutForm) { - base::test::ScopedFeatureList feature_list; - feature_list.InitAndEnableFeature( - features::kAutofillRestrictUnownedFieldsToFormlessCheckout); - - CheckFormStructureTestData( - {{{.description_for_logging = "Heuristics_NonCheckoutForm", - .fields = {{.role = ServerFieldType::NAME_FIRST, - .autocomplete_attribute = "given-name"}, - {.role = ServerFieldType::NAME_LAST, - .autocomplete_attribute = "family-name"}, - {.role = ServerFieldType::EMAIL_ADDRESS, - .autocomplete_attribute = "email"}}}, - { - .determine_heuristic_type = true, - .is_autofillable = true, - .field_count = 3, - .autofill_count = 3, - }, - {.expected_html_type = {HTML_TYPE_GIVEN_NAME, HTML_TYPE_FAMILY_NAME, - HTML_TYPE_EMAIL}, - .expected_heuristic_type = {NAME_FIRST, NAME_LAST, EMAIL_ADDRESS}}}, - - {{.description_for_logging = "Heuristics_FormlessNonCheckoutForm", - .fields = {{.role = ServerFieldType::NAME_FIRST, - .autocomplete_attribute = "given-name"}, - {.role = ServerFieldType::NAME_LAST, - .autocomplete_attribute = "family-name"}, - {.role = ServerFieldType::EMAIL_ADDRESS, - .autocomplete_attribute = "email"}}, - .is_form_tag = false}, - { - .determine_heuristic_type = true, - .is_autofillable = true, - .field_count = 3, - .autofill_count = 3, - }, - {.expected_html_type = {HTML_TYPE_GIVEN_NAME, HTML_TYPE_FAMILY_NAME, - HTML_TYPE_EMAIL}, - .expected_heuristic_type = {UNKNOWN_TYPE, UNKNOWN_TYPE, - UNKNOWN_TYPE}}}}); -} - // All fields share a common prefix which could confuse the heuristics. Test // that the common prefixes are stripped out before running heuristics. // This test ensures that |parseable_name| is used for heuristics. @@ -615,28 +571,28 @@ TEST_F(FormStructureTestImpl, StripCommonNameAffix) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$firstname"); + field.label = u"First Name"; + field.name = u"ctl01$ctl00$ShippingAddressCreditPhone$firstname"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$lastname"); + field.label = u"Last Name"; + field.name = u"ctl01$ctl00$ShippingAddressCreditPhone$lastname"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$email"); + field.label = u"Email"; + field.name = u"ctl01$ctl00$ShippingAddressCreditPhone$email"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$phone"); + field.label = u"Phone"; + field.name = u"ctl01$ctl00$ShippingAddressCreditPhone$phone"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = base::string16(); - field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$submit"); + field.label = std::u16string(); + field.name = u"ctl01$ctl00$ShippingAddressCreditPhone$submit"; field.form_control_type = "submit"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -650,22 +606,20 @@ TEST_F(FormStructureTestImpl, StripCommonNameAffix) { ASSERT_EQ(4U, form_structure->autofill_count()); // First name. - EXPECT_EQ(ASCIIToUTF16("firstname"), - form_structure->field(0)->parseable_name()); + EXPECT_EQ(u"firstname", form_structure->field(0)->parseable_name()); EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); // Last name. - EXPECT_EQ(ASCIIToUTF16("lastname"), - form_structure->field(1)->parseable_name()); + EXPECT_EQ(u"lastname", form_structure->field(1)->parseable_name()); EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); // Email. - EXPECT_EQ(ASCIIToUTF16("email"), form_structure->field(2)->parseable_name()); + EXPECT_EQ(u"email", form_structure->field(2)->parseable_name()); EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); // Phone. - EXPECT_EQ(ASCIIToUTF16("phone"), form_structure->field(3)->parseable_name()); + EXPECT_EQ(u"phone", form_structure->field(3)->parseable_name()); EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER, form_structure->field(3)->heuristic_type()); // Submit. - EXPECT_EQ(ASCIIToUTF16("submit"), form_structure->field(4)->parseable_name()); + EXPECT_EQ(u"submit", form_structure->field(4)->parseable_name()); EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(4)->heuristic_type()); } @@ -681,16 +635,16 @@ TEST_F(FormStructureTestImpl, StripCommonNameAffix_SmallPrefix) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Address 1"); - field.name = ASCIIToUTF16("address1"); + field.label = u"Address 1"; + field.name = u"address1"; form.fields.push_back(field); - field.label = ASCIIToUTF16("Address 2"); - field.name = ASCIIToUTF16("address2"); + field.label = u"Address 2"; + field.name = u"address2"; form.fields.push_back(field); - field.label = ASCIIToUTF16("Address 3"); - field.name = ASCIIToUTF16("address3"); + field.label = u"Address 3"; + field.name = u"address3"; form.fields.push_back(field); std::unique_ptr<FormStructure> form_structure(new FormStructure(form)); @@ -699,14 +653,11 @@ TEST_F(FormStructureTestImpl, StripCommonNameAffix_SmallPrefix) { ASSERT_EQ(3U, form_structure->field_count()); // Address 1. - EXPECT_EQ(ASCIIToUTF16("address1"), - form_structure->field(0)->parseable_name()); + EXPECT_EQ(u"address1", form_structure->field(0)->parseable_name()); // Address 2. - EXPECT_EQ(ASCIIToUTF16("address2"), - form_structure->field(1)->parseable_name()); + EXPECT_EQ(u"address2", form_structure->field(1)->parseable_name()); // Address 3 - EXPECT_EQ(ASCIIToUTF16("address3"), - form_structure->field(2)->parseable_name()); + EXPECT_EQ(u"address3", form_structure->field(2)->parseable_name()); } // All fields share both a common prefix and suffix which could confuse the @@ -722,29 +673,24 @@ TEST_F(FormStructureTestImpl, StripCommonNameAffix_PrefixAndSuffix) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = - ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$firstname_data"); + field.label = u"First Name"; + field.name = u"ctl01$ctl00$ShippingAddressCreditPhone$firstname_data"; form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = - ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$lastname_data"); + field.label = u"Last Name"; + field.name = u"ctl01$ctl00$ShippingAddressCreditPhone$lastname_data"; form.fields.push_back(field); - field.label = ASCIIToUTF16("Email"); - field.name = - ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$email_data"); + field.label = u"Email"; + field.name = u"ctl01$ctl00$ShippingAddressCreditPhone$email_data"; form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone"); - field.name = - ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$phone_data"); + field.label = u"Phone"; + field.name = u"ctl01$ctl00$ShippingAddressCreditPhone$phone_data"; form.fields.push_back(field); - field.label = base::string16(); - field.name = - ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$submit_data"); + field.label = std::u16string(); + field.name = u"ctl01$ctl00$ShippingAddressCreditPhone$submit_data"; field.form_control_type = "submit"; form.fields.push_back(field); @@ -754,17 +700,15 @@ TEST_F(FormStructureTestImpl, StripCommonNameAffix_PrefixAndSuffix) { ASSERT_EQ(5U, form_structure->field_count()); // First name. - EXPECT_EQ(ASCIIToUTF16("firstname"), - form_structure->field(0)->parseable_name()); + EXPECT_EQ(u"firstname", form_structure->field(0)->parseable_name()); // Last name. - EXPECT_EQ(ASCIIToUTF16("lastname"), - form_structure->field(1)->parseable_name()); + EXPECT_EQ(u"lastname", form_structure->field(1)->parseable_name()); // Email. - EXPECT_EQ(ASCIIToUTF16("email"), form_structure->field(2)->parseable_name()); + EXPECT_EQ(u"email", form_structure->field(2)->parseable_name()); // Phone. - EXPECT_EQ(ASCIIToUTF16("phone"), form_structure->field(3)->parseable_name()); + EXPECT_EQ(u"phone", form_structure->field(3)->parseable_name()); // Submit. - EXPECT_EQ(ASCIIToUTF16("submit"), form_structure->field(4)->parseable_name()); + EXPECT_EQ(u"submit", form_structure->field(4)->parseable_name()); } // Only some fields share a long common long prefix, no fields share a suffix. @@ -780,24 +724,24 @@ TEST_F(FormStructureTestImpl, StripCommonNameAffix_SelectiveLongPrefix) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$firstname"); + field.label = u"First Name"; + field.name = u"ctl01$ctl00$ShippingAddressCreditPhone$firstname"; form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$lastname"); + field.label = u"Last Name"; + field.name = u"ctl01$ctl00$ShippingAddressCreditPhone$lastname"; form.fields.push_back(field); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("phone"); + field.label = u"Phone"; + field.name = u"phone"; form.fields.push_back(field); - field.label = base::string16(); - field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$submit"); + field.label = std::u16string(); + field.name = u"ctl01$ctl00$ShippingAddressCreditPhone$submit"; field.form_control_type = "submit"; form.fields.push_back(field); @@ -807,17 +751,15 @@ TEST_F(FormStructureTestImpl, StripCommonNameAffix_SelectiveLongPrefix) { ASSERT_EQ(5U, form_structure->field_count()); // First name. - EXPECT_EQ(ASCIIToUTF16("firstname"), - form_structure->field(0)->parseable_name()); + EXPECT_EQ(u"firstname", form_structure->field(0)->parseable_name()); // Last name. - EXPECT_EQ(ASCIIToUTF16("lastname"), - form_structure->field(1)->parseable_name()); + EXPECT_EQ(u"lastname", form_structure->field(1)->parseable_name()); // Email. - EXPECT_EQ(ASCIIToUTF16("email"), form_structure->field(2)->parseable_name()); + EXPECT_EQ(u"email", form_structure->field(2)->parseable_name()); // Phone. - EXPECT_EQ(ASCIIToUTF16("phone"), form_structure->field(3)->parseable_name()); + EXPECT_EQ(u"phone", form_structure->field(3)->parseable_name()); // Submit. - EXPECT_EQ(ASCIIToUTF16("submit"), form_structure->field(4)->parseable_name()); + EXPECT_EQ(u"submit", form_structure->field(4)->parseable_name()); } // Only some fields share a long common short prefix, no fields share a suffix. @@ -834,24 +776,24 @@ TEST_F(FormStructureTestImpl, FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; form.fields.push_back(field); - field.label = ASCIIToUTF16("Street Name"); - field.name = ASCIIToUTF16("address_streetname"); + field.label = u"Street Name"; + field.name = u"address_streetname"; form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("address_housenumber"); + field.label = u"Phone"; + field.name = u"address_housenumber"; form.fields.push_back(field); - field.label = base::string16(); - field.name = ASCIIToUTF16("address_apartmentnumber"); + field.label = std::u16string(); + field.name = u"address_apartmentnumber"; form.fields.push_back(field); std::unique_ptr<FormStructure> form_structure(new FormStructure(form)); @@ -860,19 +802,15 @@ TEST_F(FormStructureTestImpl, ASSERT_EQ(5U, form_structure->field_count()); // First name. - EXPECT_EQ(ASCIIToUTF16("firstname"), - form_structure->field(0)->parseable_name()); + EXPECT_EQ(u"firstname", form_structure->field(0)->parseable_name()); // Last name. - EXPECT_EQ(ASCIIToUTF16("lastname"), - form_structure->field(1)->parseable_name()); + EXPECT_EQ(u"lastname", form_structure->field(1)->parseable_name()); // Email. - EXPECT_EQ(ASCIIToUTF16("address_streetname"), - form_structure->field(2)->parseable_name()); + EXPECT_EQ(u"address_streetname", form_structure->field(2)->parseable_name()); // Phone. - EXPECT_EQ(ASCIIToUTF16("address_housenumber"), - form_structure->field(3)->parseable_name()); + EXPECT_EQ(u"address_housenumber", form_structure->field(3)->parseable_name()); // Submit. - EXPECT_EQ(ASCIIToUTF16("address_apartmentnumber"), + EXPECT_EQ(u"address_apartmentnumber", form_structure->field(4)->parseable_name()); } @@ -1068,13 +1006,13 @@ TEST_F(FormStructureTestImpl, FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -1108,14 +1046,14 @@ TEST_F(FormStructureTestImpl, field.form_control_type = "text"; // Set a valid autocompelete attribute to the first field. - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; field.autocomplete_attribute = "given-name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; field.autocomplete_attribute = ""; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -1153,24 +1091,24 @@ TEST_F(FormStructureTestImpl, PasswordFormShouldBeQueried) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; field.autocomplete_attribute = "username"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Password"); - field.name = ASCIIToUTF16("Password"); + field.label = u"Password"; + field.name = u"Password"; field.form_control_type = "password"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -1355,22 +1293,22 @@ TEST_F(FormStructureTestImpl, FormFieldData field; field.form_control_type = "text"; - field.name = ASCIIToUTF16("one"); + field.name = u"one"; field.autocomplete_attribute = "address-line1"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.name = base::string16(); + field.name = std::u16string(); field.autocomplete_attribute = "section-foo email"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.name = base::string16(); + field.name = std::u16string(); field.autocomplete_attribute = "name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.name = ASCIIToUTF16("two"); + field.name = u"two"; field.autocomplete_attribute = "address-line1"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -1385,8 +1323,8 @@ TEST_F(FormStructureTestImpl, // Normally, the two separate address fields would cause us to detect two // separate sections; but because there is an author-specified section in this // form, we do not apply these usual heuristics. - EXPECT_EQ(ASCIIToUTF16("one"), form_structure.field(0)->name); - EXPECT_EQ(ASCIIToUTF16("two"), form_structure.field(3)->name); + EXPECT_EQ(u"one", form_structure.field(0)->name); + EXPECT_EQ(u"two", form_structure.field(3)->name); EXPECT_EQ(form_structure.field(0)->section, form_structure.field(3)->section); } @@ -1398,53 +1336,53 @@ TEST_F(FormStructureTestImpl, HeuristicsSample8) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Your First Name:"); - field.name = ASCIIToUTF16("bill.first"); + field.label = u"Your First Name:"; + field.name = u"bill.first"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Your Last Name:"); - field.name = ASCIIToUTF16("bill.last"); + field.label = u"Your Last Name:"; + field.name = u"bill.last"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Street Address Line 1:"); - field.name = ASCIIToUTF16("bill.street1"); + field.label = u"Street Address Line 1:"; + field.name = u"bill.street1"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Street Address Line 2:"); - field.name = ASCIIToUTF16("bill.street2"); + field.label = u"Street Address Line 2:"; + field.name = u"bill.street2"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("bill.city"); + field.label = u"City"; + field.name = u"bill.city"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State (U.S.):"); - field.name = ASCIIToUTF16("bill.state"); + field.label = u"State (U.S.):"; + field.name = u"bill.state"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Zip/Postal Code:"); - field.name = ASCIIToUTF16("BillTo.PostalCode"); + field.label = u"Zip/Postal Code:"; + field.name = u"BillTo.PostalCode"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country:"); - field.name = ASCIIToUTF16("bill.country"); + field.label = u"Country:"; + field.name = u"bill.country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone Number:"); - field.name = ASCIIToUTF16("BillTo.Phone"); + field.label = u"Phone Number:"; + field.name = u"BillTo.Phone"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = base::string16(); - field.name = ASCIIToUTF16("Submit"); + field.label = std::u16string(); + field.name = u"Submit"; field.form_control_type = "submit"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -1486,39 +1424,39 @@ TEST_F(FormStructureTestImpl, HeuristicsSample6) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("E-mail address"); - field.name = ASCIIToUTF16("email"); + field.label = u"E-mail address"; + field.name = u"email"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Full name"); - field.name = ASCIIToUTF16("name"); + field.label = u"Full name"; + field.name = u"name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Company"); - field.name = ASCIIToUTF16("company"); + field.label = u"Company"; + field.name = u"company"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Zip Code"); - field.name = ASCIIToUTF16("Home.PostalCode"); + field.label = u"Zip Code"; + field.name = u"Home.PostalCode"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = base::string16(); - field.name = ASCIIToUTF16("Submit"); - field.value = ASCIIToUTF16("continue"); + field.label = std::u16string(); + field.name = u"Submit"; + field.value = u"continue"; field.form_control_type = "submit"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -1556,43 +1494,43 @@ TEST_F(FormStructureTestImpl, HeuristicsLabelsOnly) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = base::string16(); + field.label = u"First Name"; + field.name = std::u16string(); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = base::string16(); + field.label = u"Last Name"; + field.name = std::u16string(); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Email"); - field.name = base::string16(); + field.label = u"Email"; + field.name = std::u16string(); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone"); - field.name = base::string16(); + field.label = u"Phone"; + field.name = std::u16string(); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = base::string16(); + field.label = u"Address"; + field.name = std::u16string(); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = base::string16(); + field.label = u"Address"; + field.name = std::u16string(); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Zip code"); - field.name = base::string16(); + field.label = u"Zip code"; + field.name = std::u16string(); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = base::string16(); - field.name = ASCIIToUTF16("Submit"); + field.label = std::u16string(); + field.name = u"Submit"; field.form_control_type = "submit"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -1630,33 +1568,33 @@ TEST_F(FormStructureTestImpl, HeuristicsCreditCardInfo) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Name on Card"); - field.name = ASCIIToUTF16("name_on_card"); + field.label = u"Name on Card"; + field.name = u"name_on_card"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Card Number"); - field.name = ASCIIToUTF16("card_number"); + field.label = u"Card Number"; + field.name = u"card_number"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Exp Month"); - field.name = ASCIIToUTF16("ccmonth"); + field.label = u"Exp Month"; + field.name = u"ccmonth"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Exp Year"); - field.name = ASCIIToUTF16("ccyear"); + field.label = u"Exp Year"; + field.name = u"ccyear"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Verification"); - field.name = ASCIIToUTF16("verification"); + field.label = u"Verification"; + field.name = u"verification"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = base::string16(); - field.name = ASCIIToUTF16("Submit"); + field.label = std::u16string(); + field.name = u"Submit"; field.form_control_type = "submit"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -1691,40 +1629,40 @@ TEST_F(FormStructureTestImpl, HeuristicsCreditCardInfoWithUnknownCardField) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Name on Card"); - field.name = ASCIIToUTF16("name_on_card"); + field.label = u"Name on Card"; + field.name = u"name_on_card"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); // This is not a field we know how to process. But we should skip over it // and process the other fields in the card block. - field.label = ASCIIToUTF16("Card image"); - field.name = ASCIIToUTF16("card_image"); + field.label = u"Card image"; + field.name = u"card_image"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Card Number"); - field.name = ASCIIToUTF16("card_number"); + field.label = u"Card Number"; + field.name = u"card_number"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Exp Month"); - field.name = ASCIIToUTF16("ccmonth"); + field.label = u"Exp Month"; + field.name = u"ccmonth"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Exp Year"); - field.name = ASCIIToUTF16("ccyear"); + field.label = u"Exp Year"; + field.name = u"ccyear"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Verification"); - field.name = ASCIIToUTF16("verification"); + field.label = u"Verification"; + field.name = u"verification"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = base::string16(); - field.name = ASCIIToUTF16("Submit"); + field.label = std::u16string(); + field.name = u"Submit"; field.form_control_type = "submit"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -1761,23 +1699,23 @@ TEST_F(FormStructureTestImpl, ThreeAddressLines) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Address Line1"); - field.name = ASCIIToUTF16("Address"); + field.label = u"Address Line1"; + field.name = u"Address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address Line2"); - field.name = ASCIIToUTF16("Address"); + field.label = u"Address Line2"; + field.name = u"Address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address Line3"); - field.name = ASCIIToUTF16("Address"); + field.label = u"Address Line3"; + field.name = u"Address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -1806,23 +1744,23 @@ TEST_F(FormStructureTestImpl, SurplusAddressLinesIgnored) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Address Line1"); - field.name = ASCIIToUTF16("shipping.address.addressLine1"); + field.label = u"Address Line1"; + field.name = u"shipping.address.addressLine1"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address Line2"); - field.name = ASCIIToUTF16("shipping.address.addressLine2"); + field.label = u"Address Line2"; + field.name = u"shipping.address.addressLine2"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address Line3"); - field.name = ASCIIToUTF16("billing.address.addressLine3"); + field.label = u"Address Line3"; + field.name = u"billing.address.addressLine3"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address Line4"); - field.name = ASCIIToUTF16("billing.address.addressLine4"); + field.label = u"Address Line4"; + field.name = u"billing.address.addressLine4"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -1854,23 +1792,23 @@ TEST_F(FormStructureTestImpl, ThreeAddressLinesExpedia) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Street:"); - field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_ads1"); + field.label = u"Street:"; + field.name = u"FOPIH_RgWebCC_0_IHAddress_ads1"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Suite or Apt:"); - field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adap"); + field.label = u"Suite or Apt:"; + field.name = u"FOPIH_RgWebCC_0_IHAddress_adap"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Street address second line"); - field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_ads2"); + field.label = u"Street address second line"; + field.name = u"FOPIH_RgWebCC_0_IHAddress_ads2"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City:"); - field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adct"); + field.label = u"City:"; + field.name = u"FOPIH_RgWebCC_0_IHAddress_adct"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -1901,18 +1839,18 @@ TEST_F(FormStructureTestImpl, TwoAddressLinesEbay) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Address Line1"); - field.name = ASCIIToUTF16("address1"); + field.label = u"Address Line1"; + field.name = u"address1"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Floor number, suite number, etc"); - field.name = ASCIIToUTF16("address2"); + field.label = u"Floor number, suite number, etc"; + field.name = u"address2"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City:"); - field.name = ASCIIToUTF16("city"); + field.label = u"City:"; + field.name = u"city"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -1938,18 +1876,18 @@ TEST_F(FormStructureTestImpl, HeuristicsStateWithProvince) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Address Line1"); - field.name = ASCIIToUTF16("Address"); + field.label = u"Address Line1"; + field.name = u"Address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address Line2"); - field.name = ASCIIToUTF16("Address"); + field.label = u"Address Line2"; + field.name = u"Address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State/Province/Region"); - field.name = ASCIIToUTF16("State"); + field.label = u"State/Province/Region"; + field.name = u"State"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -1976,58 +1914,58 @@ TEST_F(FormStructureTestImpl, HeuristicsWithBilling) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name*:"); - field.name = ASCIIToUTF16("editBillingAddress$firstNameBox"); + field.label = u"First Name*:"; + field.name = u"editBillingAddress$firstNameBox"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name*:"); - field.name = ASCIIToUTF16("editBillingAddress$lastNameBox"); + field.label = u"Last Name*:"; + field.name = u"editBillingAddress$lastNameBox"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Company Name:"); - field.name = ASCIIToUTF16("editBillingAddress$companyBox"); + field.label = u"Company Name:"; + field.name = u"editBillingAddress$companyBox"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address*:"); - field.name = ASCIIToUTF16("editBillingAddress$addressLine1Box"); + field.label = u"Address*:"; + field.name = u"editBillingAddress$addressLine1Box"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Apt/Suite :"); - field.name = ASCIIToUTF16("editBillingAddress$addressLine2Box"); + field.label = u"Apt/Suite :"; + field.name = u"editBillingAddress$addressLine2Box"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City*:"); - field.name = ASCIIToUTF16("editBillingAddress$cityBox"); + field.label = u"City*:"; + field.name = u"editBillingAddress$cityBox"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State/Province*:"); - field.name = ASCIIToUTF16("editBillingAddress$stateDropDown"); + field.label = u"State/Province*:"; + field.name = u"editBillingAddress$stateDropDown"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country*:"); - field.name = ASCIIToUTF16("editBillingAddress$countryDropDown"); + field.label = u"Country*:"; + field.name = u"editBillingAddress$countryDropDown"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Postal Code*:"); - field.name = ASCIIToUTF16("editBillingAddress$zipCodeBox"); + field.label = u"Postal Code*:"; + field.name = u"editBillingAddress$zipCodeBox"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone*:"); - field.name = ASCIIToUTF16("editBillingAddress$phoneBox"); + field.label = u"Phone*:"; + field.name = u"editBillingAddress$phoneBox"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Email Address*:"); - field.name = ASCIIToUTF16("email$emailBox"); + field.label = u"Email Address*:"; + field.name = u"email$emailBox"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -2059,28 +1997,28 @@ TEST_F(FormStructureTestImpl, ThreePartPhoneNumber) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Phone:"); - field.name = ASCIIToUTF16("dayphone1"); + field.label = u"Phone:"; + field.name = u"dayphone1"; field.max_length = 0; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("-"); - field.name = ASCIIToUTF16("dayphone2"); + field.label = u"-"; + field.name = u"dayphone2"; field.max_length = 3; // Size of prefix is 3. field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("-"); - field.name = ASCIIToUTF16("dayphone3"); + field.label = u"-"; + field.name = u"dayphone3"; field.max_length = 4; // Size of suffix is 4. If unlimited size is // passed, phone will be parsed as // <country code> - <area code> - <phone>. field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("ext.:"); - field.name = ASCIIToUTF16("dayphone4"); + field.label = u"ext.:"; + field.name = u"dayphone4"; field.max_length = 0; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -2109,28 +2047,28 @@ TEST_F(FormStructureTestImpl, HeuristicsInfernoCC) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Name on Card"); - field.name = ASCIIToUTF16("name_on_card"); + field.label = u"Name on Card"; + field.name = u"name_on_card"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("billing_address"); + field.label = u"Address"; + field.name = u"billing_address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Card Number"); - field.name = ASCIIToUTF16("card_number"); + field.label = u"Card Number"; + field.name = u"card_number"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Expiration Date"); - field.name = ASCIIToUTF16("expiration_month"); + field.label = u"Expiration Date"; + field.name = u"expiration_month"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Expiration Year"); - field.name = ASCIIToUTF16("expiration_year"); + field.label = u"Expiration Year"; + field.name = u"expiration_year"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -2165,33 +2103,33 @@ TEST_F(FormStructureTestImpl, HeuristicsInferCCNames_NamesNotFirst) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Card number"); - field.name = ASCIIToUTF16("ccnumber"); + field.label = u"Card number"; + field.name = u"ccnumber"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("First name"); - field.name = ASCIIToUTF16("first_name"); + field.label = u"First name"; + field.name = u"first_name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last name"); - field.name = ASCIIToUTF16("last_name"); + field.label = u"Last name"; + field.name = u"last_name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Expiration date"); - field.name = ASCIIToUTF16("ccexpiresmonth"); + field.label = u"Expiration date"; + field.name = u"ccexpiresmonth"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = base::string16(); - field.name = ASCIIToUTF16("ccexpiresyear"); + field.label = std::u16string(); + field.name = u"ccexpiresyear"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("cvc number"); - field.name = ASCIIToUTF16("csc"); + field.label = u"cvc number"; + field.name = u"csc"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -2230,33 +2168,33 @@ TEST_F(FormStructureTestImpl, HeuristicsInferCCNames_NamesFirst) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Cardholder Name"); - field.name = ASCIIToUTF16("cc_first_name"); + field.label = u"Cardholder Name"; + field.name = u"cc_first_name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last name"); - field.name = ASCIIToUTF16("last_name"); + field.label = u"Last name"; + field.name = u"last_name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Card number"); - field.name = ASCIIToUTF16("ccnumber"); + field.label = u"Card number"; + field.name = u"ccnumber"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Expiration date"); - field.name = ASCIIToUTF16("ccexpiresmonth"); + field.label = u"Expiration date"; + field.name = u"ccexpiresmonth"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = base::string16(); - field.name = ASCIIToUTF16("ccexpiresyear"); + field.label = std::u16string(); + field.name = u"ccexpiresyear"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("cvc number"); - field.name = ASCIIToUTF16("csc"); + field.label = u"cvc number"; + field.name = u"csc"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -2291,28 +2229,28 @@ TEST_F(FormStructureTestImpl, EncodeQueryRequest) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Name on Card"); - field.name = ASCIIToUTF16("name_on_card"); + field.label = u"Name on Card"; + field.name = u"name_on_card"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("billing_address"); + field.label = u"Address"; + field.name = u"billing_address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Card Number"); - field.name = ASCIIToUTF16("card_number"); + field.label = u"Card Number"; + field.name = u"card_number"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Expiration Date"); - field.name = ASCIIToUTF16("expiration_month"); + field.label = u"Expiration Date"; + field.name = u"expiration_month"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Expiration Year"); - field.name = ASCIIToUTF16("expiration_year"); + field.label = u"Expiration Year"; + field.name = u"expiration_year"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -2320,8 +2258,8 @@ TEST_F(FormStructureTestImpl, EncodeQueryRequest) { FormFieldData checkable_field; checkable_field.check_status = FormFieldData::CheckStatus::kCheckableButUnchecked; - checkable_field.label = ASCIIToUTF16("Checkable1"); - checkable_field.name = ASCIIToUTF16("Checkable1"); + checkable_field.label = u"Checkable1"; + checkable_field.name = u"Checkable1"; checkable_field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(checkable_field); @@ -2376,8 +2314,8 @@ TEST_F(FormStructureTestImpl, EncodeQueryRequest) { // Add 5 address fields - this should be still a valid form. for (size_t i = 0; i < 5; ++i) { - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); } @@ -2413,7 +2351,7 @@ TEST_F(FormStructureTestImpl, EncodeQueryRequest) { EXPECT_EQ(expected_query_string, encoded_query_string); // |form_structures4| will have the same signature as |form_structure3|. - form.fields.back().name = ASCIIToUTF16("address123456789"); + form.fields.back().name = u"address123456789"; FormStructure form_structure4(form); forms.push_back(&form_structure4); @@ -2433,8 +2371,8 @@ TEST_F(FormStructureTestImpl, EncodeQueryRequest) { // Add 300 address fields - the form is not valid anymore, but previous ones // are. The result should be the same as in previous test. for (size_t i = 0; i < 300; ++i) { - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); malformed_form.fields.push_back(field); } @@ -2558,24 +2496,24 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithMatchingValidities) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_FIRST}, {AutofillProfile::UNVALIDATED}); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_LAST}, {AutofillProfile::UNVALIDATED}); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; field.form_control_type = "email"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {EMAIL_ADDRESS}, @@ -2583,8 +2521,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithMatchingValidities) { field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("phone"); + field.label = u"Phone"; + field.name = u"phone"; field.form_control_type = "number"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, @@ -2592,8 +2530,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithMatchingValidities) { field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.form_control_type = "select-one"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, @@ -2605,8 +2543,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithMatchingValidities) { FormFieldData checkable_field; checkable_field.check_status = FormFieldData::CheckStatus::kCheckableButUnchecked; - checkable_field.label = ASCIIToUTF16("Checkable1"); - checkable_field.name = ASCIIToUTF16("Checkable1"); + checkable_field.label = u"Checkable1"; + checkable_field.name = u"Checkable1"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {ADDRESS_HOME_COUNTRY}, {AutofillProfile::VALID}); @@ -2697,8 +2635,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithMatchingValidities) { //////////////// // Add 2 address fields - this should be still a valid form. for (size_t i = 0; i < 2; ++i) { - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -2764,24 +2702,24 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithNonMatchingValidities) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_FIRST}, {AutofillProfile::UNVALIDATED}); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_LAST}, {AutofillProfile::UNVALIDATED}); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; field.form_control_type = "email"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {EMAIL_ADDRESS}, @@ -2789,8 +2727,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithNonMatchingValidities) { field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("phone"); + field.label = u"Phone"; + field.name = u"phone"; field.form_control_type = "number"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, @@ -2798,8 +2736,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithNonMatchingValidities) { field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.form_control_type = "select-one"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, @@ -2811,8 +2749,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithNonMatchingValidities) { FormFieldData checkable_field; checkable_field.check_status = FormFieldData::CheckStatus::kCheckableButUnchecked; - checkable_field.label = ASCIIToUTF16("Checkable1"); - checkable_field.name = ASCIIToUTF16("Checkable1"); + checkable_field.label = u"Checkable1"; + checkable_field.name = u"Checkable1"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {ADDRESS_HOME_COUNTRY}, {AutofillProfile::VALID}); @@ -2902,24 +2840,24 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithMultipleValidities) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_FIRST}, {AutofillProfile::UNVALIDATED, AutofillProfile::VALID}); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_LAST}, {AutofillProfile::UNVALIDATED, AutofillProfile::VALID}); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; field.form_control_type = "email"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {EMAIL_ADDRESS}, @@ -2927,8 +2865,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithMultipleValidities) { field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("phone"); + field.label = u"Phone"; + field.name = u"phone"; field.form_control_type = "number"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, @@ -2937,8 +2875,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithMultipleValidities) { field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.form_control_type = "select-one"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, @@ -2950,8 +2888,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithMultipleValidities) { FormFieldData checkable_field; checkable_field.check_status = FormFieldData::CheckStatus::kCheckableButUnchecked; - checkable_field.label = ASCIIToUTF16("Checkable1"); - checkable_field.name = ASCIIToUTF16("Checkable1"); + checkable_field.label = u"Checkable1"; + checkable_field.name = u"Checkable1"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {ADDRESS_HOME_COUNTRY}, {AutofillProfile::VALID, AutofillProfile::VALID}); @@ -3040,30 +2978,30 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_FIRST}); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_LAST}); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; field.form_control_type = "email"; test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {EMAIL_ADDRESS}); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("phone"); + field.label = u"Phone"; + field.name = u"phone"; field.form_control_type = "number"; test::InitializePossibleTypesAndValidities(possible_field_types, possible_field_types_validities, @@ -3071,8 +3009,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest) { field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.form_control_type = "select-one"; test::InitializePossibleTypesAndValidities(possible_field_types, possible_field_types_validities, @@ -3084,8 +3022,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest) { FormFieldData checkable_field; checkable_field.check_status = FormFieldData::CheckStatus::kCheckableButUnchecked; - checkable_field.label = ASCIIToUTF16("Checkable1"); - checkable_field.name = ASCIIToUTF16("Checkable1"); + checkable_field.label = u"Checkable1"; + checkable_field.name = u"Checkable1"; test::InitializePossibleTypesAndValidities(possible_field_types, possible_field_types_validities, {ADDRESS_HOME_COUNTRY}); @@ -3176,8 +3114,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest) { // Add 2 address fields - this should be still a valid form. for (size_t i = 0; i < 2; ++i) { - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -3234,8 +3172,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest) { // Add 300 address fields - now the form is invalid, as it has too many // fields. for (size_t i = 0; i < 300; ++i) { - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -3273,24 +3211,24 @@ TEST_F(FormStructureTestImpl, form_structure->DetermineHeuristicTypes(nullptr, nullptr); FormFieldData field; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; field.autocomplete_attribute = "given-name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_FIRST}); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; field.autocomplete_attribute = "family-name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_LAST}); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; field.form_control_type = "email"; field.autocomplete_attribute = "email"; field.unique_renderer_id = MakeFieldRendererId(); @@ -3298,16 +3236,16 @@ TEST_F(FormStructureTestImpl, test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {EMAIL_ADDRESS}); - field.label = ASCIIToUTF16("username"); - field.name = ASCIIToUTF16("username"); + field.label = u"username"; + field.name = u"username"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {USERNAME}); - field.label = ASCIIToUTF16("password"); - field.name = ASCIIToUTF16("password"); + field.label = u"password"; + field.name = u"password"; field.form_control_type = "password"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -3326,13 +3264,13 @@ TEST_F(FormStructureTestImpl, form_structure->field(i)->set_possible_types_validities( possible_field_types_validities[i]); - if (form_structure->field(i)->name == ASCIIToUTF16("password")) { + if (form_structure->field(i)->name == u"password") { form_structure->field(i)->set_generation_type( AutofillUploadContents::Field:: MANUALLY_TRIGGERED_GENERATION_ON_SIGN_UP_FORM); form_structure->field(i)->set_generated_password_changed(true); } - if (form_structure->field(i)->name == ASCIIToUTF16("username")) { + if (form_structure->field(i)->name == u"username") { form_structure->field(i)->set_vote_type( AutofillUploadContents::Field::CREDENTIALS_REUSED); } @@ -3413,24 +3351,24 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithAutocomplete) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; field.autocomplete_attribute = "given-name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_FIRST}); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; field.autocomplete_attribute = "family-name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_LAST}); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; field.form_control_type = "email"; field.autocomplete_attribute = "email"; field.unique_renderer_id = MakeFieldRendererId(); @@ -3503,24 +3441,24 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequestWithPropertiesMask) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; field.name_attribute = field.name; - field.id_attribute = ASCIIToUTF16("first_name"); + field.id_attribute = u"first_name"; field.autocomplete_attribute = "given-name"; - field.css_classes = ASCIIToUTF16("class1 class2"); + field.css_classes = u"class1 class2"; field.properties_mask = FieldPropertiesFlags::kHadFocus; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_FIRST}); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; field.name_attribute = field.name; - field.id_attribute = ASCIIToUTF16("last_name"); + field.id_attribute = u"last_name"; field.autocomplete_attribute = "family-name"; - field.css_classes = ASCIIToUTF16("class1 class2"); + field.css_classes = u"class1 class2"; field.properties_mask = FieldPropertiesFlags::kHadFocus | FieldPropertiesFlags::kUserTyped; field.unique_renderer_id = MakeFieldRendererId(); @@ -3528,13 +3466,13 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequestWithPropertiesMask) { test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_LAST}); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; field.name_attribute = field.name; - field.id_attribute = ASCIIToUTF16("e-mail"); + field.id_attribute = u"e-mail"; field.form_control_type = "email"; field.autocomplete_attribute = "email"; - field.css_classes = ASCIIToUTF16("class1 class2"); + field.css_classes = u"class1 class2"; field.properties_mask = FieldPropertiesFlags::kHadFocus | FieldPropertiesFlags::kUserTyped; field.unique_renderer_id = MakeFieldRendererId(); @@ -3612,24 +3550,24 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_ObservedSubmissionFalse) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; field.name_attribute = field.name; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_FIRST}); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; field.name_attribute = field.name; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_LAST}); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; field.name_attribute = field.name; field.form_control_type = "email"; field.unique_renderer_id = MakeFieldRendererId(); @@ -3708,13 +3646,13 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithLabels) { test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_FIRST}); - field.label = ASCIIToUTF16("Last Name"); + field.label = u"Last Name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_LAST}); - field.label = ASCIIToUTF16("Email"); + field.label = u"Email"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( @@ -3786,15 +3724,15 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithCssClassesAndIds) { test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_FIRST}); - field.css_classes = ASCIIToUTF16("last_name_field"); - field.id_attribute = ASCIIToUTF16("lastname_id"); + field.css_classes = u"last_name_field"; + field.id_attribute = u"lastname_id"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_LAST}); - field.css_classes = ASCIIToUTF16("email_field required_field"); - field.id_attribute = ASCIIToUTF16("email_id"); + field.css_classes = u"email_field required_field"; + field.id_attribute = u"email_id"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( @@ -3869,7 +3807,7 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithFormName) { form.is_form_tag = true; // Setting the form name which we expect to see in the upload. - form.name = ASCIIToUTF16("myform"); + form.name = u"myform"; form_structure = std::make_unique<FormStructure>(form); form_structure->DetermineHeuristicTypes(nullptr, nullptr); @@ -3966,8 +3904,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequestPartialMetadata) { test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_FIRST}); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; field.name_attribute = field.name; field.autocomplete_attribute = "family-name"; field.unique_renderer_id = MakeFieldRendererId(); @@ -3975,7 +3913,7 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequestPartialMetadata) { test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_LAST}); - field.label = ASCIIToUTF16("Email"); + field.label = u"Email"; field.form_control_type = "email"; field.autocomplete_attribute = "email"; field.unique_renderer_id = MakeFieldRendererId(); @@ -4050,35 +3988,35 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_DisabledMetadata) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstname"); + field.label = u"First Name"; + field.name = u"firstname"; field.name_attribute = field.name; - field.id_attribute = ASCIIToUTF16("first_name"); + field.id_attribute = u"first_name"; field.autocomplete_attribute = "given-name"; - field.css_classes = ASCIIToUTF16("class1 class2"); + field.css_classes = u"class1 class2"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_FIRST}); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastname"); + field.label = u"Last Name"; + field.name = u"lastname"; field.name_attribute = field.name; - field.id_attribute = ASCIIToUTF16("last_name"); + field.id_attribute = u"last_name"; field.autocomplete_attribute = "family-name"; - field.css_classes = ASCIIToUTF16("class1 class2"); + field.css_classes = u"class1 class2"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_LAST}); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; field.name_attribute = field.name; - field.id_attribute = ASCIIToUTF16("e-mail"); + field.id_attribute = u"e-mail"; field.form_control_type = "email"; field.autocomplete_attribute = "email"; - field.css_classes = ASCIIToUTF16("class1 class2"); + field.css_classes = u"class1 class2"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( @@ -4145,20 +4083,20 @@ TEST_F(FormStructureTestImpl, CheckDataPresence) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("first"); + field.label = u"First Name"; + field.name = u"first"; field.name_attribute = field.name; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("last"); + field.label = u"Last Name"; + field.name = u"last"; field.name_attribute = field.name; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Email"); - field.name = ASCIIToUTF16("email"); + field.label = u"Email"; + field.name = u"email"; field.name_attribute = field.name; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -4434,32 +4372,32 @@ TEST_F(FormStructureTestImpl, CheckMultipleTypes) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("email"); - field.name = ASCIIToUTF16("email"); + field.label = u"email"; + field.name = u"email"; field.name_attribute = field.name; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {EMAIL_ADDRESS}); - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("first"); + field.label = u"First Name"; + field.name = u"first"; field.name_attribute = field.name; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_FIRST}); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("last"); + field.label = u"Last Name"; + field.name = u"last"; field.name_attribute = field.name; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); test::InitializePossibleTypesAndValidities( possible_field_types, possible_field_types_validities, {NAME_LAST}); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.name_attribute = field.name; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -4584,17 +4522,17 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_PasswordsRevealed) { // Add 3 fields, to make the form uploadable. FormFieldData field; - field.name = ASCIIToUTF16("email"); + field.name = u"email"; field.name_attribute = field.name; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.name = ASCIIToUTF16("first"); + field.name = u"first"; field.name_attribute = field.name; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.name = ASCIIToUTF16("last"); + field.name = u"last"; field.name_attribute = field.name; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -4617,7 +4555,7 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_IsFormTag) { FormData form; form.url = GURL("http://www.foo.com/"); FormFieldData field; - field.name = ASCIIToUTF16("email"); + field.name = u"email"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -4656,11 +4594,10 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_RichMetadata) { }; FormData form; - form.id_attribute = ASCIIToUTF16("form-id"); + form.id_attribute = u"form-id"; form.url = GURL("http://www.foo.com/"); - form.button_titles = { - std::make_pair(ASCIIToUTF16("Submit"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; + form.button_titles = {std::make_pair( + u"Submit", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; form.full_url = GURL("http://www.foo.com/?foo=bar"); for (const auto& f : kFieldMetadata) { FormFieldData field; @@ -4805,15 +4742,15 @@ TEST_F(FormStructureTestImpl, Metadata_OnlySendFullUrlWithUserConsent) { SCOPED_TRACE(testing::Message() << " has_consent=" << has_consent); SetUpForEncoder(); FormData form; - form.id_attribute = ASCIIToUTF16("form-id"); + form.id_attribute = u"form-id"; form.url = GURL("http://www.foo.com/"); form.full_url = GURL("http://www.foo.com/?foo=bar"); // One form field needed to be valid form. FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("email"); - field.name = ASCIIToUTF16("email"); + field.label = u"email"; + field.name = u"email"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -4846,19 +4783,19 @@ TEST_F(FormStructureTestImpl, CheckFormSignature) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("email"); - field.name = ASCIIToUTF16("email"); + field.label = u"email"; + field.name = u"email"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("first"); + field.label = u"First Name"; + field.name = u"first"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); // Checkable fields shouldn't affect the signature. - field.label = ASCIIToUTF16("Select"); - field.name = ASCIIToUTF16("Select"); + field.label = u"Select"; + field.name = u"Select"; field.form_control_type = "checkbox"; field.check_status = FormFieldData::CheckStatus::kCheckableButUnchecked; field.unique_renderer_id = MakeFieldRendererId(); @@ -4881,7 +4818,7 @@ TEST_F(FormStructureTestImpl, CheckFormSignature) { std::string("https://login.facebook.com&&email&first")), form_structure->FormSignatureAsStr()); - form.name = ASCIIToUTF16("login_form"); + form.name = u"login_form"; form_structure = std::make_unique<FormStructure>(form); EXPECT_EQ(FormStructureTestImpl::Hash64Bit(std::string( "https://login.facebook.com&login_form&email&first")), @@ -4889,24 +4826,24 @@ TEST_F(FormStructureTestImpl, CheckFormSignature) { // Checks how digits are removed from field names. field.check_status = FormFieldData::CheckStatus::kNotCheckable; - field.label = ASCIIToUTF16("Random Field label"); - field.name = ASCIIToUTF16("random1234"); + field.label = u"Random Field label"; + field.name = u"random1234"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Random Field label2"); - field.name = ASCIIToUTF16("random12345"); + field.label = u"Random Field label2"; + field.name = u"random12345"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Random Field label3"); - field.name = ASCIIToUTF16("1ran12dom12345678"); + field.label = u"Random Field label3"; + field.name = u"1ran12dom12345678"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Random Field label3"); - field.name = ASCIIToUTF16("12345ran123456dom123"); + field.label = u"Random Field label3"; + field.name = u"12345ran123456dom123"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -4919,25 +4856,25 @@ TEST_F(FormStructureTestImpl, CheckFormSignature) { TEST_F(FormStructureTestImpl, ToFormData) { FormData form; - form.name = ASCIIToUTF16("the-name"); + form.name = u"the-name"; form.url = GURL("http://cool.com"); form.action = form.url.Resolve("/login"); FormFieldData field; - field.label = ASCIIToUTF16("username"); - field.name = ASCIIToUTF16("username"); + field.label = u"username"; + field.name = u"username"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("password"); - field.name = ASCIIToUTF16("password"); + field.label = u"password"; + field.name = u"password"; field.form_control_type = "password"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = base::string16(); - field.name = ASCIIToUTF16("Submit"); + field.label = std::u16string(); + field.name = u"Submit"; field.form_control_type = "submit"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -4947,26 +4884,26 @@ TEST_F(FormStructureTestImpl, ToFormData) { TEST_F(FormStructureTestImpl, SkipFieldTest) { FormData form; - form.name = ASCIIToUTF16("the-name"); + form.name = u"the-name"; form.url = GURL("http://cool.com"); form.action = form.url.Resolve("/login"); FormFieldData field; - field.label = ASCIIToUTF16("username"); - field.name = ASCIIToUTF16("username"); + field.label = u"username"; + field.name = u"username"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("select"); - field.name = ASCIIToUTF16("select"); + field.label = u"select"; + field.name = u"select"; field.form_control_type = "checkbox"; field.check_status = FormFieldData::CheckStatus::kCheckableButUnchecked; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = base::string16(); - field.name = ASCIIToUTF16("email"); + field.label = std::u16string(); + field.name = u"email"; field.form_control_type = "text"; field.check_status = FormFieldData::CheckStatus::kNotCheckable; field.unique_renderer_id = MakeFieldRendererId(); @@ -5004,25 +4941,25 @@ TEST_F(FormStructureTestImpl, SkipFieldTest) { TEST_F(FormStructureTestImpl, EncodeQueryRequest_WithLabels) { FormData form; - form.name = ASCIIToUTF16("the-name"); + form.name = u"the-name"; form.url = GURL("http://cool.com"); form.action = form.url.Resolve("/login"); FormFieldData field; // No label on the first field. - field.name = ASCIIToUTF16("username"); + field.name = u"username"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Enter your Email address"); - field.name = ASCIIToUTF16("email"); + field.label = u"Enter your Email address"; + field.name = u"email"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Enter your Password"); - field.name = ASCIIToUTF16("password"); + field.label = u"Enter your Password"; + field.name = u"password"; field.form_control_type = "password"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -5056,13 +4993,13 @@ TEST_F(FormStructureTestImpl, EncodeQueryRequest_WithLabels) { TEST_F(FormStructureTestImpl, EncodeQueryRequest_WithLongLabels) { FormData form; - form.name = ASCIIToUTF16("the-name"); + form.name = u"the-name"; form.url = GURL("http://cool.com"); form.action = form.url.Resolve("/login"); FormFieldData field; // No label on the first field. - field.name = ASCIIToUTF16("username"); + field.name = u"username"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -5073,13 +5010,13 @@ TEST_F(FormStructureTestImpl, EncodeQueryRequest_WithLongLabels) { "Hope To Get In Order To Send You Unwanted Publicity Because That's What " "Marketers Do! We Know That Your Email Address Has The Possibility Of " "Exceeding A Certain Number Of Characters..."); - field.name = ASCIIToUTF16("email"); + field.name = u"email"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Enter your Password"); - field.name = ASCIIToUTF16("password"); + field.label = u"Enter your Password"; + field.name = u"password"; field.form_control_type = "password"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -5119,15 +5056,15 @@ TEST_F(FormStructureTestImpl, EncodeQueryRequest_MissingNames) { form.action = form.url.Resolve("/login"); FormFieldData field; - field.label = ASCIIToUTF16("username"); - field.name = ASCIIToUTF16("username"); + field.label = u"username"; + field.name = u"username"; field.form_control_type = "text"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = base::string16(); + field.label = std::u16string(); // No name set for this field. - field.name = ASCIIToUTF16(""); + field.name = u""; field.form_control_type = "text"; field.check_status = FormFieldData::CheckStatus::kNotCheckable; field.unique_renderer_id = MakeFieldRendererId(); @@ -5170,12 +5107,12 @@ TEST_F(FormStructureTestImpl, PossibleValues) { FormFieldData field; field.autocomplete_attribute = "billing country"; - field.option_contents.push_back(ASCIIToUTF16("Down Under")); - field.option_values.push_back(ASCIIToUTF16("AU")); - field.option_contents.push_back(ASCIIToUTF16("Fr")); - field.option_values.push_back(ASCIIToUTF16("")); - field.option_contents.push_back(ASCIIToUTF16("Germany")); - field.option_values.push_back(ASCIIToUTF16("GRMNY")); + field.option_contents.push_back(u"Down Under"); + field.option_values.push_back(u"AU"); + field.option_contents.push_back(u"Fr"); + field.option_values.push_back(u""); + field.option_contents.push_back(u"Germany"); + field.option_values.push_back(u"GRMNY"); field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); @@ -5184,16 +5121,16 @@ TEST_F(FormStructureTestImpl, PossibleValues) { form_structure.ParseFieldTypesFromAutocompleteAttributes(); // All values in <option> value= or contents are returned, set to upper case. - std::set<base::string16> possible_values = + std::set<std::u16string> possible_values = form_structure.PossibleValues(ADDRESS_BILLING_COUNTRY); EXPECT_EQ(5U, possible_values.size()); - EXPECT_EQ(1U, possible_values.count(ASCIIToUTF16("AU"))); - EXPECT_EQ(1U, possible_values.count(ASCIIToUTF16("FR"))); - EXPECT_EQ(1U, possible_values.count(ASCIIToUTF16("DOWN UNDER"))); - EXPECT_EQ(1U, possible_values.count(ASCIIToUTF16("GERMANY"))); - EXPECT_EQ(1U, possible_values.count(ASCIIToUTF16("GRMNY"))); - EXPECT_EQ(0U, possible_values.count(ASCIIToUTF16("Fr"))); - EXPECT_EQ(0U, possible_values.count(ASCIIToUTF16("DE"))); + EXPECT_EQ(1U, possible_values.count(u"AU")); + EXPECT_EQ(1U, possible_values.count(u"FR")); + EXPECT_EQ(1U, possible_values.count(u"DOWN UNDER")); + EXPECT_EQ(1U, possible_values.count(u"GERMANY")); + EXPECT_EQ(1U, possible_values.count(u"GRMNY")); + EXPECT_EQ(0U, possible_values.count(u"Fr")); + EXPECT_EQ(0U, possible_values.count(u"DE")); // No field for the given type; empty value set. EXPECT_EQ(0U, form_structure.PossibleValues(ADDRESS_HOME_COUNTRY).size()); @@ -5218,16 +5155,16 @@ TEST_F(FormStructureTestImpl, ParseQueryResponse_ServerPredictionIsOverride) { field.form_control_type = "text"; // Just some field. - field.label = ASCIIToUTF16("some field"); - field.name = ASCIIToUTF16("some_field"); + field.label = u"some field"; + field.name = u"some_field"; // But this field has an autocomplete attribute. field.autocomplete_attribute = "name"; field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); // Some other field. - field.label = ASCIIToUTF16("some other field"); - field.name = ASCIIToUTF16("some_other_field"); + field.label = u"some other field"; + field.name = u"some_other_field"; // Which has the same attribute. field.autocomplete_attribute = "name"; field.unique_renderer_id = MakeFieldRendererId(); @@ -5327,22 +5264,22 @@ TEST_F(FormStructureTestImpl, field.form_control_type = "text"; // First name field. - field.label = ASCIIToUTF16("Nombre"); - field.name = ASCIIToUTF16("Nombre"); + field.label = u"Nombre"; + field.name = u"Nombre"; field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); // First last name field. // Should be identified by local heuristics. - field.label = ASCIIToUTF16("Apellido Paterno"); - field.name = ASCIIToUTF16("apellido_paterno"); + field.label = u"Apellido Paterno"; + field.name = u"apellido_paterno"; field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); // Second last name field. // Should be identified by local heuristics. - field.label = ASCIIToUTF16("Apellido Materno"); - field.name = ASCIIToUTF16("apellido materno"); + field.label = u"Apellido Materno"; + field.name = u"apellido materno"; field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); @@ -5413,26 +5350,26 @@ TEST_F(FormStructureTestImpl, field.form_control_type = "text"; // Field for the name. - field.label = ASCIIToUTF16("Name"); - field.name = ASCIIToUTF16("Name"); + field.label = u"Name"; + field.name = u"Name"; field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); // Field for the street name. - field.label = ASCIIToUTF16("Street Name"); - field.name = ASCIIToUTF16("street_name"); + field.label = u"Street Name"; + field.name = u"street_name"; field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); // Field for the house number. - field.label = ASCIIToUTF16("House Number"); - field.name = ASCIIToUTF16("house_number"); + field.label = u"House Number"; + field.name = u"house_number"; field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); // Field for the postal code. - field.label = ASCIIToUTF16("ZIP"); - field.name = ASCIIToUTF16("ZIP"); + field.label = u"ZIP"; + field.name = u"ZIP"; field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); @@ -5498,18 +5435,18 @@ TEST_F(FormStructureTestImpl, ParseQueryResponse_TooManyTypes) { form_data.url = GURL("http://foo.com"); field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("fname"); + field.label = u"First Name"; + field.name = u"fname"; field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lname"); + field.label = u"Last Name"; + field.name = u"lname"; field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); - field.label = ASCIIToUTF16("email"); - field.name = ASCIIToUTF16("email"); + field.label = u"email"; + field.name = u"email"; field.autocomplete_attribute = "address-level2"; field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); @@ -5572,18 +5509,18 @@ TEST_F(FormStructureTestImpl, ParseQueryResponse_UnknownType) { form_data.url = GURL("http://foo.com"); field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("fname"); + field.label = u"First Name"; + field.name = u"fname"; field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lname"); + field.label = u"Last Name"; + field.name = u"lname"; field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); - field.label = ASCIIToUTF16("email"); - field.name = ASCIIToUTF16("email"); + field.label = u"email"; + field.name = u"email"; field.autocomplete_attribute = "address-level2"; field.unique_renderer_id = MakeFieldRendererId(); form_data.fields.push_back(field); @@ -5634,19 +5571,19 @@ TEST_F(FormStructureTestImpl, ParseApiQueryResponse) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("fullname"); - field.name = ASCIIToUTF16("fullname"); + field.label = u"fullname"; + field.name = u"fullname"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("address"); - field.name = ASCIIToUTF16("address"); + field.label = u"address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); // Checkable fields should be ignored in parsing FormFieldData checkable_field; - checkable_field.label = ASCIIToUTF16("radio_button"); + checkable_field.label = u"radio_button"; checkable_field.form_control_type = "radio"; checkable_field.check_status = FormFieldData::CheckStatus::kCheckableButUnchecked; @@ -5659,13 +5596,13 @@ TEST_F(FormStructureTestImpl, ParseApiQueryResponse) { // Make form 2 data. FormData form2; - field.label = ASCIIToUTF16("email"); - field.name = ASCIIToUTF16("email"); + field.label = u"email"; + field.name = u"email"; field.unique_renderer_id = MakeFieldRendererId(); form2.fields.push_back(field); - field.label = ASCIIToUTF16("password"); - field.name = ASCIIToUTF16("password"); + field.label = u"password"; + field.name = u"password"; field.form_control_type = "password"; field.unique_renderer_id = MakeFieldRendererId(); form2.fields.push_back(field); @@ -5730,8 +5667,8 @@ TEST_F(FormStructureTestImpl, form.url = GURL("http://foo.com"); FormFieldData field; field.form_control_type = "email"; - field.label = ASCIIToUTF16("emailaddress"); - field.name = ASCIIToUTF16("emailaddress"); + field.label = u"emailaddress"; + field.name = u"emailaddress"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -5760,8 +5697,8 @@ TEST_F(FormStructureTestImpl, ParseApiQueryResponseWhenPayloadNotBase64) { form.url = GURL("http://foo.com"); FormFieldData field; field.form_control_type = "email"; - field.label = ASCIIToUTF16("emailaddress"); - field.name = ASCIIToUTF16("emailaddress"); + field.label = u"emailaddress"; + field.name = u"emailaddress"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -5800,15 +5737,15 @@ TEST_F(FormStructureTestImpl, ParseQueryResponse_AuthorDefinedTypes) { form.url = GURL("http://foo.com"); FormFieldData field; - field.label = ASCIIToUTF16("email"); - field.name = ASCIIToUTF16("email"); + field.label = u"email"; + field.name = u"email"; field.form_control_type = "text"; field.autocomplete_attribute = "email"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("password"); - field.name = ASCIIToUTF16("password"); + field.label = u"password"; + field.name = u"password"; field.form_control_type = "password"; field.autocomplete_attribute = "new-password"; field.unique_renderer_id = MakeFieldRendererId(); @@ -5845,23 +5782,23 @@ TEST_F(FormStructureTestImpl, ParseQueryResponse_RationalizeLoneField) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("fullname"); - field.name = ASCIIToUTF16("fullname"); + field.label = u"fullname"; + field.name = u"fullname"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("address"); - field.name = ASCIIToUTF16("address"); + field.label = u"address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("height"); - field.name = ASCIIToUTF16("height"); + field.label = u"height"; + field.name = u"height"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("email"); - field.name = ASCIIToUTF16("email"); + field.label = u"email"; + field.name = u"email"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -5896,18 +5833,18 @@ TEST_F(FormStructureTestImpl, ParseQueryResponse_RationalizeCCName) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("fname"); + field.label = u"First Name"; + field.name = u"fname"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lname"); + field.label = u"Last Name"; + field.name = u"lname"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("email"); - field.name = ASCIIToUTF16("email"); + field.label = u"email"; + field.name = u"email"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -5941,28 +5878,28 @@ TEST_F(FormStructureTestImpl, ParseQueryResponse_RationalizeMultiMonth_1) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Cardholder"); - field.name = ASCIIToUTF16("fullname"); + field.label = u"Cardholder"; + field.name = u"fullname"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Card Number"); - field.name = ASCIIToUTF16("address"); + field.label = u"Card Number"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Month)"); - field.name = ASCIIToUTF16("expiry_month"); + field.label = u"Month)"; + field.name = u"expiry_month"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Year"); - field.name = ASCIIToUTF16("expiry_year"); + field.label = u"Year"; + field.name = u"expiry_year"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Quantity"); - field.name = ASCIIToUTF16("quantity"); + field.label = u"Quantity"; + field.name = u"quantity"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -6005,23 +5942,23 @@ TEST_F(FormStructureTestImpl, ParseQueryResponse_RationalizeMultiMonth_2) { FormFieldData field; field.form_control_type = "text"; - field.label = ASCIIToUTF16("Cardholder"); - field.name = ASCIIToUTF16("fullname"); + field.label = u"Cardholder"; + field.name = u"fullname"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Card Number"); - field.name = ASCIIToUTF16("address"); + field.label = u"Card Number"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Expiry Date (MMYY)"); - field.name = ASCIIToUTF16("expiry"); + field.label = u"Expiry Date (MMYY)"; + field.name = u"expiry"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Quantity"); - field.name = ASCIIToUTF16("quantity"); + field.label = u"Quantity"; + field.name = u"quantity"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -6070,23 +6007,23 @@ TEST_P(ParameterizedFormStructureTest, field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Home Phone"); - field.name = ASCIIToUTF16("homePhoneNumber"); + field.label = u"Home Phone"; + field.name = u"homePhoneNumber"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Cell Phone"); - field.name = ASCIIToUTF16("cellPhoneNumber"); + field.label = u"Cell Phone"; + field.name = u"cellPhoneNumber"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -6109,9 +6046,12 @@ TEST_P(ParameterizedFormStructureTest, response_string, forms, test::GetEncodedSignatures(forms), nullptr); if (section_with_renderer_ids) { - EXPECT_FALSE(form_structure.phone_rationalized_["fullName_11-default"]); - form_structure.RationalizePhoneNumbersInSection("fullName_11-default"); - EXPECT_TRUE(form_structure.phone_rationalized_["fullName_11-default"]); + EXPECT_FALSE(form_structure.phone_rationalized_ + ["fullName_00000000000000000000000000000000_11-default"]); + form_structure.RationalizePhoneNumbersInSection( + "fullName_00000000000000000000000000000000_11-default"); + EXPECT_TRUE(form_structure.phone_rationalized_ + ["fullName_00000000000000000000000000000000_11-default"]); } else { EXPECT_FALSE(form_structure.phone_rationalized_["fullName_1-default"]); form_structure.RationalizePhoneNumbersInSection("fullName_1-default"); @@ -6138,18 +6078,18 @@ TEST_F(FormStructureTestImpl, RationalizeRepeatedFields_OneAddress) { field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -6188,23 +6128,23 @@ TEST_F(FormStructureTestImpl, RationalizeRepreatedFields_TwoAddresses) { field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -6245,28 +6185,28 @@ TEST_F(FormStructureTestImpl, RationalizeRepreatedFields_ThreeAddresses) { field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -6311,33 +6251,33 @@ TEST_F(FormStructureTestImpl, RationalizeRepreatedFields_FourAddresses) { field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -6388,38 +6328,38 @@ TEST_F(FormStructureTestImpl, field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.section = "Billing"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.section = "Billing"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.section = "Billing"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.section = "Shipping"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.section = "Shipping"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.section = "Shipping"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -6474,94 +6414,94 @@ TEST_F( field.max_length = 10000; // Shipping - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.section = "Shipping"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.section = "Shipping"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.section = "Shipping"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.section = "Shipping"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); // Billing - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.section = "Billing"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.section = "Billing"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.section = "Billing"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.section = "Billing"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.section = "Billing"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); // Work address (not realistic) - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.section = "Work"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.section = "Work"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.section = "Work"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.section = "Work"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.section = "Work"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.section = "Work"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -6642,33 +6582,33 @@ TEST_F(FormStructureTestImpl, field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -6723,49 +6663,49 @@ TEST_F( field.max_length = 10000; // Shipping - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); // Billing - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -6821,56 +6761,56 @@ TEST_F(FormStructureTestImpl, field.form_control_type = "text"; field.max_length = 10000; // First Section - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); // Second Section - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); // Third Section - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); // Fourth Section - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -6933,30 +6873,30 @@ TEST_F(FormStructureTestImpl, field.section = "shipping"; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); field.section = "billing"; - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country2"); + field.label = u"Country"; + field.name = u"country2"; field.form_control_type = "select-one"; field.is_focusable = false; // hidden field.unique_renderer_id = MakeFieldRendererId(); @@ -6964,27 +6904,27 @@ TEST_F(FormStructureTestImpl, field.is_focusable = true; // visible - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country2"); + field.label = u"Country"; + field.name = u"country2"; field.form_control_type = "select-one"; field.is_focusable = false; // hidden field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country2"); + field.label = u"Country"; + field.name = u"country2"; field.form_control_type = "select-one"; field.is_focusable = false; // hidden field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country2"); + field.label = u"Country"; + field.name = u"country2"; field.form_control_type = "select-one"; field.is_focusable = false; // hidden field.unique_renderer_id = MakeFieldRendererId(); @@ -6992,30 +6932,30 @@ TEST_F(FormStructureTestImpl, field.is_focusable = true; // visible - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); field.section = "billing-2"; - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -7080,13 +7020,13 @@ TEST_F(FormStructureTestImpl, field.form_control_type = "text"; field.max_length = 10000; // First Section - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.form_control_type = "select-one"; field.is_focusable = false; // hidden field.unique_renderer_id = MakeFieldRendererId(); @@ -7094,18 +7034,18 @@ TEST_F(FormStructureTestImpl, field.is_focusable = true; // visible - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country2"); + field.label = u"Country"; + field.name = u"country2"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("city"); - field.name = ASCIIToUTF16("City"); + field.label = u"city"; + field.name = u"City"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state2"); + field.label = u"State"; + field.name = u"state2"; field.form_control_type = "select-one"; field.role = FormFieldData::RoleAttribute::kPresentation; // hidden field.unique_renderer_id = MakeFieldRendererId(); @@ -7113,35 +7053,35 @@ TEST_F(FormStructureTestImpl, field.role = FormFieldData::RoleAttribute::kOther; // visible - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); // Second Section - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("city"); - field.name = ASCIIToUTF16("City"); + field.label = u"city"; + field.name = u"City"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); // Third Section - field.label = ASCIIToUTF16("city"); - field.name = ASCIIToUTF16("City"); + field.label = u"city"; + field.name = u"City"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state2"); + field.label = u"State"; + field.name = u"state2"; field.form_control_type = "select-one"; field.role = FormFieldData::RoleAttribute::kPresentation; // hidden field.unique_renderer_id = MakeFieldRendererId(); @@ -7149,18 +7089,18 @@ TEST_F(FormStructureTestImpl, field.role = FormFieldData::RoleAttribute::kOther; // visible - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country2"); + field.label = u"Country"; + field.name = u"country2"; field.form_control_type = "select-one"; field.is_focusable = false; // hidden field.unique_renderer_id = MakeFieldRendererId(); @@ -7239,20 +7179,20 @@ TEST_F(FormStructureTestImpl, field.section = "billing"; - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country2"); + field.label = u"Country"; + field.name = u"country2"; field.form_control_type = "select-one"; field.is_focusable = false; // hidden field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country3"); + field.label = u"Country"; + field.name = u"country3"; field.form_control_type = "select-one"; field.is_focusable = false; // hidden field.unique_renderer_id = MakeFieldRendererId(); @@ -7260,13 +7200,13 @@ TEST_F(FormStructureTestImpl, field.is_focusable = true; // visible - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -7308,20 +7248,20 @@ TEST_F(FormStructureTestImpl, field.section = "billing"; - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country2"); + field.label = u"Country"; + field.name = u"country2"; field.form_control_type = "select-one"; field.is_focusable = false; // hidden field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country3"); + field.label = u"Country"; + field.name = u"country3"; field.form_control_type = "select-one"; field.is_focusable = false; // hidden field.unique_renderer_id = MakeFieldRendererId(); @@ -7329,19 +7269,19 @@ TEST_F(FormStructureTestImpl, field.is_focusable = true; // visible - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state"); + field.label = u"State"; + field.name = u"state"; field.is_focusable = false; // hidden field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("State"); - field.name = ASCIIToUTF16("state2"); + field.label = u"State"; + field.name = u"state2"; field.is_focusable = true; // visible field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -7395,27 +7335,27 @@ TEST_F(ParameterizedFormStructureTest, field.should_autocomplete = false; // Autocomplete Off, with server data. - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstName"); + field.label = u"First Name"; + field.name = u"firstName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); // Autocomplete Off, without server data. - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastName"); + field.label = u"Last Name"; + field.name = u"lastName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); // Autocomplete On, with server data. field.should_autocomplete = true; - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); // Autocomplete On, without server data. - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -7461,23 +7401,23 @@ TEST_F(ParameterizedFormStructureTest, NoServerDataCCFields_CVC_NoOverwrite) { field.should_autocomplete = false; // All fields with autocomplete off and no server data. - field.label = ASCIIToUTF16("Cardholder Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Cardholder Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Credit Card Number"); - field.name = ASCIIToUTF16("cc-number"); + field.label = u"Credit Card Number"; + field.name = u"cc-number"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Expiration Date"); - field.name = ASCIIToUTF16("exp-date"); + field.label = u"Expiration Date"; + field.name = u"exp-date"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("CVC"); - field.name = ASCIIToUTF16("cvc"); + field.label = u"CVC"; + field.name = u"cvc"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -7527,23 +7467,23 @@ TEST_F(ParameterizedFormStructureTest, WithServerDataCCFields_CVC_NoOverwrite) { field.should_autocomplete = false; // All fields with autocomplete off and no server data. - field.label = ASCIIToUTF16("Cardholder Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Cardholder Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Credit Card Number"); - field.name = ASCIIToUTF16("cc-number"); + field.label = u"Credit Card Number"; + field.name = u"cc-number"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Expiration Date"); - field.name = ASCIIToUTF16("exp-date"); + field.label = u"Expiration Date"; + field.name = u"exp-date"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("CVC"); - field.name = ASCIIToUTF16("cvc"); + field.label = u"CVC"; + field.name = u"cvc"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -7622,23 +7562,23 @@ TEST_P(RationalizationFieldTypeFilterTest, Rationalization_Rules_Filter_Out) { field.should_autocomplete = true; // Just adding >=3 random fields to trigger rationalization. - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstName"); + field.label = u"First Name"; + field.name = u"firstName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastName"); + field.label = u"Last Name"; + field.name = u"lastName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Address"); - field.name = ASCIIToUTF16("address"); + field.label = u"Address"; + field.name = u"address"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Something under test"); - field.name = ASCIIToUTF16("tested-thing"); + field.label = u"Something under test"; + field.name = u"tested-thing"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -7688,23 +7628,23 @@ TEST_P(RationalizationFieldTypeRelationshipsTest, field.should_autocomplete = true; // Just adding >=3 random fields to trigger rationalization. - field.label = ASCIIToUTF16("First Name"); - field.name = ASCIIToUTF16("firstName"); + field.label = u"First Name"; + field.name = u"firstName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Last Name"); - field.name = ASCIIToUTF16("lastName"); + field.label = u"Last Name"; + field.name = u"lastName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Some field with required type"); - field.name = ASCIIToUTF16("some-name"); + field.label = u"Some field with required type"; + field.name = u"some-name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Something under test"); - field.name = ASCIIToUTF16("tested-thing"); + field.label = u"Something under test"; + field.name = u"tested-thing"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -7751,7 +7691,7 @@ TEST_F(FormStructureTestImpl, AllowBigForms) { // Check that the form with 250 fields are processed correctly. for (size_t i = 0; i < 250; ++i) { field.form_control_type = "text"; - field.name = ASCIIToUTF16("text") + base::NumberToString16(i); + field.name = u"text" + base::NumberToString16(i); field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); } @@ -7773,7 +7713,7 @@ TEST_F(FormStructureTestImpl, AllowBigForms) { TEST_F(FormStructureTestImpl, OneFieldPasswordFormShouldNotBeUpload) { FormData form; FormFieldData field; - field.name = ASCIIToUTF16("Password"); + field.name = u"Password"; field.form_control_type = "password"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -7817,33 +7757,33 @@ TEST_P(ParameterizedFormStructureTest, NoAutocompleteSectionNames) { field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("phone"); + field.label = u"Phone"; + field.name = u"phone"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("phone"); + field.label = u"Phone"; + field.name = u"phone"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -7864,12 +7804,18 @@ TEST_P(ParameterizedFormStructureTest, NoAutocompleteSectionNames) { ASSERT_EQ(6U, form_structure.field_count()); if (section_with_renderer_ids) { - EXPECT_EQ("fullName_11-default", form_structure.field(0)->section); - EXPECT_EQ("fullName_11-default", form_structure.field(1)->section); - EXPECT_EQ("fullName_11-default", form_structure.field(2)->section); - EXPECT_EQ("fullName_14-default", form_structure.field(3)->section); - EXPECT_EQ("fullName_14-default", form_structure.field(4)->section); - EXPECT_EQ("fullName_14-default", form_structure.field(5)->section); + EXPECT_EQ("fullName_00000000000000000000000000000000_11-default", + form_structure.field(0)->section); + EXPECT_EQ("fullName_00000000000000000000000000000000_11-default", + form_structure.field(1)->section); + EXPECT_EQ("fullName_00000000000000000000000000000000_11-default", + form_structure.field(2)->section); + EXPECT_EQ("fullName_00000000000000000000000000000000_14-default", + form_structure.field(3)->section); + EXPECT_EQ("fullName_00000000000000000000000000000000_14-default", + form_structure.field(4)->section); + EXPECT_EQ("fullName_00000000000000000000000000000000_14-default", + form_structure.field(5)->section); } else { EXPECT_EQ("fullName_1-default", form_structure.field(0)->section); EXPECT_EQ("fullName_1-default", form_structure.field(1)->section); @@ -7892,41 +7838,41 @@ TEST_F(FormStructureTestImpl, NoSplitByRecurringPhoneFieldType) { field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("phone"); + field.label = u"Phone"; + field.name = u"phone"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Mobile Number"); - field.name = ASCIIToUTF16("mobileNumber"); + field.label = u"Mobile Number"; + field.name = u"mobileNumber"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.autocomplete_attribute = "section-blue billing name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("phone"); + field.label = u"Phone"; + field.name = u"phone"; field.autocomplete_attribute = "section-blue billing tel"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Mobile Number"); - field.name = ASCIIToUTF16("mobileNumber"); + field.label = u"Mobile Number"; + field.name = u"mobileNumber"; field.autocomplete_attribute = "section-blue billing tel"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -7974,26 +7920,26 @@ TEST_P(ParameterizedFormStructureTest, SplitByRecurringFieldType) { field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.autocomplete_attribute = "section-blue shipping name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.autocomplete_attribute = "section-blue shipping country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.autocomplete_attribute = "section-blue shipping name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.autocomplete_attribute = ""; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -8016,7 +7962,8 @@ TEST_P(ParameterizedFormStructureTest, SplitByRecurringFieldType) { EXPECT_EQ("blue-shipping-default", form_structure.field(1)->section); EXPECT_EQ("blue-shipping-default", form_structure.field(2)->section); if (section_with_renderer_ids) { - EXPECT_EQ("country_14-default", form_structure.field(3)->section); + EXPECT_EQ("country_00000000000000000000000000000000_14-default", + form_structure.field(3)->section); } else { EXPECT_EQ("country_2-default", form_structure.field(3)->section); } @@ -8042,26 +7989,26 @@ TEST_P(ParameterizedFormStructureTest, field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.autocomplete_attribute = "section-blue shipping name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.autocomplete_attribute = "section-blue billing country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.autocomplete_attribute = ""; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.autocomplete_attribute = ""; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -8085,7 +8032,8 @@ TEST_P(ParameterizedFormStructureTest, EXPECT_EQ("blue-billing-default", form_structure.field(1)->section); EXPECT_EQ("blue-billing-default", form_structure.field(2)->section); if (section_with_renderer_ids) { - EXPECT_EQ("country_14-default", form_structure.field(3)->section); + EXPECT_EQ("country_00000000000000000000000000000000_14-default", + form_structure.field(3)->section); } else { EXPECT_EQ("country_2-default", form_structure.field(3)->section); } @@ -8103,26 +8051,26 @@ TEST_F(FormStructureTestImpl, SplitByNewAutocompleteSectionName) { field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.autocomplete_attribute = "section-blue shipping name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.autocomplete_attribute = ""; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.autocomplete_attribute = "section-blue billing name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.autocomplete_attribute = ""; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -8162,25 +8110,25 @@ TEST_F( field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.autocomplete_attribute = "section-blue shipping country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.autocomplete_attribute = "section-blue billing name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("City"); - field.name = ASCIIToUTF16("city"); + field.label = u"City"; + field.name = u"city"; field.autocomplete_attribute = ""; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -8218,13 +8166,13 @@ TEST_F(FormStructureTestImpl, FromEmptyAutocompleteSectionToDefinedOne) { field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.autocomplete_attribute = "section-blue shipping country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); @@ -8259,19 +8207,19 @@ TEST_F(FormStructureTestImpl, field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Phone"); - field.name = ASCIIToUTF16("phone"); + field.label = u"Phone"; + field.name = u"phone"; field.is_focusable = false; // hidden field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("FullName"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"FullName"; + field.name = u"fullName"; field.is_focusable = true; // visible field.autocomplete_attribute = "shipping name"; field.unique_renderer_id = MakeFieldRendererId(); @@ -8308,14 +8256,14 @@ TEST_F(FormStructureTestImpl, IgnoreAribtraryAutocompleteSectionName) { field.form_control_type = "text"; field.max_length = 10000; - field.label = ASCIIToUTF16("Full Name"); - field.name = ASCIIToUTF16("fullName"); + field.label = u"Full Name"; + field.name = u"fullName"; field.autocomplete_attribute = "section-red ship name"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); - field.label = ASCIIToUTF16("Country"); - field.name = ASCIIToUTF16("country"); + field.label = u"Country"; + field.name = u"country"; field.autocomplete_attribute = "section-blue shipping country"; field.unique_renderer_id = MakeFieldRendererId(); form.fields.push_back(field); diff --git a/chromium/components/autofill/core/browser/geo/address_i18n.cc b/chromium/components/autofill/core/browser/geo/address_i18n.cc index d02f02c6a89..3843023f34c 100644 --- a/chromium/components/autofill/core/browser/geo/address_i18n.cc +++ b/chromium/components/autofill/core/browser/geo/address_i18n.cc @@ -19,7 +19,7 @@ namespace i18n { namespace { -base::string16 GetInfoHelper(const AutofillProfile& profile, +std::u16string GetInfoHelper(const AutofillProfile& profile, const std::string& app_locale, const AutofillType& type) { return profile.GetInfo(type, app_locale); @@ -31,7 +31,7 @@ using ::i18n::addressinput::AddressData; using ::i18n::addressinput::AddressField; std::unique_ptr<AddressData> CreateAddressData( - const base::RepeatingCallback<base::string16(const AutofillType&)>& + const base::RepeatingCallback<std::u16string(const AutofillType&)>& get_info) { auto address_data = std::make_unique<AddressData>(); address_data->recipient = diff --git a/chromium/components/autofill/core/browser/geo/address_i18n.h b/chromium/components/autofill/core/browser/geo/address_i18n.h index 87e25a534a4..16b5cc8db89 100644 --- a/chromium/components/autofill/core/browser/geo/address_i18n.h +++ b/chromium/components/autofill/core/browser/geo/address_i18n.h @@ -6,9 +6,9 @@ #define COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_ADDRESS_I18N_H_ #include <memory> +#include <string> #include "base/callback_forward.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/field_types.h" #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_field.h" @@ -28,7 +28,7 @@ namespace i18n { // Creates an AddressData object for internationalized address display or // validation using |get_info| for field values. std::unique_ptr<::i18n::addressinput::AddressData> CreateAddressData( - const base::RepeatingCallback<base::string16(const AutofillType&)>& + const base::RepeatingCallback<std::u16string(const AutofillType&)>& get_info); // Creates an |AddressData| from |profile|. diff --git a/chromium/components/autofill/core/browser/geo/alternative_state_name_map.cc b/chromium/components/autofill/core/browser/geo/alternative_state_name_map.cc index 614000521de..a6c9e3ad499 100644 --- a/chromium/components/autofill/core/browser/geo/alternative_state_name_map.cc +++ b/chromium/components/autofill/core/browser/geo/alternative_state_name_map.cc @@ -30,7 +30,7 @@ AlternativeStateNameMap* AlternativeStateNameMap::GetInstance() { // static AlternativeStateNameMap::StateName AlternativeStateNameMap::NormalizeStateName( const StateName& text) { - base::string16 normalized_text; + std::u16string normalized_text; base::RemoveChars(text.value(), base::ASCIIToUTF16(kCharsToStrip), &normalized_text); return StateName(normalized_text); @@ -40,7 +40,7 @@ AlternativeStateNameMap::StateName AlternativeStateNameMap::NormalizeStateName( base::Optional<AlternativeStateNameMap::CanonicalStateName> AlternativeStateNameMap::GetCanonicalStateName( const std::string& country_code, - const base::string16& state_name) { + const std::u16string& state_name) { return AlternativeStateNameMap::GetInstance()->GetCanonicalStateName( AlternativeStateNameMap::CountryCode(country_code), AlternativeStateNameMap::StateName(state_name)); diff --git a/chromium/components/autofill/core/browser/geo/alternative_state_name_map.h b/chromium/components/autofill/core/browser/geo/alternative_state_name_map.h index 5af1556d6ec..0b3687e2aee 100644 --- a/chromium/components/autofill/core/browser/geo/alternative_state_name_map.h +++ b/chromium/components/autofill/core/browser/geo/alternative_state_name_map.h @@ -5,13 +5,14 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_ALTERNATIVE_STATE_NAME_MAP_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_ALTERNATIVE_STATE_NAME_MAP_H_ +#include <string> + #include "components/autofill/core/browser/proto/states.pb.h" #include "base/i18n/case_conversion.h" #include "base/no_destructor.h" #include "base/optional.h" #include "base/sequence_checker.h" -#include "base/strings/string16.h" #include "base/types/strong_alias.h" namespace autofill { @@ -71,13 +72,13 @@ class AlternativeStateNameMap { // Represents either a canonical state name, or an abbreviation, or an // alternative name or normalized state name from the profile. - using StateName = base::StrongAlias<class StateNameTag, base::string16>; + using StateName = base::StrongAlias<class StateNameTag, std::u16string>; // States can be represented as different strings (different spellings, // translations, abbreviations). All representations of a single state in a // single country are mapped to the same canonical name. using CanonicalStateName = - base::StrongAlias<class CanonicalStateNameTag, base::string16>; + base::StrongAlias<class CanonicalStateNameTag, std::u16string>; static AlternativeStateNameMap* GetInstance(); @@ -89,7 +90,7 @@ class AlternativeStateNameMap { // |state_name| if present. static base::Optional<AlternativeStateNameMap::CanonicalStateName> GetCanonicalStateName(const std::string& country_code, - const base::string16& state_name); + const std::u16string& state_name); ~AlternativeStateNameMap() = delete; AlternativeStateNameMap(const AlternativeStateNameMap&) = delete; diff --git a/chromium/components/autofill/core/browser/geo/alternative_state_name_map_unittest.cc b/chromium/components/autofill/core/browser/geo/alternative_state_name_map_unittest.cc index 04523a93b18..15cea81e118 100644 --- a/chromium/components/autofill/core/browser/geo/alternative_state_name_map_unittest.cc +++ b/chromium/components/autofill/core/browser/geo/alternative_state_name_map_unittest.cc @@ -34,14 +34,11 @@ TEST(AlternativeStateNameMapTest, StateCanonicalString) { base::nullopt); } - EXPECT_EQ(AlternativeStateNameMap::GetCanonicalStateName( - "US", base::ASCIIToUTF16("Bavaria")), + EXPECT_EQ(AlternativeStateNameMap::GetCanonicalStateName("US", u"Bavaria"), base::nullopt); - EXPECT_EQ(AlternativeStateNameMap::GetCanonicalStateName( - "DE", base::ASCIIToUTF16("")), + EXPECT_EQ(AlternativeStateNameMap::GetCanonicalStateName("DE", u""), base::nullopt); - EXPECT_EQ(AlternativeStateNameMap::GetCanonicalStateName( - "", base::ASCIIToUTF16("")), + EXPECT_EQ(AlternativeStateNameMap::GetCanonicalStateName("", u""), base::nullopt); } @@ -51,11 +48,9 @@ TEST(AlternativeStateNameMapTest, SeparateEntryForDifferentCounties) { test::ClearAlternativeStateNameMapForTesting(); test::PopulateAlternativeStateNameMapForTesting("DE"); test::PopulateAlternativeStateNameMapForTesting("US"); - EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName( - "DE", base::ASCIIToUTF16("Bavaria")), + EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName("DE", u"Bavaria"), base::nullopt); - EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName( - "US", base::ASCIIToUTF16("Bavaria")), + EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName("US", u"Bavaria"), base::nullopt); } @@ -86,14 +81,13 @@ TEST(AlternativeStateNameMapTest, GetEntry) { test::PopulateAlternativeStateNameMapForTesting(); AlternativeStateNameMap* alternative_state_name_map = AlternativeStateNameMap::GetInstance(); - EXPECT_EQ( - alternative_state_name_map->GetEntry( - AlternativeStateNameMap::CountryCode("DE"), - AlternativeStateNameMap::StateName(base::ASCIIToUTF16("Random"))), - base::nullopt); + EXPECT_EQ(alternative_state_name_map->GetEntry( + AlternativeStateNameMap::CountryCode("DE"), + AlternativeStateNameMap::StateName(u"Random")), + base::nullopt); auto entry = alternative_state_name_map->GetEntry( AlternativeStateNameMap::CountryCode("DE"), - AlternativeStateNameMap::StateName(base::ASCIIToUTF16("Bavaria"))); + AlternativeStateNameMap::StateName(u"Bavaria")); EXPECT_NE(entry, base::nullopt); ASSERT_TRUE(entry->has_canonical_name()); EXPECT_EQ(entry->canonical_name(), "Bavaria"); diff --git a/chromium/components/autofill/core/browser/geo/alternative_state_name_map_updater_unittest.cc b/chromium/components/autofill/core/browser/geo/alternative_state_name_map_updater_unittest.cc index 7633ea97630..3a520a2f1e5 100644 --- a/chromium/components/autofill/core/browser/geo/alternative_state_name_map_updater_unittest.cc +++ b/chromium/components/autofill/core/browser/geo/alternative_state_name_map_updater_unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "components/autofill/core/browser/geo/alternative_state_name_map_updater.h" +#include "base/callback_helpers.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" @@ -94,14 +95,14 @@ TEST_F(AlternativeStateNameMapUpdaterTest, EntryAddedToStateMap) { test::ClearAlternativeStateNameMapForTesting(); std::string states_data = test::CreateStatesProtoAsString(); std::vector<AlternativeStateNameMap::StateName> test_strings = { - AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria")), - AlternativeStateNameMap::StateName(ASCIIToUTF16("Bayern")), - AlternativeStateNameMap::StateName(ASCIIToUTF16("B.Y")), - AlternativeStateNameMap::StateName(ASCIIToUTF16("Bav-aria")), - AlternativeStateNameMap::StateName(UTF8ToUTF16("amapá")), - AlternativeStateNameMap::StateName(ASCIIToUTF16("Broen")), - AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria is in Germany")), - AlternativeStateNameMap::StateName(ASCIIToUTF16("BA is in Germany"))}; + AlternativeStateNameMap::StateName(u"Bavaria"), + AlternativeStateNameMap::StateName(u"Bayern"), + AlternativeStateNameMap::StateName(u"B.Y"), + AlternativeStateNameMap::StateName(u"Bav-aria"), + AlternativeStateNameMap::StateName(u"amapá"), + AlternativeStateNameMap::StateName(u"Broen"), + AlternativeStateNameMap::StateName(u"Bavaria is in Germany"), + AlternativeStateNameMap::StateName(u"BA is in Germany")}; std::vector<bool> state_data_present = {true, true, true, true, false, false, false, false}; @@ -128,15 +129,14 @@ TEST_F(AlternativeStateNameMapUpdaterTest, TestLoadStatesData) { WritePathToPref(GetPath()); CountryToStateNamesListMapping country_to_state_names_list_mapping = { {AlternativeStateNameMap::CountryCode("DE"), - {AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria"))}}}; + {AlternativeStateNameMap::StateName(u"Bavaria")}}}; base::RunLoop run_loop; alternative_state_name_map_updater_->LoadStatesDataForTesting( country_to_state_names_list_mapping, autofill_client_.GetPrefs(), run_loop.QuitClosure()); run_loop.Run(); - EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName( - "DE", ASCIIToUTF16("Bavaria")), + EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName("DE", u"Bavaria"), base::nullopt); } @@ -152,7 +152,7 @@ TEST_F(AlternativeStateNameMapUpdaterTest, NoTaskIsPosted) { CountryToStateNamesListMapping country_to_state_names_list_mapping = { {AlternativeStateNameMap::CountryCode("DEE"), - {AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria"))}}}; + {AlternativeStateNameMap::StateName(u"Bavaria")}}}; base::RunLoop run_loop; alternative_state_name_map_updater_->LoadStatesDataForTesting( country_to_state_names_list_mapping, autofill_client_.GetPrefs(), @@ -178,7 +178,7 @@ TEST_F(AlternativeStateNameMapUpdaterTest, TestLoadStatesDataUTF8) { CountryToStateNamesListMapping country_to_state_names_list_mapping = { {AlternativeStateNameMap::CountryCode("ES"), - {AlternativeStateNameMap::StateName(ASCIIToUTF16("Parana"))}}}; + {AlternativeStateNameMap::StateName(u"Parana")}}}; base::RunLoop run_loop; alternative_state_name_map_updater_->LoadStatesDataForTesting( @@ -189,7 +189,7 @@ TEST_F(AlternativeStateNameMapUpdaterTest, TestLoadStatesDataUTF8) { base::Optional<StateEntry> entry1 = AlternativeStateNameMap::GetInstance()->GetEntry( AlternativeStateNameMap::CountryCode("ES"), - AlternativeStateNameMap::StateName(UTF8ToUTF16("Paraná"))); + AlternativeStateNameMap::StateName(u"Paraná")); EXPECT_NE(entry1, base::nullopt); EXPECT_EQ(entry1->canonical_name(), "Paraná"); EXPECT_THAT(entry1->abbreviations(), @@ -200,7 +200,7 @@ TEST_F(AlternativeStateNameMapUpdaterTest, TestLoadStatesDataUTF8) { base::Optional<StateEntry> entry2 = AlternativeStateNameMap::GetInstance()->GetEntry( AlternativeStateNameMap::CountryCode("ES"), - AlternativeStateNameMap::StateName(UTF8ToUTF16("Parana"))); + AlternativeStateNameMap::StateName(u"Parana")); EXPECT_NE(entry2, base::nullopt); EXPECT_EQ(entry2->canonical_name(), "Paraná"); EXPECT_THAT(entry2->abbreviations(), @@ -228,9 +228,9 @@ TEST_F(AlternativeStateNameMapUpdaterTest, CountryToStateNamesListMapping country_to_state_names = { {AlternativeStateNameMap::CountryCode("ES"), - {AlternativeStateNameMap::StateName(ASCIIToUTF16("Parana"))}}, + {AlternativeStateNameMap::StateName(u"Parana")}}, {AlternativeStateNameMap::CountryCode("DE"), - {AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria"))}}}; + {AlternativeStateNameMap::StateName(u"Bavaria")}}}; base::RunLoop run_loop; alternative_state_name_map_updater_->LoadStatesDataForTesting( @@ -241,7 +241,7 @@ TEST_F(AlternativeStateNameMapUpdaterTest, base::Optional<StateEntry> entry1 = AlternativeStateNameMap::GetInstance()->GetEntry( AlternativeStateNameMap::CountryCode("ES"), - AlternativeStateNameMap::StateName(UTF8ToUTF16("Paraná"))); + AlternativeStateNameMap::StateName(u"Paraná")); EXPECT_NE(entry1, base::nullopt); EXPECT_EQ(entry1->canonical_name(), "Paraná"); EXPECT_THAT(entry1->abbreviations(), @@ -252,7 +252,7 @@ TEST_F(AlternativeStateNameMapUpdaterTest, base::Optional<StateEntry> entry2 = AlternativeStateNameMap::GetInstance()->GetEntry( AlternativeStateNameMap::CountryCode("DE"), - AlternativeStateNameMap::StateName(UTF8ToUTF16("Bavaria"))); + AlternativeStateNameMap::StateName(u"Bavaria")); EXPECT_NE(entry2, base::nullopt); EXPECT_EQ(entry2->canonical_name(), "Bavaria"); EXPECT_THAT(entry2->abbreviations(), @@ -264,15 +264,15 @@ TEST_F(AlternativeStateNameMapUpdaterTest, // Tests the |StateNameMapUpdater::ContainsState()| functionality. TEST_F(AlternativeStateNameMapUpdaterTest, ContainsState) { EXPECT_TRUE(AlternativeStateNameMapUpdater::ContainsStateForTesting( - {AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria")), - AlternativeStateNameMap::StateName(ASCIIToUTF16("Bayern")), - AlternativeStateNameMap::StateName(ASCIIToUTF16("BY"))}, - AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria")))); + {AlternativeStateNameMap::StateName(u"Bavaria"), + AlternativeStateNameMap::StateName(u"Bayern"), + AlternativeStateNameMap::StateName(u"BY")}, + AlternativeStateNameMap::StateName(u"Bavaria"))); EXPECT_FALSE(AlternativeStateNameMapUpdater::ContainsStateForTesting( - {AlternativeStateNameMap::StateName(ASCIIToUTF16("Bavaria")), - AlternativeStateNameMap::StateName(ASCIIToUTF16("Bayern")), - AlternativeStateNameMap::StateName(ASCIIToUTF16("BY"))}, - AlternativeStateNameMap::StateName(ASCIIToUTF16("California")))); + {AlternativeStateNameMap::StateName(u"Bavaria"), + AlternativeStateNameMap::StateName(u"Bayern"), + AlternativeStateNameMap::StateName(u"BY")}, + AlternativeStateNameMap::StateName(u"California"))); } // Tests that the |AlternativeStateNameMap| is populated with the help of the @@ -286,8 +286,8 @@ TEST_F(AlternativeStateNameMapUpdaterTest, test::CreateStatesProtoAsString()); AutofillProfile profile; - profile.SetInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("Bavaria"), "en-US"); - profile.SetInfo(ADDRESS_HOME_COUNTRY, base::ASCIIToUTF16("DE"), "en-US"); + profile.SetInfo(ADDRESS_HOME_STATE, u"Bavaria", "en-US"); + profile.SetInfo(ADDRESS_HOME_COUNTRY, u"DE", "en-US"); base::RunLoop run_loop; MockAlternativeStateNameMapUpdater mock_alternative_state_name_updater( @@ -300,10 +300,8 @@ TEST_F(AlternativeStateNameMapUpdaterTest, EXPECT_FALSE( AlternativeStateNameMap::GetInstance()->IsLocalisedStateNamesMapEmpty()); - EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName( - "DE", base::ASCIIToUTF16("Bavaria")), - AlternativeStateNameMap::CanonicalStateName( - base::ASCIIToUTF16("Bayern"))); + EXPECT_NE(AlternativeStateNameMap::GetCanonicalStateName("DE", u"Bavaria"), + AlternativeStateNameMap::CanonicalStateName(u"Bayern")); } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/geo/autofill_country.cc b/chromium/components/autofill/core/browser/geo/autofill_country.cc index b415b59908b..2dc8e9792c0 100644 --- a/chromium/components/autofill/core/browser/geo/autofill_country.cc +++ b/chromium/components/autofill/core/browser/geo/autofill_country.cc @@ -75,9 +75,9 @@ const std::string AutofillCountry::CountryCodeForLocale( } AutofillCountry::AutofillCountry(const std::string& country_code, - const base::string16& name, - const base::string16& postal_code_label, - const base::string16& state_label) + const std::u16string& name, + const std::u16string& postal_code_label, + const std::u16string& state_label) : country_code_(country_code), name_(name) {} // Prints a formatted log of a |AutofillCountry| to a |LogBuffer|. diff --git a/chromium/components/autofill/core/browser/geo/autofill_country.h b/chromium/components/autofill/core/browser/geo/autofill_country.h index c1d3a3eb1b7..eaab92d0328 100644 --- a/chromium/components/autofill/core/browser/geo/autofill_country.h +++ b/chromium/components/autofill/core/browser/geo/autofill_country.h @@ -9,7 +9,6 @@ #include <vector> #include "base/macros.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/geo/country_data.h" namespace autofill { @@ -30,7 +29,7 @@ class AutofillCountry { static const std::string CountryCodeForLocale(const std::string& locale); const std::string& country_code() const { return country_code_; } - const base::string16& name() const { return name_; } + const std::u16string& name() const { return name_; } // City is expected in a complete address for this country. bool requires_city() const { @@ -61,15 +60,15 @@ class AutofillCountry { private: AutofillCountry(const std::string& country_code, - const base::string16& name, - const base::string16& postal_code_label, - const base::string16& state_label); + const std::u16string& name, + const std::u16string& postal_code_label, + const std::u16string& state_label); // The two-letter ISO-3166 country code. std::string country_code_; // The country's name, localized to the app locale. - base::string16 name_; + std::u16string name_; // Required fields for an address import for the country. RequiredFieldsForAddressImport required_fields_for_address_import_; diff --git a/chromium/components/autofill/core/browser/geo/autofill_country_unittest.cc b/chromium/components/autofill/core/browser/geo/autofill_country_unittest.cc index 39892b620ea..5ee6e2dc0ec 100644 --- a/chromium/components/autofill/core/browser/geo/autofill_country_unittest.cc +++ b/chromium/components/autofill/core/browser/geo/autofill_country_unittest.cc @@ -23,24 +23,24 @@ namespace autofill { TEST(AutofillCountryTest, AutofillCountry) { AutofillCountry united_states_en("US", "en_US"); EXPECT_EQ("US", united_states_en.country_code()); - EXPECT_EQ(ASCIIToUTF16("United States"), united_states_en.name()); + EXPECT_EQ(u"United States", united_states_en.name()); AutofillCountry united_states_es("US", "es"); EXPECT_EQ("US", united_states_es.country_code()); - EXPECT_EQ(ASCIIToUTF16("Estados Unidos"), united_states_es.name()); + EXPECT_EQ(u"Estados Unidos", united_states_es.name()); AutofillCountry great_britain_uk_alias("UK", "en_GB"); EXPECT_EQ("GB", great_britain_uk_alias.country_code()); EXPECT_EQ("GB", great_britain_uk_alias.country_code()); - EXPECT_EQ(ASCIIToUTF16("United Kingdom"), great_britain_uk_alias.name()); + EXPECT_EQ(u"United Kingdom", great_britain_uk_alias.name()); AutofillCountry canada_en("CA", "en_US"); EXPECT_EQ("CA", canada_en.country_code()); - EXPECT_EQ(ASCIIToUTF16("Canada"), canada_en.name()); + EXPECT_EQ(u"Canada", canada_en.name()); AutofillCountry canada_hu("CA", "hu"); EXPECT_EQ("CA", canada_hu.country_code()); - EXPECT_EQ(ASCIIToUTF16("Kanada"), canada_hu.name()); + EXPECT_EQ(u"Kanada", canada_hu.name()); } // Test locale to country code mapping. diff --git a/chromium/components/autofill/core/browser/geo/country_names.cc b/chromium/components/autofill/core/browser/geo/country_names.cc index a5db1d0573d..24124430176 100644 --- a/chromium/components/autofill/core/browser/geo/country_names.cc +++ b/chromium/components/autofill/core/browser/geo/country_names.cc @@ -89,7 +89,7 @@ CountryNames::CountryNames() : CountryNames(g_application_locale.Get()) { CountryNames::~CountryNames() = default; const std::string CountryNames::GetCountryCode( - const base::string16& country) const { + const std::u16string& country) const { // First, check common country names, including 2- and 3-letter country codes. std::string country_utf8 = base::UTF16ToUTF8(base::ToUpperASCII(country)); const auto result = common_names_.find(country_utf8); @@ -107,7 +107,7 @@ const std::string CountryNames::GetCountryCode( } const std::string CountryNames::GetCountryCodeForLocalizedCountryName( - const base::string16& country, + const std::u16string& country, const std::string& locale_name) { // Do an unconditional lookup using the default and app_locale. // Chances are that the name of the country matches the localized one. diff --git a/chromium/components/autofill/core/browser/geo/country_names.h b/chromium/components/autofill/core/browser/geo/country_names.h index 92a68c8a49e..1a3a7ac72a6 100644 --- a/chromium/components/autofill/core/browser/geo/country_names.h +++ b/chromium/components/autofill/core/browser/geo/country_names.h @@ -12,7 +12,6 @@ #include "base/containers/mru_cache.h" #include "base/macros.h" -#include "base/strings/string16.h" #include "base/synchronization/lock.h" #include "components/autofill/core/browser/geo/country_names_for_locale.h" @@ -38,14 +37,14 @@ class CountryNames { // Returns the country code corresponding to the |country_name| queried for // the application and default locale. - const std::string GetCountryCode(const base::string16& country_name) const; + const std::string GetCountryCode(const std::u16string& country_name) const; // Returns the country code for a |country_name| provided with a // |locale_name|. If no country code can be determined, an empty string is // returned. The purpose of this method is to translate country names from a // locale different to one the instance was constructed for. const std::string GetCountryCodeForLocalizedCountryName( - const base::string16& country_name, + const std::u16string& country_name, const std::string& locale_name); #if defined(UNIT_TEST) diff --git a/chromium/components/autofill/core/browser/geo/country_names_for_locale.cc b/chromium/components/autofill/core/browser/geo/country_names_for_locale.cc index 2f9a69dafbc..7a9ad244fd6 100644 --- a/chromium/components/autofill/core/browser/geo/country_names_for_locale.cc +++ b/chromium/components/autofill/core/browser/geo/country_names_for_locale.cc @@ -5,10 +5,10 @@ #include "components/autofill/core/browser/geo/country_names_for_locale.h" #include <map> +#include <string> #include <utility> #include "base/check_op.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/geo/country_data.h" #include "components/autofill/core/common/autofill_l10n_util.h" #include "third_party/icu/source/common/unicode/locid.h" @@ -22,7 +22,7 @@ namespace { // effect. |buffer_size| should specify the |buffer|'s size, and is updated if // the |buffer| is resized. const std::string GetSortKey(const icu::Collator& collator, - const base::string16& str, + const std::u16string& str, std::unique_ptr<uint8_t[]>* buffer, int32_t* buffer_size) { DCHECK(buffer); @@ -77,7 +77,7 @@ std::map<std::string, std::string> GetLocalizedNames( for (const std::string& country_code : CountryDataMap::GetInstance()->country_codes()) { - base::string16 country_name = + std::u16string country_name = l10n_util::GetDisplayNameForCountry(country_code, locale); std::string sort_key = GetSortKey(*collator, country_name, &buffer, &buffer_size); @@ -102,7 +102,7 @@ CountryNamesForLocale::CountryNamesForLocale(CountryNamesForLocale&& source) localized_names_(std::move(source.localized_names_)) {} const std::string CountryNamesForLocale::GetCountryCode( - const base::string16& country_name) const { + const std::u16string& country_name) const { // As recommended[1] by ICU, initialize the buffer size to four times the // source string length. // [1] http://userguide.icu-project.org/collation/api#TOC-Examples diff --git a/chromium/components/autofill/core/browser/geo/country_names_for_locale.h b/chromium/components/autofill/core/browser/geo/country_names_for_locale.h index 4c04eb3a510..4498e21a2b7 100644 --- a/chromium/components/autofill/core/browser/geo/country_names_for_locale.h +++ b/chromium/components/autofill/core/browser/geo/country_names_for_locale.h @@ -9,7 +9,6 @@ #include <memory> #include <string> -#include "base/strings/string16.h" #include "third_party/icu/source/i18n/unicode/coll.h" namespace autofill { @@ -26,7 +25,7 @@ class CountryNamesForLocale { // Returns the country code corresponding to the |country_name| localized to // |locale_name_|. Returns an empty string if no matching country code can be // found. - const std::string GetCountryCode(const base::string16& country_name) const; + const std::string GetCountryCode(const std::u16string& country_name) const; private: // Returns an ICU collator -- i.e. string comparator -- appropriate for the diff --git a/chromium/components/autofill/core/browser/geo/country_names_for_locale_unittest.cc b/chromium/components/autofill/core/browser/geo/country_names_for_locale_unittest.cc index 7c1f994329b..e62db32f409 100644 --- a/chromium/components/autofill/core/browser/geo/country_names_for_locale_unittest.cc +++ b/chromium/components/autofill/core/browser/geo/country_names_for_locale_unittest.cc @@ -5,7 +5,6 @@ #include <string> #include <utility> -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/geo/country_names_for_locale.h" #include "testing/gtest/include/gtest/gtest.h" @@ -31,10 +30,10 @@ class TestCountryNamesForLocale : public CountryNamesForLocale { // Test that the correct country code is returned for various locales. TEST(CountryNamesForLocaleTest, GetCountryCode) { TestCountryNamesForLocale en_us_names("en_US"); - EXPECT_EQ("US", en_us_names.GetCountryCode(ASCIIToUTF16("United States"))); + EXPECT_EQ("US", en_us_names.GetCountryCode(u"United States")); TestCountryNamesForLocale de_names("de"); - EXPECT_EQ("DE", de_names.GetCountryCode(ASCIIToUTF16("Deutschland"))); + EXPECT_EQ("DE", de_names.GetCountryCode(u"Deutschland")); } // Test that supplying an non-empty but invalid locale reverts back to 'en_US' @@ -43,8 +42,7 @@ TEST(CountryNamesForLocaleTest, EmptyCountryCodeForInvalidLocale) { TestCountryNamesForLocale not_a_locale_names("not_a_locale"); // The creation of an non-empty invalid locale reverts back to "en_US". - EXPECT_EQ("US", - not_a_locale_names.GetCountryCode(ASCIIToUTF16("United States"))); + EXPECT_EQ("US", not_a_locale_names.GetCountryCode(u"United States")); } // The behavior depends on the platform. On Android the locale reverts back to @@ -53,33 +51,32 @@ TEST(CountryNamesForLocaleTest, EmptyCountryCodeForInvalidLocale) { // Test that an empty string is returned for an empty locale. TEST(CountryNamesForLocaleTest, EmptyCountryCodeForEmptyLocale) { TestCountryNamesForLocale empty_locale_names(""); - EXPECT_EQ("", - empty_locale_names.GetCountryCode(ASCIIToUTF16("United States"))); + EXPECT_EQ("", empty_locale_names.GetCountryCode(u"United States")); } #endif // Test that an empty string is returned for an empty country name. TEST(CountryNamesForLocaleTest, EmptyCountryCodeForEmptyCountryName) { TestCountryNamesForLocale de_names("de"); - EXPECT_EQ("", de_names.GetCountryCode(ASCIIToUTF16(""))); + EXPECT_EQ("", de_names.GetCountryCode(u"")); } // Test that an empty string is returned for an invalid country name. TEST(CountryNamesForLocaleTest, EmptyCountryCodeForInvalidCountryName) { TestCountryNamesForLocale de_names("de"); - EXPECT_EQ("", de_names.GetCountryCode(ASCIIToUTF16("ThisISNotACountry"))); + EXPECT_EQ("", de_names.GetCountryCode(u"ThisISNotACountry")); } // Test that an instance is correctly constructed using the move semantics. TEST(CountryNamesForLocaleTest, MoveConstructior) { // Construct a working |CountryNamesForLocale| instance. TestCountryNamesForLocale de_names("de"); - EXPECT_EQ("DE", de_names.GetCountryCode(ASCIIToUTF16("Deutschland"))); + EXPECT_EQ("DE", de_names.GetCountryCode(u"Deutschland")); // Construct another instance using the move semantics. TestCountryNamesForLocale moved_names(std::move(de_names)); // Test that the new instance returns the correct values. - EXPECT_EQ("DE", moved_names.GetCountryCode(ASCIIToUTF16("Deutschland"))); + EXPECT_EQ("DE", moved_names.GetCountryCode(u"Deutschland")); } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/geo/country_names_unittest.cc b/chromium/components/autofill/core/browser/geo/country_names_unittest.cc index 2f971cb599c..9cfc1accd67 100644 --- a/chromium/components/autofill/core/browser/geo/country_names_unittest.cc +++ b/chromium/components/autofill/core/browser/geo/country_names_unittest.cc @@ -5,7 +5,6 @@ #include <string> #include <utility> -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/geo/country_names.h" #include "testing/gtest/include/gtest/gtest.h" @@ -28,57 +27,52 @@ class TestCountryNames : public CountryNames { // Test mapping of localized country names to country codes. TEST(CountryNamesTest, GetCountryCode_BasicMapping) { TestCountryNames en_us_names("en_US"); - EXPECT_EQ("US", en_us_names.GetCountryCode(ASCIIToUTF16("United States"))); - EXPECT_EQ("CA", en_us_names.GetCountryCode(ASCIIToUTF16("Canada"))); + EXPECT_EQ("US", en_us_names.GetCountryCode(u"United States")); + EXPECT_EQ("CA", en_us_names.GetCountryCode(u"Canada")); } TEST(CountryNamesTest, GetCountryCode_CaseInsensitiveMapping) { - EXPECT_EQ("US", TestCountryNames("en_US").GetCountryCode( - ASCIIToUTF16("united states"))); + EXPECT_EQ("US", TestCountryNames("en_US").GetCountryCode(u"united states")); } TEST(CountryNamesTest, GetCountryCode_CodesMapToThemselves) { TestCountryNames en_us_names("en_US"); TestCountryNames fr_ca_names("fr_CA"); - EXPECT_EQ("US", en_us_names.GetCountryCode(ASCIIToUTF16("US"))); - EXPECT_EQ("HU", en_us_names.GetCountryCode(ASCIIToUTF16("hu"))); - EXPECT_EQ("CA", fr_ca_names.GetCountryCode(ASCIIToUTF16("CA"))); - EXPECT_EQ("MX", fr_ca_names.GetCountryCode(ASCIIToUTF16("mx"))); + EXPECT_EQ("US", en_us_names.GetCountryCode(u"US")); + EXPECT_EQ("HU", en_us_names.GetCountryCode(u"hu")); + EXPECT_EQ("CA", fr_ca_names.GetCountryCode(u"CA")); + EXPECT_EQ("MX", fr_ca_names.GetCountryCode(u"mx")); } TEST(CountryNamesTest, GetCountryCode_BasicSynonyms) { TestCountryNames en_us_names("en_US"); - EXPECT_EQ("US", en_us_names.GetCountryCode( - ASCIIToUTF16("United States of America"))); - EXPECT_EQ("US", en_us_names.GetCountryCode(ASCIIToUTF16("USA"))); + EXPECT_EQ("US", en_us_names.GetCountryCode(u"United States of America")); + EXPECT_EQ("US", en_us_names.GetCountryCode(u"USA")); } TEST(CountryNamesTest, GetCountryCode_OtherLocales) { - EXPECT_EQ("US", TestCountryNames("es").GetCountryCode( - ASCIIToUTF16("Estados Unidos"))); - EXPECT_EQ("IT", - TestCountryNames("it").GetCountryCode(ASCIIToUTF16("Italia"))); - EXPECT_EQ("DE", - TestCountryNames("nl").GetCountryCode(ASCIIToUTF16("duitsland"))); + EXPECT_EQ("US", TestCountryNames("es").GetCountryCode(u"Estados Unidos")); + EXPECT_EQ("IT", TestCountryNames("it").GetCountryCode(u"Italia")); + EXPECT_EQ("DE", TestCountryNames("nl").GetCountryCode(u"duitsland")); } TEST(CountryNamesTest, GetCountryCode_EnUsFallback) { TestCountryNames es_names("es"); - EXPECT_EQ("US", es_names.GetCountryCode(ASCIIToUTF16("United States"))); - EXPECT_EQ("US", es_names.GetCountryCode(ASCIIToUTF16("united states"))); - EXPECT_EQ("US", es_names.GetCountryCode(ASCIIToUTF16("USA"))); + EXPECT_EQ("US", es_names.GetCountryCode(u"United States")); + EXPECT_EQ("US", es_names.GetCountryCode(u"united states")); + EXPECT_EQ("US", es_names.GetCountryCode(u"USA")); } TEST(CountryNamesTest, GetCountryCodeForLocalizedCountryName) { // Initialize with the default locale. TestCountryNames names("en_US"); - EXPECT_EQ("AM", names.GetCountryCodeForLocalizedCountryName( - ASCIIToUTF16("Armenien"), "de")); + EXPECT_EQ("AM", + names.GetCountryCodeForLocalizedCountryName(u"Armenien", "de")); // Check that there is no cache by requesting the same result twice. - EXPECT_EQ("AM", names.GetCountryCodeForLocalizedCountryName( - ASCIIToUTF16("Armenien"), "de")); - EXPECT_EQ("AZ", names.GetCountryCodeForLocalizedCountryName( - ASCIIToUTF16("Azerbeidzjan"), "nl")); + EXPECT_EQ("AM", + names.GetCountryCodeForLocalizedCountryName(u"Armenien", "de")); + EXPECT_EQ("AZ", + names.GetCountryCodeForLocalizedCountryName(u"Azerbeidzjan", "nl")); } TEST(CountryNamesTest, GetCachedCountryCodeForLocalizedCountryName) { @@ -89,8 +83,8 @@ TEST(CountryNamesTest, GetCachedCountryCodeForLocalizedCountryName) { EXPECT_FALSE(names.IsCountryNamesForLocaleCachedForTesting("de")); // Make a lookup of the entry that should result in a cache write. - EXPECT_EQ("AM", names.GetCountryCodeForLocalizedCountryName( - ASCIIToUTF16("Armenien"), "de")); + EXPECT_EQ("AM", + names.GetCountryCodeForLocalizedCountryName(u"Armenien", "de")); // Verify that the entry is cached. EXPECT_TRUE(names.IsCountryNamesForLocaleCachedForTesting("de")); @@ -99,7 +93,7 @@ TEST(CountryNamesTest, GetCachedCountryCodeForLocalizedCountryName) { // Test mapping of an empty country name to an country code. TEST(CountryNamesTest, EmptyCountryNameHasEmptyCountryCode) { std::string country_code = - TestCountryNames("en").GetCountryCode(base::string16()); + TestCountryNames("en").GetCountryCode(std::u16string()); EXPECT_TRUE(country_code.empty()) << country_code; } diff --git a/chromium/components/autofill/core/browser/geo/phone_number_i18n.cc b/chromium/components/autofill/core/browser/geo/phone_number_i18n.cc index 0e1d01ee171..d936d62e091 100644 --- a/chromium/components/autofill/core/browser/geo/phone_number_i18n.cc +++ b/chromium/components/autofill/core/browser/geo/phone_number_i18n.cc @@ -4,6 +4,7 @@ #include "components/autofill/core/browser/geo/phone_number_i18n.h" +#include <memory> #include <utility> #include "base/check_op.h" @@ -57,9 +58,9 @@ std::string SanitizeRegion(const std::string& region, // in explicitly, as |number| might have an implicit country code set, even // though the original input lacked a country code. void FormatValidatedNumber(const ::i18n::phonenumbers::PhoneNumber& number, - const base::string16& country_code, - base::string16* formatted_number, - base::string16* normalized_number) { + const std::u16string& country_code, + std::u16string* formatted_number, + std::u16string* normalized_number) { PhoneNumberUtil::PhoneNumberFormat format = country_code.empty() ? PhoneNumberUtil::NATIONAL : PhoneNumberUtil::INTERNATIONAL; @@ -143,11 +144,11 @@ bool IsValidPhoneNumber(const std::string& phone_number, // Parses the number stored in |value| as it should be interpreted in the given // |default_region|, and stores the results into the remaining arguments. // The |default_region| should be sanitized prior to calling this function. -bool ParsePhoneNumber(const base::string16& value, +bool ParsePhoneNumber(const std::u16string& value, const std::string& default_region, - base::string16* country_code, - base::string16* city_code, - base::string16* number, + std::u16string* country_code, + std::u16string* city_code, + std::u16string* number, std::string* inferred_region, ::i18n::phonenumbers::PhoneNumber* i18n_number) { country_code->clear(); @@ -224,32 +225,32 @@ bool ParsePhoneNumber(const base::string16& value, return true; } -base::string16 NormalizePhoneNumber(const base::string16& value, +std::u16string NormalizePhoneNumber(const std::u16string& value, const std::string& region) { DCHECK_EQ(2u, region.size()); - base::string16 country_code, unused_city_code, unused_number; + std::u16string country_code, unused_city_code, unused_number; std::string unused_region; ::i18n::phonenumbers::PhoneNumber phone_number; if (!ParsePhoneNumber(value, region, &country_code, &unused_city_code, &unused_number, &unused_region, &phone_number)) { - return base::string16(); // Parsing failed - do not store phone. + return std::u16string(); // Parsing failed - do not store phone. } - base::string16 normalized_number; + std::u16string normalized_number; FormatValidatedNumber(phone_number, country_code, nullptr, &normalized_number); return normalized_number; } -bool ConstructPhoneNumber(const base::string16& country_code, - const base::string16& city_code, - const base::string16& number, +bool ConstructPhoneNumber(const std::u16string& country_code, + const std::u16string& city_code, + const std::u16string& number, const std::string& region, - base::string16* whole_number) { + std::u16string* whole_number) { DCHECK_EQ(2u, region.size()); whole_number->clear(); - base::string16 unused_country_code, unused_city_code, unused_number; + std::u16string unused_country_code, unused_city_code, unused_number; std::string unused_region; ::i18n::phonenumbers::PhoneNumber phone_number; if (!ParsePhoneNumber(country_code + city_code + number, region, @@ -262,8 +263,8 @@ bool ConstructPhoneNumber(const base::string16& country_code, return true; } -bool PhoneNumbersMatch(const base::string16& number_a, - const base::string16& number_b, +bool PhoneNumbersMatch(const std::u16string& number_a, + const std::u16string& number_b, const std::string& raw_region, const std::string& app_locale) { if (number_a.empty() && number_b.empty()) { @@ -307,7 +308,7 @@ bool PhoneNumbersMatch(const base::string16& number_a, return false; } -base::string16 GetFormattedPhoneNumberForDisplay(const AutofillProfile& profile, +std::u16string GetFormattedPhoneNumberForDisplay(const AutofillProfile& profile, const std::string& locale) { // Since the "+" is removed for some country's phone numbers, try to add a "+" // and see if it is a valid phone number for a country. @@ -365,7 +366,7 @@ std::string FormatPhoneForResponse(const std::string& phone_number, return phone_number; } -PhoneObject::PhoneObject(const base::string16& number, +PhoneObject::PhoneObject(const std::u16string& number, const std::string& region) { DCHECK_EQ(2u, region.size()); // TODO(isherman): Autofill profiles should always have a |region| set, but in @@ -396,7 +397,7 @@ PhoneObject::PhoneObject() {} PhoneObject::~PhoneObject() {} -const base::string16& PhoneObject::GetFormattedNumber() const { +const std::u16string& PhoneObject::GetFormattedNumber() const { if (i18n_number_ && formatted_number_.empty()) { FormatValidatedNumber(*i18n_number_, country_code_, &formatted_number_, &whole_number_); @@ -405,15 +406,15 @@ const base::string16& PhoneObject::GetFormattedNumber() const { return formatted_number_; } -base::string16 PhoneObject::GetNationallyFormattedNumber() const { - base::string16 formatted = whole_number_; +std::u16string PhoneObject::GetNationallyFormattedNumber() const { + std::u16string formatted = whole_number_; if (i18n_number_) - FormatValidatedNumber(*i18n_number_, base::string16(), &formatted, nullptr); + FormatValidatedNumber(*i18n_number_, std::u16string(), &formatted, nullptr); return formatted; } -const base::string16& PhoneObject::GetWholeNumber() const { +const std::u16string& PhoneObject::GetWholeNumber() const { if (i18n_number_ && whole_number_.empty()) { FormatValidatedNumber(*i18n_number_, country_code_, &formatted_number_, &whole_number_); @@ -428,11 +429,12 @@ PhoneObject& PhoneObject::operator=(const PhoneObject& other) { region_ = other.region_; - if (other.i18n_number_) - i18n_number_.reset( - new ::i18n::phonenumbers::PhoneNumber(*other.i18n_number_)); - else + if (other.i18n_number_) { + i18n_number_ = std::make_unique<::i18n::phonenumbers::PhoneNumber>( + *other.i18n_number_); + } else { i18n_number_.reset(); + } country_code_ = other.country_code_; city_code_ = other.city_code_; diff --git a/chromium/components/autofill/core/browser/geo/phone_number_i18n.h b/chromium/components/autofill/core/browser/geo/phone_number_i18n.h index 539bc6fcfb6..e5158ae4535 100644 --- a/chromium/components/autofill/core/browser/geo/phone_number_i18n.h +++ b/chromium/components/autofill/core/browser/geo/phone_number_i18n.h @@ -10,7 +10,6 @@ #include <vector> #include "base/compiler_specific.h" -#include "base/strings/string16.h" namespace i18n { namespace phonenumbers { @@ -54,18 +53,18 @@ bool IsPossiblePhoneNumber(const std::string& phone_number, // |default_region| if |value| has an international country code, for example). // This is an internal function, exposed in the header file so that it can be // tested. -bool ParsePhoneNumber(const base::string16& value, +bool ParsePhoneNumber(const std::u16string& value, const std::string& default_region, - base::string16* country_code, - base::string16* city_code, - base::string16* number, + std::u16string* country_code, + std::u16string* city_code, + std::u16string* number, std::string* inferred_region, ::i18n::phonenumbers::PhoneNumber* i18n_number) WARN_UNUSED_RESULT; // Normalizes phone number, by changing digits in the extended fonts // (such as \xFF1x) into '0'-'9'. Also strips out non-digit characters. -base::string16 NormalizePhoneNumber(const base::string16& value, +std::u16string NormalizePhoneNumber(const std::u16string& value, const std::string& default_region); // Constructs whole phone number from parts. @@ -76,16 +75,16 @@ base::string16 NormalizePhoneNumber(const base::string16& value, // |whole_number| - constructed whole number. // Separator characters are stripped before parsing the digits. // Returns true if parsing was successful, false otherwise. -bool ConstructPhoneNumber(const base::string16& country_code, - const base::string16& city_code, - const base::string16& number, +bool ConstructPhoneNumber(const std::u16string& country_code, + const std::u16string& city_code, + const std::u16string& number, const std::string& default_region, - base::string16* whole_number) WARN_UNUSED_RESULT; + std::u16string* whole_number) WARN_UNUSED_RESULT; // Returns true if |number_a| and |number_b| parse to the same phone number in // the given |region|. -bool PhoneNumbersMatch(const base::string16& number_a, - const base::string16& number_b, +bool PhoneNumbersMatch(const std::u16string& number_a, + const std::u16string& number_b, const std::string& region, const std::string& app_locale); @@ -93,7 +92,7 @@ bool PhoneNumbersMatch(const base::string16& number_a, // If it's a valid number for the profile's country or for the |locale| given // as a fallback, returns the number in international format; otherwise returns // the raw number string from profile. -base::string16 GetFormattedPhoneNumberForDisplay(const AutofillProfile& profile, +std::u16string GetFormattedPhoneNumberForDisplay(const AutofillProfile& profile, const std::string& locale); // Returns |phone_number| in i18n::phonenumbers::PhoneNumberUtil:: @@ -121,20 +120,20 @@ std::string FormatPhoneForResponse(const std::string& phone_number, // The cached phone number, does parsing only once, improves performance. class PhoneObject { public: - PhoneObject(const base::string16& number, const std::string& default_region); + PhoneObject(const std::u16string& number, const std::string& default_region); PhoneObject(const PhoneObject&); PhoneObject(); ~PhoneObject(); const std::string& region() const { return region_; } - const base::string16& country_code() const { return country_code_; } - const base::string16& city_code() const { return city_code_; } - const base::string16& number() const { return number_; } + const std::u16string& country_code() const { return country_code_; } + const std::u16string& city_code() const { return city_code_; } + const std::u16string& number() const { return number_; } - const base::string16& GetFormattedNumber() const; - base::string16 GetNationallyFormattedNumber() const; - const base::string16& GetWholeNumber() const; + const std::u16string& GetFormattedNumber() const; + std::u16string GetNationallyFormattedNumber() const; + const std::u16string& GetWholeNumber() const; PhoneObject& operator=(const PhoneObject& other); @@ -147,17 +146,17 @@ class PhoneObject { // The parsed number and its components. // std::unique_ptr<::i18n::phonenumbers::PhoneNumber> i18n_number_; - base::string16 city_code_; - base::string16 country_code_; - base::string16 number_; + std::u16string city_code_; + std::u16string country_code_; + std::u16string number_; // Pretty printed version of the whole number, or empty if parsing failed. // Set on first request. - mutable base::string16 formatted_number_; + mutable std::u16string formatted_number_; // The whole number, normalized to contain only digits if possible. // Set on first request. - mutable base::string16 whole_number_; + mutable std::u16string whole_number_; }; } // namespace i18n diff --git a/chromium/components/autofill/core/browser/geo/phone_number_i18n_fuzzer.cc b/chromium/components/autofill/core/browser/geo/phone_number_i18n_fuzzer.cc index 77a3805f0f8..1cf4a92b41a 100644 --- a/chromium/components/autofill/core/browser/geo/phone_number_i18n_fuzzer.cc +++ b/chromium/components/autofill/core/browser/geo/phone_number_i18n_fuzzer.cc @@ -9,7 +9,6 @@ #include "base/at_exit.h" #include "base/i18n/icu_util.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/geo/phone_number_i18n.h" #include "third_party/libphonenumber/phonenumber_api.h" @@ -30,11 +29,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { return 0; std::string default_region(reinterpret_cast<const char*>(data), 2); - base::string16 value(reinterpret_cast<const base::char16*>(data + 2), + std::u16string value(reinterpret_cast<const char16_t*>(data + 2), (size - 2) / 2); - base::string16 dummy_country_code; - base::string16 dummy_city_code; - base::string16 dummy_number; + std::u16string dummy_country_code; + std::u16string dummy_city_code; + std::u16string dummy_number; std::string dummy_inferred_region; ::i18n::phonenumbers::PhoneNumber dummy_i18n_number; diff --git a/chromium/components/autofill/core/browser/geo/phone_number_i18n_unittest.cc b/chromium/components/autofill/core/browser/geo/phone_number_i18n_unittest.cc index 4f4e36e3357..5b5148fb6fc 100644 --- a/chromium/components/autofill/core/browser/geo/phone_number_i18n_unittest.cc +++ b/chromium/components/autofill/core/browser/geo/phone_number_i18n_unittest.cc @@ -6,8 +6,9 @@ #include <stddef.h> +#include <string> + #include "base/macros.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" #include "components/autofill/core/browser/field_types.h" @@ -26,26 +27,26 @@ using i18n::PhoneNumbersMatch; TEST(PhoneNumberI18NTest, NormalizePhoneNumber) { // "Large" digits. - base::string16 phone1( + std::u16string phone1( UTF8ToUTF16("\xEF\xBC\x91\xEF\xBC\x96\xEF\xBC\x95\xEF\xBC\x90" "\xEF\xBC\x97\xEF\xBC\x94\xEF\xBC\x99\xEF\xBC\x98" "\xEF\xBC\x93\xEF\xBC\x92\xEF\xBC\x93")); - EXPECT_EQ(NormalizePhoneNumber(phone1, "US"), ASCIIToUTF16("16507498323")); + EXPECT_EQ(NormalizePhoneNumber(phone1, "US"), u"16507498323"); // Devanagari script digits. - base::string16 phone2( + std::u16string phone2( UTF8ToUTF16("\xD9\xA1\xD9\xA6\xD9\xA5\xD9\xA0\xD9\xA8\xD9\xA3" "\xD9\xA2\xD9\xA3\xD9\xA7\xD9\xA4\xD9\xA9")); - EXPECT_EQ(NormalizePhoneNumber(phone2, "US"), ASCIIToUTF16("16508323749")); + EXPECT_EQ(NormalizePhoneNumber(phone2, "US"), u"16508323749"); - base::string16 phone3(UTF8ToUTF16("16503334\xef\xbc\x92\x35\xd9\xa5")); - EXPECT_EQ(NormalizePhoneNumber(phone3, "US"), ASCIIToUTF16("16503334255")); + std::u16string phone3(UTF8ToUTF16("16503334\xef\xbc\x92\x35\xd9\xa5")); + EXPECT_EQ(NormalizePhoneNumber(phone3, "US"), u"16503334255"); - base::string16 phone4(UTF8ToUTF16("+1(650)2346789")); - EXPECT_EQ(NormalizePhoneNumber(phone4, "US"), ASCIIToUTF16("16502346789")); + std::u16string phone4(u"+1(650)2346789"); + EXPECT_EQ(NormalizePhoneNumber(phone4, "US"), u"16502346789"); - base::string16 phone5(UTF8ToUTF16("6502346789")); - EXPECT_EQ(NormalizePhoneNumber(phone5, "US"), ASCIIToUTF16("6502346789")); + std::u16string phone5(u"6502346789"); + EXPECT_EQ(NormalizePhoneNumber(phone5, "US"), u"6502346789"); } struct ParseNumberTestCase { @@ -76,7 +77,7 @@ TEST_P(ParseNumberTest, ParsePhoneNumber) { auto test_case = GetParam(); SCOPED_TRACE("Testing phone number " + test_case.input); - base::string16 country_code, city_code, number; + std::u16string country_code, city_code, number; std::string deduced_region; ::i18n::phonenumbers::PhoneNumber unused_i18n_number; EXPECT_EQ( @@ -190,79 +191,69 @@ INSTANTIATE_TEST_SUITE_P( "", "DE"})); TEST(PhoneNumberI18NTest, ConstructPhoneNumber) { - base::string16 number; - EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("1"), ASCIIToUTF16("650"), - ASCIIToUTF16("2345678"), "US", &number)); - EXPECT_EQ(ASCIIToUTF16("1 650-234-5678"), number); - EXPECT_TRUE(ConstructPhoneNumber(base::string16(), ASCIIToUTF16("650"), - ASCIIToUTF16("2345678"), "US", &number)); - EXPECT_EQ(ASCIIToUTF16("(650) 234-5678"), number); - EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("1"), base::string16(), - ASCIIToUTF16("6502345678"), "US", &number)); - EXPECT_EQ(ASCIIToUTF16("1 650-234-5678"), number); - EXPECT_TRUE(ConstructPhoneNumber(base::string16(), base::string16(), - ASCIIToUTF16("6502345678"), "US", &number)); - EXPECT_EQ(ASCIIToUTF16("(650) 234-5678"), number); - - EXPECT_FALSE(ConstructPhoneNumber(base::string16(), ASCIIToUTF16("650"), - ASCIIToUTF16("234567890"), "US", &number)); - EXPECT_EQ(base::string16(), number); + std::u16string number; + EXPECT_TRUE(ConstructPhoneNumber(u"1", u"650", u"2345678", "US", &number)); + EXPECT_EQ(u"1 650-234-5678", number); + EXPECT_TRUE(ConstructPhoneNumber(std::u16string(), u"650", u"2345678", "US", + &number)); + EXPECT_EQ(u"(650) 234-5678", number); + EXPECT_TRUE(ConstructPhoneNumber(u"1", std::u16string(), u"6502345678", "US", + &number)); + EXPECT_EQ(u"1 650-234-5678", number); + EXPECT_TRUE(ConstructPhoneNumber(std::u16string(), std::u16string(), + u"6502345678", "US", &number)); + EXPECT_EQ(u"(650) 234-5678", number); + + EXPECT_FALSE(ConstructPhoneNumber(std::u16string(), u"650", u"234567890", + "US", &number)); + EXPECT_EQ(std::u16string(), number); // Italian number - EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("39"), ASCIIToUTF16("347"), - ASCIIToUTF16("2345678"), "IT", &number)); - EXPECT_EQ(ASCIIToUTF16("+39 347 234 5678"), number); - EXPECT_TRUE(ConstructPhoneNumber(base::string16(), ASCIIToUTF16("347"), - ASCIIToUTF16("2345678"), "IT", &number)); - EXPECT_EQ(ASCIIToUTF16("347 234 5678"), number); + EXPECT_TRUE(ConstructPhoneNumber(u"39", u"347", u"2345678", "IT", &number)); + EXPECT_EQ(u"+39 347 234 5678", number); + EXPECT_TRUE(ConstructPhoneNumber(std::u16string(), u"347", u"2345678", "IT", + &number)); + EXPECT_EQ(u"347 234 5678", number); // German number. - EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("49"), ASCIIToUTF16("024"), - ASCIIToUTF16("2345678901"), "DE", &number)); - EXPECT_EQ(ASCIIToUTF16("+49 2423 45678901"), number); - EXPECT_TRUE(ConstructPhoneNumber(base::string16(), ASCIIToUTF16("024"), - ASCIIToUTF16("2345678901"), "DE", &number)); - EXPECT_EQ(ASCIIToUTF16("02423 45678901"), number); + EXPECT_TRUE( + ConstructPhoneNumber(u"49", u"024", u"2345678901", "DE", &number)); + EXPECT_EQ(u"+49 2423 45678901", number); + EXPECT_TRUE(ConstructPhoneNumber(std::u16string(), u"024", u"2345678901", + "DE", &number)); + EXPECT_EQ(u"02423 45678901", number); } TEST(PhoneNumberI18NTest, PhoneNumbersMatch) { // Same numbers, defined country code. - EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), - ASCIIToUTF16("4158889999"), "US", "en-US")); + EXPECT_TRUE(PhoneNumbersMatch(u"4158889999", u"4158889999", "US", "en-US")); // Same numbers, undefined country code. - EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), - ASCIIToUTF16("4158889999"), std::string(), - "en-US")); + EXPECT_TRUE( + PhoneNumbersMatch(u"4158889999", u"4158889999", std::string(), "en-US")); // Numbers differ by country code only. - EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), - ASCIIToUTF16("4158889999"), "US", "en-US")); + EXPECT_TRUE(PhoneNumbersMatch(u"14158889999", u"4158889999", "US", "en-US")); // Same numbers, different formats. - EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), - ASCIIToUTF16("415-888-9999"), "US", "en-US")); - EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), - ASCIIToUTF16("(415)888-9999"), "US", "en-US")); - EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), - ASCIIToUTF16("415 888 9999"), "US", "en-US")); - EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), - ASCIIToUTF16("415 TUV WXYZ"), "US", "en-US")); - EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("1(415)888-99-99"), - ASCIIToUTF16("+14158889999"), "US", "en-US")); + EXPECT_TRUE(PhoneNumbersMatch(u"4158889999", u"415-888-9999", "US", "en-US")); + EXPECT_TRUE( + PhoneNumbersMatch(u"4158889999", u"(415)888-9999", "US", "en-US")); + EXPECT_TRUE(PhoneNumbersMatch(u"4158889999", u"415 888 9999", "US", "en-US")); + EXPECT_TRUE(PhoneNumbersMatch(u"4158889999", u"415 TUV WXYZ", "US", "en-US")); + EXPECT_TRUE( + PhoneNumbersMatch(u"1(415)888-99-99", u"+14158889999", "US", "en-US")); // Partial matches don't count. - EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), - ASCIIToUTF16("8889999"), "US", "en-US")); + EXPECT_FALSE(PhoneNumbersMatch(u"14158889999", u"8889999", "US", "en-US")); // Different numbers don't match. - EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), - ASCIIToUTF16("1415888"), "US", "en-US")); + EXPECT_FALSE(PhoneNumbersMatch(u"14158889999", u"1415888", "US", "en-US")); // Two empty numbers match. EXPECT_TRUE( - PhoneNumbersMatch(base::string16(), base::string16(), "US", "en-US")); + PhoneNumbersMatch(std::u16string(), std::u16string(), "US", "en-US")); // An empty and a non-empty number do not match. - EXPECT_FALSE(PhoneNumbersMatch(base::string16(), ASCIIToUTF16("5088585123"), - "US", "en-US")); + EXPECT_FALSE( + PhoneNumbersMatch(std::u16string(), u"5088585123", "US", "en-US")); } // Tests that the phone numbers are correctly formatted for the Payment diff --git a/chromium/components/autofill/core/browser/geo/state_names.cc b/chromium/components/autofill/core/browser/geo/state_names.cc index 1d4a0e0f1da..deecc9ae400 100644 --- a/chromium/components/autofill/core/browser/geo/state_names.cc +++ b/chromium/components/autofill/core/browser/geo/state_names.cc @@ -79,27 +79,27 @@ const StateData kStateData[] = { } // namespace -base::string16 GetAbbreviationForName(const base::string16& name) { +std::u16string GetAbbreviationForName(const std::u16string& name) { for (const StateData& state : kStateData) { if (base::LowerCaseEqualsASCII(name, state.name)) return base::ASCIIToUTF16(state.abbreviation); } - return base::string16(); + return std::u16string(); } -base::string16 GetNameForAbbreviation(const base::string16& abbreviation) { +std::u16string GetNameForAbbreviation(const std::u16string& abbreviation) { for (const StateData& state : kStateData) { if (base::LowerCaseEqualsASCII(abbreviation, state.abbreviation)) return base::ASCIIToUTF16(state.name); } - return base::string16(); + return std::u16string(); } -void GetNameAndAbbreviation(const base::string16& value, - base::string16* name, - base::string16* abbreviation) { - base::string16 full = GetNameForAbbreviation(value); - base::string16 abbr = value; +void GetNameAndAbbreviation(const std::u16string& value, + std::u16string* name, + std::u16string* abbreviation) { + std::u16string full = GetNameForAbbreviation(value); + std::u16string abbr = value; if (full.empty()) { abbr = GetAbbreviationForName(value); full = value; diff --git a/chromium/components/autofill/core/browser/geo/state_names.h b/chromium/components/autofill/core/browser/geo/state_names.h index 0524f1f080c..621c8fd6086 100644 --- a/chromium/components/autofill/core/browser/geo/state_names.h +++ b/chromium/components/autofill/core/browser/geo/state_names.h @@ -5,25 +5,26 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_STATE_NAMES_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_STATE_NAMES_H_ -#include "base/strings/string16.h" +#include <string> + namespace autofill { namespace state_names { // Returns the abbreviation corresponding to the state |name|, or the // empty string if there is no such state. -base::string16 GetAbbreviationForName(const base::string16& name); +std::u16string GetAbbreviationForName(const std::u16string& name); // Returns the full state name corresponding to the |abbrevation|, or the empty // string if there is no such state. -base::string16 GetNameForAbbreviation(const base::string16& abbreviation); +std::u16string GetNameForAbbreviation(const std::u16string& abbreviation); // |value| is either a state name or abbreviation. Detects which it is, and // outputs both |name| and |abbreviation|. If it's neither, then |name| is // set to |value| and |abbreviation| will be empty. -void GetNameAndAbbreviation(const base::string16& value, - base::string16* name, - base::string16* abbreviation); +void GetNameAndAbbreviation(const std::u16string& value, + std::u16string* name, + std::u16string* abbreviation); } // namespace state_names } // namespace autofill diff --git a/chromium/components/autofill/core/browser/metrics/credit_card_form_event_logger.cc b/chromium/components/autofill/core/browser/metrics/credit_card_form_event_logger.cc index ecae251fd12..0209935b9cd 100644 --- a/chromium/components/autofill/core/browser/metrics/credit_card_form_event_logger.cc +++ b/chromium/components/autofill/core/browser/metrics/credit_card_form_event_logger.cc @@ -9,7 +9,6 @@ #include "base/metrics/histogram_functions.h" #include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics_action.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/form_data_importer.h" #include "components/autofill/core/browser/payments/credit_card_access_manager.h" #include "components/autofill/core/browser/validation.h" @@ -33,7 +32,6 @@ CreditCardFormEventLogger::~CreditCardFormEventLogger() = default; void CreditCardFormEventLogger::set_suggestions( std::vector<Suggestion> suggestions) { suggestions_.clear(); - card_selected_has_offer_ = false; for (auto suggestion : suggestions) { suggestions_.emplace_back(suggestion); @@ -49,6 +47,7 @@ void CreditCardFormEventLogger::OnDidSelectCardSuggestion( AutofillSyncSigninState sync_state) { sync_state_ = sync_state; + card_selected_has_offer_ = false; if (has_eligible_offer_) { card_selected_has_offer_ = DoesCardHaveOffer(credit_card); base::UmaHistogramBoolean("Autofill.Offer.SelectedCardHasOffer", @@ -161,7 +160,7 @@ void CreditCardFormEventLogger::LogFormSubmitted(const FormStructure& form) { Log(FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, form); } - if (has_eligible_offer_) { + if (has_logged_suggestion_filled_ && has_eligible_offer_) { base::UmaHistogramBoolean("Autofill.Offer.SubmittedCardHasOffer", card_selected_has_offer_); } @@ -208,7 +207,7 @@ void CreditCardFormEventLogger::OnLog(const std::string& name, FormEvent CreditCardFormEventLogger::GetCardNumberStatusFormEvent( const CreditCard& credit_card) { - const base::string16 number = credit_card.number(); + const std::u16string number = credit_card.number(); FormEvent form_event = FORM_EVENT_SUBMIT_WITHOUT_SELECTING_SUGGESTIONS_UNKNOWN_CARD; diff --git a/chromium/components/autofill/core/browser/mock_autocomplete_history_manager.h b/chromium/components/autofill/core/browser/mock_autocomplete_history_manager.h index 9a87d7fa745..02b0395367f 100644 --- a/chromium/components/autofill/core/browser/mock_autocomplete_history_manager.h +++ b/chromium/components/autofill/core/browser/mock_autocomplete_history_manager.h @@ -22,8 +22,8 @@ class MockAutocompleteHistoryManager : public AutocompleteHistoryManager { void(int query_id, bool is_autocomplete_enabled, bool autoselect_first_suggestion, - const base::string16& name, - const base::string16& prefix, + const std::u16string& name, + const std::u16string& prefix, const std::string& form_control_type, base::WeakPtr<AutocompleteHistoryManager::SuggestionsHandler> handler)); @@ -35,8 +35,8 @@ class MockAutocompleteHistoryManager : public AutocompleteHistoryManager { MOCK_METHOD1(CancelPendingQueries, void(const AutocompleteHistoryManager::SuggestionsHandler*)); MOCK_METHOD2(OnRemoveAutocompleteEntry, - void(const base::string16&, const base::string16&)); - MOCK_METHOD1(OnAutocompleteEntrySelected, void(const base::string16&)); + void(const std::u16string&, const std::u16string&)); + MOCK_METHOD1(OnAutocompleteEntrySelected, void(const std::u16string&)); }; } // namespace autofill diff --git a/chromium/components/autofill/core/browser/pattern_provider/pattern_configuration_parser.cc b/chromium/components/autofill/core/browser/pattern_provider/pattern_configuration_parser.cc index b7818c26d0c..90a25140693 100644 --- a/chromium/components/autofill/core/browser/pattern_provider/pattern_configuration_parser.cc +++ b/chromium/components/autofill/core/browser/pattern_provider/pattern_configuration_parser.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "base/feature_list.h" +#include "base/strings/utf_string_conversions.h" #include "base/task/task_traits.h" #include "base/task/thread_pool.h" #include "base/values.h" @@ -53,12 +54,12 @@ bool ParseMatchingPattern(PatternProvider::Map& patterns, return false; autofill::MatchingPattern new_pattern; - new_pattern.positive_pattern = *positive_pattern; + new_pattern.positive_pattern = base::UTF8ToUTF16(*positive_pattern); new_pattern.positive_score = *positive_score; if (negative_pattern != nullptr) { - new_pattern.negative_pattern = *negative_pattern; + new_pattern.negative_pattern = base::UTF8ToUTF16(*negative_pattern); } else { - new_pattern.negative_pattern = ""; + new_pattern.negative_pattern = u""; } new_pattern.match_field_attributes = match_field_attributes.value(); new_pattern.match_field_input_types = match_field_input_types.value(); diff --git a/chromium/components/autofill/core/browser/pattern_provider/pattern_configuration_parser.h b/chromium/components/autofill/core/browser/pattern_provider/pattern_configuration_parser.h index 8f72b18bf31..78dc78ca275 100644 --- a/chromium/components/autofill/core/browser/pattern_provider/pattern_configuration_parser.h +++ b/chromium/components/autofill/core/browser/pattern_provider/pattern_configuration_parser.h @@ -7,6 +7,7 @@ #include <string> +#include "base/callback_helpers.h" #include "base/json/json_reader.h" #include "base/version.h" #include "components/autofill/core/browser/form_parsing/autofill_parsing_utils.h" diff --git a/chromium/components/autofill/core/browser/pattern_provider/pattern_configuration_parser_unittest.cc b/chromium/components/autofill/core/browser/pattern_provider/pattern_configuration_parser_unittest.cc index de78bc26736..71094b51f2f 100644 --- a/chromium/components/autofill/core/browser/pattern_provider/pattern_configuration_parser_unittest.cc +++ b/chromium/components/autofill/core/browser/pattern_provider/pattern_configuration_parser_unittest.cc @@ -90,8 +90,8 @@ TEST(PatternConfigurationParserTest, WellFormedParsedCorrectly) { // Test one |MatchingPattern| to check that they are parsed correctly. MatchingPattern* pattern = &patterns["FULL_NAME"][LanguageCode("fr")][0]; - ASSERT_EQ("nom|prenom", pattern->positive_pattern); - ASSERT_EQ("compagne", pattern->negative_pattern); + ASSERT_EQ(u"nom|prenom", pattern->positive_pattern); + ASSERT_EQ(u"compagne", pattern->negative_pattern); ASSERT_EQ(LanguageCode("fr"), pattern->language); ASSERT_NEAR(2.0, pattern->positive_score, 1e-6); ASSERT_EQ(2, pattern->match_field_attributes); diff --git a/chromium/components/autofill/core/browser/pattern_provider/pattern_provider_unittest.cc b/chromium/components/autofill/core/browser/pattern_provider/pattern_provider_unittest.cc index c3faf37c79f..0adb4c4a298 100644 --- a/chromium/components/autofill/core/browser/pattern_provider/pattern_provider_unittest.cc +++ b/chromium/components/autofill/core/browser/pattern_provider/pattern_provider_unittest.cc @@ -8,6 +8,7 @@ #include <string> #include <vector> +#include "base/task/thread_pool.h" #include "base/test/gtest_util.h" #include "base/test/scoped_feature_list.h" #include "base/test/task_environment.h" @@ -33,9 +34,9 @@ LanguageCode kLanguageEn("en"); MatchingPattern GetCompanyPatternEn() { autofill::MatchingPattern m_p; - m_p.positive_pattern = "company|business|organization|organisation"; + m_p.positive_pattern = u"company|business|organization|organisation"; m_p.positive_score = 1.1; - m_p.negative_pattern = ""; + m_p.negative_pattern = u""; m_p.match_field_attributes = MATCH_NAME; m_p.match_field_input_types = MATCH_TEXT; m_p.language = kLanguageEn; @@ -44,9 +45,9 @@ MatchingPattern GetCompanyPatternEn() { MatchingPattern GetCompanyPatternDe() { autofill::MatchingPattern m_p; - m_p.positive_pattern = "|(?<!con)firma|firmenname"; + m_p.positive_pattern = u"|(?<!con)firma|firmenname"; m_p.positive_score = 1.1; - m_p.negative_pattern = ""; + m_p.negative_pattern = u""; m_p.match_field_attributes = MATCH_LABEL | MATCH_NAME; m_p.match_field_input_types = MATCH_TEXT; m_p.language = kLanguageDe; diff --git a/chromium/components/autofill/core/browser/pattern_provider/transpile_default_regex_patterns.py b/chromium/components/autofill/core/browser/pattern_provider/transpile_default_regex_patterns.py index 4bd93d80565..37f3950cca5 100755 --- a/chromium/components/autofill/core/browser/pattern_provider/transpile_default_regex_patterns.py +++ b/chromium/components/autofill/core/browser/pattern_provider/transpile_default_regex_patterns.py @@ -28,12 +28,12 @@ def build_cpp_map_population(input): match_field_attributes = pattern['match_field_attributes'] match_field_input_types = pattern['match_field_input_types'] - positive_pattern = to_string_literal(positive_pattern) + positive_pattern = 'u' + to_string_literal(positive_pattern) if negative_pattern is None: negative_pattern = 'nullptr'; else: - negative_pattern = to_string_literal(negative_pattern) + negative_pattern = 'u' + to_string_literal(negative_pattern) # Shift to the right to match the MatchFieldTypes enum, which # temporarily starts at 1<<2 instead of 1<<0. @@ -76,8 +76,8 @@ def build_cpp_function(cpp, output_handle): output(' struct JsonPattern {\n') output(' const char* name;\n') output(' const char* language;\n') - output(' const char* positive_pattern;\n') - output(' const char* negative_pattern;\n') + output(' const char16_t* positive_pattern;\n') + output(' const char16_t* negative_pattern;\n') output(' float positive_score;\n') output(' uint8_t match_field_attributes;\n') output(' uint16_t match_field_input_types;\n') @@ -94,7 +94,7 @@ def build_cpp_function(cpp, output_handle): output(' mp.language = LanguageCode(p.language);\n') output(' mp.positive_pattern = p.positive_pattern;\n') output(' mp.negative_pattern = ' - 'p.negative_pattern ? p.negative_pattern : "";\n') + 'p.negative_pattern ? p.negative_pattern : u"";\n') output(' mp.positive_score = p.positive_score;\n') output(' mp.match_field_input_types = p.match_field_input_types;\n') output(' mp.match_field_attributes = p.match_field_attributes;\n') diff --git a/chromium/components/autofill/core/browser/payments/autofill_credit_card_filling_infobar_delegate_mobile.cc b/chromium/components/autofill/core/browser/payments/autofill_credit_card_filling_infobar_delegate_mobile.cc index 7a77ca039f3..4e934854fe0 100644 --- a/chromium/components/autofill/core/browser/payments/autofill_credit_card_filling_infobar_delegate_mobile.cc +++ b/chromium/components/autofill/core/browser/payments/autofill_credit_card_filling_infobar_delegate_mobile.cc @@ -27,7 +27,7 @@ AutofillCreditCardFillingInfoBarDelegateMobile:: #if defined(OS_IOS) card_label_(card.NetworkAndLastFourDigits()), #else - card_label_(base::string16(kMidlineEllipsis) + card.LastFourDigits()), + card_label_(std::u16string(kMidlineEllipsis) + card.LastFourDigits()), #endif card_sub_label_(card.AbbreviatedExpirationDateForDisplay(false)) { } @@ -46,7 +46,7 @@ int AutofillCreditCardFillingInfoBarDelegateMobile::GetIconId() const { return IDR_INFOBAR_AUTOFILL_CC; } -base::string16 AutofillCreditCardFillingInfoBarDelegateMobile::GetMessageText() +std::u16string AutofillCreditCardFillingInfoBarDelegateMobile::GetMessageText() const { #if defined(OS_ANDROID) return l10n_util::GetStringUTF16( @@ -78,7 +78,7 @@ AutofillCreditCardFillingInfoBarDelegateMobile::GetIdentifier() const { return AUTOFILL_CREDIT_CARD_FILLING_INFOBAR_DELEGATE_ANDROID; } -base::string16 AutofillCreditCardFillingInfoBarDelegateMobile::GetButtonLabel( +std::u16string AutofillCreditCardFillingInfoBarDelegateMobile::GetButtonLabel( InfoBarButton button) const { return l10n_util::GetStringUTF16( button == BUTTON_OK ? IDS_AUTOFILL_CREDIT_CARD_FILLING_INFOBAR_ACCEPT diff --git a/chromium/components/autofill/core/browser/payments/autofill_credit_card_filling_infobar_delegate_mobile.h b/chromium/components/autofill/core/browser/payments/autofill_credit_card_filling_infobar_delegate_mobile.h index 721af6e2491..ebd7013e6da 100644 --- a/chromium/components/autofill/core/browser/payments/autofill_credit_card_filling_infobar_delegate_mobile.h +++ b/chromium/components/autofill/core/browser/payments/autofill_credit_card_filling_infobar_delegate_mobile.h @@ -6,10 +6,10 @@ #define COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_AUTOFILL_CREDIT_CARD_FILLING_INFOBAR_DELEGATE_MOBILE_H_ #include <memory> +#include <string> #include "base/callback.h" #include "base/macros.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/autofill_metrics.h" #include "components/infobars/core/confirm_infobar_delegate.h" @@ -28,13 +28,13 @@ class AutofillCreditCardFillingInfoBarDelegateMobile ~AutofillCreditCardFillingInfoBarDelegateMobile() override; int issuer_icon_id() const { return issuer_icon_id_; } - const base::string16& card_label() const { return card_label_; } - const base::string16& card_sub_label() const { return card_sub_label_; } + const std::u16string& card_label() const { return card_label_; } + const std::u16string& card_sub_label() const { return card_sub_label_; } void set_was_shown() { was_shown_ = true; } // ConfirmInfoBarDelegate (publicly exposed): int GetIconId() const override; - base::string16 GetMessageText() const override; + std::u16string GetMessageText() const override; void InfoBarDismissed() override; bool Accept() override; bool Cancel() override; @@ -42,7 +42,7 @@ class AutofillCreditCardFillingInfoBarDelegateMobile private: // ConfirmInfoBarDelegate (continued): infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; - base::string16 GetButtonLabel(InfoBarButton button) const override; + std::u16string GetButtonLabel(InfoBarButton button) const override; void LogUserAction(AutofillMetrics::InfoBarMetric user_action); @@ -59,8 +59,8 @@ class AutofillCreditCardFillingInfoBarDelegateMobile // The resource ID for the icon that identifies the issuer of the card. int issuer_icon_id_; - base::string16 card_label_; - base::string16 card_sub_label_; + std::u16string card_label_; + std::u16string card_sub_label_; DISALLOW_COPY_AND_ASSIGN(AutofillCreditCardFillingInfoBarDelegateMobile); }; diff --git a/chromium/components/autofill/core/browser/payments/autofill_offer_manager.cc b/chromium/components/autofill/core/browser/payments/autofill_offer_manager.cc index 7784a1e9241..595d94665c1 100644 --- a/chromium/components/autofill/core/browser/payments/autofill_offer_manager.cc +++ b/chromium/components/autofill/core/browser/payments/autofill_offer_manager.cc @@ -83,9 +83,12 @@ void AutofillOfferManager::UpdateSuggestionsWithOffers( } bool AutofillOfferManager::IsUrlEligible(const GURL& last_committed_url) { - GURL last_committed_url_origin = last_committed_url.GetOrigin(); - return base::ranges::count(eligible_merchant_domains_, - last_committed_url_origin); + // Checking set::empty and using set::count to prevent possible crashes (see + // crbug.com/1195949). + // For most cases this vector will be empty, so add the empty check to avoid + // unnecessary calls. + return !eligible_merchant_domains_.empty() && + eligible_merchant_domains_.count(last_committed_url.GetOrigin()); } std::tuple<std::vector<GURL>, GURL, CreditCard*> diff --git a/chromium/components/autofill/core/browser/payments/autofill_offer_manager.h b/chromium/components/autofill/core/browser/payments/autofill_offer_manager.h index dab84da0594..e330f35d8d7 100644 --- a/chromium/components/autofill/core/browser/payments/autofill_offer_manager.h +++ b/chromium/components/autofill/core/browser/payments/autofill_offer_manager.h @@ -11,7 +11,6 @@ #include <tuple> #include <vector> -#include "base/strings/string16.h" #include "base/time/time.h" #include "base/timer/timer.h" #include "components/autofill/core/browser/autofill_client.h" diff --git a/chromium/components/autofill/core/browser/payments/autofill_offer_notification_infobar_delegate_mobile.cc b/chromium/components/autofill/core/browser/payments/autofill_offer_notification_infobar_delegate_mobile.cc index b1d73910379..8e3ec2e247b 100644 --- a/chromium/components/autofill/core/browser/payments/autofill_offer_notification_infobar_delegate_mobile.cc +++ b/chromium/components/autofill/core/browser/payments/autofill_offer_notification_infobar_delegate_mobile.cc @@ -60,7 +60,7 @@ int AutofillOfferNotificationInfoBarDelegateMobile::GetIconId() const { return IDR_AUTOFILL_GOOGLE_PAY_WITH_DIVIDER; } -base::string16 AutofillOfferNotificationInfoBarDelegateMobile::GetMessageText() +std::u16string AutofillOfferNotificationInfoBarDelegateMobile::GetMessageText() const { return l10n_util::GetStringUTF16(IDS_AUTOFILL_OFFERS_REMINDER_TITLE); } @@ -74,7 +74,7 @@ int AutofillOfferNotificationInfoBarDelegateMobile::GetButtons() const { return BUTTON_OK; } -base::string16 AutofillOfferNotificationInfoBarDelegateMobile::GetButtonLabel( +std::u16string AutofillOfferNotificationInfoBarDelegateMobile::GetButtonLabel( InfoBarButton button) const { if (button == BUTTON_OK) { return l10n_util::GetStringUTF16( @@ -82,7 +82,7 @@ base::string16 AutofillOfferNotificationInfoBarDelegateMobile::GetButtonLabel( } NOTREACHED() << "Unsupported button label requested: " << button; - return base::string16(); + return std::u16string(); } void AutofillOfferNotificationInfoBarDelegateMobile::InfoBarDismissed() { diff --git a/chromium/components/autofill/core/browser/payments/autofill_offer_notification_infobar_delegate_mobile.h b/chromium/components/autofill/core/browser/payments/autofill_offer_notification_infobar_delegate_mobile.h index a4a0e967d9a..4f7b501a13f 100644 --- a/chromium/components/autofill/core/browser/payments/autofill_offer_notification_infobar_delegate_mobile.h +++ b/chromium/components/autofill/core/browser/payments/autofill_offer_notification_infobar_delegate_mobile.h @@ -6,10 +6,10 @@ #define COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_AUTOFILL_OFFER_NOTIFICATION_INFOBAR_DELEGATE_MOBILE_H_ #include <memory> +#include <string> #include "base/callback.h" #include "base/macros.h" -#include "base/strings/string16.h" #include "build/build_config.h" #include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_metrics.h" @@ -35,7 +35,7 @@ class AutofillOfferNotificationInfoBarDelegateMobile AutofillOfferNotificationInfoBarDelegateMobile& operator=( const AutofillOfferNotificationInfoBarDelegateMobile&) = delete; - const base::string16& credit_card_identifier_string() const { + const std::u16string& credit_card_identifier_string() const { return credit_card_identifier_string_; } int network_icon_id() { return network_icon_id_; } @@ -46,16 +46,16 @@ class AutofillOfferNotificationInfoBarDelegateMobile // ConfirmInfoBarDelegate: int GetIconId() const override; - base::string16 GetMessageText() const override; + std::u16string GetMessageText() const override; infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; int GetButtons() const override; - base::string16 GetButtonLabel(InfoBarButton button) const override; + std::u16string GetButtonLabel(InfoBarButton button) const override; void InfoBarDismissed() override; bool Accept() override; private: // Identifier for the credit card associated with the offer. - base::string16 credit_card_identifier_string_; + std::u16string credit_card_identifier_string_; // Resource id for the icon representing the network of the credit card. int network_icon_id_; // URL that links to the offer details page in the Google Pay app. diff --git a/chromium/components/autofill/core/browser/payments/autofill_save_card_infobar_delegate_mobile.cc b/chromium/components/autofill/core/browser/payments/autofill_save_card_infobar_delegate_mobile.cc index 8fdc3912d20..aaed50feabe 100644 --- a/chromium/components/autofill/core/browser/payments/autofill_save_card_infobar_delegate_mobile.cc +++ b/chromium/components/autofill/core/browser/payments/autofill_save_card_infobar_delegate_mobile.cc @@ -94,12 +94,12 @@ bool AutofillSaveCardInfoBarDelegateMobile::IsGooglePayBrandingEnabled() const { #endif } -base::string16 AutofillSaveCardInfoBarDelegateMobile::GetDescriptionText() +std::u16string AutofillSaveCardInfoBarDelegateMobile::GetDescriptionText() const { // Without Google Pay branding, the title acts as the description (see // |GetMessageText|). if (!IsGooglePayBrandingEnabled()) - return base::string16(); + return std::u16string(); return l10n_util::GetStringUTF16( IDS_AUTOFILL_SAVE_CARD_PROMPT_UPLOAD_EXPLANATION_V3); @@ -110,7 +110,7 @@ int AutofillSaveCardInfoBarDelegateMobile::GetIconId() const { : IDR_INFOBAR_AUTOFILL_CC; } -base::string16 AutofillSaveCardInfoBarDelegateMobile::GetMessageText() const { +std::u16string AutofillSaveCardInfoBarDelegateMobile::GetMessageText() const { return l10n_util::GetStringUTF16( IsGooglePayBrandingEnabled() ? IDS_AUTOFILL_SAVE_CARD_PROMPT_TITLE_TO_CLOUD_V3 @@ -160,7 +160,7 @@ int AutofillSaveCardInfoBarDelegateMobile::GetButtons() const { return BUTTON_OK | BUTTON_CANCEL; } -base::string16 AutofillSaveCardInfoBarDelegateMobile::GetButtonLabel( +std::u16string AutofillSaveCardInfoBarDelegateMobile::GetButtonLabel( InfoBarButton button) const { if (button == BUTTON_OK) { // Requesting name or expiration date from the user makes the save prompt a @@ -179,7 +179,7 @@ base::string16 AutofillSaveCardInfoBarDelegateMobile::GetButtonLabel( } NOTREACHED() << "Unsupported button label requested."; - return base::string16(); + return std::u16string(); } bool AutofillSaveCardInfoBarDelegateMobile::Accept() { @@ -191,9 +191,9 @@ bool AutofillSaveCardInfoBarDelegateMobile::Accept() { #if defined(OS_IOS) bool AutofillSaveCardInfoBarDelegateMobile::UpdateAndAccept( - base::string16 cardholder_name, - base::string16 expiration_date_month, - base::string16 expiration_date_year) { + std::u16string cardholder_name, + std::u16string expiration_date_month, + std::u16string expiration_date_year) { AutofillClient::UserProvidedCardDetails user_provided_details; user_provided_details.cardholder_name = cardholder_name; user_provided_details.expiration_date_month = expiration_date_month; diff --git a/chromium/components/autofill/core/browser/payments/autofill_save_card_infobar_delegate_mobile.h b/chromium/components/autofill/core/browser/payments/autofill_save_card_infobar_delegate_mobile.h index f1f9011b1e2..34cf8d8f4cb 100644 --- a/chromium/components/autofill/core/browser/payments/autofill_save_card_infobar_delegate_mobile.h +++ b/chromium/components/autofill/core/browser/payments/autofill_save_card_infobar_delegate_mobile.h @@ -6,10 +6,10 @@ #define COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_AUTOFILL_SAVE_CARD_INFOBAR_DELEGATE_MOBILE_H_ #include <memory> +#include <string> #include "base/callback.h" #include "base/macros.h" -#include "base/strings/string16.h" #include "build/build_config.h" #include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_metrics.h" @@ -46,19 +46,19 @@ class AutofillSaveCardInfoBarDelegateMobile : public ConfirmInfoBarDelegate { bool upload() const { return upload_; } int issuer_icon_id() const { return issuer_icon_id_; } - const base::string16& card_label() const { return card_label_; } - const base::string16& card_sub_label() const { return card_sub_label_; } + const std::u16string& card_label() const { return card_label_; } + const std::u16string& card_sub_label() const { return card_sub_label_; } const LegalMessageLines& legal_message_lines() const { return legal_message_lines_; } - const base::string16& card_last_four_digits() const { + const std::u16string& card_last_four_digits() const { return card_last_four_digits_; } - const base::string16& cardholder_name() const { return cardholder_name_; } - const base::string16& expiration_date_month() const { + const std::u16string& cardholder_name() const { return cardholder_name_; } + const std::u16string& expiration_date_month() const { return expiration_date_month_; } - const base::string16& expiration_date_year() const { + const std::u16string& expiration_date_year() const { return expiration_date_year_; } @@ -70,16 +70,16 @@ class AutofillSaveCardInfoBarDelegateMobile : public ConfirmInfoBarDelegate { bool IsGooglePayBrandingEnabled() const; // Description text to be shown above the card information in the infobar. - base::string16 GetDescriptionText() const; + std::u16string GetDescriptionText() const; // ConfirmInfoBarDelegate: int GetIconId() const override; - base::string16 GetMessageText() const override; + std::u16string GetMessageText() const override; infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; bool ShouldExpire(const NavigationDetails& details) const override; void InfoBarDismissed() override; int GetButtons() const override; - base::string16 GetButtonLabel(InfoBarButton button) const override; + std::u16string GetButtonLabel(InfoBarButton button) const override; bool Accept() override; bool Cancel() override; @@ -87,9 +87,9 @@ class AutofillSaveCardInfoBarDelegateMobile : public ConfirmInfoBarDelegate { // Updates and then saves the card using |cardholder_name|, // |expiration_date_month| and |expiration_date_year|, which were provided // as part of the iOS save card Infobar dialog. - virtual bool UpdateAndAccept(base::string16 cardholder_name, - base::string16 expiration_date_month, - base::string16 expiration_date_year); + virtual bool UpdateAndAccept(std::u16string cardholder_name, + std::u16string expiration_date_month, + std::u16string expiration_date_year); #endif // defined(OS_IOS) private: @@ -132,22 +132,22 @@ class AutofillSaveCardInfoBarDelegateMobile : public ConfirmInfoBarDelegate { int issuer_icon_id_; // The label for the card to show in the content of the infobar. - base::string16 card_label_; + std::u16string card_label_; // The sub-label for the card to show in the content of the infobar. - base::string16 card_sub_label_; + std::u16string card_sub_label_; // The last four digits of the card for which save is being offered. - base::string16 card_last_four_digits_; + std::u16string card_last_four_digits_; // The card holder name of the card for which save is being offered. - base::string16 cardholder_name_; + std::u16string cardholder_name_; // The expiration month of the card for which save is being offered. - base::string16 expiration_date_month_; + std::u16string expiration_date_month_; // The expiration year of the card for which save is being offered. - base::string16 expiration_date_year_; + std::u16string expiration_date_year_; // The legal message lines to show in the content of the infobar. const LegalMessageLines& legal_message_lines_; diff --git a/chromium/components/autofill/core/browser/payments/card_unmask_delegate.h b/chromium/components/autofill/core/browser/payments/card_unmask_delegate.h index 4df39155e89..bfbe27a59ff 100644 --- a/chromium/components/autofill/core/browser/payments/card_unmask_delegate.h +++ b/chromium/components/autofill/core/browser/payments/card_unmask_delegate.h @@ -7,7 +7,6 @@ #include <string> -#include "base/strings/string16.h" namespace autofill { @@ -19,13 +18,13 @@ class CardUnmaskDelegate { ~UserProvidedUnmaskDetails(); // User input data. - base::string16 cvc; + std::u16string cvc; // Two digit month. - base::string16 exp_month; + std::u16string exp_month; // Four digit year. - base::string16 exp_year; + std::u16string exp_year; // State of "copy to this device" checkbox. bool should_store_pan; diff --git a/chromium/components/autofill/core/browser/payments/credit_card_access_manager.cc b/chromium/components/autofill/core/browser/payments/credit_card_access_manager.cc index 560f30b57c8..eb7dbae6a4f 100644 --- a/chromium/components/autofill/core/browser/payments/credit_card_access_manager.cc +++ b/chromium/components/autofill/core/browser/payments/credit_card_access_manager.cc @@ -13,7 +13,6 @@ #include "base/bind.h" #include "base/guid.h" #include "base/metrics/histogram_functions.h" -#include "base/strings/string16.h" #include "base/synchronization/waitable_event.h" #include "base/task/post_task.h" #include "base/task/task_traits.h" @@ -133,8 +132,8 @@ bool CreditCardAccessManager::DeleteCard(const CreditCard* card) { bool CreditCardAccessManager::GetDeletionConfirmationText( const CreditCard* card, - base::string16* title, - base::string16* body) { + std::u16string* title, + std::u16string* body) { if (!IsLocalCard(card)) return false; @@ -370,7 +369,7 @@ void CreditCardAccessManager::SignalCanFetchUnmaskDetails() { } void CreditCardAccessManager::CacheUnmaskedCardInfo(const CreditCard& card, - const base::string16& cvc) { + const std::u16string& cvc) { DCHECK_EQ(card.record_type(), CreditCard::FULL_SERVER_CARD); CachedServerCardInfo card_info = {card, cvc, 0}; unmasked_card_cache_[card.server_id()] = card_info; @@ -609,7 +608,7 @@ bool CreditCardAccessManager::UserOptedInToFidoFromSettingsPageOnMobile() void CreditCardAccessManager::OnFIDOAuthenticationComplete( bool did_succeed, const CreditCard* card, - const base::string16& cvc) { + const std::u16string& cvc) { #if !defined(OS_ANDROID) // Close the Webauthn verify pending dialog. If FIDO authentication succeeded, // card is filled to the form, otherwise fall back to CVC authentication which @@ -642,7 +641,7 @@ void CreditCardAccessManager::OnFidoAuthorizationComplete(bool did_succeed) { unmask_auth_flow_type_); } unmask_auth_flow_type_ = UnmaskAuthFlowType::kNone; - cvc_ = base::string16(); + cvc_ = std::u16string(); } #endif diff --git a/chromium/components/autofill/core/browser/payments/credit_card_access_manager.h b/chromium/components/autofill/core/browser/payments/credit_card_access_manager.h index 6bdf8b8c647..28436a7dfd2 100644 --- a/chromium/components/autofill/core/browser/payments/credit_card_access_manager.h +++ b/chromium/components/autofill/core/browser/payments/credit_card_access_manager.h @@ -12,7 +12,6 @@ #include <utility> #include <vector> -#include "base/strings/string16.h" #include "base/synchronization/waitable_event.h" #include "base/task/cancelable_task_tracker.h" #include "build/build_config.h" @@ -51,7 +50,7 @@ struct CachedServerCardInfo { // An unmasked CreditCard. CreditCard card; - base::string16 cvc; + std::u16string cvc; // Number of times this card was accessed from the cache. int cache_uses = 0; @@ -72,7 +71,7 @@ class CreditCardAccessManager : public CreditCardCVCAuthenticator::Requester, virtual void OnCreditCardFetched( bool did_succeed, const CreditCard* credit_card = nullptr, - const base::string16& cvc = base::string16()) = 0; + const std::u16string& cvc = std::u16string()) = 0; }; CreditCardAccessManager( @@ -95,8 +94,8 @@ class CreditCardAccessManager : public CreditCardCVCAuthenticator::Requester, // Returns true if the |card| is deletable. Fills out // |title| and |body| with relevant user-facing text. bool GetDeletionConfirmationText(const CreditCard* card, - base::string16* title, - base::string16* body); + std::u16string* title, + std::u16string* body); // Returns false only if some form of authentication is still in progress. bool ShouldClearPreviewedForm(); @@ -130,7 +129,7 @@ class CreditCardAccessManager : public CreditCardCVCAuthenticator::Requester, // Caches CreditCard and corresponding CVC for unmasked card so that // card info can later be filled without attempting to auth again. // TODO(crbug/1069929): Add browsertests for this. - void CacheUnmaskedCardInfo(const CreditCard& card, const base::string16& cvc); + void CacheUnmaskedCardInfo(const CreditCard& card, const std::u16string& cvc); CreditCardCVCAuthenticator* GetOrCreateCVCAuthenticator(); @@ -198,7 +197,7 @@ class CreditCardAccessManager : public CreditCardCVCAuthenticator::Requester, void OnFIDOAuthenticationComplete( bool did_succeed, const CreditCard* card = nullptr, - const base::string16& cvc = base::string16()) override; + const std::u16string& cvc = std::u16string()) override; void OnFidoAuthorizationComplete(bool did_succeed) override; #endif @@ -313,7 +312,7 @@ class CreditCardAccessManager : public CreditCardCVCAuthenticator::Requester, // When authorizing a new card, the CVC will be temporarily stored after the // first CVC check, and then will be used to fill the form after FIDO // authentication is complete. - base::string16 cvc_ = base::string16(); + std::u16string cvc_ = std::u16string(); // Set to true only if user has a verifying platform authenticator. // e.g. Touch/Face ID, Windows Hello, Android fingerprint, etc., is available diff --git a/chromium/components/autofill/core/browser/payments/credit_card_access_manager_unittest.cc b/chromium/components/autofill/core/browser/payments/credit_card_access_manager_unittest.cc index faa396e337d..57c84e78c77 100644 --- a/chromium/components/autofill/core/browser/payments/credit_card_access_manager_unittest.cc +++ b/chromium/components/autofill/core/browser/payments/credit_card_access_manager_unittest.cc @@ -21,7 +21,6 @@ #include "base/metrics/metrics_hashes.h" #include "base/run_loop.h" #include "base/stl_util.h" -#include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -109,7 +108,7 @@ class TestAccessor : public CreditCardAccessManager::Accessor { void OnCreditCardFetched(bool did_succeed, const CreditCard* card, - const base::string16& cvc) override { + const std::u16string& cvc) override { did_succeed_ = did_succeed; if (did_succeed_) { DCHECK(card); @@ -118,8 +117,8 @@ class TestAccessor : public CreditCardAccessManager::Accessor { } } - base::string16 number() { return number_; } - base::string16 cvc() { return cvc_; } + std::u16string number() { return number_; } + std::u16string cvc() { return cvc_; } bool did_succeed() { return did_succeed_; } @@ -127,9 +126,9 @@ class TestAccessor : public CreditCardAccessManager::Accessor { // Is set to true if authentication was successful. bool did_succeed_ = false; // The card number returned from OnCreditCardFetched(). - base::string16 number_; + std::u16string number_; // The returned CVC, if any. - base::string16 cvc_; + std::u16string cvc_; base::WeakPtrFactory<TestAccessor> weak_ptr_factory_{this}; }; @@ -446,8 +445,8 @@ TEST_F(CreditCardAccessManagerTest, LocalCardGetDeletionConfirmationText) { CreateLocalCard(kTestGUID); CreditCard* card = credit_card_access_manager_->GetCreditCard(kTestGUID); - base::string16 title = base::string16(); - base::string16 body = base::string16(); + std::u16string title = std::u16string(); + std::u16string body = std::u16string(); EXPECT_TRUE(credit_card_access_manager_->GetDeletionConfirmationText( card, &title, &body)); @@ -463,14 +462,14 @@ TEST_F(CreditCardAccessManagerTest, ServerCardGetDeletionConfirmationText) { CreateServerCard(kTestGUID); CreditCard* card = credit_card_access_manager_->GetCreditCard(kTestGUID); - base::string16 title = base::string16(); - base::string16 body = base::string16(); + std::u16string title = std::u16string(); + std::u16string body = std::u16string(); EXPECT_FALSE(credit_card_access_manager_->GetDeletionConfirmationText( card, &title, &body)); // |title| and |body| should remain unchanged. - EXPECT_EQ(title, base::string16()); - EXPECT_EQ(body, base::string16()); + EXPECT_EQ(title, std::u16string()); + EXPECT_EQ(body, std::u16string()); } // Tests retrieving local cards. @@ -1096,8 +1095,8 @@ TEST_F(CreditCardAccessManagerTest, FIDONewCardAuthorization) { /*fido_opt_in=*/false, /*follow_with_fido_auth=*/false)); // Ensure that form is not filled yet (OnCreditCardFetched is not called). - EXPECT_EQ(accessor_->number(), base::string16()); - EXPECT_EQ(accessor_->cvc(), base::string16()); + EXPECT_EQ(accessor_->number(), std::u16string()); + EXPECT_EQ(accessor_->cvc(), std::u16string()); // Mock user response. EXPECT_EQ(CreditCardFIDOAuthenticator::Flow::FOLLOWUP_AFTER_CVC_AUTH_FLOW, @@ -1129,7 +1128,7 @@ TEST_F(CreditCardAccessManagerTest, FetchExpiredServerCardInvokesCvcPrompt) { // card. CreateServerCard(kTestGUID, kTestNumber); CreditCard* card = credit_card_access_manager_->GetCreditCard(kTestGUID); - card->SetExpirationYearFromString(base::UTF8ToUTF16("2010")); + card->SetExpirationYearFromString(u"2010"); GetFIDOAuthenticator()->SetUserVerifiable(true); SetUserOptedIn(true); payments_client_->AddFidoEligibleCard(card->server_id(), kCredentialId, @@ -1176,8 +1175,8 @@ TEST_F(CreditCardAccessManagerTest, FIDOOptInSuccess_Android) { EXPECT_EQ(CreditCardFIDOAuthenticator::Flow::OPT_IN_WITH_CHALLENGE_FLOW, GetFIDOAuthenticator()->current_flow()); // Ensure that form is not filled yet (OnCreditCardFetched is not called). - EXPECT_EQ(accessor_->number(), base::string16()); - EXPECT_EQ(accessor_->cvc(), base::string16()); + EXPECT_EQ(accessor_->number(), std::u16string()); + EXPECT_EQ(accessor_->cvc(), std::u16string()); // Mock user response. TestCreditCardFIDOAuthenticator::GetAssertion(GetFIDOAuthenticator(), @@ -1224,8 +1223,8 @@ TEST_F(CreditCardAccessManagerTest, FIDOOptInUserVerificationFailure) { EXPECT_EQ(CreditCardFIDOAuthenticator::Flow::OPT_IN_WITH_CHALLENGE_FLOW, GetFIDOAuthenticator()->current_flow()); // Ensure that form is not filled yet (OnCreditCardFetched is not called). - EXPECT_EQ(accessor_->number(), base::string16()); - EXPECT_EQ(accessor_->cvc(), base::string16()); + EXPECT_EQ(accessor_->number(), std::u16string()); + EXPECT_EQ(accessor_->cvc(), std::u16string()); // Mock GetAssertion failure. TestCreditCardFIDOAuthenticator::GetAssertion(GetFIDOAuthenticator(), @@ -1264,8 +1263,8 @@ TEST_F(CreditCardAccessManagerTest, FIDOOptInServerFailure) { EXPECT_EQ(CreditCardFIDOAuthenticator::Flow::OPT_IN_WITH_CHALLENGE_FLOW, GetFIDOAuthenticator()->current_flow()); // Ensure that form is not filled yet (OnCreditCardFetched is not called). - EXPECT_EQ(accessor_->number(), base::string16()); - EXPECT_EQ(accessor_->cvc(), base::string16()); + EXPECT_EQ(accessor_->number(), std::u16string()); + EXPECT_EQ(accessor_->cvc(), std::u16string()); // Mock user response and OptChange payments call. TestCreditCardFIDOAuthenticator::GetAssertion(GetFIDOAuthenticator(), diff --git a/chromium/components/autofill/core/browser/payments/credit_card_cvc_authenticator.cc b/chromium/components/autofill/core/browser/payments/credit_card_cvc_authenticator.cc index 1f3916fe2e6..a09f0cb90fc 100644 --- a/chromium/components/autofill/core/browser/payments/credit_card_cvc_authenticator.cc +++ b/chromium/components/autofill/core/browser/payments/credit_card_cvc_authenticator.cc @@ -5,8 +5,8 @@ #include "components/autofill/core/browser/payments/credit_card_cvc_authenticator.h" #include <memory> +#include <string> -#include "base/strings/string16.h" #include "build/build_config.h" #include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/data_model/credit_card.h" @@ -45,7 +45,7 @@ void CreditCardCVCAuthenticator::Authenticate( void CreditCardCVCAuthenticator::OnFullCardRequestSucceeded( const payments::FullCardRequest& full_card_request, const CreditCard& card, - const base::string16& cvc) { + const std::u16string& cvc) { payments::PaymentsClient::UnmaskResponseDetails response = full_card_request.unmask_response_details(); requester_->OnCVCAuthenticationComplete( @@ -92,9 +92,9 @@ payments::FullCardRequest* CreditCardCVCAuthenticator::GetFullCardRequest() { // CreditCardAccessManager to retrieve cards from payments instead of calling // this function directly. if (!full_card_request_) { - full_card_request_.reset( - new payments::FullCardRequest(client_, client_->GetPaymentsClient(), - client_->GetPersonalDataManager())); + full_card_request_ = std::make_unique<payments::FullCardRequest>( + client_, client_->GetPaymentsClient(), + client_->GetPersonalDataManager()); } return full_card_request_.get(); } diff --git a/chromium/components/autofill/core/browser/payments/credit_card_cvc_authenticator.h b/chromium/components/autofill/core/browser/payments/credit_card_cvc_authenticator.h index 20fe78c46e8..42b4fa3a733 100644 --- a/chromium/components/autofill/core/browser/payments/credit_card_cvc_authenticator.h +++ b/chromium/components/autofill/core/browser/payments/credit_card_cvc_authenticator.h @@ -6,8 +6,8 @@ #define COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_CREDIT_CARD_CVC_AUTHENTICATOR_H_ #include <memory> +#include <string> -#include "base/strings/string16.h" #include "build/build_config.h" #include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/data_model/credit_card.h" @@ -34,8 +34,8 @@ class CreditCardCVCAuthenticator card = c; return *this; } - CVCAuthenticationResponse& with_cvc(const base::string16 s) { - cvc = base::string16(s); + CVCAuthenticationResponse& with_cvc(const std::u16string s) { + cvc = std::u16string(s); return *this; } CVCAuthenticationResponse& with_creation_options( @@ -54,7 +54,7 @@ class CreditCardCVCAuthenticator } bool did_succeed = false; const CreditCard* card = nullptr; - base::string16 cvc = base::string16(); + std::u16string cvc = std::u16string(); base::Optional<base::Value> creation_options = base::nullopt; base::Optional<base::Value> request_options = base::nullopt; std::string card_authorization_token = std::string(); @@ -94,7 +94,7 @@ class CreditCardCVCAuthenticator void OnFullCardRequestSucceeded( const payments::FullCardRequest& full_card_request, const CreditCard& card, - const base::string16& cvc) override; + const std::u16string& cvc) override; void OnFullCardRequestFailed( payments::FullCardRequest::FailureType failure_type) override; diff --git a/chromium/components/autofill/core/browser/payments/credit_card_cvc_authenticator_unittest.cc b/chromium/components/autofill/core/browser/payments/credit_card_cvc_authenticator_unittest.cc index 8430cb6dbb1..af0930d6522 100644 --- a/chromium/components/autofill/core/browser/payments/credit_card_cvc_authenticator_unittest.cc +++ b/chromium/components/autofill/core/browser/payments/credit_card_cvc_authenticator_unittest.cc @@ -20,7 +20,6 @@ #include "base/metrics/field_trial.h" #include "base/metrics/metrics_hashes.h" #include "base/stl_util.h" -#include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -92,7 +91,7 @@ class CreditCardCVCAuthenticatorTest : public testing::Test { /*is_off_the_record=*/false); personal_data_manager_.SetPrefService(autofill_client_.GetPrefs()); - requester_.reset(new TestAuthenticationRequester()); + requester_ = std::make_unique<TestAuthenticationRequester>(); autofill_driver_ = std::make_unique<testing::NiceMock<TestAutofillDriver>>(); @@ -137,7 +136,7 @@ class CreditCardCVCAuthenticatorTest : public testing::Test { // Mock user response. payments::FullCardRequest::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; full_card_request->OnUnmaskPromptAccepted(details); // Mock payments response. diff --git a/chromium/components/autofill/core/browser/payments/credit_card_fido_authenticator.cc b/chromium/components/autofill/core/browser/payments/credit_card_fido_authenticator.cc index 51882104cf3..897c4429b7a 100644 --- a/chromium/components/autofill/core/browser/payments/credit_card_fido_authenticator.cc +++ b/chromium/components/autofill/core/browser/payments/credit_card_fido_authenticator.cc @@ -4,13 +4,13 @@ #include "components/autofill/core/browser/payments/credit_card_fido_authenticator.h" +#include <memory> #include <string> #include <utility> #include <vector> #include "base/base64.h" #include "base/containers/flat_set.h" -#include "base/strings/string16.h" #include "base/strings/string_util.h" #include "build/build_config.h" #include "components/autofill/core/browser/autofill_client.h" @@ -414,9 +414,9 @@ void CreditCardFIDOAuthenticator::OnDidGetAssertion( if (current_flow_ == AUTHENTICATION_FLOW) { base::Value response = ParseAssertionResponse(std::move(assertion_response)); - full_card_request_.reset(new payments::FullCardRequest( + full_card_request_ = std::make_unique<payments::FullCardRequest>( autofill_client_, autofill_client_->GetPaymentsClient(), - autofill_client_->GetPersonalDataManager(), form_parsed_timestamp_)); + autofill_client_->GetPersonalDataManager(), form_parsed_timestamp_); full_card_request_->GetFullCardViaFIDO( *card_, AutofillClient::UNMASK_FOR_AUTOFILL, weak_ptr_factory_.GetWeakPtr(), std::move(response)); @@ -514,7 +514,7 @@ void CreditCardFIDOAuthenticator::OnDidGetOptChangeResult( void CreditCardFIDOAuthenticator::OnFullCardRequestSucceeded( const payments::FullCardRequest& full_card_request, const CreditCard& card, - const base::string16& cvc) { + const std::u16string& cvc) { DCHECK_EQ(AUTHENTICATION_FLOW, current_flow_); current_flow_ = NONE_FLOW; requester_->OnFIDOAuthenticationComplete(/*did_succeed=*/true, &card, cvc); diff --git a/chromium/components/autofill/core/browser/payments/credit_card_fido_authenticator.h b/chromium/components/autofill/core/browser/payments/credit_card_fido_authenticator.h index c857d8481c6..2846aaa461d 100644 --- a/chromium/components/autofill/core/browser/payments/credit_card_fido_authenticator.h +++ b/chromium/components/autofill/core/browser/payments/credit_card_fido_authenticator.h @@ -6,8 +6,8 @@ #define COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_CREDIT_CARD_FIDO_AUTHENTICATOR_H_ #include <memory> +#include <string> -#include "base/strings/string16.h" #include "build/build_config.h" #include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_driver.h" @@ -82,7 +82,7 @@ class CreditCardFIDOAuthenticator virtual void OnFIDOAuthenticationComplete( bool did_succeed, const CreditCard* card = nullptr, - const base::string16& cvc = base::string16()) = 0; + const std::u16string& cvc = std::u16string()) = 0; virtual void OnFidoAuthorizationComplete(bool did_succeed) = 0; }; CreditCardFIDOAuthenticator(AutofillDriver* driver, AutofillClient* client); @@ -193,7 +193,7 @@ class CreditCardFIDOAuthenticator void OnFullCardRequestSucceeded( const payments::FullCardRequest& full_card_request, const CreditCard& card, - const base::string16& cvc) override; + const std::u16string& cvc) override; void OnFullCardRequestFailed( payments::FullCardRequest::FailureType failure_type) override; diff --git a/chromium/components/autofill/core/browser/payments/credit_card_fido_authenticator_unittest.cc b/chromium/components/autofill/core/browser/payments/credit_card_fido_authenticator_unittest.cc index a8180c90fcb..7a719920bd5 100644 --- a/chromium/components/autofill/core/browser/payments/credit_card_fido_authenticator_unittest.cc +++ b/chromium/components/autofill/core/browser/payments/credit_card_fido_authenticator_unittest.cc @@ -20,7 +20,6 @@ #include "base/metrics/field_trial.h" #include "base/metrics/metrics_hashes.h" #include "base/stl_util.h" -#include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -121,7 +120,7 @@ class CreditCardFIDOAuthenticatorTest : public testing::Test { /*is_off_the_record=*/false); personal_data_manager_.SetPrefService(autofill_client_.GetPrefs()); - requester_.reset(new TestAuthenticationRequester()); + requester_ = std::make_unique<TestAuthenticationRequester>(); autofill_driver_ = std::make_unique<testing::NiceMock<TestAutofillDriver>>(); autofill_driver_->SetAuthenticator(new TestInternalAuthenticator()); diff --git a/chromium/components/autofill/core/browser/payments/credit_card_save_manager.cc b/chromium/components/autofill/core/browser/payments/credit_card_save_manager.cc index dbd58bb9209..0013bafed2b 100644 --- a/chromium/components/autofill/core/browser/payments/credit_card_save_manager.cc +++ b/chromium/components/autofill/core/browser/payments/credit_card_save_manager.cc @@ -11,6 +11,7 @@ #include <limits> #include <map> #include <set> +#include <string> #include <utility> #include <vector> @@ -18,7 +19,6 @@ #include "base/callback_helpers.h" #include "base/feature_list.h" #include "base/metrics/histogram_functions.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" @@ -60,16 +60,16 @@ namespace { // src/components/autofill/core/browser/data_model/contact_info.cc. However, for // now we want the logic of which variations of names are considered to be the // same to exactly match the logic applied on the Payments server. -base::string16 RemoveMiddleInitial(const base::string16& name) { +std::u16string RemoveMiddleInitial(const std::u16string& name) { std::vector<base::StringPiece16> parts = base::SplitStringPiece(name, base::kWhitespaceUTF16, base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); - if (parts.size() == 3 && (parts[1].length() == 1 || - (parts[1].length() == 2 && - base::EndsWith(parts[1], base::ASCIIToUTF16("."), - base::CompareCase::SENSITIVE)))) { + if (parts.size() == 3 && + (parts[1].length() == 1 || + (parts[1].length() == 2 && + base::EndsWith(parts[1], u".", base::CompareCase::SENSITIVE)))) { parts.erase(parts.begin() + 1); - return base::JoinString(parts, base::ASCIIToUTF16(" ")); + return base::JoinString(parts, u" "); } return name; } @@ -365,7 +365,7 @@ CreditCardSaveManager::GetLocalCardMigrationStrikeDatabase() { void CreditCardSaveManager::OnDidGetUploadDetails( AutofillClient::PaymentsRpcResult result, - const base::string16& context_token, + const std::u16string& context_token, std::unique_ptr<base::Value> legal_message, std::vector<std::pair<int, int>> supported_card_bin_ranges) { if (observer_for_testing_) @@ -597,16 +597,16 @@ void CreditCardSaveManager::SetProfilesForCreditCardUpload( // candidate set is invalid. This matches the rules for name matching applied // server-side by Google Payments and ensures that we don't send upload // requests that are guaranteed to fail. - const base::string16 card_name = + const std::u16string card_name = card.GetInfo(AutofillType(CREDIT_CARD_NAME_FULL), app_locale_); - base::string16 verified_name; + std::u16string verified_name; if (candidate_profiles.empty()) { verified_name = card_name; } else { bool found_conflicting_names = false; verified_name = RemoveMiddleInitial(card_name); for (const AutofillProfile& profile : candidate_profiles) { - const base::string16 address_name = + const std::u16string address_name = RemoveMiddleInitial(profile.GetInfo(NAME_FULL, app_locale_)); if (address_name.empty()) continue; @@ -632,10 +632,10 @@ void CreditCardSaveManager::SetProfilesForCreditCardUpload( // If any of the candidate addresses have a non-empty zip that doesn't match // any other non-empty zip, then the candidate set is invalid. - base::string16 verified_zip; + std::u16string verified_zip; const AutofillType kZipCode(ADDRESS_HOME_ZIP); for (const AutofillProfile& profile : candidate_profiles) { - const base::string16 zip = profile.GetRawInfo(ADDRESS_HOME_ZIP); + const std::u16string zip = profile.GetRawInfo(ADDRESS_HOME_ZIP); if (!zip.empty()) { if (verified_zip.empty()) { verified_zip = zip; @@ -820,19 +820,19 @@ void CreditCardSaveManager::OnUserDidDecideOnUploadSave( #if defined(OS_ANDROID) || defined(OS_IOS) void CreditCardSaveManager::OnUserDidAcceptAccountNameFixFlow( - const base::string16& cardholder_name) { + const std::u16string& cardholder_name) { DCHECK(should_request_name_from_user_); OnUserDidAcceptUploadHelper({cardholder_name, - /*expiration_date_month=*/base::string16(), - /*expiration_date_year=*/base::string16()}); + /*expiration_date_month=*/std::u16string(), + /*expiration_date_year=*/std::u16string()}); } void CreditCardSaveManager::OnUserDidAcceptExpirationDateFixFlow( - const base::string16& month, - const base::string16& year) { + const std::u16string& month, + const std::u16string& year) { OnUserDidAcceptUploadHelper( - {/*cardholder_name=*/base::string16(), month, year}); + {/*cardholder_name=*/std::u16string(), month, year}); } #endif // defined(OS_ANDROID) || defined(OS_IOS) @@ -914,7 +914,7 @@ void CreditCardSaveManager::SendUploadCardRequest() { } void CreditCardSaveManager::OnUserDidIgnoreOrDeclineSave( - const base::string16& card_last_four_digits) { + const std::u16string& card_last_four_digits) { if (show_save_prompt_.has_value() && show_save_prompt_.value()) { // If the user rejected or ignored save and the offer-to-save bubble or // infobar was actually shown (NOT just the icon if on desktop), count diff --git a/chromium/components/autofill/core/browser/payments/credit_card_save_manager.h b/chromium/components/autofill/core/browser/payments/credit_card_save_manager.h index a1e77140599..affdd8893b2 100644 --- a/chromium/components/autofill/core/browser/payments/credit_card_save_manager.h +++ b/chromium/components/autofill/core/browser/payments/credit_card_save_manager.h @@ -12,7 +12,6 @@ #include <vector> #include "base/optional.h" -#include "base/strings/string16.h" #include "build/build_config.h" #include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_metrics.h" @@ -168,7 +167,7 @@ class CreditCardSaveManager { // and end of the range. void OnDidGetUploadDetails( AutofillClient::PaymentsRpcResult result, - const base::string16& context_token, + const std::u16string& context_token, std::unique_ptr<base::Value> legal_message, std::vector<std::pair<int, int>> supported_card_bin_ranges); @@ -226,13 +225,13 @@ class CreditCardSaveManager { // Upload the card details with the user provided cardholder_name. // Only relevant for mobile as fix flow is two steps on mobile compared to // one step on desktop. - void OnUserDidAcceptAccountNameFixFlow(const base::string16& cardholder_name); + void OnUserDidAcceptAccountNameFixFlow(const std::u16string& cardholder_name); // Upload the card details with the user provided expiration date month and // year. Only relevant for mobile as fix flow is two steps on mobile compared // to one step on desktop. - void OnUserDidAcceptExpirationDateFixFlow(const base::string16& month, - const base::string16& year); + void OnUserDidAcceptExpirationDateFixFlow(const std::u16string& month, + const std::u16string& year); #endif // defined(OS_ANDROID) || defined(OS_IOS) // Helper function that calls SendUploadCardRequest by setting @@ -252,7 +251,7 @@ class CreditCardSaveManager { // a strike for the given card in order to help deter future offers to save, // provided that save was actually offered to the user. void OnUserDidIgnoreOrDeclineSave( - const base::string16& card_last_four_digits); + const std::u16string& card_last_four_digits); // Used for browsertests. Gives the |observer_for_testing_| a notification // a strike change has been made. diff --git a/chromium/components/autofill/core/browser/payments/credit_card_save_manager_unittest.cc b/chromium/components/autofill/core/browser/payments/credit_card_save_manager_unittest.cc index 50fce2c7cf0..6e56702b3b4 100644 --- a/chromium/components/autofill/core/browser/payments/credit_card_save_manager_unittest.cc +++ b/chromium/components/autofill/core/browser/payments/credit_card_save_manager_unittest.cc @@ -16,7 +16,6 @@ #include "base/guid.h" #include "base/metrics/metrics_hashes.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" @@ -139,7 +138,7 @@ class CreditCardSaveManagerTest : public testing::Test { autocomplete_history_manager_.Init( /*profile_database=*/database_, /*is_off_the_record=*/false); - autofill_driver_.reset(new TestAutofillDriver()); + autofill_driver_ = std::make_unique<TestAutofillDriver>(); payments_client_ = new payments::TestPaymentsClient( autofill_driver_->GetURLLoaderFactory(), autofill_client_.GetIdentityManager(), &personal_data_); @@ -157,9 +156,9 @@ class CreditCardSaveManagerTest : public testing::Test { autofill_client_.set_test_form_data_importer( std::unique_ptr<TestFormDataImporter>(test_form_data_importer)); autofill_client_.GetStrikeDatabase(); - autofill_manager_.reset(new TestAutofillManager( + autofill_manager_ = std::make_unique<TestAutofillManager>( autofill_driver_.get(), &autofill_client_, &personal_data_, - &autocomplete_history_manager_)); + &autocomplete_history_manager_); autofill_manager_->SetExpectedObservedSubmission(true); } @@ -194,17 +193,14 @@ class CreditCardSaveManagerTest : public testing::Test { // configured using the provided |options|. void CreateTestCreditCardFormData(FormData* form, CreditCardFormOptions options) { - form->name = ASCIIToUTF16("MyForm"); - base::string16 scheme = - options.is_https ? ASCIIToUTF16("https://") : ASCIIToUTF16("http://"); - base::string16 host = options.is_google_host - ? ASCIIToUTF16("pay.google.com") - : ASCIIToUTF16("myform.com"); - base::string16 root_host = options.is_google_host - ? ASCIIToUTF16("pay.google.com") - : ASCIIToUTF16("myform.root.com"); - base::string16 form_path = ASCIIToUTF16("/form.html"); - base::string16 submit_path = ASCIIToUTF16("/submit.html"); + form->name = u"MyForm"; + std::u16string scheme = options.is_https ? u"https://" : u"http://"; + std::u16string host = + options.is_google_host ? u"pay.google.com" : u"myform.com"; + std::u16string root_host = + options.is_google_host ? u"pay.google.com" : u"myform.root.com"; + std::u16string form_path = u"/form.html"; + std::u16string submit_path = u"/submit.html"; form->url = GURL(scheme + host + form_path); form->action = GURL(scheme + host + submit_path); form->main_frame_origin = @@ -249,11 +245,11 @@ class CreditCardSaveManagerTest : public testing::Test { else if (base::EqualsASCII(field.name, "lastname")) field.value = ASCIIToUTF16(last_name); else if (base::EqualsASCII(field.name, "addr1")) - field.value = ASCIIToUTF16("123 Maple"); + field.value = u"123 Maple"; else if (base::EqualsASCII(field.name, "city")) - field.value = ASCIIToUTF16("Dallas"); + field.value = u"Dallas"; else if (base::EqualsASCII(field.name, "state")) - field.value = ASCIIToUTF16("Texas"); + field.value = u"Texas"; else if (base::EqualsASCII(field.name, "zipcode")) field.value = ASCIIToUTF16(zip_code); else if (base::EqualsASCII(field.name, "country")) @@ -271,7 +267,7 @@ class CreditCardSaveManagerTest : public testing::Test { FormsSeen(forms); // Edit the data, and submit. - form.fields[1].value = ASCIIToUTF16("4111111111111111"); + form.fields[1].value = u"4111111111111111"; form.fields[2].value = ASCIIToUTF16(test::NextMonth()); form.fields[3].value = ASCIIToUTF16(test::NextYear()); FormSubmitted(form); @@ -415,7 +411,7 @@ TEST_F(CreditCardSaveManagerTest, MAYBE_CreditCardSavedWhenAutocompleteOff) { FormsSeen(forms); // Edit the data, and submit. - form.fields[1].value = ASCIIToUTF16("4111111111111111"); + form.fields[1].value = u"4111111111111111"; form.fields[2].value = ASCIIToUTF16(test::NextMonth()); form.fields[3].value = ASCIIToUTF16(test::NextYear()); FormSubmitted(form); @@ -458,11 +454,11 @@ TEST_F(CreditCardSaveManagerTest, CreditCardDisabledDoesNotSave) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -496,11 +492,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_OnlyCountryInAddresses) { ExpectFillableFormParsedUkm(2 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -513,7 +509,7 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_OnlyCountryInAddresses) { // country was included in the upload details request to payments. EXPECT_EQ(1U, personal_data_.GetProfiles().size()); AutofillProfile only_country; - only_country.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US"); + only_country.SetInfo(ADDRESS_HOME_COUNTRY, u"US", "en-US"); EXPECT_EQ(1U, payments_client_->addresses_in_upload_details().size()); // AutofillProfile::Compare will ignore the difference in guid between our // actual profile being sent and the expected one constructed here. @@ -561,12 +557,12 @@ TEST_F(CreditCardSaveManagerTest, LocalCreditCard_FirstAndLastName) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; base::HistogramTester histogram_tester; @@ -600,7 +596,7 @@ TEST_F(CreditCardSaveManagerTest, LocalCreditCard_LastAndFirstName) { // Set up our credit card form data with credit card first and last name // fields. FormData credit_card_form; - credit_card_form.name = ASCIIToUTF16("MyForm"); + credit_card_form.name = u"MyForm"; credit_card_form.url = GURL("https://myform.com/form.html"); credit_card_form.action = GURL("https://myform.com/submit.html"); credit_card_form.main_frame_origin = @@ -627,12 +623,12 @@ TEST_F(CreditCardSaveManagerTest, LocalCreditCard_LastAndFirstName) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Master"; + credit_card_form.fields[1].value = u"Flo"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; base::HistogramTester histogram_tester; @@ -667,11 +663,11 @@ TEST_F(CreditCardSaveManagerTest, LocalCreditCard_ExpirationDateMissing) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, but don't include a expiration date, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); - credit_card_form.fields[2].value = ASCIIToUTF16(""); - credit_card_form.fields[3].value = ASCIIToUTF16(""); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; + credit_card_form.fields[2].value = u""; + credit_card_form.fields[3].value = u""; + credit_card_form.fields[4].value = u"123"; FormSubmitted(credit_card_form); EXPECT_FALSE(autofill_client_.ConfirmSaveCardLocallyWasCalled()); @@ -703,12 +699,12 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_WithNonFocusableField) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; base::HistogramTester histogram_tester; @@ -750,12 +746,12 @@ TEST_F(CreditCardSaveManagerTest, LocalCreditCard_WithNonFocusableField) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; FormSubmitted(credit_card_form); EXPECT_TRUE(autofill_client_.ConfirmSaveCardLocallyWasCalled()); @@ -777,12 +773,12 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; FormSubmitted(credit_card_form); EXPECT_TRUE(autofill_client_.ConfirmSaveCardLocallyWasCalled()); @@ -810,12 +806,12 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; FormSubmitted(credit_card_form); EXPECT_TRUE(autofill_client_.ConfirmSaveCardLocallyWasCalled()); @@ -853,12 +849,12 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; FormSubmitted(credit_card_form); EXPECT_TRUE(autofill_client_.ConfirmSaveCardLocallyWasCalled()); @@ -892,12 +888,12 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; FormSubmitted(credit_card_form); EXPECT_TRUE(credit_card_save_manager_->CreditCardWasUploaded()); @@ -918,12 +914,12 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; FormSubmitted(credit_card_form); EXPECT_TRUE(autofill_client_.ConfirmSaveCardLocallyWasCalled()); @@ -946,12 +942,12 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(2, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; FormSubmitted(credit_card_form); EXPECT_TRUE(autofill_client_.ConfirmSaveCardLocallyWasCalled()); @@ -978,12 +974,12 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(2, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; FormSubmitted(credit_card_form); EXPECT_TRUE(autofill_client_.ConfirmSaveCardLocallyWasCalled()); @@ -1020,12 +1016,12 @@ TEST_F( FormsSeen(std::vector<FormData>(2, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; FormSubmitted(credit_card_form); EXPECT_TRUE(autofill_client_.ConfirmSaveCardLocallyWasCalled()); @@ -1058,12 +1054,12 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(2, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; FormSubmitted(credit_card_form); EXPECT_TRUE(credit_card_save_manager_->CreditCardWasUploaded()); @@ -1085,12 +1081,12 @@ TEST_F(CreditCardSaveManagerTest, SaveCreditCardOptions_WithoutDynamicForms) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; FormSubmitted(credit_card_form); EXPECT_TRUE(autofill_client_.ConfirmSaveCardLocallyWasCalled()); @@ -1123,12 +1119,12 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_FirstAndLastName) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; base::HistogramTester histogram_tester; @@ -1174,7 +1170,7 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_LastAndFirstName) { // Set up our credit card form data with credit card first and last name // fields. FormData credit_card_form; - credit_card_form.name = ASCIIToUTF16("MyForm"); + credit_card_form.name = u"MyForm"; credit_card_form.url = GURL("https://myform.com/form.html"); credit_card_form.action = GURL("https://myform.com/submit.html"); credit_card_form.main_frame_origin = @@ -1201,12 +1197,12 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_LastAndFirstName) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Master"; + credit_card_form.fields[1].value = u"Flo"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; base::HistogramTester histogram_tester; @@ -1257,11 +1253,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NotSavedLocally) { // Edit the data, and submit. const char* const card_number = "4111111111111111"; - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); + credit_card_form.fields[0].value = u"Flo Master"; credit_card_form.fields[1].value = ASCIIToUTF16(card_number); credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; FormSubmitted(credit_card_form); EXPECT_TRUE(credit_card_save_manager_->CreditCardWasUploaded()); @@ -1287,11 +1283,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_FeatureNotEnabled) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -1325,11 +1321,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CvcUnavailable) { ExpectFillableFormParsedUkm(2 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING + credit_card_form.fields[4].value = u""; // CVC MISSING base::HistogramTester histogram_tester; @@ -1367,11 +1363,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CvcInvalidLength) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("1234"); + credit_card_form.fields[4].value = u"1234"; base::HistogramTester histogram_tester; @@ -1405,7 +1401,7 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_MultipleCvcFields) { // Set up our credit card form data. FormData credit_card_form; - credit_card_form.name = ASCIIToUTF16("MyForm"); + credit_card_form.name = u"MyForm"; credit_card_form.url = GURL("https://myform.com/form.html"); credit_card_form.action = GURL("https://myform.com/submit.html"); credit_card_form.main_frame_origin = @@ -1428,12 +1424,12 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_MultipleCvcFields) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u""; // CVC MISSING + credit_card_form.fields[5].value = u"123"; base::HistogramTester histogram_tester; @@ -1464,7 +1460,7 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NoCvcFieldOnForm) { // Set up our credit card form data. Note that CVC field is missing. FormData credit_card_form; - credit_card_form.name = ASCIIToUTF16("MyForm"); + credit_card_form.name = u"MyForm"; credit_card_form.url = GURL("https://myform.com/form.html"); credit_card_form.action = GURL("https://myform.com/submit.html"); credit_card_form.main_frame_origin = @@ -1483,8 +1479,8 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NoCvcFieldOnForm) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); @@ -1521,7 +1517,7 @@ TEST_F(CreditCardSaveManagerTest, // Set up our credit card form data. Note that CVC field is missing. FormData credit_card_form; - credit_card_form.name = ASCIIToUTF16("MyForm"); + credit_card_form.name = u"MyForm"; credit_card_form.url = GURL("https://myform.com/form.html"); credit_card_form.action = GURL("https://myform.com/submit.html"); credit_card_form.main_frame_origin = @@ -1542,11 +1538,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen({credit_card_form}); // Enter an invalid cvc in "Random Field" and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("1234"); + credit_card_form.fields[4].value = u"1234"; base::HistogramTester histogram_tester; @@ -1581,7 +1577,7 @@ TEST_F(CreditCardSaveManagerTest, // Set up our credit card form data. Note that CVC field is missing. FormData credit_card_form; - credit_card_form.name = ASCIIToUTF16("MyForm"); + credit_card_form.name = u"MyForm"; credit_card_form.url = GURL("https://myform.com/form.html"); credit_card_form.action = GURL("https://myform.com/submit.html"); credit_card_form.main_frame_origin = @@ -1602,11 +1598,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen({credit_card_form}); // Enter a valid cvc in "Random Field" and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -1643,7 +1639,7 @@ TEST_F(CreditCardSaveManagerTest, // Set up our credit card form data. Note that CVC field is missing. FormData credit_card_form; - credit_card_form.name = ASCIIToUTF16("MyForm"); + credit_card_form.name = u"MyForm"; credit_card_form.url = GURL("https://myform.com/form.html"); credit_card_form.action = GURL("https://myform.com/submit.html"); credit_card_form.main_frame_origin = @@ -1664,11 +1660,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen({credit_card_form}); // Enter a valid cvc in "Random Field" and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -1700,11 +1696,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NoProfileAvailable) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Bob Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Bob Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -1750,11 +1746,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NoRecentlyUsedProfile) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -1789,11 +1785,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING + credit_card_form.fields[4].value = u""; // CVC MISSING base::HistogramTester histogram_tester; @@ -1835,10 +1831,10 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NoNameAvailable) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, but don't include a name, and submit. - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -1876,10 +1872,10 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, but don't include a name, and submit. - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -1935,11 +1931,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_ZipCodesConflict) { ExpectFillableFormParsedUkm(3 /* num_fillable_forms_parsed */); // Edit the data and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -1969,16 +1965,16 @@ TEST_F(CreditCardSaveManagerTest, // instead of submitting a form, because they're deduped on form submit. AutofillProfile profile1; profile1.set_guid("00000000-0000-0000-0000-000000000001"); - profile1.SetInfo(NAME_FULL, ASCIIToUTF16("Flo Master"), "en-US"); - profile1.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("H3B2Y5"), "en-US"); - profile1.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA"), "en-US"); + profile1.SetInfo(NAME_FULL, u"Flo Master", "en-US"); + profile1.SetInfo(ADDRESS_HOME_ZIP, u"H3B2Y5", "en-US"); + profile1.SetInfo(ADDRESS_HOME_COUNTRY, u"CA", "en-US"); personal_data_.AddProfile(profile1); AutofillProfile profile2; profile2.set_guid("00000000-0000-0000-0000-000000000002"); - profile2.SetInfo(NAME_FULL, ASCIIToUTF16("Flo Master"), "en-US"); - profile2.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("h3b 2y5"), "en-US"); - profile2.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA"), "en-US"); + profile2.SetInfo(NAME_FULL, u"Flo Master", "en-US"); + profile2.SetInfo(ADDRESS_HOME_ZIP, u"h3b 2y5", "en-US"); + profile2.SetInfo(ADDRESS_HOME_COUNTRY, u"CA", "en-US"); personal_data_.AddProfile(profile2); // Set up our credit card form data. @@ -1987,11 +1983,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen({credit_card_form}); // Edit the data and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2038,11 +2034,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_ZipCodesHavePrefixMatch) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2084,11 +2080,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NoZipCodeAvailable) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2133,11 +2129,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormHasMiddleInitial) { // Edit the data, but use the name with a middle initial *and* period, and // submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo W. Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo W. Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2176,11 +2172,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NoMiddleInitialInCCForm) { FormsSeen({credit_card_form}); // Edit the data, but do not use middle initial. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2215,11 +2211,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen({credit_card_form}); // Edit the name by adding a middle name. - credit_card_form.fields[0].value = ASCIIToUTF16("John Quincy Adams"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"John Quincy Adams"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2261,11 +2257,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormHasAddressMiddleName) { FormsSeen({credit_card_form}); // Edit the name by removing middle name. - credit_card_form.fields[0].value = ASCIIToUTF16("John Adams"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"John Adams"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2316,11 +2312,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NamesCanMismatch) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, but use yet another name, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Bob Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Bob Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2375,11 +2371,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_IgnoreOldProfiles) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, but use yet another name, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Master Blaster"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Master Blaster"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2412,10 +2408,10 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, but don't include a name, and submit. - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2451,11 +2447,11 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, but include a conflicting name, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Jane Doe"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Jane Doe"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2490,11 +2486,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2526,11 +2522,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2560,11 +2556,11 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2609,10 +2605,10 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, but don't include a name, and submit. - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2658,11 +2654,11 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, but include a conflicting name, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Jane Doe"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Jane Doe"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2706,10 +2702,10 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, but don't include a name, and submit. - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; // With the offer-to-save decision deferred to Google Payments, Payments can // still decide to allow saving despite the missing name. @@ -2759,11 +2755,11 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, but don't include a expiration date, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Jane Doe"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); - credit_card_form.fields[2].value = ASCIIToUTF16(""); - credit_card_form.fields[3].value = ASCIIToUTF16(""); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[0].value = u"Jane Doe"; + credit_card_form.fields[1].value = u"4111111111111111"; + credit_card_form.fields[2].value = u""; + credit_card_form.fields[3].value = u""; + credit_card_form.fields[4].value = u"123"; // With the offer-to-save decision deferred to Google Payments, Payments can // still decide to allow saving despite the missing expiration date. @@ -2776,11 +2772,11 @@ TEST_F( credit_card_save_manager_->should_request_expiration_date_from_user_); // Edit the data, include a expiration date, and submit this time. - credit_card_form.fields[0].value = ASCIIToUTF16("Jane Doe"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Jane Doe"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; FormSubmitted(credit_card_form); // Verify the |credit_card_save_manager_| is NOT requesting expiration date. @@ -2816,11 +2812,11 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, but don't include a expiration date, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); - credit_card_form.fields[2].value = ASCIIToUTF16(""); - credit_card_form.fields[3].value = ASCIIToUTF16(""); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; + credit_card_form.fields[2].value = u""; + credit_card_form.fields[3].value = u""; + credit_card_form.fields[4].value = u"123"; FormSubmitted(credit_card_form); @@ -2858,11 +2854,11 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, but don't include a expiration date, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); - credit_card_form.fields[2].value = ASCIIToUTF16(""); - credit_card_form.fields[3].value = ASCIIToUTF16(""); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; + credit_card_form.fields[2].value = u""; + credit_card_form.fields[3].value = u""; + credit_card_form.fields[4].value = u"123"; // With the offer-to-save decision deferred to Google Payments, Payments can // still decide to allow saving despite the missing expiration date. @@ -2898,11 +2894,11 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); - credit_card_form.fields[2].value = ASCIIToUTF16(""); - credit_card_form.fields[3].value = ASCIIToUTF16(""); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[0].value = u""; + credit_card_form.fields[1].value = u"4111111111111111"; + credit_card_form.fields[2].value = u""; + credit_card_form.fields[3].value = u""; + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2931,11 +2927,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -2977,11 +2973,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("John Smith"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); - credit_card_form.fields[2].value = ASCIIToUTF16(""); - credit_card_form.fields[3].value = ASCIIToUTF16(""); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[0].value = u"John Smith"; + credit_card_form.fields[1].value = u"4111111111111111"; + credit_card_form.fields[2].value = u""; + credit_card_form.fields[3].value = u""; + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; FormSubmitted(credit_card_form); @@ -3028,11 +3024,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("John Smith"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); - credit_card_form.fields[2].value = ASCIIToUTF16(""); + credit_card_form.fields[0].value = u"John Smith"; + credit_card_form.fields[1].value = u"4111111111111111"; + credit_card_form.fields[2].value = u""; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; FormSubmitted(credit_card_form); @@ -3079,11 +3075,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("John Smith"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"John Smith"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); - credit_card_form.fields[3].value = ASCIIToUTF16(""); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[3].value = u""; + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; FormSubmitted(credit_card_form); @@ -3130,11 +3126,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("John Smith"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); - credit_card_form.fields[2].value = ASCIIToUTF16("09"); - credit_card_form.fields[3].value = ASCIIToUTF16("2000"); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[0].value = u"John Smith"; + credit_card_form.fields[1].value = u"4111111111111111"; + credit_card_form.fields[2].value = u"09"; + credit_card_form.fields[3].value = u"2000"; + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; FormSubmitted(credit_card_form); @@ -3182,11 +3178,11 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data with 2 digit year and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("John Smith"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); - credit_card_form.fields[2].value = ASCIIToUTF16("01"); - credit_card_form.fields[3].value = ASCIIToUTF16("10"); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[0].value = u"John Smith"; + credit_card_form.fields[1].value = u"4111111111111111"; + credit_card_form.fields[2].value = u"01"; + credit_card_form.fields[3].value = u"10"; + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; FormSubmitted(credit_card_form); @@ -3229,11 +3225,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_UploadDetailsFails) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -3276,11 +3272,11 @@ TEST_F(CreditCardSaveManagerTest, DuplicateMaskedCreditCard_NoUpload) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; // Local save prompt should not be shown as there is alredy masked // card with same |TypeAndLastFourDigits|. @@ -3296,11 +3292,11 @@ TEST_F(CreditCardSaveManagerTest, NothingIfNothingFound) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name set - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name set + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC set + credit_card_form.fields[4].value = u""; // No CVC set // Submit the form and check what detected_values for an upload save would be. FormSubmitted(credit_card_form); @@ -3326,11 +3322,11 @@ TEST_F(CreditCardSaveManagerTest, DetectCvc) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name set - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name set + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; // Submit the form and ensure the detected_values for an upload save contained // the expected bit. @@ -3348,11 +3344,11 @@ TEST_F(CreditCardSaveManagerTest, DetectCardholderName) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("John Smith"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"John Smith"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC set + credit_card_form.fields[4].value = u""; // No CVC set // Submit the form and ensure the detected_values for an upload save contained // the expected bit. @@ -3368,7 +3364,7 @@ TEST_F(CreditCardSaveManagerTest, DetectAddressName) { // Set up a new address profile. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(NAME_FULL, ASCIIToUTF16("John Smith"), "en-US"); + profile.SetInfo(NAME_FULL, u"John Smith", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -3377,11 +3373,11 @@ TEST_F(CreditCardSaveManagerTest, DetectAddressName) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name set - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name set + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC set + credit_card_form.fields[4].value = u""; // No CVC set // Submit the form and ensure the detected_values for an upload save contained // the expected bit. @@ -3397,7 +3393,7 @@ TEST_F(CreditCardSaveManagerTest, DetectCardholderAndAddressNameIfMatching) { // Set up a new address profile. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(NAME_FULL, ASCIIToUTF16("John Smith"), "en-US"); + profile.SetInfo(NAME_FULL, u"John Smith", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -3406,11 +3402,11 @@ TEST_F(CreditCardSaveManagerTest, DetectCardholderAndAddressNameIfMatching) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("John Smith"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"John Smith"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC set + credit_card_form.fields[4].value = u""; // No CVC set // Submit the form and ensure the detected_values for an upload save contained // the expected bits. @@ -3427,7 +3423,7 @@ TEST_F(CreditCardSaveManagerTest, DetectNoUniqueNameIfNamesConflict) { // Set up a new address profile. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(NAME_FULL, ASCIIToUTF16("John Smith"), "en-US"); + profile.SetInfo(NAME_FULL, u"John Smith", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -3436,11 +3432,11 @@ TEST_F(CreditCardSaveManagerTest, DetectNoUniqueNameIfNamesConflict) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Miles Prower"); // Conflict! - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Miles Prower"; // Conflict! + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC set + credit_card_form.fields[4].value = u""; // No CVC set // Submit the form and check what detected_values for an upload save would be. FormSubmitted(credit_card_form); @@ -3455,7 +3451,7 @@ TEST_F(CreditCardSaveManagerTest, DetectPostalCode) { // Set up a new address profile. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("94043"), "en-US"); + profile.SetInfo(ADDRESS_HOME_ZIP, u"94043", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -3464,11 +3460,11 @@ TEST_F(CreditCardSaveManagerTest, DetectPostalCode) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name set - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name set + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC set + credit_card_form.fields[4].value = u""; // No CVC set // Submit the form and ensure the detected_values for an upload save contained // the expected bit. @@ -3484,11 +3480,11 @@ TEST_F(CreditCardSaveManagerTest, DetectNoUniquePostalCodeIfZipsConflict) { // Set up two new address profiles with conflicting postal codes. AutofillProfile profile1; profile1.set_guid("00000000-0000-0000-0000-000000000200"); - profile1.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("94043"), "en-US"); + profile1.SetInfo(ADDRESS_HOME_ZIP, u"94043", "en-US"); personal_data_.AddProfile(profile1); AutofillProfile profile2; profile2.set_guid("00000000-0000-0000-0000-000000000201"); - profile2.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("95051"), "en-US"); + profile2.SetInfo(ADDRESS_HOME_ZIP, u"95051", "en-US"); personal_data_.AddProfile(profile2); // Set up our credit card form data. @@ -3497,11 +3493,11 @@ TEST_F(CreditCardSaveManagerTest, DetectNoUniquePostalCodeIfZipsConflict) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name set - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name set + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC set + credit_card_form.fields[4].value = u""; // No CVC set // Submit the form and check what detected_values for an upload save would be. FormSubmitted(credit_card_form); @@ -3513,7 +3509,7 @@ TEST_F(CreditCardSaveManagerTest, DetectAddressLine) { // Set up a new address profile. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Testing St."), "en-US"); + profile.SetInfo(ADDRESS_HOME_LINE1, u"123 Testing St.", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -3522,11 +3518,11 @@ TEST_F(CreditCardSaveManagerTest, DetectAddressLine) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name set - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name set + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC set + credit_card_form.fields[4].value = u""; // No CVC set // Submit the form and ensure the detected_values for an upload save contained // the expected bit. @@ -3542,7 +3538,7 @@ TEST_F(CreditCardSaveManagerTest, DetectLocality) { // Set up a new address profile. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Mountain View"), "en-US"); + profile.SetInfo(ADDRESS_HOME_CITY, u"Mountain View", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -3551,11 +3547,11 @@ TEST_F(CreditCardSaveManagerTest, DetectLocality) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name set - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name set + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC set + credit_card_form.fields[4].value = u""; // No CVC set // Submit the form and ensure the detected_values for an upload save contained // the expected bit. @@ -3570,7 +3566,7 @@ TEST_F(CreditCardSaveManagerTest, DetectAdministrativeArea) { // Set up a new address profile. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"), "en-US"); + profile.SetInfo(ADDRESS_HOME_STATE, u"California", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -3579,11 +3575,11 @@ TEST_F(CreditCardSaveManagerTest, DetectAdministrativeArea) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name set - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name set + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC set + credit_card_form.fields[4].value = u""; // No CVC set // Submit the form and ensure the detected_values for an upload save contained // the expected bit. @@ -3599,7 +3595,7 @@ TEST_F(CreditCardSaveManagerTest, DetectCountryCode) { // Set up a new address profile. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US"); + profile.SetInfo(ADDRESS_HOME_COUNTRY, u"US", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -3608,11 +3604,11 @@ TEST_F(CreditCardSaveManagerTest, DetectCountryCode) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name set - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name set + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC set + credit_card_form.fields[4].value = u""; // No CVC set // Submit the form and ensure the detected_values for an upload save contained // the expected bit. @@ -3636,11 +3632,11 @@ TEST_F(CreditCardSaveManagerTest, DetectHasGooglePaymentAccount) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name set - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name set + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC set + credit_card_form.fields[4].value = u""; // No CVC set // Submit the form and ensure the detected_values for an upload save contained // the expected bit. @@ -3656,12 +3652,12 @@ TEST_F(CreditCardSaveManagerTest, DetectEverythingAtOnce) { // Set up a new address profile. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(NAME_FULL, ASCIIToUTF16("John Smith"), "en-US"); - profile.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Testing St."), "en-US"); - profile.SetInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Mountain View"), "en-US"); - profile.SetInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"), "en-US"); - profile.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("94043"), "en-US"); - profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US"); + profile.SetInfo(NAME_FULL, u"John Smith", "en-US"); + profile.SetInfo(ADDRESS_HOME_LINE1, u"123 Testing St.", "en-US"); + profile.SetInfo(ADDRESS_HOME_CITY, u"Mountain View", "en-US"); + profile.SetInfo(ADDRESS_HOME_STATE, u"California", "en-US"); + profile.SetInfo(ADDRESS_HOME_ZIP, u"94043", "en-US"); + profile.SetInfo(ADDRESS_HOME_COUNTRY, u"US", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -3670,11 +3666,11 @@ TEST_F(CreditCardSaveManagerTest, DetectEverythingAtOnce) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("John Smith"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"John Smith"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; // Submit the form and ensure the detected_values for an upload save contained // the expected bits. @@ -3697,10 +3693,10 @@ TEST_F(CreditCardSaveManagerTest, DetectSubsetOfPossibleFields) { // Set up a new address profile, taking out address line and state. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(NAME_FULL, ASCIIToUTF16("John Smith"), "en-US"); - profile.SetInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Mountain View"), "en-US"); - profile.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("94043"), "en-US"); - profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US"); + profile.SetInfo(NAME_FULL, u"John Smith", "en-US"); + profile.SetInfo(ADDRESS_HOME_CITY, u"Mountain View", "en-US"); + profile.SetInfo(ADDRESS_HOME_ZIP, u"94043", "en-US"); + profile.SetInfo(ADDRESS_HOME_COUNTRY, u"US", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -3709,11 +3705,11 @@ TEST_F(CreditCardSaveManagerTest, DetectSubsetOfPossibleFields) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Miles Prower"); // Conflict! - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Miles Prower"; // Conflict! + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; // Submit the form and ensure the detected_values for an upload save contained // the expected bits. @@ -3735,20 +3731,19 @@ TEST_F(CreditCardSaveManagerTest, DetectAddressComponentsAcrossProfiles) { // Set up four new address profiles, each with a different address component. AutofillProfile profile1; profile1.set_guid("00000000-0000-0000-0000-000000000200"); - profile1.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Testing St."), - "en-US"); + profile1.SetInfo(ADDRESS_HOME_LINE1, u"123 Testing St.", "en-US"); personal_data_.AddProfile(profile1); AutofillProfile profile2; profile2.set_guid("00000000-0000-0000-0000-000000000201"); - profile2.SetInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Mountain View"), "en-US"); + profile2.SetInfo(ADDRESS_HOME_CITY, u"Mountain View", "en-US"); personal_data_.AddProfile(profile2); AutofillProfile profile3; profile3.set_guid("00000000-0000-0000-0000-000000000202"); - profile3.SetInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"), "en-US"); + profile3.SetInfo(ADDRESS_HOME_STATE, u"California", "en-US"); personal_data_.AddProfile(profile3); AutofillProfile profile4; profile4.set_guid("00000000-0000-0000-0000-000000000203"); - profile4.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US"); + profile4.SetInfo(ADDRESS_HOME_COUNTRY, u"US", "en-US"); personal_data_.AddProfile(profile4); // Set up our credit card form data. @@ -3757,11 +3752,11 @@ TEST_F(CreditCardSaveManagerTest, DetectAddressComponentsAcrossProfiles) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name set - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name set + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC set + credit_card_form.fields[4].value = u""; // No CVC set // Submit the form and ensure the detected_values for an upload save contained // the expected bits. @@ -3788,10 +3783,10 @@ TEST_F(CreditCardSaveManagerTest, // Set up a new address profile without a name or postal code. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Testing St."), "en-US"); - profile.SetInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Mountain View"), "en-US"); - profile.SetInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"), "en-US"); - profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US"); + profile.SetInfo(ADDRESS_HOME_LINE1, u"123 Testing St.", "en-US"); + profile.SetInfo(ADDRESS_HOME_CITY, u"Mountain View", "en-US"); + profile.SetInfo(ADDRESS_HOME_STATE, u"California", "en-US"); + profile.SetInfo(ADDRESS_HOME_COUNTRY, u"US", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -3800,11 +3795,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name! - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name! + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC! + credit_card_form.fields[4].value = u""; // No CVC! base::HistogramTester histogram_tester; FormSubmitted(credit_card_form); @@ -3845,12 +3840,12 @@ TEST_F( // Set up a new address profile. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(NAME_FULL, ASCIIToUTF16("John Smith"), "en-US"); - profile.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Testing St."), "en-US"); - profile.SetInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Mountain View"), "en-US"); - profile.SetInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"), "en-US"); - profile.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("94043"), "en-US"); - profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US"); + profile.SetInfo(NAME_FULL, u"John Smith", "en-US"); + profile.SetInfo(ADDRESS_HOME_LINE1, u"123 Testing St.", "en-US"); + profile.SetInfo(ADDRESS_HOME_CITY, u"Mountain View", "en-US"); + profile.SetInfo(ADDRESS_HOME_STATE, u"California", "en-US"); + profile.SetInfo(ADDRESS_HOME_ZIP, u"94043", "en-US"); + profile.SetInfo(ADDRESS_HOME_COUNTRY, u"US", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -3859,11 +3854,11 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("John Smith"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"John Smith"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -3885,12 +3880,12 @@ TEST_F( // Set up a new address profile. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(NAME_FULL, ASCIIToUTF16("John Smith"), "en-US"); - profile.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Testing St."), "en-US"); - profile.SetInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Mountain View"), "en-US"); - profile.SetInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"), "en-US"); - profile.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("94043"), "en-US"); - profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US"); + profile.SetInfo(NAME_FULL, u"John Smith", "en-US"); + profile.SetInfo(ADDRESS_HOME_LINE1, u"123 Testing St.", "en-US"); + profile.SetInfo(ADDRESS_HOME_CITY, u"Mountain View", "en-US"); + profile.SetInfo(ADDRESS_HOME_STATE, u"California", "en-US"); + profile.SetInfo(ADDRESS_HOME_ZIP, u"94043", "en-US"); + profile.SetInfo(ADDRESS_HOME_COUNTRY, u"US", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data with credit card first and last name @@ -3901,12 +3896,12 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("John"); - credit_card_form.fields[1].value = ASCIIToUTF16("Smith"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"John"; + credit_card_form.fields[1].value = u"Smith"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; base::HistogramTester histogram_tester; @@ -3935,10 +3930,10 @@ TEST_F( // Set up a new address profile without a name or postal code. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Testing St."), "en-US"); - profile.SetInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Mountain View"), "en-US"); - profile.SetInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"), "en-US"); - profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US"); + profile.SetInfo(ADDRESS_HOME_LINE1, u"123 Testing St.", "en-US"); + profile.SetInfo(ADDRESS_HOME_CITY, u"Mountain View", "en-US"); + profile.SetInfo(ADDRESS_HOME_STATE, u"California", "en-US"); + profile.SetInfo(ADDRESS_HOME_COUNTRY, u"US", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -3947,11 +3942,11 @@ TEST_F( FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name! - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name! + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC! + credit_card_form.fields[4].value = u""; // No CVC! base::HistogramTester histogram_tester; @@ -3981,11 +3976,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC! + credit_card_form.fields[4].value = u""; // No CVC! base::HistogramTester histogram_tester; @@ -4028,11 +4023,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name! - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name! + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -4079,11 +4074,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Miles Prower"); // Conflict! - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Miles Prower"; // Conflict! + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -4119,11 +4114,11 @@ TEST_F(CreditCardSaveManagerTest, // Set up a new address profile without a postal code. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(NAME_FULL, ASCIIToUTF16("Flo Master"), "en-US"); - profile.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Testing St."), "en-US"); - profile.SetInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Mountain View"), "en-US"); - profile.SetInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"), "en-US"); - profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US"); + profile.SetInfo(NAME_FULL, u"Flo Master", "en-US"); + profile.SetInfo(ADDRESS_HOME_LINE1, u"123 Testing St.", "en-US"); + profile.SetInfo(ADDRESS_HOME_CITY, u"Mountain View", "en-US"); + profile.SetInfo(ADDRESS_HOME_STATE, u"California", "en-US"); + profile.SetInfo(ADDRESS_HOME_COUNTRY, u"US", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -4132,11 +4127,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -4167,23 +4162,21 @@ TEST_F(CreditCardSaveManagerTest, // Set up two new address profiles with conflicting postal codes. AutofillProfile profile1; profile1.set_guid("00000000-0000-0000-0000-000000000200"); - profile1.SetInfo(NAME_FULL, ASCIIToUTF16("Flo Master"), "en-US"); - profile1.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Testing St."), - "en-US"); - profile1.SetInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Mountain View"), "en-US"); - profile1.SetInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"), "en-US"); - profile1.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("94043"), "en-US"); - profile1.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US"); + profile1.SetInfo(NAME_FULL, u"Flo Master", "en-US"); + profile1.SetInfo(ADDRESS_HOME_LINE1, u"123 Testing St.", "en-US"); + profile1.SetInfo(ADDRESS_HOME_CITY, u"Mountain View", "en-US"); + profile1.SetInfo(ADDRESS_HOME_STATE, u"California", "en-US"); + profile1.SetInfo(ADDRESS_HOME_ZIP, u"94043", "en-US"); + profile1.SetInfo(ADDRESS_HOME_COUNTRY, u"US", "en-US"); personal_data_.AddProfile(profile1); AutofillProfile profile2; profile2.set_guid("00000000-0000-0000-0000-000000000201"); - profile2.SetInfo(NAME_FULL, ASCIIToUTF16("Flo Master"), "en-US"); - profile2.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("234 Other Place"), - "en-US"); - profile2.SetInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Fake City"), "en-US"); - profile2.SetInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("Stateland"), "en-US"); - profile2.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("12345"), "en-US"); - profile2.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US"); + profile2.SetInfo(NAME_FULL, u"Flo Master", "en-US"); + profile2.SetInfo(ADDRESS_HOME_LINE1, u"234 Other Place", "en-US"); + profile2.SetInfo(ADDRESS_HOME_CITY, u"Fake City", "en-US"); + profile2.SetInfo(ADDRESS_HOME_STATE, u"Stateland", "en-US"); + profile2.SetInfo(ADDRESS_HOME_ZIP, u"12345", "en-US"); + profile2.SetInfo(ADDRESS_HOME_COUNTRY, u"US", "en-US"); personal_data_.AddProfile(profile2); // Set up our credit card form data. @@ -4192,11 +4185,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -4227,10 +4220,10 @@ TEST_F(CreditCardSaveManagerTest, // Set up a new address profile without a name or postal code. AutofillProfile profile; profile.set_guid("00000000-0000-0000-0000-000000000200"); - profile.SetInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Testing St."), "en-US"); - profile.SetInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Mountain View"), "en-US"); - profile.SetInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"), "en-US"); - profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US"); + profile.SetInfo(ADDRESS_HOME_LINE1, u"123 Testing St.", "en-US"); + profile.SetInfo(ADDRESS_HOME_CITY, u"Mountain View", "en-US"); + profile.SetInfo(ADDRESS_HOME_STATE, u"California", "en-US"); + profile.SetInfo(ADDRESS_HOME_COUNTRY, u"US", "en-US"); personal_data_.AddProfile(profile); // Set up our credit card form data. @@ -4239,11 +4232,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16(""); // No name! - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u""; // No name! + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16(""); // No CVC! + credit_card_form.fields[4].value = u""; // No CVC! base::HistogramTester histogram_tester; @@ -4303,11 +4296,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_UploadOfLocalCard) { ExpectFillableFormParsedUkm(2 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -4343,11 +4336,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_UploadOfNewCard) { ExpectFillableFormParsedUkm(2 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -4399,11 +4392,11 @@ TEST_F(CreditCardSaveManagerTest, ExpectFillableFormParsedUkm(2 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -4434,11 +4427,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; // Confirm that upload happened and that no experiment flag state was sent in // the request. @@ -4464,11 +4457,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; // Confirm that the preflight request contained // kUploadCardBillableServiceNumber in the request. @@ -4493,11 +4486,11 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; // Confirm that the preflight request contained the correct UploadCardSource. FormSubmitted(credit_card_form); @@ -4524,11 +4517,11 @@ TEST_F(CreditCardSaveManagerTest, ExpectFillableFormParsedUkm(1 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -4573,11 +4566,11 @@ TEST_F(CreditCardSaveManagerTest, ExpectFillableFormParsedUkm(2 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -4615,11 +4608,11 @@ TEST_F(CreditCardSaveManagerTest, ExpectFillableFormParsedUkm(1 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -4665,11 +4658,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_MaxStrikesDisallowsSave) { ExpectFillableFormParsedUkm(2 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -4713,11 +4706,11 @@ TEST_F(CreditCardSaveManagerTest, ExpectFillableFormParsedUkm(1 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -4764,11 +4757,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_MaxStrikesStillAllowsSave) { ExpectFillableFormParsedUkm(2 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -4817,12 +4810,12 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; base::HistogramTester histogram_tester; @@ -4865,12 +4858,12 @@ TEST_F(CreditCardSaveManagerTest, FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo"); - credit_card_form.fields[1].value = ASCIIToUTF16("Master"); - credit_card_form.fields[2].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo"; + credit_card_form.fields[1].value = u"Master"; + credit_card_form.fields[2].value = u"4111111111111111"; credit_card_form.fields[3].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[4].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[5].value = ASCIIToUTF16("123"); + credit_card_form.fields[5].value = u"123"; base::HistogramTester histogram_tester; @@ -4901,11 +4894,11 @@ TEST_F(CreditCardSaveManagerTest, LocallySaveCreditCard_ClearStrikesOnAdd) { ExpectFillableFormParsedUkm(1 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; FormSubmitted(credit_card_form); EXPECT_TRUE(autofill_client_.ConfirmSaveCardLocallyWasCalled()); @@ -4942,11 +4935,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_ClearStrikesOnAdd) { ExpectFillableFormParsedUkm(2 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; FormSubmitted(credit_card_form); EXPECT_FALSE(autofill_client_.ConfirmSaveCardLocallyWasCalled()); @@ -4975,11 +4968,11 @@ TEST_F(CreditCardSaveManagerTest, LocallySaveCreditCard_NumStrikesLoggedOnAdd) { ExpectFillableFormParsedUkm(1 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -5020,11 +5013,11 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NumStrikesLoggedOnAdd) { ExpectFillableFormParsedUkm(2 /* num_fillable_forms_parsed */); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; @@ -5052,7 +5045,7 @@ TEST_F(CreditCardSaveManagerTest, // by 1. credit_card_save_manager_->set_show_save_prompt(true); credit_card_save_manager_->set_upload_request_card_number( - ASCIIToUTF16("4111111111111111")); + u"4111111111111111"); credit_card_save_manager_->OnDidUploadCard(AutofillClient::TRY_AGAIN_FAILURE, server_id); EXPECT_EQ(1, credit_card_save_strike_database.GetStrikes("1111")); @@ -5080,11 +5073,11 @@ TEST_F(CreditCardSaveManagerTest, UploadSaveNotOfferedForUnsupportedCard) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("5454545454545454"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"5454545454545454"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; // Since card isn't in any of the supported ranges, local save should be // offered and upload save should not. @@ -5115,11 +5108,11 @@ TEST_F(CreditCardSaveManagerTest, LocalSaveNotOfferedForSavedUnsupportedCard) { personal_data_.AddCreditCard(local_card); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("5454545454545454"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"5454545454545454"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; // Since card is already saved, local save should not be offered. FormSubmitted(credit_card_form); @@ -5140,11 +5133,11 @@ TEST_F(CreditCardSaveManagerTest, UploadSaveOfferedForSupportedCard) { FormsSeen(std::vector<FormData>(1, credit_card_form)); // Edit the data, and submit. - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); - credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); + credit_card_form.fields[0].value = u"Flo Master"; + credit_card_form.fields[1].value = u"4111111111111111"; credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; // Since card is in one of the supported ranges(4111-4113), upload save should // be offered. @@ -5174,11 +5167,11 @@ TEST_F(CreditCardSaveManagerTest, InvalidLegalMessageInOnDidGetUploadDetails) { // Edit the data, and submit. const char* const card_number = "4111111111111111"; - credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); + credit_card_form.fields[0].value = u"Flo Master"; credit_card_form.fields[1].value = ASCIIToUTF16(card_number); credit_card_form.fields[2].value = ASCIIToUTF16(test::NextMonth()); credit_card_form.fields[3].value = ASCIIToUTF16(test::NextYear()); - credit_card_form.fields[4].value = ASCIIToUTF16("123"); + credit_card_form.fields[4].value = u"123"; base::HistogramTester histogram_tester; FormSubmitted(credit_card_form); diff --git a/chromium/components/autofill/core/browser/payments/full_card_request.cc b/chromium/components/autofill/core/browser/payments/full_card_request.cc index 16acda82fdc..11354c420df 100644 --- a/chromium/components/autofill/core/browser/payments/full_card_request.cc +++ b/chromium/components/autofill/core/browser/payments/full_card_request.cc @@ -4,6 +4,8 @@ #include "components/autofill/core/browser/payments/full_card_request.h" +#include <memory> + #include "base/bind.h" #include "base/check_op.h" #include "base/notreached.h" @@ -87,7 +89,7 @@ void FullCardRequest::GetFullCard( } result_delegate_ = result_delegate; - request_.reset(new payments::PaymentsClient::UnmaskRequestDetails); + request_ = std::make_unique<payments::PaymentsClient::UnmaskRequestDetails>(); request_->card = card; request_->reason = reason; should_unmask_card_ = card.record_type() == CreditCard::MASKED_SERVER_CARD || @@ -244,7 +246,7 @@ void FullCardRequest::OnDidGetRealPan( // to avoid an unwanted registration prompt. unmask_response_details_ = response_details; - const base::string16 cvc = + const std::u16string cvc = (base::FeatureList::IsEnabled( features::kAutofillEnableGoogleIssuedCard) || base::FeatureList::IsEnabled( diff --git a/chromium/components/autofill/core/browser/payments/full_card_request.h b/chromium/components/autofill/core/browser/payments/full_card_request.h index b09fbb8d213..fa41ba8cd10 100644 --- a/chromium/components/autofill/core/browser/payments/full_card_request.h +++ b/chromium/components/autofill/core/browser/payments/full_card_request.h @@ -10,7 +10,6 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "base/strings/string16.h" #include "base/time/time.h" #include "build/build_config.h" #include "components/autofill/core/browser/autofill_client.h" @@ -57,7 +56,7 @@ class FullCardRequest final : public CardUnmaskDelegate { virtual void OnFullCardRequestSucceeded( const payments::FullCardRequest& full_card_request, const CreditCard& card, - const base::string16& cvc) = 0; + const std::u16string& cvc) = 0; virtual void OnFullCardRequestFailed(FailureType failure_type) = 0; }; diff --git a/chromium/components/autofill/core/browser/payments/full_card_request_unittest.cc b/chromium/components/autofill/core/browser/payments/full_card_request_unittest.cc index d7967c39587..5f756f7e621 100644 --- a/chromium/components/autofill/core/browser/payments/full_card_request_unittest.cc +++ b/chromium/components/autofill/core/browser/payments/full_card_request_unittest.cc @@ -41,7 +41,7 @@ class MockResultDelegate : public FullCardRequest::ResultDelegate, MOCK_METHOD3(OnFullCardRequestSucceeded, void(const payments::FullCardRequest&, const CreditCard&, - const base::string16&)); + const std::u16string&)); MOCK_METHOD1(OnFullCardRequestFailed, void(payments::FullCardRequest::FailureType)); }; @@ -174,7 +174,7 @@ TEST_F(FullCardRequestTest, GetFullCardPanAndCvcForMaskedServerCardViaCvc) { AutofillClient::UNMASK_FOR_AUTOFILL, result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::SUCCESS, "4111"); card_unmask_delegate()->OnUnmaskPromptClosed(); @@ -199,7 +199,7 @@ TEST_F(FullCardRequestTest, GetFullCardPanAndDcvvForMaskedServerCardViaDcvv) { AutofillClient::UNMASK_FOR_AUTOFILL, result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPanWithDcvv(AutofillClient::SUCCESS, "4111", "321"); card_unmask_delegate()->OnUnmaskPromptClosed(); @@ -224,7 +224,7 @@ TEST_F(FullCardRequestTest, GetFullCardPanForMaskedServerCardWithoutDcvv) { AutofillClient::UNMASK_FOR_AUTOFILL, result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::SUCCESS, "4111"); card_unmask_delegate()->OnUnmaskPromptClosed(); @@ -249,7 +249,7 @@ TEST_F(FullCardRequestTest, GetFullCardPanAndUseCvcInUnmaskResponse) { AutofillClient::UNMASK_FOR_AUTOFILL, result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPanWithDcvv(AutofillClient::SUCCESS, "4111", "321"); card_unmask_delegate()->OnUnmaskPromptClosed(); @@ -274,7 +274,7 @@ TEST_F(FullCardRequestTest, GetFullCardPanWithoutCvcInUnmaskResponse) { AutofillClient::UNMASK_FOR_AUTOFILL, result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::SUCCESS, "4111"); card_unmask_delegate()->OnUnmaskPromptClosed(); @@ -312,7 +312,7 @@ TEST_F(FullCardRequestTest, GetFullCardPanAndCvcForLocalCard) { result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); card_unmask_delegate()->OnUnmaskPromptClosed(); } @@ -335,7 +335,7 @@ TEST_F(FullCardRequestTest, GetFullCardPanAndCvcForFullServerCard) { result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); card_unmask_delegate()->OnUnmaskPromptClosed(); } @@ -362,9 +362,9 @@ TEST_F(FullCardRequestTest, result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); - details.exp_year = base::ASCIIToUTF16("2051"); - details.exp_month = base::ASCIIToUTF16("12"); + details.cvc = u"123"; + details.exp_year = u"2051"; + details.exp_month = u"12"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::SUCCESS, "4111"); card_unmask_delegate()->OnUnmaskPromptClosed(); @@ -394,9 +394,9 @@ TEST_F(FullCardRequestTest, GetFullCardPanAndCvcForExpiredFullServerCard) { result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); - details.exp_year = base::ASCIIToUTF16("2051"); - details.exp_month = base::ASCIIToUTF16("12"); + details.cvc = u"123"; + details.exp_year = u"2051"; + details.exp_month = u"12"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::SUCCESS, "4111"); card_unmask_delegate()->OnUnmaskPromptClosed(); @@ -440,7 +440,7 @@ TEST_F(FullCardRequestTest, SecondRequestOkAfterFirstFinished) { result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); card_unmask_delegate()->OnUnmaskPromptClosed(); @@ -482,7 +482,7 @@ TEST_F(FullCardRequestTest, PermanentFailure) { AutofillClient::UNMASK_FOR_AUTOFILL, result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::PERMANENT_FAILURE, ""); card_unmask_delegate()->OnUnmaskPromptClosed(); @@ -503,7 +503,7 @@ TEST_F(FullCardRequestTest, NetworkError) { AutofillClient::UNMASK_FOR_AUTOFILL, result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::NETWORK_ERROR, ""); card_unmask_delegate()->OnUnmaskPromptClosed(); @@ -524,7 +524,7 @@ TEST_F(FullCardRequestTest, TryAgainFailureGiveUp) { AutofillClient::UNMASK_FOR_AUTOFILL, result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::TRY_AGAIN_FAILURE, ""); card_unmask_delegate()->OnUnmaskPromptClosed(); @@ -550,10 +550,10 @@ TEST_F(FullCardRequestTest, TryAgainFailureRetry) { AutofillClient::UNMASK_FOR_AUTOFILL, result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("789"); + details.cvc = u"789"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::TRY_AGAIN_FAILURE, ""); - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::SUCCESS, "4111"); card_unmask_delegate()->OnUnmaskPromptClosed(); @@ -575,9 +575,9 @@ TEST_F(FullCardRequestTest, UpdateExpDateForMaskedServerCard) { AutofillClient::UNMASK_FOR_AUTOFILL, result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); - details.exp_month = base::ASCIIToUTF16("12"); - details.exp_year = base::ASCIIToUTF16("2050"); + details.cvc = u"123"; + details.exp_month = u"12"; + details.exp_year = u"2050"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::SUCCESS, "4111"); card_unmask_delegate()->OnUnmaskPromptClosed(); @@ -601,9 +601,9 @@ TEST_F(FullCardRequestTest, UpdateExpDateForFullServerCard) { result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); - details.exp_month = base::ASCIIToUTF16("12"); - details.exp_year = base::ASCIIToUTF16("2050"); + details.cvc = u"123"; + details.exp_month = u"12"; + details.exp_year = u"2050"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::SUCCESS, "4111"); card_unmask_delegate()->OnUnmaskPromptClosed(); @@ -633,9 +633,9 @@ TEST_F(FullCardRequestTest, UpdateExpDateForLocalCard) { result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); - details.exp_month = base::ASCIIToUTF16("12"); - details.exp_year = base::ASCIIToUTF16("2051"); + details.cvc = u"123"; + details.exp_month = u"12"; + details.exp_year = u"2051"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); card_unmask_delegate()->OnUnmaskPromptClosed(); } @@ -659,9 +659,9 @@ TEST_F(FullCardRequestTest, SaveRealPan) { AutofillClient::UNMASK_FOR_AUTOFILL, result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); - details.exp_month = base::ASCIIToUTF16("12"); - details.exp_year = base::ASCIIToUTF16("2050"); + details.cvc = u"123"; + details.exp_month = u"12"; + details.exp_year = u"2050"; details.should_store_pan = true; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::SUCCESS, "4111"); @@ -684,7 +684,7 @@ TEST_F(FullCardRequestTest, UnmaskForPaymentRequest) { AutofillClient::UNMASK_FOR_PAYMENT_REQUEST, result_delegate()->AsWeakPtr(), ui_delegate()->AsWeakPtr()); CardUnmaskDelegate::UserProvidedUnmaskDetails details; - details.cvc = base::ASCIIToUTF16("123"); + details.cvc = u"123"; card_unmask_delegate()->OnUnmaskPromptAccepted(details); OnDidGetRealPan(AutofillClient::SUCCESS, "4111"); card_unmask_delegate()->OnUnmaskPromptClosed(); diff --git a/chromium/components/autofill/core/browser/payments/legal_message_line.cc b/chromium/components/autofill/core/browser/payments/legal_message_line.cc index e34143f6a2f..9eda6187838 100644 --- a/chromium/components/autofill/core/browser/payments/legal_message_line.cc +++ b/chromium/components/autofill/core/browser/payments/legal_message_line.cc @@ -19,9 +19,9 @@ namespace { // Return false on failure. If false is returned then contents of |out_message| // and |out_offsets| are undefined. bool ReplaceTemplatePlaceholders( - const base::string16& template_icu, - const std::vector<base::string16>& display_texts, - base::string16* out_message, + const std::u16string& template_icu, + const std::vector<std::u16string>& display_texts, + std::u16string* out_message, std::vector<size_t>* out_offsets) { // Escape "$" -> "$$" for ReplaceStringPlaceholders(). // @@ -38,13 +38,12 @@ bool ReplaceTemplatePlaceholders( // // Both of these cases are noted in the header file, and are unlikely to // occur in any actual legal message. - base::string16 template_icu_escaped; - base::ReplaceChars(template_icu, base::ASCIIToUTF16("$"), - base::ASCIIToUTF16("$$"), &template_icu_escaped); + std::u16string template_icu_escaped; + base::ReplaceChars(template_icu, u"$", u"$$", &template_icu_escaped); // Replace "{0}" -> "$1", "{1}" -> "$2", ... to prepare |template_dollars| // for ReplaceStringPlaceholders(). - base::string16 template_dollars = + std::u16string template_dollars = base::i18n::MessageFormatter::FormatWithNumberedArgs( template_icu_escaped, "$1", "$2", "$3", "$4", "$5", "$6", "$7"); @@ -107,7 +106,7 @@ bool LegalMessageLine::ParseLine(const base::Value& line, // |display_texts| elements are the strings that will be substituted for // "{0}", "{1}", etc. in the template string. - std::vector<base::string16> display_texts; + std::vector<std::u16string> display_texts; // Process all the template parameters. const base::Value* template_parameters = @@ -141,7 +140,7 @@ bool LegalMessageLine::ParseLine(const base::Value& line, if (!template_icu_utf8) return false; - base::string16 template_icu = base::UTF8ToUTF16(*template_icu_utf8); + std::u16string template_icu = base::UTF8ToUTF16(*template_icu_utf8); if (escape_apostrophes) { // The ICU standard counts "'{" as beginning an escaped string literal, even // if there's no closing apostrophe. This fails legal message templates @@ -149,8 +148,7 @@ bool LegalMessageLine::ParseLine(const base::Value& line, // Italian. Therefore, when |escape_apostrophes| is true, escape all // apostrophes in the string by doubling them up. // http://www.icu-project.org/apiref/icu4c/messagepattern_8h.html#af6e0757e0eb81c980b01ee5d68a9978b - base::ReplaceChars(template_icu, base::ASCIIToUTF16("'"), - base::ASCIIToUTF16("''"), &template_icu); + base::ReplaceChars(template_icu, u"'", u"''", &template_icu); } // Replace the placeholders in |template_icu| with strings from diff --git a/chromium/components/autofill/core/browser/payments/legal_message_line.h b/chromium/components/autofill/core/browser/payments/legal_message_line.h index e99a588b544..8c033ec986b 100644 --- a/chromium/components/autofill/core/browser/payments/legal_message_line.h +++ b/chromium/components/autofill/core/browser/payments/legal_message_line.h @@ -10,7 +10,6 @@ #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "base/strings/string16.h" #include "ui/gfx/range/range.h" #include "url/gurl.h" @@ -75,7 +74,7 @@ class LegalMessageLine { LegalMessageLines* out, bool escape_apostrophes = false); - const base::string16& text() const { return text_; } + const std::u16string& text() const { return text_; } const Links& links() const { return links_; } private: @@ -83,7 +82,7 @@ class LegalMessageLine { bool ParseLine(const base::Value& line, bool escape_apostrophes); - base::string16 text_; + std::u16string text_; Links links_; }; diff --git a/chromium/components/autofill/core/browser/payments/local_card_migration_manager.cc b/chromium/components/autofill/core/browser/payments/local_card_migration_manager.cc index 2f3dd6e8a35..08f571eac02 100644 --- a/chromium/components/autofill/core/browser/payments/local_card_migration_manager.cc +++ b/chromium/components/autofill/core/browser/payments/local_card_migration_manager.cc @@ -199,7 +199,7 @@ bool LocalCardMigrationManager::IsCreditCardMigrationEnabled() { void LocalCardMigrationManager::OnDidGetUploadDetails( bool is_from_settings_page, AutofillClient::PaymentsRpcResult result, - const base::string16& context_token, + const std::u16string& context_token, std::unique_ptr<base::Value> legal_message, std::vector<std::pair<int, int>> supported_card_bin_ranges) { if (observer_for_testing_) diff --git a/chromium/components/autofill/core/browser/payments/local_card_migration_manager.h b/chromium/components/autofill/core/browser/payments/local_card_migration_manager.h index 3f2c73c3720..9604d5debe3 100644 --- a/chromium/components/autofill/core/browser/payments/local_card_migration_manager.h +++ b/chromium/components/autofill/core/browser/payments/local_card_migration_manager.h @@ -11,7 +11,6 @@ #include <utility> #include <vector> -#include "base/strings/string16.h" #include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_metrics.h" #include "components/autofill/core/browser/payments/legal_message_line.h" @@ -153,7 +152,7 @@ class LocalCardMigrationManager { virtual void OnDidGetUploadDetails( bool is_from_settings_page, AutofillClient::PaymentsRpcResult result, - const base::string16& context_token, + const std::u16string& context_token, std::unique_ptr<base::Value> legal_message, std::vector<std::pair<int, int>> supported_card_bin_ranges); @@ -223,7 +222,7 @@ class LocalCardMigrationManager { PersonalDataManager* personal_data_manager_; // The imported credit card number from the form submission. - base::Optional<base::string16> imported_credit_card_number_; + base::Optional<std::u16string> imported_credit_card_number_; // The imported credit card record type from the form submission. int imported_credit_card_record_type_; diff --git a/chromium/components/autofill/core/browser/payments/local_card_migration_manager_unittest.cc b/chromium/components/autofill/core/browser/payments/local_card_migration_manager_unittest.cc index bb3b77081de..ef074d4b21b 100644 --- a/chromium/components/autofill/core/browser/payments/local_card_migration_manager_unittest.cc +++ b/chromium/components/autofill/core/browser/payments/local_card_migration_manager_unittest.cc @@ -67,7 +67,7 @@ class LocalCardMigrationManagerTest : public testing::Test { autofill_client_.SetPrefs(test::PrefServiceForTesting()); personal_data_.SetPrefService(autofill_client_.GetPrefs()); personal_data_.SetSyncServiceForTest(&sync_service_); - autofill_driver_.reset(new TestAutofillDriver()); + autofill_driver_ = std::make_unique<TestAutofillDriver>(); payments_client_ = new payments::TestPaymentsClient( autofill_driver_->GetURLLoaderFactory(), autofill_client_.GetIdentityManager(), &personal_data_); @@ -93,9 +93,9 @@ class LocalCardMigrationManagerTest : public testing::Test { local_card_migration_manager_)); autofill_client_.set_test_form_data_importer( std::unique_ptr<TestFormDataImporter>(test_form_data_importer)); - autofill_manager_.reset(new TestAutofillManager( + autofill_manager_ = std::make_unique<TestAutofillManager>( autofill_driver_.get(), &autofill_client_, &personal_data_, - &autocomplete_history_manager_)); + &autocomplete_history_manager_); autofill_manager_->SetExpectedObservedSubmission(true); } @@ -970,7 +970,7 @@ TEST_F(LocalCardMigrationManagerTest, EXPECT_EQ(local_card_migration_manager_->migratable_credit_cards_[0] .credit_card() .number(), - base::ASCIIToUTF16("4111111111111111")); + u"4111111111111111"); EXPECT_TRUE(local_card_migration_manager_->IntermediatePromptWasShown()); } diff --git a/chromium/components/autofill/core/browser/payments/payments_client.cc b/chromium/components/autofill/core/browser/payments/payments_client.cc index 06cd9bfdf62..80a30d17034 100644 --- a/chromium/components/autofill/core/browser/payments/payments_client.cc +++ b/chromium/components/autofill/core/browser/payments/payments_client.cc @@ -134,7 +134,7 @@ void SetStringIfNotEmpty(const AutofillDataModel& profile, const std::string& app_locale, const std::string& path, base::Value& dictionary) { - const base::string16 value = profile.GetInfo(AutofillType(type), app_locale); + const std::u16string value = profile.GetInfo(AutofillType(type), app_locale); if (!value.empty()) dictionary.SetKey(path, base::Value(value)); } @@ -143,7 +143,7 @@ void AppendStringIfNotEmpty(const AutofillProfile& profile, const ServerFieldType& type, const std::string& app_locale, base::Value& list) { - const base::string16 value = profile.GetInfo(type, app_locale); + const std::u16string value = profile.GetInfo(type, app_locale); if (!value.empty()) list.Append(value); } @@ -180,7 +180,7 @@ base::Value BuildAddressDictionary(const AutofillProfile& profile, "postal_code_number", postal_address); // Use GetRawInfo to get a country code instead of the country name: - const base::string16 country_code = profile.GetRawInfo(ADDRESS_HOME_COUNTRY); + const std::u16string country_code = profile.GetRawInfo(ADDRESS_HOME_COUNTRY); if (!country_code.empty()) postal_address.SetKey("country_name_code", base::Value(country_code)); @@ -206,9 +206,9 @@ base::Value BuildCreditCardDictionary(const CreditCard& credit_card, base::Value card(base::Value::Type::DICTIONARY); card.SetKey("unique_id", base::Value(credit_card.guid())); - const base::string16 exp_month = + const std::u16string exp_month = credit_card.GetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), app_locale); - const base::string16 exp_year = credit_card.GetInfo( + const std::u16string exp_year = credit_card.GetInfo( AutofillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), app_locale); int value = 0; if (base::StringToInt(exp_month, &value)) @@ -595,7 +595,7 @@ class GetUploadDetailsRequest : public PaymentsRequest { const bool full_sync_enabled, const std::string& app_locale, base::OnceCallback<void(AutofillClient::PaymentsRpcResult, - const base::string16&, + const std::u16string&, std::unique_ptr<base::Value>, std::vector<std::pair<int, int>>)> callback, const int billable_service_number, @@ -686,7 +686,7 @@ class GetUploadDetailsRequest : public PaymentsRequest { void ParseResponse(const base::Value& response) override { const auto* context_token = response.FindStringKey("context_token"); context_token_ = - context_token ? base::UTF8ToUTF16(*context_token) : base::string16(); + context_token ? base::UTF8ToUTF16(*context_token) : std::u16string(); const base::Value* dictionary_value = response.FindKeyOfType("legal_message", base::Value::Type::DICTIONARY); @@ -745,11 +745,11 @@ class GetUploadDetailsRequest : public PaymentsRequest { const bool full_sync_enabled_; std::string app_locale_; base::OnceCallback<void(AutofillClient::PaymentsRpcResult, - const base::string16&, + const std::u16string&, std::unique_ptr<base::Value>, std::vector<std::pair<int, int>>)> callback_; - base::string16 context_token_; + std::u16string context_token_; std::unique_ptr<base::Value> legal_message_; std::vector<std::pair<int, int>> supported_card_bin_ranges_; const int billable_service_number_; @@ -813,9 +813,9 @@ class UploadCardRequest : public PaymentsRequest { base::Value(request_details_.context_token)); int value = 0; - const base::string16 exp_month = request_details_.card.GetInfo( + const std::u16string exp_month = request_details_.card.GetInfo( AutofillType(CREDIT_CARD_EXP_MONTH), app_locale); - const base::string16 exp_year = request_details_.card.GetInfo( + const std::u16string exp_year = request_details_.card.GetInfo( AutofillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), app_locale); if (base::StringToInt(exp_month, &value)) request_dict.SetKey("expiration_month", base::Value(value)); @@ -829,7 +829,7 @@ class UploadCardRequest : public PaymentsRequest { SetActiveExperiments(request_details_.active_experiments, request_dict); - const base::string16 pan = request_details_.card.GetInfo( + const std::u16string pan = request_details_.card.GetInfo( AutofillType(CREDIT_CARD_NUMBER), app_locale); std::string json_request; base::JSONWriter::Write(request_dict, &json_request); @@ -985,7 +985,7 @@ class MigrateCardsRequest : public PaymentsRequest { std::string GetAppendPan(const CreditCard& credit_card, const std::string& app_locale, const std::string& pan_field_name) { - const base::string16 pan = + const std::u16string pan = credit_card.GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale); std::string pan_str = net::EscapeUrlEncodedData(base::UTF16ToASCII(pan), true).c_str(); @@ -1160,7 +1160,7 @@ void PaymentsClient::GetUploadDetails( const std::vector<const char*>& active_experiments, const std::string& app_locale, base::OnceCallback<void(AutofillClient::PaymentsRpcResult, - const base::string16&, + const std::u16string&, std::unique_ptr<base::Value>, std::vector<std::pair<int, int>>)> callback, const int billable_service_number, diff --git a/chromium/components/autofill/core/browser/payments/payments_client.h b/chromium/components/autofill/core/browser/payments/payments_client.h index 8b7e1b05a6f..3fc99c7b258 100644 --- a/chromium/components/autofill/core/browser/payments/payments_client.h +++ b/chromium/components/autofill/core/browser/payments/payments_client.h @@ -192,9 +192,9 @@ class PaymentsClient { int64_t billing_customer_number = 0; int detected_values; CreditCard card; - base::string16 cvc; + std::u16string cvc; std::vector<AutofillProfile> profiles; - base::string16 context_token; + std::u16string context_token; std::string risk_data; std::string app_locale; std::vector<const char*> active_experiments; @@ -208,7 +208,7 @@ class PaymentsClient { ~MigrationRequestDetails(); int64_t billing_customer_number = 0; - base::string16 context_token; + std::u16string context_token; std::string risk_data; std::string app_locale; }; @@ -293,7 +293,7 @@ class PaymentsClient { const std::vector<const char*>& active_experiments, const std::string& app_locale, base::OnceCallback<void(AutofillClient::PaymentsRpcResult, - const base::string16&, + const std::u16string&, std::unique_ptr<base::Value>, std::vector<std::pair<int, int>>)> callback, const int billable_service_number, diff --git a/chromium/components/autofill/core/browser/payments/payments_client_unittest.cc b/chromium/components/autofill/core/browser/payments/payments_client_unittest.cc index 0ee7b134ddf..de72a4e15ec 100644 --- a/chromium/components/autofill/core/browser/payments/payments_client_unittest.cc +++ b/chromium/components/autofill/core/browser/payments/payments_client_unittest.cc @@ -151,7 +151,7 @@ class PaymentsClientTest : public testing::Test { void OnDidGetUploadDetails( AutofillClient::PaymentsRpcResult result, - const base::string16& context_token, + const std::u16string& context_token, std::unique_ptr<base::Value> legal_message, std::vector<std::pair<int, int>> supported_card_bin_ranges) { result_ = result; @@ -240,12 +240,12 @@ class PaymentsClientTest : public testing::Test { request_details.billing_customer_number = 111222333444; request_details.card = test::GetCreditCard(); if (include_cvc) - request_details.cvc = base::ASCIIToUTF16("123"); + request_details.cvc = u"123"; if (include_nickname) { - upstream_nickname_ = base::ASCIIToUTF16("grocery"); + upstream_nickname_ = u"grocery"; request_details.card.SetNickname(upstream_nickname_); } - request_details.context_token = base::ASCIIToUTF16("context token"); + request_details.context_token = u"context token"; request_details.risk_data = "some risk data"; request_details.app_locale = "language-LOCALE"; request_details.profiles = BuildTestProfiles(); @@ -258,18 +258,18 @@ class PaymentsClientTest : public testing::Test { void StartMigrating(bool has_cardholder_name, bool set_nickname_for_first_card = false) { PaymentsClient::MigrationRequestDetails request_details; - request_details.context_token = base::ASCIIToUTF16("context token"); + request_details.context_token = u"context token"; request_details.risk_data = "some risk data"; request_details.app_locale = "language-LOCALE"; migratable_credit_cards_.clear(); CreditCard card1 = test::GetCreditCard(); if (set_nickname_for_first_card) - card1.SetNickname(base::ASCIIToUTF16("grocery")); + card1.SetNickname(u"grocery"); CreditCard card2 = test::GetCreditCard2(); if (!has_cardholder_name) { - card1.SetRawInfo(CREDIT_CARD_NAME_FULL, base::UTF8ToUTF16("")); - card2.SetRawInfo(CREDIT_CARD_NAME_FULL, base::UTF8ToUTF16("")); + card1.SetRawInfo(CREDIT_CARD_NAME_FULL, u""); + card2.SetRawInfo(CREDIT_CARD_NAME_FULL, u""); } migratable_credit_cards_.push_back(MigratableCreditCard(card1)); migratable_credit_cards_.push_back(MigratableCreditCard(card2)); @@ -321,7 +321,7 @@ class PaymentsClientTest : public testing::Test { // GetDetails upload save preflight call. std::vector<std::pair<int, int>> supported_card_bin_ranges_; // The nickname name in the UploadRequest that was supposed to be saved. - base::string16 upstream_nickname_; + std::u16string upstream_nickname_; #if !defined(OS_ANDROID) && !defined(OS_IOS) // Credit cards to be upload saved during a local credit card migration call. diff --git a/chromium/components/autofill/core/browser/payments/payments_util.cc b/chromium/components/autofill/core/browser/payments/payments_util.cc index 7437638ad6a..fb8d642e16c 100644 --- a/chromium/components/autofill/core/browser/payments/payments_util.cc +++ b/chromium/components/autofill/core/browser/payments/payments_util.cc @@ -38,9 +38,9 @@ bool HasGooglePaymentsAccount(PersonalDataManager* personal_data_manager) { } bool IsCreditCardNumberSupported( - const base::string16& card_number, + const std::u16string& card_number, const std::vector<std::pair<int, int>>& supported_card_bin_ranges) { - base::string16 stripped_number = CreditCard::StripSeparators(card_number); + std::u16string stripped_number = CreditCard::StripSeparators(card_number); for (auto& bin_range : supported_card_bin_ranges) { unsigned long range_num_of_digits = base::NumberToString(bin_range.first).size(); diff --git a/chromium/components/autofill/core/browser/payments/payments_util.h b/chromium/components/autofill/core/browser/payments/payments_util.h index 2e2cf761dfc..7c4ff35ddd0 100644 --- a/chromium/components/autofill/core/browser/payments/payments_util.h +++ b/chromium/components/autofill/core/browser/payments/payments_util.h @@ -29,7 +29,7 @@ bool HasGooglePaymentsAccount(PersonalDataManager* personal_data_manager); // For example, if the range consists of std::pair<34, 36>, then all cards // with first two digits of 34, 35 and 36 are supported. bool IsCreditCardNumberSupported( - const base::string16& card_number, + const std::u16string& card_number, const std::vector<std::pair<int, int>>& supported_card_bin_ranges); } // namespace payments diff --git a/chromium/components/autofill/core/browser/payments/payments_util_unittest.cc b/chromium/components/autofill/core/browser/payments/payments_util_unittest.cc index 27a324939f8..620e4ed9fb0 100644 --- a/chromium/components/autofill/core/browser/payments/payments_util_unittest.cc +++ b/chromium/components/autofill/core/browser/payments/payments_util_unittest.cc @@ -4,8 +4,9 @@ #include "components/autofill/core/browser/payments/payments_util.h" +#include <string> + #include "base/guid.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_test_utils.h" #include "components/autofill/core/browser/payments/payments_customer_data.h" @@ -62,7 +63,7 @@ TEST_F(PaymentsUtilTest, HasGooglePaymentsAccount_NoData) { TEST_F(PaymentsUtilTest, IsCreditCardNumberSupported_EmptyBin) { // Create empty supported card bin ranges. std::vector<std::pair<int, int>> supported_card_bin_ranges; - base::string16 card_number = base::ASCIIToUTF16("4111111111111111"); + std::u16string card_number = u"4111111111111111"; // Card number is not supported since the supported bin range is empty. EXPECT_FALSE( IsCreditCardNumberSupported(card_number, supported_card_bin_ranges)); @@ -71,7 +72,7 @@ TEST_F(PaymentsUtilTest, IsCreditCardNumberSupported_EmptyBin) { TEST_F(PaymentsUtilTest, IsCreditCardNumberSupported_SameStartAndEnd) { std::vector<std::pair<int, int>> supported_card_bin_ranges{ std::make_pair(411111, 411111)}; - base::string16 card_number = base::ASCIIToUTF16("4111111111111111"); + std::u16string card_number = u"4111111111111111"; // Card number is supported since it is within the range of the same start and // end. EXPECT_TRUE( @@ -81,7 +82,7 @@ TEST_F(PaymentsUtilTest, IsCreditCardNumberSupported_SameStartAndEnd) { TEST_F(PaymentsUtilTest, IsCreditCardNumberSupported_InsideRange) { std::vector<std::pair<int, int>> supported_card_bin_ranges{ std::make_pair(411110, 411112)}; - base::string16 card_number = base::ASCIIToUTF16("4111111111111111"); + std::u16string card_number = u"4111111111111111"; // Card number is supported since it is inside the range. EXPECT_TRUE( IsCreditCardNumberSupported(card_number, supported_card_bin_ranges)); @@ -90,7 +91,7 @@ TEST_F(PaymentsUtilTest, IsCreditCardNumberSupported_InsideRange) { TEST_F(PaymentsUtilTest, IsCreditCardNumberSupported_StartBoundary) { std::vector<std::pair<int, int>> supported_card_bin_ranges{ std::make_pair(411111, 422222)}; - base::string16 card_number = base::ASCIIToUTF16("4111111111111111"); + std::u16string card_number = u"4111111111111111"; // Card number is supported since it is at the start boundary. EXPECT_TRUE( IsCreditCardNumberSupported(card_number, supported_card_bin_ranges)); @@ -99,7 +100,7 @@ TEST_F(PaymentsUtilTest, IsCreditCardNumberSupported_StartBoundary) { TEST_F(PaymentsUtilTest, IsCreditCardNumberSupported_EndBoundary) { std::vector<std::pair<int, int>> supported_card_bin_ranges{ std::make_pair(410000, 411111)}; - base::string16 card_number = base::ASCIIToUTF16("4111111111111111"); + std::u16string card_number = u"4111111111111111"; // Card number is supported since it is at the end boundary. EXPECT_TRUE( IsCreditCardNumberSupported(card_number, supported_card_bin_ranges)); @@ -109,7 +110,7 @@ TEST_F(PaymentsUtilTest, IsCreditCardNumberSupported_OutOfRange) { std::vector<std::pair<int, int>> supported_card_bin_ranges{ std::make_pair(2111, 2111), std::make_pair(412, 413), std::make_pair(300, 305)}; - base::string16 card_number = base::ASCIIToUTF16("4111111111111111"); + std::u16string card_number = u"4111111111111111"; // Card number is not supported since it is out of any range. EXPECT_FALSE( IsCreditCardNumberSupported(card_number, supported_card_bin_ranges)); @@ -118,7 +119,7 @@ TEST_F(PaymentsUtilTest, IsCreditCardNumberSupported_OutOfRange) { TEST_F(PaymentsUtilTest, IsCreditCardNumberSupported_SeparatorStripped) { std::vector<std::pair<int, int>> supported_card_bin_ranges{ std::make_pair(4111, 4111)}; - base::string16 card_number = base::ASCIIToUTF16("4111-1111-1111-1111"); + std::u16string card_number = u"4111-1111-1111-1111"; // The separators are correctly stripped and the card number is supported. EXPECT_TRUE( IsCreditCardNumberSupported(card_number, supported_card_bin_ranges)); diff --git a/chromium/components/autofill/core/browser/payments/test_authentication_requester.cc b/chromium/components/autofill/core/browser/payments/test_authentication_requester.cc index e7ae1c9407f..97b7fb1d55f 100644 --- a/chromium/components/autofill/core/browser/payments/test_authentication_requester.cc +++ b/chromium/components/autofill/core/browser/payments/test_authentication_requester.cc @@ -4,7 +4,8 @@ #include "components/autofill/core/browser/payments/test_authentication_requester.h" -#include "base/strings/string16.h" +#include <string> + #include "build/build_config.h" #include "components/autofill/core/browser/data_model/credit_card.h" @@ -43,7 +44,7 @@ bool TestAuthenticationRequester::UserOptedInToFidoFromSettingsPageOnMobile() void TestAuthenticationRequester::OnFIDOAuthenticationComplete( bool did_succeed, const CreditCard* card, - const base::string16& cvc) { + const std::u16string& cvc) { did_succeed_ = did_succeed; if (did_succeed_) { DCHECK(card); diff --git a/chromium/components/autofill/core/browser/payments/test_authentication_requester.h b/chromium/components/autofill/core/browser/payments/test_authentication_requester.h index d343aaaaddf..b17dc78377c 100644 --- a/chromium/components/autofill/core/browser/payments/test_authentication_requester.h +++ b/chromium/components/autofill/core/browser/payments/test_authentication_requester.h @@ -10,7 +10,6 @@ #include <utility> #include <vector> -#include "base/strings/string16.h" #include "build/build_config.h" #include "components/autofill/core/browser/data_model/credit_card.h" #include "components/autofill/core/browser/payments/credit_card_cvc_authenticator.h" @@ -49,7 +48,7 @@ class TestAuthenticationRequester void OnFIDOAuthenticationComplete( bool did_succeed, const CreditCard* card = nullptr, - const base::string16& cvc = base::string16()) override; + const std::u16string& cvc = std::u16string()) override; void OnFidoAuthorizationComplete(bool did_succeed) override; void IsUserVerifiableCallback(bool is_user_verifiable); @@ -61,7 +60,7 @@ class TestAuthenticationRequester bool did_succeed() { return did_succeed_; } - base::string16 number() { return number_; } + std::u16string number() { return number_; } private: // Set when CreditCardFIDOAuthenticator invokes IsUserVerifiableCallback(). @@ -71,7 +70,7 @@ class TestAuthenticationRequester bool did_succeed_ = false; // The card number returned from On*AuthenticationComplete(). - base::string16 number_; + std::u16string number_; base::WeakPtrFactory<TestAuthenticationRequester> weak_ptr_factory_{this}; }; diff --git a/chromium/components/autofill/core/browser/payments/test_credit_card_fido_authenticator.cc b/chromium/components/autofill/core/browser/payments/test_credit_card_fido_authenticator.cc index e5354b265de..25ed8573cc7 100644 --- a/chromium/components/autofill/core/browser/payments/test_credit_card_fido_authenticator.cc +++ b/chromium/components/autofill/core/browser/payments/test_credit_card_fido_authenticator.cc @@ -4,9 +4,9 @@ #include "components/autofill/core/browser/payments/test_credit_card_fido_authenticator.h" +#include <string> #include <utility> -#include "base/strings/string16.h" #include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_driver.h" #include "third_party/blink/public/mojom/webauthn/authenticator.mojom.h" diff --git a/chromium/components/autofill/core/browser/payments/test_credit_card_fido_authenticator.h b/chromium/components/autofill/core/browser/payments/test_credit_card_fido_authenticator.h index 9446d2fd8f6..893a1a4b95e 100644 --- a/chromium/components/autofill/core/browser/payments/test_credit_card_fido_authenticator.h +++ b/chromium/components/autofill/core/browser/payments/test_credit_card_fido_authenticator.h @@ -9,7 +9,6 @@ #include <string> #include <vector> -#include "base/strings/string16.h" #include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_driver.h" #include "components/autofill/core/browser/data_model/credit_card.h" diff --git a/chromium/components/autofill/core/browser/payments/test_credit_card_save_manager.cc b/chromium/components/autofill/core/browser/payments/test_credit_card_save_manager.cc index 19fc90cace1..6fa87d0d7ff 100644 --- a/chromium/components/autofill/core/browser/payments/test_credit_card_save_manager.cc +++ b/chromium/components/autofill/core/browser/payments/test_credit_card_save_manager.cc @@ -38,7 +38,7 @@ void TestCreditCardSaveManager::set_show_save_prompt(bool show_save_prompt) { } void TestCreditCardSaveManager::set_upload_request_card_number( - const base::string16& credit_card_number) { + const std::u16string& credit_card_number) { upload_request_.card.SetNumber(credit_card_number); } diff --git a/chromium/components/autofill/core/browser/payments/test_credit_card_save_manager.h b/chromium/components/autofill/core/browser/payments/test_credit_card_save_manager.h index bf13c0285c7..2d440204d90 100644 --- a/chromium/components/autofill/core/browser/payments/test_credit_card_save_manager.h +++ b/chromium/components/autofill/core/browser/payments/test_credit_card_save_manager.h @@ -36,7 +36,7 @@ class TestCreditCardSaveManager : public CreditCardSaveManager { void set_show_save_prompt(bool show_save_prompt); - void set_upload_request_card_number(const base::string16& credit_card_number); + void set_upload_request_card_number(const std::u16string& credit_card_number); private: void OnDidUploadCard(AutofillClient::PaymentsRpcResult result, diff --git a/chromium/components/autofill/core/browser/payments/test_local_card_migration_manager.cc b/chromium/components/autofill/core/browser/payments/test_local_card_migration_manager.cc index daae0b7a833..60f4f9f96dc 100644 --- a/chromium/components/autofill/core/browser/payments/test_local_card_migration_manager.cc +++ b/chromium/components/autofill/core/browser/payments/test_local_card_migration_manager.cc @@ -60,7 +60,7 @@ void TestLocalCardMigrationManager::ResetSyncState( void TestLocalCardMigrationManager::OnDidGetUploadDetails( bool is_from_settings_page, AutofillClient::PaymentsRpcResult result, - const base::string16& context_token, + const std::u16string& context_token, std::unique_ptr<base::Value> legal_message, std::vector<std::pair<int, int>> supported_bin_ranges) { if (result == AutofillClient::SUCCESS) { diff --git a/chromium/components/autofill/core/browser/payments/test_local_card_migration_manager.h b/chromium/components/autofill/core/browser/payments/test_local_card_migration_manager.h index 25d38d7aefb..5565710ba52 100644 --- a/chromium/components/autofill/core/browser/payments/test_local_card_migration_manager.h +++ b/chromium/components/autofill/core/browser/payments/test_local_card_migration_manager.h @@ -62,7 +62,7 @@ class TestLocalCardMigrationManager : public LocalCardMigrationManager { void OnDidGetUploadDetails( bool is_from_settings_page, AutofillClient::PaymentsRpcResult result, - const base::string16& context_token, + const std::u16string& context_token, std::unique_ptr<base::Value> legal_message, std::vector<std::pair<int, int>> supported_bin_ranges) override; diff --git a/chromium/components/autofill/core/browser/payments/test_payments_client.cc b/chromium/components/autofill/core/browser/payments/test_payments_client.cc index 0d8110e12ca..c47cbe943f0 100644 --- a/chromium/components/autofill/core/browser/payments/test_payments_client.cc +++ b/chromium/components/autofill/core/browser/payments/test_payments_client.cc @@ -57,7 +57,7 @@ void TestPaymentsClient::GetUploadDetails( const std::vector<const char*>& active_experiments, const std::string& app_locale, base::OnceCallback<void(AutofillClient::PaymentsRpcResult, - const base::string16&, + const std::u16string&, std::unique_ptr<base::Value>, std::vector<std::pair<int, int>>)> callback, const int billable_service_number, @@ -70,8 +70,8 @@ void TestPaymentsClient::GetUploadDetails( std::move(callback).Run( app_locale == "en-US" ? AutofillClient::SUCCESS : AutofillClient::PERMANENT_FAILURE, - base::ASCIIToUTF16("this is a context token"), - TestPaymentsClient::LegalMessage(), supported_card_bin_ranges_); + u"this is a context token", TestPaymentsClient::LegalMessage(), + supported_card_bin_ranges_); } void TestPaymentsClient::UploadCard( diff --git a/chromium/components/autofill/core/browser/payments/test_payments_client.h b/chromium/components/autofill/core/browser/payments/test_payments_client.h index 51939a152f3..52135648a12 100644 --- a/chromium/components/autofill/core/browser/payments/test_payments_client.h +++ b/chromium/components/autofill/core/browser/payments/test_payments_client.h @@ -46,7 +46,7 @@ class TestPaymentsClient : public payments::PaymentsClient { const std::vector<const char*>& active_experiments, const std::string& app_locale, base::OnceCallback<void(AutofillClient::PaymentsRpcResult, - const base::string16&, + const std::u16string&, std::unique_ptr<base::Value>, std::vector<std::pair<int, int>>)> callback, const int billable_service_number, diff --git a/chromium/components/autofill/core/browser/payments/upi_vpa_save_manager.h b/chromium/components/autofill/core/browser/payments/upi_vpa_save_manager.h index 150a380b1d7..6a00772d178 100644 --- a/chromium/components/autofill/core/browser/payments/upi_vpa_save_manager.h +++ b/chromium/components/autofill/core/browser/payments/upi_vpa_save_manager.h @@ -7,7 +7,6 @@ #include <string> -#include "base/strings/string16.h" #include "build/build_config.h" #include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/personal_data_manager.h" diff --git a/chromium/components/autofill/core/browser/personal_data_manager.cc b/chromium/components/autofill/core/browser/personal_data_manager.cc index caabfdf41a8..9d898ef1676 100644 --- a/chromium/components/autofill/core/browser/personal_data_manager.cc +++ b/chromium/components/autofill/core/browser/personal_data_manager.cc @@ -1211,14 +1211,14 @@ std::vector<AutofillProfile*> PersonalDataManager::GetProfilesToSuggest() std::vector<Suggestion> PersonalDataManager::GetProfileSuggestions( const AutofillType& type, - const base::string16& field_contents, + const std::u16string& field_contents, bool field_is_autofilled, const std::vector<ServerFieldType>& field_types) { if (IsInAutofillSuggestionsDisabledExperiment()) return std::vector<Suggestion>(); const AutofillProfileComparator comparator(app_locale_); - base::string16 field_contents_canon = + std::u16string field_contents_canon = comparator.NormalizeForComparison(field_contents); if (base::FeatureList::IsEnabled( @@ -1270,7 +1270,7 @@ std::vector<Suggestion> PersonalDataManager::GetProfileSuggestions( : nullptr; // Generate disambiguating labels based on the list of matches. - std::vector<base::string16> labels; + std::vector<std::u16string> labels; if (formatter) { labels = formatter->GetLabels(); } else { @@ -1348,7 +1348,7 @@ void PersonalDataManager::RemoveExpiredCreditCardsNotUsedSinceTimestamp( std::vector<Suggestion> PersonalDataManager::GetCreditCardSuggestions( const AutofillType& type, - const base::string16& field_contents, + const std::u16string& field_contents, bool include_server_cards) { if (IsInAutofillSuggestionsDisabledExperiment()) return std::vector<Suggestion>(); @@ -2049,14 +2049,14 @@ void PersonalDataManager::OnCreditCardSaved(bool is_local_card) { std::vector<Suggestion> PersonalDataManager::GetSuggestionsForCards( const AutofillType& type, - const base::string16& field_contents, + const std::u16string& field_contents, const std::vector<CreditCard*>& cards_to_suggest) const { std::vector<Suggestion> suggestions; - base::string16 field_contents_lower = base::i18n::ToLower(field_contents); + std::u16string field_contents_lower = base::i18n::ToLower(field_contents); for (const CreditCard* credit_card : cards_to_suggest) { // The value of the stored data for this field type in the |credit_card|. - base::string16 creditcard_field_value = + std::u16string creditcard_field_value = credit_card->GetInfo(type, app_locale_); if (creditcard_field_value.empty()) continue; @@ -2079,7 +2079,7 @@ std::vector<Suggestion> PersonalDataManager::GetSuggestionsForCards( // Get the nickname for the card suggestion, which may not be the same as // the card's nickname if there are duplicates of the card on file. - base::string16 suggestion_nickname = + std::u16string suggestion_nickname = GetDisplayNicknameForCreditCard(*credit_card); // If the value is the card number, the label is the expiration date. @@ -2366,7 +2366,7 @@ void PersonalDataManager::MigrateUserOptedInWalletSyncTransportIfNeeded() { /*opted_in=*/true); } -base::string16 PersonalDataManager::GetDisplayNicknameForCreditCard( +std::u16string PersonalDataManager::GetDisplayNicknameForCreditCard( const CreditCard& card) const { // Always prefer a local nickname if available. if (card.HasNonEmptyValidNickname() && diff --git a/chromium/components/autofill/core/browser/personal_data_manager.h b/chromium/components/autofill/core/browser/personal_data_manager.h index 0ccbd642d61..a4f87f76bfc 100644 --- a/chromium/components/autofill/core/browser/personal_data_manager.h +++ b/chromium/components/autofill/core/browser/personal_data_manager.h @@ -18,7 +18,6 @@ #include "base/macros.h" #include "base/observer_list.h" #include "base/scoped_observation.h" -#include "base/strings/string16.h" #include "build/build_config.h" #include "components/autofill/core/browser/autofill_profile_validator.h" #include "components/autofill/core/browser/data_model/autofill_offer_data.h" @@ -304,7 +303,7 @@ class PersonalDataManager : public KeyedService, // user is interacting. std::vector<Suggestion> GetProfileSuggestions( const AutofillType& type, - const base::string16& field_contents, + const std::u16string& field_contents, bool field_is_autofilled, const std::vector<ServerFieldType>& field_types); @@ -329,7 +328,7 @@ class PersonalDataManager : public KeyedService, // side cards should not be included. std::vector<Suggestion> GetCreditCardSuggestions( const AutofillType& type, - const base::string16& field_contents, + const std::u16string& field_contents, bool include_server_cards); // Re-loads profiles and credit cards from the WebDatabase asynchronously. @@ -676,7 +675,7 @@ class PersonalDataManager : public KeyedService, // |type| and |field_contents| of the credit card field. std::vector<Suggestion> GetSuggestionsForCards( const AutofillType& type, - const base::string16& field_contents, + const std::u16string& field_contents, const std::vector<CreditCard*>& cards_to_suggest) const; // Converts the Wallet addresses to local autofill profiles. This should be @@ -750,7 +749,7 @@ class PersonalDataManager : public KeyedService, // stored in |card|, unless |card| exists as a local and a server copy. In // this case, we prefer the nickname of the local if it is defined. If only // one copy has a nickname, take that. - base::string16 GetDisplayNicknameForCreditCard(const CreditCard& card) const; + std::u16string GetDisplayNicknameForCreditCard(const CreditCard& card) const; // Returns true if the sync is enabled for |model_type|. bool IsSyncEnabledFor(syncer::ModelType model_type); diff --git a/chromium/components/autofill/core/browser/personal_data_manager_unittest.cc b/chromium/components/autofill/core/browser/personal_data_manager_unittest.cc index 70d5a739895..289083e0e15 100644 --- a/chromium/components/autofill/core/browser/personal_data_manager_unittest.cc +++ b/chromium/components/autofill/core/browser/personal_data_manager_unittest.cc @@ -352,7 +352,7 @@ class PersonalDataManagerHelper : public PersonalDataManagerTestBase { bool use_account_server_storage = false) { if (personal_data_) personal_data_->Shutdown(); - personal_data_.reset(new PersonalDataManager("EN", "US")); + personal_data_ = std::make_unique<PersonalDataManager>("EN", "US"); PersonalDataManagerTestBase::ResetPersonalDataManager( user_mode, use_account_server_storage, personal_data_.get()); } @@ -611,7 +611,8 @@ class PersonalDataManagerMockTest : public PersonalDataManagerTestBase, void ResetPersonalDataManager(UserMode user_mode) { if (personal_data_) personal_data_->Shutdown(); - personal_data_.reset(new PersonalDataManagerMock("en", std::string())); + personal_data_ = + std::make_unique<PersonalDataManagerMock>("en", std::string()); PersonalDataManagerTestBase::ResetPersonalDataManager( user_mode, /*use_account_server_storage=*/true, personal_data_.get()); } @@ -712,7 +713,7 @@ class PersonalDataManagerMockTest : public PersonalDataManagerTestBase, TEST_F(PersonalDataManagerTest, AddProfile) { // Add profile0 to the database. AutofillProfile profile0(test::GetFullProfile()); - profile0.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("j@s.com")); + profile0.SetRawInfo(EMAIL_ADDRESS, u"j@s.com"); AddProfileToPersonalDataManager(profile0); // Reload the database. ResetPersonalDataManager(USER_MODE_NORMAL); @@ -738,7 +739,7 @@ TEST_F(PersonalDataManagerTest, AddProfile) { // New profile with different email. AutofillProfile profile1 = profile0; profile1.set_guid(base::GenerateGUID()); - profile1.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("john@smith.com")); + profile1.SetRawInfo(EMAIL_ADDRESS, u"john@smith.com"); // Add the different profile. This should save as a separate profile. // Note that if this same profile was "merged" it would collapse to one @@ -776,25 +777,23 @@ TEST_F(PersonalDataManagerTest, AddRemoveUpdateProfileSequence) { ASSERT_EQ(0U, profiles.size()); personal_data_->AddProfile(profile); - profile.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("new@email.com")); + profile.SetRawInfo(EMAIL_ADDRESS, u"new@email.com"); personal_data_->UpdateProfile(profile); WaitForOnPersonalDataChanged(); profiles = personal_data_->GetProfiles(); ASSERT_EQ(1U, profiles.size()); - EXPECT_EQ(profiles[0]->GetRawInfo(EMAIL_ADDRESS), - base::ASCIIToUTF16("new@email.com")); + EXPECT_EQ(profiles[0]->GetRawInfo(EMAIL_ADDRESS), u"new@email.com"); - profile.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("newer@email.com")); + profile.SetRawInfo(EMAIL_ADDRESS, u"newer@email.com"); personal_data_->UpdateProfile(profile); - profile.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("newest@email.com")); + profile.SetRawInfo(EMAIL_ADDRESS, u"newest@email.com"); personal_data_->UpdateProfile(profile); WaitForOnPersonalDataChanged(); profiles = personal_data_->GetProfiles(); ASSERT_EQ(1U, profiles.size()); - EXPECT_EQ(profiles[0]->GetRawInfo(EMAIL_ADDRESS), - base::ASCIIToUTF16("newest@email.com")); + EXPECT_EQ(profiles[0]->GetRawInfo(EMAIL_ADDRESS), u"newest@email.com"); } // The changes should happen in the same order as requested. If the later change @@ -809,15 +808,14 @@ TEST_F(PersonalDataManagerTest, InconsistentValidationSequence) { // No validator, zero delay for validation. personal_data_->set_client_profile_validator_for_test(nullptr); - profile.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("new@email.com")); + profile.SetRawInfo(EMAIL_ADDRESS, u"new@email.com"); personal_data_->UpdateProfile(profile); WaitForOnPersonalDataChanged(); auto profiles = personal_data_->GetProfiles(); ASSERT_EQ(1U, profiles.size()); - EXPECT_EQ(profiles[0]->GetRawInfo(EMAIL_ADDRESS), - base::ASCIIToUTF16("new@email.com")); + EXPECT_EQ(profiles[0]->GetRawInfo(EMAIL_ADDRESS), u"new@email.com"); EXPECT_FALSE(profiles[0]->is_client_validity_states_updated()); } @@ -829,7 +827,7 @@ TEST_F(PersonalDataManagerTest, AddProfile_BasicInformation) { // Add a profile to the database. AutofillProfile profile(test::GetFullProfile()); - profile.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("j@s.com")); + profile.SetRawInfo(EMAIL_ADDRESS, u"j@s.com"); AddProfileToPersonalDataManager(profile); // Reload the database. @@ -850,117 +848,103 @@ TEST_F(PersonalDataManagerTest, AddProfile_BasicInformation) { TEST_F(PersonalDataManagerTest, AddProfile_CrazyCharacters) { std::vector<AutofillProfile> profiles; AutofillProfile profile1; - profile1.SetRawInfo( - NAME_FIRST, - base::WideToUTF16(L"\u0623\u0648\u0628\u0627\u0645\u0627 " - L"\u064a\u0639\u062a\u0630\u0631 " - L"\u0647\u0627\u062a\u0641\u064a\u0627 " - L"\u0644\u0645\u0648\u0638\u0641\u0629 " - L"\u0633\u0648\u062f\u0627\u0621 " - L"\u0627\u0633\u062a\u0642\u0627\u0644\u062a " - L"\u0628\u0633\u0628\u0628 " - L"\u062a\u0635\u0631\u064a\u062d\u0627\u062a " - L"\u0645\u062c\u062a\u0632\u0623\u0629")); - profile1.SetRawInfo(NAME_MIDDLE, base::WideToUTF16(L"BANK\xcBERF\xc4LLE")); + profile1.SetRawInfo(NAME_FIRST, + u"\u0623\u0648\u0628\u0627\u0645\u0627 " + u"\u064a\u0639\u062a\u0630\u0631 " + u"\u0647\u0627\u062a\u0641\u064a\u0627 " + u"\u0644\u0645\u0648\u0638\u0641\u0629 " + u"\u0633\u0648\u062f\u0627\u0621 " + u"\u0627\u0633\u062a\u0642\u0627\u0644\u062a " + u"\u0628\u0633\u0628\u0628 " + u"\u062a\u0635\u0631\u064a\u062d\u0627\u062a " + u"\u0645\u062c\u062a\u0632\u0623\u0629"); + profile1.SetRawInfo(NAME_MIDDLE, u"BANK\xcBERF\xc4LLE"); profile1.SetRawInfo(EMAIL_ADDRESS, - base::WideToUTF16(L"\uacbd\uc81c \ub274\uc2a4 " - L"\ub354\ubcf4\uae30@google.com")); - profile1.SetRawInfo( - ADDRESS_HOME_LINE1, - base::WideToUTF16(L"\uad6d\uc815\uc6d0\xb7\uac80\ucc30, " - L"\ub178\ubb34\ud604\uc815\ubd80 " - L"\ub300\ubd81\uc811\ucd09 \ub2f4\ub2f9 " - L"\uc778\uc0ac\ub4e4 \uc870\uc0ac")); - profile1.SetRawInfo( - ADDRESS_HOME_CITY, - base::WideToUTF16(L"\u653f\u5e9c\u4e0d\u6392\u9664\u7acb\u6cd5" - L"\u898f\u7ba1\u5c0e\u904a")); - profile1.SetRawInfo(ADDRESS_HOME_ZIP, base::WideToUTF16(L"YOHO_54676")); - profile1.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::WideToUTF16(L"861088828000")); - profile1.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), - base::WideToUTF16(L"India"), "en-US"); + u"\uacbd\uc81c \ub274\uc2a4 " + u"\ub354\ubcf4\uae30@google.com"); + profile1.SetRawInfo(ADDRESS_HOME_LINE1, + u"\uad6d\uc815\uc6d0\xb7\uac80\ucc30, " + u"\ub178\ubb34\ud604\uc815\ubd80 " + u"\ub300\ubd81\uc811\ucd09 \ub2f4\ub2f9 " + u"\uc778\uc0ac\ub4e4 \uc870\uc0ac"); + profile1.SetRawInfo(ADDRESS_HOME_CITY, + u"\u653f\u5e9c\u4e0d\u6392\u9664\u7acb\u6cd5" + u"\u898f\u7ba1\u5c0e\u904a"); + profile1.SetRawInfo(ADDRESS_HOME_ZIP, u"YOHO_54676"); + profile1.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"861088828000"); + profile1.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), u"India", "en-US"); profile1.FinalizeAfterImport(); profiles.push_back(profile1); AutofillProfile profile2; profile2.SetRawInfo(NAME_FIRST, - base::WideToUTF16(L"\u4e0a\u6d77\u5e02\u91d1\u5c71\u533a " - L"\u677e\u9690\u9547\u4ead\u67ab\u516c" - L"\u8def1915\u53f7")); - profile2.SetRawInfo(NAME_LAST, base::WideToUTF16(L"aguantó")); - profile2.SetRawInfo(ADDRESS_HOME_ZIP, base::WideToUTF16(L"HOME 94043")); + u"\u4e0a\u6d77\u5e02\u91d1\u5c71\u533a " + u"\u677e\u9690\u9547\u4ead\u67ab\u516c" + u"\u8def1915\u53f7"); + profile2.SetRawInfo(NAME_LAST, u"aguantó"); + profile2.SetRawInfo(ADDRESS_HOME_ZIP, u"HOME 94043"); profile2.FinalizeAfterImport(); profiles.push_back(profile2); AutofillProfile profile3; - profile3.SetRawInfo(EMAIL_ADDRESS, base::WideToUTF16(L"sue@example.com")); - profile3.SetRawInfo(COMPANY_NAME, base::WideToUTF16(L"Company X")); + profile3.SetRawInfo(EMAIL_ADDRESS, u"sue@example.com"); + profile3.SetRawInfo(COMPANY_NAME, u"Company X"); profile3.FinalizeAfterImport(); profiles.push_back(profile3); AutofillProfile profile4; - profile4.SetRawInfo(NAME_FIRST, base::WideToUTF16(L"Joe 3254")); - profile4.SetRawInfo(NAME_LAST, - base::WideToUTF16(L"\u8bb0\u8d262\u5e74\u591a")); - profile4.SetRawInfo( - ADDRESS_HOME_ZIP, - base::WideToUTF16(L"\uff08\u90ae\u7f16\uff1a201504\uff09")); - profile4.SetRawInfo(EMAIL_ADDRESS, - base::WideToUTF16(L"télévision@example.com")); - profile4.SetRawInfo( - COMPANY_NAME, - base::WideToUTF16(L"\u0907\u0932\u0947\u0915\u093f\u091f\u094d" - L"\u0930\u0928\u093f\u0915\u094d\u0938, " - L"\u0905\u092a\u094b\u0932\u094b " - L"\u091f\u093e\u092f\u0930\u094d\u0938 " - L"\u0906\u0926\u093f")); + profile4.SetRawInfo(NAME_FIRST, u"Joe 3254"); + profile4.SetRawInfo(NAME_LAST, u"\u8bb0\u8d262\u5e74\u591a"); + profile4.SetRawInfo(ADDRESS_HOME_ZIP, + u"\uff08\u90ae\u7f16\uff1a201504\uff09"); + profile4.SetRawInfo(EMAIL_ADDRESS, u"télévision@example.com"); + profile4.SetRawInfo(COMPANY_NAME, + u"\u0907\u0932\u0947\u0915\u093f\u091f\u094d" + u"\u0930\u0928\u093f\u0915\u094d\u0938, " + u"\u0905\u092a\u094b\u0932\u094b " + u"\u091f\u093e\u092f\u0930\u094d\u0938 " + u"\u0906\u0926\u093f"); profile4.FinalizeAfterImport(); profiles.push_back(profile4); AutofillProfile profile5; - profile5.SetRawInfo(NAME_FIRST, base::WideToUTF16(L"Larry")); - profile5.SetRawInfo( - NAME_LAST, base::WideToUTF16(L"\u0938\u094d\u091f\u093e\u0902\u092a " - L"\u0921\u094d\u092f\u0942\u091f\u0940")); - profile5.SetRawInfo(ADDRESS_HOME_ZIP, - base::WideToUTF16(L"111111111111110000GOOGLE")); - profile5.SetRawInfo(EMAIL_ADDRESS, base::WideToUTF16(L"page@000000.com")); - profile5.SetRawInfo(COMPANY_NAME, base::WideToUTF16(L"Google")); + profile5.SetRawInfo(NAME_FIRST, u"Larry"); + profile5.SetRawInfo(NAME_LAST, + u"\u0938\u094d\u091f\u093e\u0902\u092a " + u"\u0921\u094d\u092f\u0942\u091f\u0940"); + profile5.SetRawInfo(ADDRESS_HOME_ZIP, u"111111111111110000GOOGLE"); + profile5.SetRawInfo(EMAIL_ADDRESS, u"page@000000.com"); + profile5.SetRawInfo(COMPANY_NAME, u"Google"); profile5.FinalizeAfterImport(); profiles.push_back(profile5); AutofillProfile profile6; profile6.SetRawInfo(NAME_FIRST, - base::WideToUTF16(L"\u4e0a\u6d77\u5e02\u91d1\u5c71\u533a " - L"\u677e\u9690\u9547\u4ead\u67ab\u516c" - L"\u8def1915\u53f7")); - profile6.SetRawInfo( - NAME_LAST, - base::WideToUTF16(L"\u0646\u062c\u0627\u0645\u064a\u0646\u0627 " - L"\u062f\u0639\u0645\u0647\u0627 " - L"\u0644\u0644\u0631\u0626\u064a\u0633 " - L"\u0627\u0644\u0633\u0648\u062f\u0627\u0646" - L"\u064a \u0639\u0645\u0631 " - L"\u0627\u0644\u0628\u0634\u064a\u0631")); - profile6.SetRawInfo(ADDRESS_HOME_ZIP, base::WideToUTF16(L"HOME 94043")); + u"\u4e0a\u6d77\u5e02\u91d1\u5c71\u533a " + u"\u677e\u9690\u9547\u4ead\u67ab\u516c" + u"\u8def1915\u53f7"); + profile6.SetRawInfo(NAME_LAST, + u"\u0646\u062c\u0627\u0645\u064a\u0646\u0627 " + u"\u062f\u0639\u0645\u0647\u0627 " + u"\u0644\u0644\u0631\u0626\u064a\u0633 " + u"\u0627\u0644\u0633\u0648\u062f\u0627\u0646" + u"\u064a \u0639\u0645\u0631 " + u"\u0627\u0644\u0628\u0634\u064a\u0631"); + profile6.SetRawInfo(ADDRESS_HOME_ZIP, u"HOME 94043"); profile6.FinalizeAfterImport(); profiles.push_back(profile6); AutofillProfile profile7; - profile7.SetRawInfo(NAME_FIRST, - base::WideToUTF16(L"&$%$$$ TESTO *&*&^&^& MOKO")); - profile7.SetRawInfo(NAME_MIDDLE, base::WideToUTF16(L"WOHOOOO$$$$$$$$****")); - profile7.SetRawInfo(EMAIL_ADDRESS, base::WideToUTF16(L"yuvu@example.com")); - profile7.SetRawInfo(ADDRESS_HOME_LINE1, - base::WideToUTF16(L"34544, anderson ST.(120230)")); - profile7.SetRawInfo(ADDRESS_HOME_CITY, base::WideToUTF16(L"Sunnyvale")); - profile7.SetRawInfo(ADDRESS_HOME_STATE, base::WideToUTF16(L"CA")); - profile7.SetRawInfo(ADDRESS_HOME_ZIP, base::WideToUTF16(L"94086")); - profile7.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::WideToUTF16(L"15466784565")); - profile7.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), - base::WideToUTF16(L"United States"), "en-US"); + profile7.SetRawInfo(NAME_FIRST, u"&$%$$$ TESTO *&*&^&^& MOKO"); + profile7.SetRawInfo(NAME_MIDDLE, u"WOHOOOO$$$$$$$$****"); + profile7.SetRawInfo(EMAIL_ADDRESS, u"yuvu@example.com"); + profile7.SetRawInfo(ADDRESS_HOME_LINE1, u"34544, anderson ST.(120230)"); + profile7.SetRawInfo(ADDRESS_HOME_CITY, u"Sunnyvale"); + profile7.SetRawInfo(ADDRESS_HOME_STATE, u"CA"); + profile7.SetRawInfo(ADDRESS_HOME_ZIP, u"94086"); + profile7.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"15466784565"); + profile7.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), u"United States", + "en-US"); profile7.FinalizeAfterImport(); profiles.push_back(profile7); @@ -980,17 +964,15 @@ TEST_F(PersonalDataManagerTest, AddProfile_CrazyCharacters) { TEST_F(PersonalDataManagerTest, AddProfile_Invalid) { // First try profiles with invalid ZIP input. AutofillProfile without_invalid; - without_invalid.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("Will")); - without_invalid.SetRawInfo(ADDRESS_HOME_CITY, - base::ASCIIToUTF16("Sunnyvale")); - without_invalid.SetRawInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("CA")); - without_invalid.SetRawInfo(ADDRESS_HOME_ZIP, base::ASCIIToUTF16("my_zip")); - without_invalid.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), - base::ASCIIToUTF16("United States"), "en-US"); + without_invalid.SetRawInfo(NAME_FIRST, u"Will"); + without_invalid.SetRawInfo(ADDRESS_HOME_CITY, u"Sunnyvale"); + without_invalid.SetRawInfo(ADDRESS_HOME_STATE, u"CA"); + without_invalid.SetRawInfo(ADDRESS_HOME_ZIP, u"my_zip"); + without_invalid.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), u"United States", + "en-US"); AutofillProfile with_invalid = without_invalid; - with_invalid.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::ASCIIToUTF16("Invalid_Phone_Number")); + with_invalid.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"Invalid_Phone_Number"); std::vector<AutofillProfile> profiles; profiles.push_back(with_invalid); @@ -1040,7 +1022,7 @@ TEST_F(PersonalDataManagerTest, AddUpdateRemoveProfiles) { ExpectSameElements(profiles, personal_data_->GetProfiles()); // Update, remove, and add. - profile0.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("John")); + profile0.SetRawInfo(NAME_FIRST, u"John"); UpdateProfileOnPersonalDataManager(profile0); RemoveByGUIDFromPersonalDataManager(profile1.guid()); AddProfileToPersonalDataManager(profile2); @@ -1063,7 +1045,7 @@ TEST_F(PersonalDataManagerTest, AddUpdateRemoveCreditCards) { CreditCard credit_card0(base::GenerateGUID(), test::kEmptyOrigin); test::SetCreditCardInfo(&credit_card0, "John Dillinger", "4234567890123456" /* Visa */, "01", "2999", "1"); - credit_card0.SetNickname(base::ASCIIToUTF16("card zero")); + credit_card0.SetNickname(u"card zero"); CreditCard credit_card1(base::GenerateGUID(), test::kEmptyOrigin); test::SetCreditCardInfo(&credit_card1, "Bonnie Parker", @@ -1074,7 +1056,7 @@ TEST_F(PersonalDataManagerTest, AddUpdateRemoveCreditCards) { test::SetCreditCardInfo(&credit_card2, "Clyde Barrow", "378282246310005" /* American Express */, "04", "2999", "1"); - credit_card2.SetNickname(base::ASCIIToUTF16("card two")); + credit_card2.SetNickname(u"card two"); // Add two test credit cards to the database. personal_data_->AddCreditCard(credit_card0); @@ -1088,8 +1070,8 @@ TEST_F(PersonalDataManagerTest, AddUpdateRemoveCreditCards) { ExpectSameElements(cards, personal_data_->GetCreditCards()); // Update, remove, and add. - credit_card0.SetRawInfo(CREDIT_CARD_NAME_FULL, base::ASCIIToUTF16("Joe")); - credit_card0.SetNickname(base::ASCIIToUTF16("new card zero")); + credit_card0.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Joe"); + credit_card0.SetNickname(u"new card zero"); personal_data_->UpdateCreditCard(credit_card0); RemoveByGUIDFromPersonalDataManager(credit_card1.guid()); personal_data_->AddCreditCard(credit_card2); @@ -1223,51 +1205,47 @@ TEST_F(PersonalDataManagerTest, AddCreditCard_CrazyCharacters) { std::vector<CreditCard> cards; CreditCard card1; card1.SetRawInfo(CREDIT_CARD_NAME_FULL, - base::WideToUTF16(L"\u751f\u6d3b\u5f88\u6709\u89c4\u5f8b " - L"\u4ee5\u73a9\u4e3a\u4e3b")); - card1.SetRawInfo(CREDIT_CARD_NUMBER, base::WideToUTF16(L"6011111111111117")); - card1.SetRawInfo(CREDIT_CARD_EXP_MONTH, base::WideToUTF16(L"12")); - card1.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, base::WideToUTF16(L"2011")); + u"\u751f\u6d3b\u5f88\u6709\u89c4\u5f8b " + u"\u4ee5\u73a9\u4e3a\u4e3b"); + card1.SetRawInfo(CREDIT_CARD_NUMBER, u"6011111111111117"); + card1.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"12"); + card1.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2011"); cards.push_back(card1); CreditCard card2; - card2.SetRawInfo(CREDIT_CARD_NAME_FULL, base::WideToUTF16(L"John Williams")); - card2.SetRawInfo(CREDIT_CARD_NUMBER, base::WideToUTF16(L"WokoAwesome12345")); - card2.SetRawInfo(CREDIT_CARD_EXP_MONTH, base::WideToUTF16(L"10")); - card2.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, base::WideToUTF16(L"2015")); + card2.SetRawInfo(CREDIT_CARD_NAME_FULL, u"John Williams"); + card2.SetRawInfo(CREDIT_CARD_NUMBER, u"WokoAwesome12345"); + card2.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"10"); + card2.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2015"); cards.push_back(card2); CreditCard card3; - card3.SetRawInfo( - CREDIT_CARD_NAME_FULL, - base::WideToUTF16(L"\u0623\u062d\u0645\u062f\u064a " - L"\u0646\u062c\u0627\u062f " - L"\u0644\u0645\u062d\u0627\u0648\u0644\u0647 " - L"\u0627\u063a\u062a\u064a\u0627\u0644 " - L"\u0641\u064a \u0645\u062f\u064a\u0646\u0629 " - L"\u0647\u0645\u062f\u0627\u0646 ")); - card3.SetRawInfo( - CREDIT_CARD_NUMBER, - base::WideToUTF16(L"\u092a\u0941\u0928\u0930\u094d\u091c\u0940" - L"\u0935\u093f\u0924 \u0939\u094b\u0917\u093e " - L"\u0928\u093e\u0932\u0902\u0926\u093e")); - card3.SetRawInfo(CREDIT_CARD_EXP_MONTH, base::WideToUTF16(L"10")); - card3.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, base::WideToUTF16(L"2015")); + card3.SetRawInfo(CREDIT_CARD_NAME_FULL, + u"\u0623\u062d\u0645\u062f\u064a " + u"\u0646\u062c\u0627\u062f " + u"\u0644\u0645\u062d\u0627\u0648\u0644\u0647 " + u"\u0627\u063a\u062a\u064a\u0627\u0644 " + u"\u0641\u064a \u0645\u062f\u064a\u0646\u0629 " + u"\u0647\u0645\u062f\u0627\u0646 "); + card3.SetRawInfo(CREDIT_CARD_NUMBER, + u"\u092a\u0941\u0928\u0930\u094d\u091c\u0940" + u"\u0935\u093f\u0924 \u0939\u094b\u0917\u093e " + u"\u0928\u093e\u0932\u0902\u0926\u093e"); + card3.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"10"); + card3.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2015"); cards.push_back(card3); CreditCard card4; - card4.SetRawInfo( - CREDIT_CARD_NAME_FULL, - base::WideToUTF16(L"\u039d\u03ad\u03b5\u03c2 " - L"\u03c3\u03c5\u03b3\u03c7\u03c9\u03bd\u03b5" - L"\u03cd\u03c3\u03b5\u03b9\u03c2 " - L"\u03ba\u03b1\u03b9 " - L"\u03ba\u03b1\u03c4\u03b1\u03c1\u03b3\u03ae" - L"\u03c3\u03b5\u03b9\u03c2")); - card4.SetRawInfo(CREDIT_CARD_NUMBER, - base::WideToUTF16(L"00000000000000000000000")); - card4.SetRawInfo(CREDIT_CARD_EXP_MONTH, base::WideToUTF16(L"01")); - card4.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, base::WideToUTF16(L"2016")); + card4.SetRawInfo(CREDIT_CARD_NAME_FULL, + u"\u039d\u03ad\u03b5\u03c2 " + u"\u03c3\u03c5\u03b3\u03c7\u03c9\u03bd\u03b5" + u"\u03cd\u03c3\u03b5\u03b9\u03c2 " + u"\u03ba\u03b1\u03b9 " + u"\u03ba\u03b1\u03c4\u03b1\u03c1\u03b3\u03ae" + u"\u03c3\u03b5\u03b9\u03c2"); + card4.SetRawInfo(CREDIT_CARD_NUMBER, u"00000000000000000000000"); + card4.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"01"); + card4.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2016"); cards.push_back(card4); personal_data_->SetCreditCards(&cards); @@ -1283,7 +1261,7 @@ TEST_F(PersonalDataManagerTest, AddCreditCard_CrazyCharacters) { // Test invalid credit card numbers typed in settings UI should be saved as-is. TEST_F(PersonalDataManagerTest, AddCreditCard_Invalid) { CreditCard card; - card.SetRawInfo(CREDIT_CARD_NUMBER, base::ASCIIToUTF16("Not_0123-5Checked")); + card.SetRawInfo(CREDIT_CARD_NUMBER, u"Not_0123-5Checked"); std::vector<CreditCard> cards; cards.push_back(card); @@ -1344,8 +1322,8 @@ TEST_F(PersonalDataManagerTest, UpdateUnverifiedProfilesAndCreditCards) { EXPECT_EQ(original_credit_card.origin(), cards2[0]->origin()); // Try to update with data changed as well. - profile.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("John")); - credit_card.SetRawInfo(CREDIT_CARD_NAME_FULL, base::ASCIIToUTF16("Joe")); + profile.SetRawInfo(NAME_FIRST, u"John"); + credit_card.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Joe"); UpdateProfileOnPersonalDataManager(profile); personal_data_->UpdateCreditCard(credit_card); @@ -1520,17 +1498,17 @@ TEST_F(PersonalDataManagerTest, PopulateUniqueIDsOnLoad) { TEST_F(PersonalDataManagerTest, SetUniqueCreditCardLabels) { CreditCard credit_card0(base::GenerateGUID(), test::kEmptyOrigin); - credit_card0.SetRawInfo(CREDIT_CARD_NAME_FULL, base::ASCIIToUTF16("John")); + credit_card0.SetRawInfo(CREDIT_CARD_NAME_FULL, u"John"); CreditCard credit_card1(base::GenerateGUID(), test::kEmptyOrigin); - credit_card1.SetRawInfo(CREDIT_CARD_NAME_FULL, base::ASCIIToUTF16("Paul")); + credit_card1.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Paul"); CreditCard credit_card2(base::GenerateGUID(), test::kEmptyOrigin); - credit_card2.SetRawInfo(CREDIT_CARD_NAME_FULL, base::ASCIIToUTF16("Ringo")); + credit_card2.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Ringo"); CreditCard credit_card3(base::GenerateGUID(), test::kEmptyOrigin); - credit_card3.SetRawInfo(CREDIT_CARD_NAME_FULL, base::ASCIIToUTF16("Other")); + credit_card3.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Other"); CreditCard credit_card4(base::GenerateGUID(), test::kEmptyOrigin); - credit_card4.SetRawInfo(CREDIT_CARD_NAME_FULL, base::ASCIIToUTF16("Ozzy")); + credit_card4.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Ozzy"); CreditCard credit_card5(base::GenerateGUID(), test::kEmptyOrigin); - credit_card5.SetRawInfo(CREDIT_CARD_NAME_FULL, base::ASCIIToUTF16("Dio")); + credit_card5.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Dio"); // Add the test credit cards to the database. personal_data_->AddCreditCard(credit_card0); @@ -1637,7 +1615,7 @@ TEST_F(PersonalDataManagerTest, Refresh) { ASSERT_EQ(1U, results.size()); EXPECT_EQ(profile0, *results[0]); - profile0.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("Mar")); + profile0.SetRawInfo(NAME_FIRST, u"Mar"); profile_database_service_->UpdateAutofillProfile(profile0); personal_data_->Refresh(); @@ -1666,8 +1644,7 @@ TEST_F(PersonalDataManagerTest, SaveImportedProfileWithVerifiedData) { AutofillProfile new_verified_profile = profile; new_verified_profile.set_guid(base::GenerateGUID()); new_verified_profile.set_origin(kSettingsOrigin); - new_verified_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::ASCIIToUTF16("1 234 567-8910")); + new_verified_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"1 234 567-8910"); EXPECT_TRUE(new_verified_profile.IsVerified()); SaveImportedProfileToPersonalDataManager(new_verified_profile); @@ -1679,10 +1656,9 @@ TEST_F(PersonalDataManagerTest, SaveImportedProfileWithVerifiedData) { // The full name was missing in |profile| and was formatted from its // components. expected.SetRawInfoWithVerificationStatus( - NAME_FULL, base::ASCIIToUTF16("Marion Mitchell Morrison"), + NAME_FULL, u"Marion Mitchell Morrison", structured_address::VerificationStatus::kFormatted); - expected.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - base::ASCIIToUTF16("+1 234-567-8910")); + expected.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"+1 234-567-8910"); EXPECT_EQ(0, expected.Compare(*results[0])) << "result = {" << *results[0] << "} | expected = {" << expected << "}"; } @@ -1705,8 +1681,7 @@ TEST_F(PersonalDataManagerTest, OnAcceptedLocalCreditCardSaveWithVerifiedData) { CreditCard new_verified_card = credit_card; new_verified_card.set_guid(base::GenerateGUID()); - new_verified_card.SetRawInfo(CREDIT_CARD_NAME_FULL, - base::ASCIIToUTF16("B. Small")); + new_verified_card.SetRawInfo(CREDIT_CARD_NAME_FULL, u"B. Small"); EXPECT_TRUE(new_verified_card.IsVerified()); personal_data_->OnAcceptedLocalCreditCardSave(new_verified_card); @@ -1716,8 +1691,7 @@ TEST_F(PersonalDataManagerTest, OnAcceptedLocalCreditCardSaveWithVerifiedData) { // Expect that the saved credit card is updated. const std::vector<CreditCard*>& results = personal_data_->GetCreditCards(); ASSERT_EQ(1U, results.size()); - EXPECT_EQ(base::ASCIIToUTF16("B. Small"), - results[0]->GetRawInfo(CREDIT_CARD_NAME_FULL)); + EXPECT_EQ(u"B. Small", results[0]->GetRawInfo(CREDIT_CARD_NAME_FULL)); } TEST_F(PersonalDataManagerTest, GetNonEmptyTypes) { @@ -1926,33 +1900,31 @@ TEST_F(PersonalDataManagerTest, IncognitoReadOnly) { EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); // Saving or creating profiles from imported profiles shouldn't work. - steve_jobs.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("Steve")); + steve_jobs.SetRawInfo(NAME_FIRST, u"Steve"); personal_data_->SaveImportedProfile(steve_jobs); - bill_gates.SetRawInfo(CREDIT_CARD_NAME_FULL, - base::ASCIIToUTF16("Bill Gates")); + bill_gates.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Bill Gates"); personal_data_->OnAcceptedLocalCreditCardSave(bill_gates); ResetPersonalDataManager(USER_MODE_INCOGNITO); - EXPECT_EQ(base::ASCIIToUTF16("Steven"), + EXPECT_EQ(u"Steven", personal_data_->GetProfiles()[0]->GetRawInfo(NAME_FIRST)); EXPECT_EQ( - base::ASCIIToUTF16("William H. Gates"), + u"William H. Gates", personal_data_->GetCreditCards()[0]->GetRawInfo(CREDIT_CARD_NAME_FULL)); // Updating existing profiles shouldn't work. - steve_jobs.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("Steve")); + steve_jobs.SetRawInfo(NAME_FIRST, u"Steve"); personal_data_->UpdateProfile(steve_jobs); - bill_gates.SetRawInfo(CREDIT_CARD_NAME_FULL, - base::ASCIIToUTF16("Bill Gates")); + bill_gates.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Bill Gates"); personal_data_->UpdateCreditCard(bill_gates); ResetPersonalDataManager(USER_MODE_INCOGNITO); - EXPECT_EQ(base::ASCIIToUTF16("Steven"), + EXPECT_EQ(u"Steven", personal_data_->GetProfiles()[0]->GetRawInfo(NAME_FIRST)); EXPECT_EQ( - base::ASCIIToUTF16("William H. Gates"), + u"William H. Gates", personal_data_->GetCreditCards()[0]->GetRawInfo(CREDIT_CARD_NAME_FULL)); // Removing shouldn't work. @@ -2127,10 +2099,10 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions) { ResetPersonalDataManager(USER_MODE_NORMAL); std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( - AutofillType(ADDRESS_HOME_STREET_ADDRESS), base::ASCIIToUTF16("123"), - false, std::vector<ServerFieldType>()); + AutofillType(ADDRESS_HOME_STREET_ADDRESS), u"123", false, + std::vector<ServerFieldType>()); ASSERT_FALSE(suggestions.empty()); - EXPECT_EQ(base::ASCIIToUTF16("123 Zoo St., Second Line, Third line, unit 5"), + EXPECT_EQ(u"123 Zoo St., Second Line, Third line, unit 5", suggestions[0].value); } @@ -2149,10 +2121,10 @@ TEST_F(PersonalDataManagerTest, ResetPersonalDataManager(USER_MODE_NORMAL); std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( - AutofillType(PHONE_HOME_WHOLE_NUMBER), base::ASCIIToUTF16("234"), false, + AutofillType(PHONE_HOME_WHOLE_NUMBER), u"234", false, std::vector<ServerFieldType>()); ASSERT_FALSE(suggestions.empty()); - EXPECT_EQ(base::ASCIIToUTF16("12345678910"), suggestions[0].value); + EXPECT_EQ(u"12345678910", suggestions[0].value); } #if !defined(OS_ANDROID) && !defined(OS_IOS) @@ -2171,10 +2143,10 @@ TEST_F(PersonalDataManagerTest, ResetPersonalDataManager(USER_MODE_NORMAL); std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( - AutofillType(PHONE_HOME_WHOLE_NUMBER), base::ASCIIToUTF16("234"), false, + AutofillType(PHONE_HOME_WHOLE_NUMBER), u"234", false, std::vector<ServerFieldType>()); ASSERT_FALSE(suggestions.empty()); - EXPECT_EQ(base::ASCIIToUTF16("(234) 567-8910"), suggestions[0].value); + EXPECT_EQ(u"(234) 567-8910", suggestions[0].value); } #endif // !defined(OS_ANDROID) && !defined(OS_IOS) @@ -2188,17 +2160,17 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_HideSubsets) { // Dupe profile, except different in email address (irrelevant for this form). AutofillProfile profile1 = profile; profile1.set_guid(base::GenerateGUID()); - profile1.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("spam_me@example.com")); + profile1.SetRawInfo(EMAIL_ADDRESS, u"spam_me@example.com"); // Dupe profile, except different in address state. AutofillProfile profile2 = profile; profile2.set_guid(base::GenerateGUID()); - profile2.SetRawInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("TX")); + profile2.SetRawInfo(ADDRESS_HOME_STATE, u"TX"); // Subset profile. AutofillProfile profile3 = profile; profile3.set_guid(base::GenerateGUID()); - profile3.SetRawInfo(ADDRESS_HOME_STATE, base::string16()); + profile3.SetRawInfo(ADDRESS_HOME_STATE, std::u16string()); // For easier results verification, make sure |profile| is suggested first. profile.set_use_count(5); @@ -2213,11 +2185,10 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_HideSubsets) { types.push_back(ADDRESS_HOME_CITY); types.push_back(ADDRESS_HOME_STATE); std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( - AutofillType(ADDRESS_HOME_STREET_ADDRESS), base::ASCIIToUTF16("123"), - false, types); + AutofillType(ADDRESS_HOME_STREET_ADDRESS), u"123", false, types); ASSERT_EQ(2U, suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("Hollywood, CA"), suggestions[0].label); - EXPECT_EQ(base::ASCIIToUTF16("Hollywood, TX"), suggestions[1].label); + EXPECT_EQ(u"Hollywood, CA", suggestions[0].label); + EXPECT_EQ(u"Hollywood, TX", suggestions[1].label); } TEST_F(PersonalDataManagerTest, GetProfileSuggestions_SuggestionsLimit) { @@ -2237,8 +2208,7 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_SuggestionsLimit) { ResetPersonalDataManager(USER_MODE_NORMAL); std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( - AutofillType(NAME_FIRST), base::ASCIIToUTF16("Ma"), false, - std::vector<ServerFieldType>()); + AutofillType(NAME_FIRST), u"Ma", false, std::vector<ServerFieldType>()); ASSERT_EQ(2 * suggestion_selection::kMaxUniqueSuggestionsCount, personal_data_->GetProfiles().size()); @@ -2282,13 +2252,12 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_ProfilesLimit) { ResetPersonalDataManager(USER_MODE_NORMAL); std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( - AutofillType(NAME_FIRST), base::ASCIIToUTF16("Ma"), false, - std::vector<ServerFieldType>()); + AutofillType(NAME_FIRST), u"Ma", false, std::vector<ServerFieldType>()); ASSERT_EQ(suggestion_selection::kMaxSuggestedProfilesCount + 1, personal_data_->GetProfiles().size()); ASSERT_EQ(1U, suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("Marion"), suggestions[0].value); + EXPECT_EQ(u"Marion", suggestions[0].value); } // Tests that GetProfileSuggestions orders its suggestions based on the frecency @@ -2325,12 +2294,11 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_Ranking) { ResetPersonalDataManager(USER_MODE_NORMAL); std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( - AutofillType(NAME_FIRST), base::ASCIIToUTF16("Ma"), false, - std::vector<ServerFieldType>()); + AutofillType(NAME_FIRST), u"Ma", false, std::vector<ServerFieldType>()); ASSERT_EQ(3U, suggestions.size()); - EXPECT_EQ(suggestions[0].value, base::ASCIIToUTF16("Marion1")); - EXPECT_EQ(suggestions[1].value, base::ASCIIToUTF16("Marion2")); - EXPECT_EQ(suggestions[2].value, base::ASCIIToUTF16("Marion3")); + EXPECT_EQ(suggestions[0].value, u"Marion1"); + EXPECT_EQ(suggestions[1].value, u"Marion2"); + EXPECT_EQ(suggestions[2].value, u"Marion3"); } // Tests that GetProfileSuggestions returns all profiles suggestions. @@ -2361,7 +2329,7 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_NumberOfSuggestions) { // Verify that all the profiles are suggested. std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( - AutofillType(NAME_FIRST), base::string16(), false, + AutofillType(NAME_FIRST), std::u16string(), false, std::vector<ServerFieldType>()); EXPECT_EQ(3U, suggestions.size()); } @@ -2392,7 +2360,7 @@ TEST_F(PersonalDataManagerTest, // Query with empty string only returns profile2. { std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( - AutofillType(ADDRESS_HOME_STREET_ADDRESS), base::string16(), false, + AutofillType(ADDRESS_HOME_STREET_ADDRESS), std::u16string(), false, std::vector<ServerFieldType>()); EXPECT_EQ(1U, suggestions.size()); } @@ -2400,31 +2368,29 @@ TEST_F(PersonalDataManagerTest, // Query with non-alpha-numeric string only returns profile2. { std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( - AutofillType(ADDRESS_HOME_STREET_ADDRESS), base::ASCIIToUTF16("--"), - false, std::vector<ServerFieldType>()); + AutofillType(ADDRESS_HOME_STREET_ADDRESS), u"--", false, + std::vector<ServerFieldType>()); EXPECT_EQ(1U, suggestions.size()); } // Query with prefix for profile1 returns profile1. { std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( - AutofillType(ADDRESS_HOME_STREET_ADDRESS), base::ASCIIToUTF16("123"), - false, std::vector<ServerFieldType>()); + AutofillType(ADDRESS_HOME_STREET_ADDRESS), u"123", false, + std::vector<ServerFieldType>()); ASSERT_EQ(1U, suggestions.size()); - EXPECT_EQ( - base::ASCIIToUTF16("123 Zoo St., Second Line, Third line, unit 5"), - suggestions[0].value); + EXPECT_EQ(u"123 Zoo St., Second Line, Third line, unit 5", + suggestions[0].value); } // Query with prefix for profile2 returns profile2. { std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( - AutofillType(ADDRESS_HOME_STREET_ADDRESS), base::ASCIIToUTF16("456"), - false, std::vector<ServerFieldType>()); + AutofillType(ADDRESS_HOME_STREET_ADDRESS), u"456", false, + std::vector<ServerFieldType>()); EXPECT_EQ(1U, suggestions.size()); - EXPECT_EQ( - base::ASCIIToUTF16("456 Zoo St., Second Line, Third line, unit 5"), - suggestions[0].value); + EXPECT_EQ(u"456 Zoo St., Second Line, Third line, unit 5", + suggestions[0].value); } } @@ -2460,7 +2426,7 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_Validity) { /*disabled_features=*/{}); std::vector<Suggestion> email_suggestions = personal_data_->GetProfileSuggestions(AutofillType(EMAIL_ADDRESS), - base::string16(), false, + std::u16string(), false, std::vector<ServerFieldType>()); for (auto* profile : profiles) { @@ -2469,16 +2435,15 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_Validity) { ASSERT_TRUE(profile->IsValidByServer()); } ASSERT_EQ(1U, email_suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("alice@wonderland.ca"), - email_suggestions[0].value); + EXPECT_EQ(u"alice@wonderland.ca", email_suggestions[0].value); std::vector<Suggestion> name_suggestions = personal_data_->GetProfileSuggestions(AutofillType(NAME_FIRST), - base::string16(), false, + std::u16string(), false, std::vector<ServerFieldType>()); ASSERT_EQ(2U, name_suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("Alice"), name_suggestions[0].value); - EXPECT_EQ(base::ASCIIToUTF16("Marion1"), name_suggestions[1].value); + EXPECT_EQ(u"Alice", name_suggestions[0].value); + EXPECT_EQ(u"Marion1", name_suggestions[1].value); } // Set the validity state of ADDRESS_HOME_STATE to INVALID on the prefs. @@ -2510,7 +2475,7 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_Validity) { std::vector<Suggestion> email_suggestions = personal_data_->GetProfileSuggestions(AutofillType(EMAIL_ADDRESS), - base::string16(), false, + std::u16string(), false, std::vector<ServerFieldType>()); for (auto* profile : profiles) { @@ -2520,16 +2485,15 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_Validity) { profile->IsValidByServer()); } ASSERT_EQ(1U, email_suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("alice@wonderland.ca"), - email_suggestions[0].value); + EXPECT_EQ(u"alice@wonderland.ca", email_suggestions[0].value); std::vector<Suggestion> name_suggestions = personal_data_->GetProfileSuggestions(AutofillType(NAME_FIRST), - base::string16(), false, + std::u16string(), false, std::vector<ServerFieldType>()); ASSERT_EQ(2U, name_suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("Alice"), name_suggestions[0].value); - EXPECT_EQ(base::ASCIIToUTF16("Marion1"), name_suggestions[1].value); + EXPECT_EQ(u"Alice", name_suggestions[0].value); + EXPECT_EQ(u"Marion1", name_suggestions[1].value); } // Invalid based on client, and server. Relying only on the client source. { @@ -2539,7 +2503,7 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_Validity) { /*disabled_features=*/{features::kAutofillProfileServerValidation}); std::vector<Suggestion> email_suggestions = personal_data_->GetProfileSuggestions(AutofillType(EMAIL_ADDRESS), - base::string16(), false, + std::u16string(), false, std::vector<ServerFieldType>()); for (auto* profile : profiles) { @@ -2549,16 +2513,15 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_Validity) { profile->IsValidByServer()); } ASSERT_EQ(1U, email_suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("alice@wonderland.ca"), - email_suggestions[0].value); + EXPECT_EQ(u"alice@wonderland.ca", email_suggestions[0].value); std::vector<Suggestion> name_suggestions = personal_data_->GetProfileSuggestions(AutofillType(NAME_FIRST), - base::string16(), false, + std::u16string(), false, std::vector<ServerFieldType>()); ASSERT_EQ(2U, name_suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("Alice"), name_suggestions[0].value); - EXPECT_EQ(base::ASCIIToUTF16("Marion1"), name_suggestions[1].value); + EXPECT_EQ(u"Alice", name_suggestions[0].value); + EXPECT_EQ(u"Marion1", name_suggestions[1].value); } // Invalid based on client, and server. Relying on server as a validity // source. @@ -2569,7 +2532,7 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_Validity) { /*disabled_features=*/{features::kAutofillProfileClientValidation}); std::vector<Suggestion> email_suggestions = personal_data_->GetProfileSuggestions(AutofillType(EMAIL_ADDRESS), - base::string16(), false, + std::u16string(), false, std::vector<ServerFieldType>()); for (auto* profile : profiles) { @@ -2579,16 +2542,15 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_Validity) { profile->IsValidByServer()); } ASSERT_EQ(1U, email_suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("alice@wonderland.ca"), - email_suggestions[0].value); + EXPECT_EQ(u"alice@wonderland.ca", email_suggestions[0].value); std::vector<Suggestion> name_suggestions = personal_data_->GetProfileSuggestions(AutofillType(NAME_FIRST), - base::string16(), false, + std::u16string(), false, std::vector<ServerFieldType>()); ASSERT_EQ(2U, name_suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("Alice"), name_suggestions[0].value); - EXPECT_EQ(base::ASCIIToUTF16("Marion1"), name_suggestions[1].value); + EXPECT_EQ(u"Alice", name_suggestions[0].value); + EXPECT_EQ(u"Marion1", name_suggestions[1].value); } } @@ -2618,7 +2580,7 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_ProfileAutofillDisabled) { "77401", "US", ""); // Wallet only provides a full name, so the above first and last names // will be ignored when the profile is written to the DB. - server_profiles.back().SetRawInfo(NAME_FULL, base::ASCIIToUTF16("John Doe")); + server_profiles.back().SetRawInfo(NAME_FULL, u"John Doe"); SetServerProfiles(server_profiles); // Disable Profile autofill. @@ -2632,8 +2594,8 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_ProfileAutofillDisabled) { EXPECT_EQ(0U, personal_data_->GetProfilesToSuggest().size()); std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( - AutofillType(ADDRESS_HOME_STREET_ADDRESS), base::ASCIIToUTF16("123"), - false, std::vector<ServerFieldType>()); + AutofillType(ADDRESS_HOME_STREET_ADDRESS), u"123", false, + std::vector<ServerFieldType>()); ASSERT_EQ(0U, suggestions.size()); } @@ -2664,7 +2626,7 @@ TEST_F(PersonalDataManagerTest, "77401", "US", ""); // Wallet only provides a full name, so the above first and last names // will be ignored when the profile is written to the DB. - server_profiles.back().SetRawInfo(NAME_FULL, base::ASCIIToUTF16("John Doe")); + server_profiles.back().SetRawInfo(NAME_FULL, u"John Doe"); SetServerProfiles(server_profiles); personal_data_->Refresh(); @@ -2684,8 +2646,8 @@ TEST_F(PersonalDataManagerTest, EXPECT_EQ(0U, personal_data_->GetProfilesToSuggest().size()); std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( - AutofillType(ADDRESS_HOME_STREET_ADDRESS), base::ASCIIToUTF16("123"), - false, std::vector<ServerFieldType>()); + AutofillType(ADDRESS_HOME_STREET_ADDRESS), u"123", false, + std::vector<ServerFieldType>()); ASSERT_EQ(0U, suggestions.size()); } @@ -2723,11 +2685,10 @@ TEST_F(PersonalDataManagerTest, base::HistogramTester histogram_tester; EXPECT_THAT( personal_data_->GetProfileSuggestions( - AutofillType(NAME_FIRST), base::string16(), false, + AutofillType(NAME_FIRST), std::u16string(), false, std::vector<ServerFieldType>{NAME_FIRST, NAME_LAST, EMAIL_ADDRESS, PHONE_HOME_WHOLE_NUMBER}), - ElementsAre( - testing::Field(&Suggestion::value, base::ASCIIToUTF16("Hoa")))); + ElementsAre(testing::Field(&Suggestion::value, u"Hoa"))); histogram_tester.ExpectUniqueSample( "Autofill.ProfileSuggestionsMadeWithFormatter", true, 1); } @@ -2747,14 +2708,13 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_ForContactForm) { EXPECT_THAT( personal_data_->GetProfileSuggestions( - AutofillType(NAME_FIRST), base::string16(), false, + AutofillType(NAME_FIRST), std::u16string(), false, std::vector<ServerFieldType>{NAME_FIRST, NAME_LAST, EMAIL_ADDRESS, PHONE_HOME_WHOLE_NUMBER}), ElementsAre(AllOf( testing::Field( &Suggestion::label, - ConstructLabelLine({base::ASCIIToUTF16("(978) 674-4120"), - base::ASCIIToUTF16("hoa.pham@comcast.net")})), + ConstructLabelLine({u"(978) 674-4120", u"hoa.pham@comcast.net"})), testing::Field(&Suggestion::icon, "")))); } #endif // #if !defined(OS_ANDROID) && !defined(OS_IOS) @@ -2771,16 +2731,15 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_AddressForm) { scoped_features.InitAndEnableFeature( features::kAutofillUseImprovedLabelDisambiguation); - EXPECT_THAT(personal_data_->GetProfileSuggestions( - AutofillType(NAME_FULL), base::string16(), false, - std::vector<ServerFieldType>{ - NAME_FULL, ADDRESS_HOME_STREET_ADDRESS, ADDRESS_HOME_CITY, - ADDRESS_HOME_STATE, ADDRESS_HOME_ZIP}), - ElementsAre(AllOf( - testing::Field( - &Suggestion::label, - base::ASCIIToUTF16("401 Merrimack St, Lowell, MA 01852")), - testing::Field(&Suggestion::icon, "")))); + EXPECT_THAT( + personal_data_->GetProfileSuggestions( + AutofillType(NAME_FULL), std::u16string(), false, + std::vector<ServerFieldType>{NAME_FULL, ADDRESS_HOME_STREET_ADDRESS, + ADDRESS_HOME_CITY, ADDRESS_HOME_STATE, + ADDRESS_HOME_ZIP}), + ElementsAre(AllOf(testing::Field(&Suggestion::label, + u"401 Merrimack St, Lowell, MA 01852"), + testing::Field(&Suggestion::icon, "")))); } #endif // #if !defined(OS_ANDROID) && !defined(OS_IOS) @@ -2798,14 +2757,13 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_AddressPhoneForm) { EXPECT_THAT( personal_data_->GetProfileSuggestions( - AutofillType(NAME_FULL), base::string16(), false, + AutofillType(NAME_FULL), std::u16string(), false, std::vector<ServerFieldType>{NAME_FULL, ADDRESS_HOME_STREET_ADDRESS, PHONE_HOME_WHOLE_NUMBER}), ElementsAre(AllOf( testing::Field( &Suggestion::label, - ConstructLabelLine({base::ASCIIToUTF16("(978) 674-4120"), - base::ASCIIToUTF16("401 Merrimack St")})), + ConstructLabelLine({u"(978) 674-4120", u"401 Merrimack St"})), testing::Field(&Suggestion::icon, "")))); } #endif // #if !defined(OS_ANDROID) && !defined(OS_IOS) @@ -2822,17 +2780,15 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_AddressEmailForm) { scoped_features.InitAndEnableFeature( features::kAutofillUseImprovedLabelDisambiguation); - EXPECT_THAT( - personal_data_->GetProfileSuggestions( - AutofillType(NAME_FULL), base::string16(), false, - std::vector<ServerFieldType>{NAME_FULL, ADDRESS_HOME_STREET_ADDRESS, - EMAIL_ADDRESS}), - ElementsAre(AllOf( - testing::Field( - &Suggestion::label, - ConstructLabelLine({base::ASCIIToUTF16("401 Merrimack St"), - base::ASCIIToUTF16("hoa.pham@comcast.net")})), - testing::Field(&Suggestion::icon, "")))); + EXPECT_THAT(personal_data_->GetProfileSuggestions( + AutofillType(NAME_FULL), std::u16string(), false, + std::vector<ServerFieldType>{ + NAME_FULL, ADDRESS_HOME_STREET_ADDRESS, EMAIL_ADDRESS}), + ElementsAre(AllOf( + testing::Field(&Suggestion::label, + ConstructLabelLine({u"401 Merrimack St", + u"hoa.pham@comcast.net"})), + testing::Field(&Suggestion::icon, "")))); } #endif // #if !defined(OS_ANDROID) && !defined(OS_IOS) @@ -2850,7 +2806,7 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_FormWithOneProfile) { EXPECT_THAT( personal_data_->GetProfileSuggestions( - AutofillType(NAME_FULL), base::string16(), false, + AutofillType(NAME_FULL), std::u16string(), false, std::vector<ServerFieldType>{NAME_FULL, ADDRESS_HOME_STREET_ADDRESS, EMAIL_ADDRESS, PHONE_HOME_WHOLE_NUMBER}), ElementsAre(AllOf(testing::Field(&Suggestion::label, @@ -2894,22 +2850,19 @@ TEST_F(PersonalDataManagerTest, EXPECT_THAT( personal_data_->GetProfileSuggestions( - AutofillType(NAME_FULL), base::string16(), false, + AutofillType(NAME_FULL), std::u16string(), false, std::vector<ServerFieldType>{NAME_FULL, ADDRESS_HOME_STREET_ADDRESS, EMAIL_ADDRESS, PHONE_HOME_WHOLE_NUMBER}), ElementsAre( - AllOf( - testing::Field(&Suggestion::label, - ConstructLabelLine( - {base::ASCIIToUTF16("401 Merrimack St"), - base::ASCIIToUTF16("(978) 674-4120"), - base::ASCIIToUTF16("hoa.pham@comcast.net")})), - testing::Field(&Suggestion::icon, "")), AllOf(testing::Field( &Suggestion::label, - ConstructLabelLine({base::ASCIIToUTF16("216 Broadway St"), - base::ASCIIToUTF16("(978) 452-3366"), - base::ASCIIToUTF16("hp@aol.com")})), + ConstructLabelLine({u"401 Merrimack St", u"(978) 674-4120", + u"hoa.pham@comcast.net"})), + testing::Field(&Suggestion::icon, "")), + AllOf(testing::Field( + &Suggestion::label, + ConstructLabelLine({u"216 Broadway St", u"(978) 452-3366", + u"hp@aol.com"})), testing::Field(&Suggestion::icon, "")))); } #endif // #if !defined(OS_ANDROID) && !defined(OS_IOS) @@ -2948,28 +2901,24 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_MobileShowOne) { // Tests a form with name, email address, and phone number fields. EXPECT_THAT( personal_data_->GetProfileSuggestions( - AutofillType(EMAIL_ADDRESS), base::string16(), false, + AutofillType(EMAIL_ADDRESS), std::u16string(), false, std::vector<ServerFieldType>{NAME_FIRST, NAME_LAST, EMAIL_ADDRESS, PHONE_HOME_WHOLE_NUMBER}), - ElementsAre(AllOf(testing::Field(&Suggestion::label, - base::ASCIIToUTF16("(978) 674-4120")), + ElementsAre(AllOf(testing::Field(&Suggestion::label, u"(978) 674-4120"), testing::Field(&Suggestion::icon, "")), - AllOf(testing::Field(&Suggestion::label, - base::ASCIIToUTF16("(617) 268-6862")), + AllOf(testing::Field(&Suggestion::label, u"(617) 268-6862"), testing::Field(&Suggestion::icon, "")))); // Tests a form with name, address, phone number, and email address fields. EXPECT_THAT( personal_data_->GetProfileSuggestions( - AutofillType(EMAIL_ADDRESS), base::string16(), false, + AutofillType(EMAIL_ADDRESS), std::u16string(), false, std::vector<ServerFieldType>{NAME_FULL, ADDRESS_HOME_STREET_ADDRESS, ADDRESS_HOME_CITY, EMAIL_ADDRESS, PHONE_HOME_WHOLE_NUMBER}), - ElementsAre(AllOf(testing::Field(&Suggestion::label, - base::ASCIIToUTF16("401 Merrimack St")), + ElementsAre(AllOf(testing::Field(&Suggestion::label, u"401 Merrimack St"), testing::Field(&Suggestion::icon, "")), - AllOf(testing::Field(&Suggestion::label, - base::ASCIIToUTF16("11 Elkins St")), + AllOf(testing::Field(&Suggestion::label, u"11 Elkins St"), testing::Field(&Suggestion::icon, "")))); } #endif // if defined(OS_ANDROID) || defined(OS_IOS) @@ -3008,41 +2957,34 @@ TEST_F(PersonalDataManagerTest, GetProfileSuggestions_MobileShowAll) { // Tests a form with name, email address, and phone number fields. EXPECT_THAT( personal_data_->GetProfileSuggestions( - AutofillType(EMAIL_ADDRESS), base::string16(), false, + AutofillType(EMAIL_ADDRESS), std::u16string(), false, std::vector<ServerFieldType>{NAME_FIRST, NAME_LAST, EMAIL_ADDRESS, PHONE_HOME_WHOLE_NUMBER}), - ElementsAre( - AllOf(testing::Field(&Suggestion::label, - ConstructMobileLabelLine( - {base::ASCIIToUTF16("Hoa"), - base::ASCIIToUTF16("(978) 674-4120")})), - testing::Field(&Suggestion::icon, "")), - AllOf(testing::Field(&Suggestion::label, - ConstructMobileLabelLine( - {base::UTF8ToUTF16("María"), - base::ASCIIToUTF16("(617) 268-6862")})), - testing::Field(&Suggestion::icon, "")))); + ElementsAre(AllOf(testing::Field(&Suggestion::label, + ConstructMobileLabelLine( + {u"Hoa", u"(978) 674-4120"})), + testing::Field(&Suggestion::icon, "")), + AllOf(testing::Field(&Suggestion::label, + ConstructMobileLabelLine( + {u"María", u"(617) 268-6862"})), + testing::Field(&Suggestion::icon, "")))); // Tests a form with name, address, phone number, and email address fields. - EXPECT_THAT( - personal_data_->GetProfileSuggestions( - AutofillType(EMAIL_ADDRESS), base::string16(), false, - std::vector<ServerFieldType>{NAME_FULL, ADDRESS_HOME_STREET_ADDRESS, - ADDRESS_HOME_CITY, EMAIL_ADDRESS, - PHONE_HOME_WHOLE_NUMBER}), - ElementsAre( - AllOf(testing::Field(&Suggestion::label, - ConstructMobileLabelLine( - {base::ASCIIToUTF16("Hoa"), - base::ASCIIToUTF16("401 Merrimack St"), - base::ASCIIToUTF16("(978) 674-4120")})), - testing::Field(&Suggestion::icon, "")), - AllOf(testing::Field(&Suggestion::label, - ConstructMobileLabelLine( - {base::UTF8ToUTF16("María"), - base::ASCIIToUTF16("11 Elkins St"), - base::ASCIIToUTF16("(617) 268-6862")})), - testing::Field(&Suggestion::icon, "")))); + EXPECT_THAT(personal_data_->GetProfileSuggestions( + AutofillType(EMAIL_ADDRESS), std::u16string(), false, + std::vector<ServerFieldType>{ + NAME_FULL, ADDRESS_HOME_STREET_ADDRESS, ADDRESS_HOME_CITY, + EMAIL_ADDRESS, PHONE_HOME_WHOLE_NUMBER}), + ElementsAre(AllOf(testing::Field(&Suggestion::label, + ConstructMobileLabelLine( + {u"Hoa", u"401 Merrimack St", + u"(978) 674-4120"})), + testing::Field(&Suggestion::icon, "")), + AllOf(testing::Field(&Suggestion::label, + ConstructMobileLabelLine( + {u"María", u"11 Elkins St", + u"(617) 268-6862"})), + testing::Field(&Suggestion::icon, "")))); } #endif // if defined(OS_ANDROID) || defined(OS_IOS) @@ -3062,7 +3004,7 @@ TEST_F(PersonalDataManagerTest, IsKnownCard_MatchesMaskedServerCard) { EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); CreditCard cardToCompare; - cardToCompare.SetNumber(base::ASCIIToUTF16("4234 5678 9012 2110") /* Visa */); + cardToCompare.SetNumber(u"4234 5678 9012 2110" /* Visa */); ASSERT_TRUE(personal_data_->IsKnownCard(cardToCompare)); } @@ -3081,7 +3023,7 @@ TEST_F(PersonalDataManagerTest, IsKnownCard_MatchesFullServerCard) { EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); CreditCard cardToCompare; - cardToCompare.SetNumber(base::ASCIIToUTF16("4234 5678 9012 2110") /* Visa */); + cardToCompare.SetNumber(u"4234 5678 9012 2110" /* Visa */); ASSERT_TRUE(personal_data_->IsKnownCard(cardToCompare)); } @@ -3099,7 +3041,7 @@ TEST_F(PersonalDataManagerTest, IsKnownCard_MatchesLocalCard) { EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); CreditCard cardToCompare; - cardToCompare.SetNumber(base::ASCIIToUTF16("4234567890122110") /* Visa */); + cardToCompare.SetNumber(u"4234567890122110" /* Visa */); ASSERT_TRUE(personal_data_->IsKnownCard(cardToCompare)); } @@ -3117,8 +3059,7 @@ TEST_F(PersonalDataManagerTest, IsKnownCard_TypeDoesNotMatch) { EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); CreditCard cardToCompare; - cardToCompare.SetNumber( - base::ASCIIToUTF16("5105 1051 0510 2110") /* American Express */); + cardToCompare.SetNumber(u"5105 1051 0510 2110" /* American Express */); ASSERT_FALSE(personal_data_->IsKnownCard(cardToCompare)); } @@ -3136,7 +3077,7 @@ TEST_F(PersonalDataManagerTest, IsKnownCard_LastFourDoesNotMatch) { EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); CreditCard cardToCompare; - cardToCompare.SetNumber(base::ASCIIToUTF16("4234 5678 9012 0000") /* Visa */); + cardToCompare.SetNumber(u"4234 5678 9012 0000" /* Visa */); ASSERT_FALSE(personal_data_->IsKnownCard(cardToCompare)); } @@ -3162,7 +3103,7 @@ TEST_F(PersonalDataManagerTest, IsServerCard_DuplicateOfFullServerCard) { EXPECT_EQ(2U, personal_data_->GetCreditCards().size()); CreditCard cardToCompare; - cardToCompare.SetNumber(base::ASCIIToUTF16("4234 5678 9012 2110") /* Visa */); + cardToCompare.SetNumber(u"4234 5678 9012 2110" /* Visa */); ASSERT_TRUE(personal_data_->IsServerCard(&cardToCompare)); ASSERT_TRUE(personal_data_->IsServerCard(&local_card)); } @@ -3190,7 +3131,7 @@ TEST_F(PersonalDataManagerTest, IsServerCard_DuplicateOfMaskedServerCard) { EXPECT_EQ(2U, personal_data_->GetCreditCards().size()); CreditCard cardToCompare; - cardToCompare.SetNumber(base::ASCIIToUTF16("4234 5678 9012 2110") /* Visa */); + cardToCompare.SetNumber(u"4234 5678 9012 2110" /* Visa */); ASSERT_TRUE(personal_data_->IsServerCard(&cardToCompare)); ASSERT_TRUE(personal_data_->IsServerCard(&local_card)); } @@ -3256,7 +3197,7 @@ TEST_F(PersonalDataManagerTest, std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions(AutofillType(CREDIT_CARD_NUMBER), - base::ASCIIToUTF16("12345678"), + u"12345678", /*include_server_cards=*/true); // There should be no suggestions. @@ -3272,20 +3213,17 @@ TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_LocalCardsRanking) { std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NAME_FULL), - /*field_contents=*/base::string16(), + /*field_contents=*/std::u16string(), /*include_server_cards=*/true); ASSERT_EQ(3U, suggestions.size()); // Ordered as expected. - EXPECT_EQ(base::ASCIIToUTF16("John Dillinger"), suggestions[0].value); - EXPECT_TRUE(suggestions[0].label.find(base::ASCIIToUTF16("3456")) != - base::string16::npos); - EXPECT_EQ(base::ASCIIToUTF16("Clyde Barrow"), suggestions[1].value); - EXPECT_TRUE(suggestions[1].label.find(base::ASCIIToUTF16("0005")) != - base::string16::npos); - EXPECT_EQ(base::ASCIIToUTF16("Bonnie Parker"), suggestions[2].value); - EXPECT_TRUE(suggestions[2].label.find(base::ASCIIToUTF16("5100")) != - base::string16::npos); + EXPECT_EQ(u"John Dillinger", suggestions[0].value); + EXPECT_TRUE(suggestions[0].label.find(u"3456") != std::u16string::npos); + EXPECT_EQ(u"Clyde Barrow", suggestions[1].value); + EXPECT_TRUE(suggestions[1].label.find(u"0005") != std::u16string::npos); + EXPECT_EQ(u"Bonnie Parker", suggestions[2].value); + EXPECT_TRUE(suggestions[2].label.find(u"5100") != std::u16string::npos); } // Test that local and server cards are ordered as expected. @@ -3320,16 +3258,16 @@ TEST_F(PersonalDataManagerTest, std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NAME_FULL), - /*field_contents=*/base::string16(), + /*field_contents=*/std::u16string(), /*include_server_cards=*/true); ASSERT_EQ(5U, suggestions.size()); // All cards should be ordered as expected. - EXPECT_EQ(base::ASCIIToUTF16("Jesse James"), suggestions[0].value); - EXPECT_EQ(base::ASCIIToUTF16("John Dillinger"), suggestions[1].value); - EXPECT_EQ(base::ASCIIToUTF16("Clyde Barrow"), suggestions[2].value); - EXPECT_EQ(base::ASCIIToUTF16("Emmet Dalton"), suggestions[3].value); - EXPECT_EQ(base::ASCIIToUTF16("Bonnie Parker"), suggestions[4].value); + EXPECT_EQ(u"Jesse James", suggestions[0].value); + EXPECT_EQ(u"John Dillinger", suggestions[1].value); + EXPECT_EQ(u"Clyde Barrow", suggestions[2].value); + EXPECT_EQ(u"Emmet Dalton", suggestions[3].value); + EXPECT_EQ(u"Bonnie Parker", suggestions[4].value); } // Test that local and server cards are not shown if @@ -3373,7 +3311,7 @@ TEST_F(PersonalDataManagerTest, std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NAME_FULL), - /*field_contents=*/base::string16(), + /*field_contents=*/std::u16string(), /*include_server_cards=*/true); ASSERT_EQ(0U, suggestions.size()); } @@ -3422,7 +3360,7 @@ TEST_F(PersonalDataManagerTest, std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NAME_FULL), - /*field_contents=*/base::string16(), + /*field_contents=*/std::u16string(), /*include_server_cards=*/true); ASSERT_EQ(0U, suggestions.size()); } @@ -3487,16 +3425,16 @@ TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_ExpiredCards) { std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NAME_FULL), - /*field_contents=*/base::string16(), + /*field_contents=*/std::u16string(), /* include_server_cards= */ true); ASSERT_EQ(3U, suggestions.size()); // The never used non expired card should be suggested first. - EXPECT_EQ(base::ASCIIToUTF16("Bonnie Parker"), suggestions[0].value); + EXPECT_EQ(u"Bonnie Parker", suggestions[0].value); // The expired cards should be sorted by frecency - EXPECT_EQ(base::ASCIIToUTF16("Clyde Barrow"), suggestions[1].value); - EXPECT_EQ(base::ASCIIToUTF16("John Dillinger"), suggestions[2].value); + EXPECT_EQ(u"Clyde Barrow", suggestions[1].value); + EXPECT_EQ(u"John Dillinger", suggestions[2].value); } // Test cards that are expired AND disused are suppressed when supression is @@ -3553,44 +3491,44 @@ TEST_F(PersonalDataManagerTest, { std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( - AutofillType(CREDIT_CARD_NAME_FULL), base::string16(), + AutofillType(CREDIT_CARD_NAME_FULL), std::u16string(), /*include_server_cards=*/true); EXPECT_EQ(2U, suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("Bonnie Parker"), suggestions[0].value); - EXPECT_EQ(base::ASCIIToUTF16("Clyde Barrow"), suggestions[1].value); + EXPECT_EQ(u"Bonnie Parker", suggestions[0].value); + EXPECT_EQ(u"Clyde Barrow", suggestions[1].value); } // Query with name prefix for card0 returns card0. { std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( - AutofillType(CREDIT_CARD_NAME_FULL), base::ASCIIToUTF16("B"), + AutofillType(CREDIT_CARD_NAME_FULL), u"B", /*include_server_cards=*/true); ASSERT_EQ(1U, suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("Bonnie Parker"), suggestions[0].value); + EXPECT_EQ(u"Bonnie Parker", suggestions[0].value); } // Query with name prefix for card1 returns card1. { std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( - AutofillType(CREDIT_CARD_NAME_FULL), base::ASCIIToUTF16("Cl"), + AutofillType(CREDIT_CARD_NAME_FULL), u"Cl", /*include_server_cards=*/true); ASSERT_EQ(1U, suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("Clyde Barrow"), suggestions[0].value); + EXPECT_EQ(u"Clyde Barrow", suggestions[0].value); } // Query with name prefix for card2 returns card2. { std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( - AutofillType(CREDIT_CARD_NAME_FULL), base::ASCIIToUTF16("Jo"), + AutofillType(CREDIT_CARD_NAME_FULL), u"Jo", /*include_server_cards=*/true); ASSERT_EQ(1U, suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("John Dillinger"), suggestions[0].value); + EXPECT_EQ(u"John Dillinger", suggestions[0].value); } // Query with card number prefix for card1 returns card1 and card2. @@ -3599,7 +3537,7 @@ TEST_F(PersonalDataManagerTest, { std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( - AutofillType(CREDIT_CARD_NUMBER), base::ASCIIToUTF16("4234"), + AutofillType(CREDIT_CARD_NUMBER), u"4234", /*include_server_cards=*/true); ASSERT_EQ(2U, suggestions.size()); @@ -3647,7 +3585,7 @@ TEST_F(PersonalDataManagerTest, std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NUMBER), - /*field_contents=*/base::string16(), + /*field_contents=*/std::u16string(), /*include_server_cards=*/true); ASSERT_EQ(1U, suggestions.size()); EXPECT_EQ(base::UTF8ToUTF16(std::string("Amex ") + @@ -3655,9 +3593,9 @@ TEST_F(PersonalDataManagerTest, suggestions[0].value); #if defined(OS_ANDROID) || defined(OS_IOS) - EXPECT_EQ(base::ASCIIToUTF16("04/99"), suggestions[0].label); + EXPECT_EQ(u"04/99", suggestions[0].label); #else - EXPECT_EQ(base::ASCIIToUTF16("Expires on 04/99"), suggestions[0].label); + EXPECT_EQ(u"Expires on 04/99", suggestions[0].label); #endif // defined (OS_ANDROID) || defined(OS_IOS) } @@ -3672,7 +3610,7 @@ TEST_F(PersonalDataManagerTest, test::kEmptyOrigin); test::SetCreditCardInfo(&credit_card, "John Dillinger", "", "01", "2999", "1"); - credit_card.SetNickname(base::UTF8ToUTF16("nickname")); + credit_card.SetNickname(u"nickname"); personal_data_->AddCreditCard(credit_card); // Make sure everything is set up correctly. @@ -3683,10 +3621,10 @@ TEST_F(PersonalDataManagerTest, std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NAME_FULL), - /*field_contents=*/base::string16(), + /*field_contents=*/std::u16string(), /*include_server_cards=*/true); ASSERT_EQ(1U, suggestions.size()); - EXPECT_EQ(base::UTF8ToUTF16("nickname"), suggestions[0].label); + EXPECT_EQ(u"nickname", suggestions[0].label); } // Tests the suggestions of duplicate local and server credit cards. @@ -3728,15 +3666,15 @@ TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_ServerDuplicates) { std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NAME_FULL), - /*field_contents=*/base::string16(), + /*field_contents=*/std::u16string(), /*include_server_cards=*/true); ASSERT_EQ(3U, suggestions.size()); - EXPECT_EQ(base::ASCIIToUTF16("John Dillinger"), suggestions[0].value); - EXPECT_EQ(base::ASCIIToUTF16("Clyde Barrow"), suggestions[1].value); - EXPECT_EQ(base::ASCIIToUTF16("Bonnie Parker"), suggestions[2].value); + EXPECT_EQ(u"John Dillinger", suggestions[0].value); + EXPECT_EQ(u"Clyde Barrow", suggestions[1].value); + EXPECT_EQ(u"Bonnie Parker", suggestions[2].value); suggestions = personal_data_->GetCreditCardSuggestions( - AutofillType(CREDIT_CARD_NUMBER), /*field_contents=*/base::string16(), + AutofillType(CREDIT_CARD_NUMBER), /*field_contents=*/std::u16string(), /*include_server_cards=*/true); ASSERT_EQ(3U, suggestions.size()); EXPECT_EQ(base::UTF8ToUTF16(std::string("Visa ") + @@ -3774,7 +3712,7 @@ TEST_F(PersonalDataManagerTest, std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NAME_FULL), - /*field_contents=*/base::string16(), + /*field_contents=*/std::u16string(), /*include_server_cards=*/true); ASSERT_EQ(3U, suggestions.size()); @@ -3789,7 +3727,7 @@ TEST_F(PersonalDataManagerTest, suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NAME_FULL), - /*field_contents=*/base::string16(), /*include_server_cards=*/true); + /*field_contents=*/std::u16string(), /*include_server_cards=*/true); ASSERT_EQ(3U, suggestions.size()); } @@ -4963,22 +4901,20 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_MergedProfileValues) { EXPECT_EQ(profile3.guid(), profiles[0]->guid()); // The address syntax that results from the merge should be the one from the // imported profile (highest frecency). - EXPECT_EQ(base::UTF8ToUTF16("742. Evergreen Terrace"), + EXPECT_EQ(u"742. Evergreen Terrace", profiles[0]->GetRawInfo(ADDRESS_HOME_LINE1)); // The middle name should be full, even if the profile with the higher // frecency only had an initial (no loss of information). - EXPECT_EQ(base::UTF8ToUTF16("Jay"), profiles[0]->GetRawInfo(NAME_MIDDLE)); + EXPECT_EQ(u"Jay", profiles[0]->GetRawInfo(NAME_MIDDLE)); // The specified phone number from profile1 should be kept (no loss of // information). - EXPECT_EQ(base::UTF8ToUTF16("12345678910"), - profiles[0]->GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); + EXPECT_EQ(u"12345678910", profiles[0]->GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); // The specified company name from profile2 should be kept (no loss of // information). - EXPECT_EQ(base::UTF8ToUTF16("Fox"), profiles[0]->GetRawInfo(COMPANY_NAME)); + EXPECT_EQ(u"Fox", profiles[0]->GetRawInfo(COMPANY_NAME)); // The specified country from the imported profile shoudl be kept (no loss of // information). - EXPECT_EQ(base::UTF8ToUTF16("US"), - profiles[0]->GetRawInfo(ADDRESS_HOME_COUNTRY)); + EXPECT_EQ(u"US", profiles[0]->GetRawInfo(ADDRESS_HOME_COUNTRY)); // The use count that results from the merge should be the max of all the // profiles use counts. EXPECT_EQ(10U, profiles[0]->use_count()); @@ -5051,7 +4987,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_VerifiedProfileFirst) { // still evolved with future observations. In this case, the "." was added // from a later observation. profile1.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_NAME, base::UTF8ToUTF16("Evergreen Terrace"), + ADDRESS_HOME_STREET_NAME, u"Evergreen Terrace", structured_address::VerificationStatus::kParsed); // // Only the verified |profile1| with its original data should have been kept. @@ -5183,7 +5119,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_MultipleVerifiedProfiles) { // still evolved with future observations. In this case, the "." was removed // from a later observation. profile2.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_NAME, base::UTF8ToUTF16("Evergreen Terrace"), + ADDRESS_HOME_STREET_NAME, u"Evergreen Terrace", structured_address::VerificationStatus::kParsed); // |profile1| should have been discarded because the saved profile with the @@ -5324,18 +5260,16 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_MultipleDedupes) { // |Homer3|'s data: // The address should be saved with the syntax of |Homer1| since it has the // highest frecency score. - EXPECT_EQ(base::UTF8ToUTF16("742. Evergreen Terrace"), + EXPECT_EQ(u"742. Evergreen Terrace", profiles[0]->GetRawInfo(ADDRESS_HOME_LINE1)); // The middle name should be the full version found in |Homer2|, - EXPECT_EQ(base::UTF8ToUTF16("Jay"), profiles[0]->GetRawInfo(NAME_MIDDLE)); + EXPECT_EQ(u"Jay", profiles[0]->GetRawInfo(NAME_MIDDLE)); // The phone number from |Homer2| should be kept (no loss of information). - EXPECT_EQ(base::UTF8ToUTF16("12345678910"), - profiles[0]->GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); + EXPECT_EQ(u"12345678910", profiles[0]->GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); // The company name from |Homer3| should be kept (no loss of information). - EXPECT_EQ(base::UTF8ToUTF16("Fox"), profiles[0]->GetRawInfo(COMPANY_NAME)); + EXPECT_EQ(u"Fox", profiles[0]->GetRawInfo(COMPANY_NAME)); // The country from |Homer1| profile should be kept (no loss of information). - EXPECT_EQ(base::UTF8ToUTF16("US"), - profiles[0]->GetRawInfo(ADDRESS_HOME_COUNTRY)); + EXPECT_EQ(u"US", profiles[0]->GetRawInfo(ADDRESS_HOME_COUNTRY)); // The use count that results from the merge should be the max of Homer 1, 2 // and 3's respective use counts. EXPECT_EQ(10U, profiles[0]->use_count()); @@ -5504,12 +5438,9 @@ TEST_F(PersonalDataManagerTest, EXPECT_EQ(3U, personal_data_->GetProfiles().size()); EXPECT_EQ(2U, personal_data_->GetCreditCards().size()); - EXPECT_EQ(base::UTF8ToUTF16("Keep"), - personal_data_->GetProfiles()[0]->GetRawInfo(NAME_LAST)); - EXPECT_EQ(base::UTF8ToUTF16("Keep"), - personal_data_->GetProfiles()[1]->GetRawInfo(NAME_LAST)); - EXPECT_EQ(base::UTF8ToUTF16("Keep"), - personal_data_->GetProfiles()[2]->GetRawInfo(NAME_LAST)); + EXPECT_EQ(u"Keep", personal_data_->GetProfiles()[0]->GetRawInfo(NAME_LAST)); + EXPECT_EQ(u"Keep", personal_data_->GetProfiles()[1]->GetRawInfo(NAME_LAST)); + EXPECT_EQ(u"Keep", personal_data_->GetProfiles()[2]->GetRawInfo(NAME_LAST)); } // Tests that DeleteDisusedCreditCards deletes desired credit cards only. @@ -5593,10 +5524,8 @@ TEST_F(PersonalDataManagerTest, WaitForOnPersonalDataChanged(); EXPECT_EQ(5U, personal_data_->GetCreditCards().size()); - std::unordered_set<base::string16> expectedToRemain = { - base::UTF8ToUTF16("Alice"), base::UTF8ToUTF16("Bob"), - base::UTF8ToUTF16("Clyde"), base::UTF8ToUTF16("Emma"), - base::UTF8ToUTF16("Frank")}; + std::unordered_set<std::u16string> expectedToRemain = { + u"Alice", u"Bob", u"Clyde", u"Emma", u"Frank"}; for (auto* card : personal_data_->GetCreditCards()) { EXPECT_NE(expectedToRemain.end(), expectedToRemain.find(card->GetRawInfo(CREDIT_CARD_NAME_FULL))); @@ -5635,8 +5564,7 @@ TEST_F(PersonalDataManagerTest, DeleteLocalCreditCards) { EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); - std::unordered_set<base::string16> expectedToRemain = { - base::UTF8ToUTF16("Clyde")}; + std::unordered_set<std::u16string> expectedToRemain = {u"Clyde"}; for (auto* card : personal_data_->GetCreditCards()) { EXPECT_NE(expectedToRemain.end(), expectedToRemain.find(card->GetRawInfo(CREDIT_CARD_NAME_FULL))); @@ -5677,11 +5605,9 @@ TEST_F(PersonalDataManagerTest, // will be ignored when the profile is written to the DB. if (!StructuredNamesEnabled()) { - server_profiles.back().SetRawInfo(NAME_FULL, - base::ASCIIToUTF16("John Doe")); + server_profiles.back().SetRawInfo(NAME_FULL, u"John Doe"); } - EXPECT_EQ(server_profiles.back().GetRawInfo(NAME_FULL), - base::ASCIIToUTF16("John Doe")); + EXPECT_EQ(server_profiles.back().GetRawInfo(NAME_FULL), u"John Doe"); server_profiles.back().set_use_count(100); SetServerProfiles(server_profiles); @@ -5729,7 +5655,7 @@ TEST_F(PersonalDataManagerTest, // Make sure that the two profiles have not merged. ASSERT_EQ(2U, profiles.size()); - EXPECT_EQ(base::UTF8ToUTF16("John"), profiles[0]->GetRawInfo(NAME_FIRST)); + EXPECT_EQ(u"John", profiles[0]->GetRawInfo(NAME_FIRST)); EXPECT_EQ(local_profile, *profiles[1]); // Make sure that the billing address id of the two cards now point to the @@ -5777,7 +5703,7 @@ TEST_F(PersonalDataManagerTest, "1212 Center", "Bld. 5", "Orlando", "FL", "", "US", ""); // Wallet only provides a full name, so the above first and last names // will be ignored when the profile is written to the DB. - server_profiles.back().SetRawInfo(NAME_FULL, base::ASCIIToUTF16("John Doe")); + server_profiles.back().SetRawInfo(NAME_FULL, u"John Doe"); server_profiles.back().set_use_count(100); SetServerProfiles(server_profiles); @@ -5827,11 +5753,9 @@ TEST_F(PersonalDataManagerTest, ASSERT_EQ(1U, profiles.size()); // Check that the values were merged. - EXPECT_EQ(base::UTF8ToUTF16("john@doe.com"), - profiles[0]->GetRawInfo(EMAIL_ADDRESS)); - EXPECT_EQ(base::UTF8ToUTF16("Fox"), profiles[0]->GetRawInfo(COMPANY_NAME)); - EXPECT_EQ(base::UTF8ToUTF16("32801"), - profiles[0]->GetRawInfo(ADDRESS_HOME_ZIP)); + EXPECT_EQ(u"john@doe.com", profiles[0]->GetRawInfo(EMAIL_ADDRESS)); + EXPECT_EQ(u"Fox", profiles[0]->GetRawInfo(COMPANY_NAME)); + EXPECT_EQ(u"32801", profiles[0]->GetRawInfo(ADDRESS_HOME_ZIP)); // Make sure that the billing address id of the two cards now point to the // converted profile. @@ -5917,11 +5841,9 @@ TEST_F( // will be ignored when the profile is written to the DB. // This step happens automatically for structured names. if (!StructuredNamesEnabled()) { - server_profiles.back().SetRawInfo(NAME_FULL, - base::ASCIIToUTF16("John Doe")); + server_profiles.back().SetRawInfo(NAME_FULL, u"John Doe"); } - EXPECT_EQ(server_profiles.back().GetRawInfo(NAME_FULL), - base::ASCIIToUTF16("John Doe")); + EXPECT_EQ(server_profiles.back().GetRawInfo(NAME_FULL), u"John Doe"); server_profiles.back().set_use_count(100); // Add a similar server profile. @@ -5932,7 +5854,7 @@ TEST_F( "Orlando", "FL", "", "US", ""); // Wallet only provides a full name, so the above first and last names // will be ignored when the profile is written to the DB. - server_profiles.back().SetRawInfo(NAME_FULL, base::ASCIIToUTF16("John Doe")); + server_profiles.back().SetRawInfo(NAME_FULL, u"John Doe"); server_profiles.back().set_use_count(200); SetServerProfiles(server_profiles); @@ -5987,13 +5909,12 @@ TEST_F( // Make sure that the two Wallet addresses merged together and were added as // a new local profile. ASSERT_EQ(2U, profiles.size()); - EXPECT_EQ(base::UTF8ToUTF16("John"), profiles[0]->GetRawInfo(NAME_FIRST)); + EXPECT_EQ(u"John", profiles[0]->GetRawInfo(NAME_FIRST)); EXPECT_EQ(local_profile, *profiles[1]); // Check that the values were merged. - EXPECT_EQ(base::UTF8ToUTF16("Fox"), profiles[0]->GetRawInfo(COMPANY_NAME)); - EXPECT_EQ(base::UTF8ToUTF16("32801"), - profiles[0]->GetRawInfo(ADDRESS_HOME_ZIP)); + EXPECT_EQ(u"Fox", profiles[0]->GetRawInfo(COMPANY_NAME)); + EXPECT_EQ(u"32801", profiles[0]->GetRawInfo(ADDRESS_HOME_ZIP)); // Make sure that the billing address id of the two cards now point to the // converted profile. @@ -6027,7 +5948,7 @@ TEST_F( "1212 Center", "Bld. 5", "Orlando", "FL", "", "US", ""); // Wallet only provides a full name, so the above first and last names // will be ignored when the profile is written to the DB. - server_profiles.back().SetRawInfo(NAME_FULL, base::ASCIIToUTF16("John Doe")); + server_profiles.back().SetRawInfo(NAME_FULL, u"John Doe"); server_profiles.back().set_use_count(100); SetServerProfiles(server_profiles); @@ -6123,15 +6044,14 @@ TEST_F(PersonalDataManagerTest, DoNotConvertWalletAddressesInEphemeralStorage) { test::SetProfileInfo(&server_profiles.back(), "John", "", "Doe", "", "", "1212 Center", "Bld. 5", "Orlando", "FL", "32801", "US", ""); - server_profiles.back().SetRawInfo(NAME_FULL, base::ASCIIToUTF16("John Doe")); + server_profiles.back().SetRawInfo(NAME_FULL, u"John Doe"); server_profiles.push_back( AutofillProfile(AutofillProfile::SERVER_PROFILE, "server_address2")); test::SetProfileInfo(&server_profiles.back(), "Josephine", "Alicia", "Saenz", "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", "32801", "US", "19482937549"); - server_profiles.back().SetRawInfo( - NAME_FULL, base::ASCIIToUTF16("Josephine Alicia Saenz")); + server_profiles.back().SetRawInfo(NAME_FULL, u"Josephine Alicia Saenz"); SetServerProfiles(server_profiles); ASSERT_TRUE(AutofillProfileComparator(personal_data_->app_locale()) @@ -6558,7 +6478,7 @@ TEST_F(PersonalDataManagerTest, CreateDataForTest) { auto it = std::find_if( addresses.begin(), addresses.end(), [this](const AutofillProfile* p) { return p->GetInfo(NAME_FULL, this->personal_data_->app_locale()) == - base::UTF8ToUTF16("John McTester"); + u"John McTester"; }); ASSERT_TRUE(it != addresses.end()); EXPECT_GT((*it)->use_date(), disused_threshold); @@ -6569,7 +6489,7 @@ TEST_F(PersonalDataManagerTest, CreateDataForTest) { auto it = std::find_if( addresses.begin(), addresses.end(), [this](const AutofillProfile* p) { return p->GetInfo(NAME_FULL, this->personal_data_->app_locale()) == - base::UTF8ToUTF16("Polly Disused"); + u"Polly Disused"; }); ASSERT_TRUE(it != addresses.end()); EXPECT_LT((*it)->use_date(), disused_threshold); @@ -6580,7 +6500,7 @@ TEST_F(PersonalDataManagerTest, CreateDataForTest) { auto it = std::find_if( addresses.begin(), addresses.end(), [this](const AutofillProfile* p) { return p->GetInfo(NAME_FULL, this->personal_data_->app_locale()) == - base::UTF8ToUTF16("Polly Deletable"); + u"Polly Deletable"; }); ASSERT_TRUE(it != addresses.end()); EXPECT_LT((*it)->use_date(), deletion_threshold); @@ -6593,7 +6513,7 @@ TEST_F(PersonalDataManagerTest, CreateDataForTest) { credit_cards.begin(), credit_cards.end(), [this](const CreditCard* cc) { return cc->GetInfo(CREDIT_CARD_NAME_FULL, this->personal_data_->app_locale()) == - base::UTF8ToUTF16("Alice Testerson"); + u"Alice Testerson"; }); ASSERT_TRUE(it != credit_cards.end()); EXPECT_GT((*it)->use_date(), disused_threshold); @@ -6605,7 +6525,7 @@ TEST_F(PersonalDataManagerTest, CreateDataForTest) { credit_cards.begin(), credit_cards.end(), [this](const CreditCard* cc) { return cc->GetInfo(CREDIT_CARD_NAME_FULL, this->personal_data_->app_locale()) == - base::UTF8ToUTF16("Bob Disused"); + u"Bob Disused"; }); ASSERT_TRUE(it != credit_cards.end()); EXPECT_LT((*it)->use_date(), disused_threshold); @@ -6617,7 +6537,7 @@ TEST_F(PersonalDataManagerTest, CreateDataForTest) { credit_cards.begin(), credit_cards.end(), [this](const CreditCard* cc) { return cc->GetInfo(CREDIT_CARD_NAME_FULL, this->personal_data_->app_locale()) == - base::UTF8ToUTF16("Charlie Deletable"); + u"Charlie Deletable"; }); ASSERT_TRUE(it != credit_cards.end()); EXPECT_LT((*it)->use_date(), deletion_threshold); @@ -7198,11 +7118,11 @@ TEST_F(PersonalDataManagerMockTest, UpdateClientValidityStates_UpdatedFlag) { ASSERT_TRUE(profiles[0]->is_client_validity_states_updated()); ASSERT_TRUE(profiles[1]->is_client_validity_states_updated()); - profiles[1]->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, base::UTF8ToUTF16("")); + profiles[1]->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u""); ASSERT_TRUE(profiles[0]->is_client_validity_states_updated()); ASSERT_FALSE(profiles[1]->is_client_validity_states_updated()); - profiles[0]->SetRawInfo(NAME_FULL, base::UTF8ToUTF16("Goli Boli")); + profiles[0]->SetRawInfo(NAME_FULL, u"Goli Boli"); ASSERT_TRUE(profiles[0]->is_client_validity_states_updated()); } @@ -7217,7 +7137,7 @@ TEST_F(PersonalDataManagerMockTest, AutofillProfile profile2(test::GetFullValidProfileForCanada()); profile2.set_guid("00000000-0000-0000-0000-000000002019"); - profile2.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, base::UTF8ToUTF16("")); + profile2.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u""); profile2.FinalizeAfterImport(); AddProfileToPersonalDataManager(profile2); @@ -7248,7 +7168,7 @@ TEST_F(PersonalDataManagerMockTest, TEST_F(PersonalDataManagerMockTest, UpdateClientValidityStates_AlreadyUpdated) { // Create two profiles and add them to personal_data_. AutofillProfile profile1(test::GetFullValidProfileForCanada()); - profile1.SetRawInfo(EMAIL_ADDRESS, base::UTF8ToUTF16("invalid email!")); + profile1.SetRawInfo(EMAIL_ADDRESS, u"invalid email!"); AddProfileToPersonalDataManager(profile1); auto profiles = personal_data_->GetProfiles(); @@ -7259,7 +7179,7 @@ TEST_F(PersonalDataManagerMockTest, UpdateClientValidityStates_AlreadyUpdated) { profiles[0]->GetValidityState(EMAIL_ADDRESS, AutofillProfile::CLIENT)); // Change the email, the validity update would turn false. - profiles[0]->SetRawInfo(EMAIL_ADDRESS, base::UTF8ToUTF16("alice@gmail.com")); + profiles[0]->SetRawInfo(EMAIL_ADDRESS, u"alice@gmail.com"); EXPECT_FALSE(profiles[0]->is_client_validity_states_updated()); // Pretend that the validity states are updated. profiles[0]->set_is_client_validity_states_updated(true); @@ -7291,13 +7211,13 @@ TEST_F(PersonalDataManagerMockTest, UpdateClientValidityStates_Version) { // Create two profiles and add them to personal_data_. Set the guids // explicitly to preserve the order. AutofillProfile profile2(test::GetFullValidProfileForChina()); - profile2.SetRawInfo(ADDRESS_HOME_STATE, base::UTF8ToUTF16("invalid state!")); + profile2.SetRawInfo(ADDRESS_HOME_STATE, u"invalid state!"); profile2.set_guid("00000000-0000-0000-0000-000000000002"); profile2.set_use_date(AutofillClock::Now() - base::TimeDelta::FromDays(200)); AddProfileToPersonalDataManager(profile2); AutofillProfile profile1(test::GetFullValidProfileForCanada()); - profile1.SetRawInfo(EMAIL_ADDRESS, base::UTF8ToUTF16("invalid email!")); + profile1.SetRawInfo(EMAIL_ADDRESS, u"invalid email!"); profile1.set_use_date(AutofillClock::Now()); profile1.set_guid("00000000-0000-0000-0000-000000000001"); AddProfileToPersonalDataManager(profile1); @@ -7371,7 +7291,7 @@ TEST_F(PersonalDataManagerMockTest, UpdateProfilesValidityStates_AddUpdate) { EXPECT_EQ(true, profiles[0]->is_client_validity_states_updated()); // Update - profile1.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("email!")); + profile1.SetRawInfo(EMAIL_ADDRESS, u"email!"); UpdateProfileOnPersonalDataManager(profile1); profiles = personal_data_->GetProfiles(); @@ -7956,9 +7876,9 @@ class PersonalDataManagerTestForSharingNickname return full_server_card; } - base::string16 local_nickname_; - base::string16 server_nickname_; - base::string16 expected_nickname_; + std::u16string local_nickname_; + std::u16string server_nickname_; + std::u16string expected_nickname_; }; INSTANTIATE_TEST_SUITE_P(, @@ -7981,14 +7901,12 @@ TEST_P(PersonalDataManagerTestForSharingNickname, std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NUMBER), - /*field_contents=*/base::string16(), + /*field_contents=*/std::u16string(), /*include_server_cards=*/true); ASSERT_EQ(1U, suggestions.size()); EXPECT_EQ(suggestions[0].value, - (expected_nickname_.empty() ? base::ASCIIToUTF16("Amex") - : expected_nickname_) + - base::UTF8ToUTF16(" ") + - local_card.ObfuscatedLastFourDigits()); + (expected_nickname_.empty() ? u"Amex" : expected_nickname_) + + u" " + local_card.ObfuscatedLastFourDigits()); } TEST_P(PersonalDataManagerTestForSharingNickname, @@ -8000,7 +7918,7 @@ TEST_P(PersonalDataManagerTestForSharingNickname, std::vector<CreditCard> server_cards; CreditCard server_card = GetServerCard(); // Make sure the cards are different by giving a different card number. - server_card.SetNumber(base::ASCIIToUTF16("371449635398431")); + server_card.SetNumber(u"371449635398431"); server_cards.emplace_back(server_card); SetServerCards(server_cards); @@ -8012,18 +7930,16 @@ TEST_P(PersonalDataManagerTestForSharingNickname, std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NUMBER), - /*field_contents=*/base::string16(), + /*field_contents=*/std::u16string(), /*include_server_cards=*/true); ASSERT_EQ(2U, suggestions.size()); EXPECT_THAT( - std::vector<base::string16>({suggestions[0].value, suggestions[1].value}), + std::vector<std::u16string>({suggestions[0].value, suggestions[1].value}), testing::UnorderedElementsAre( - (server_nickname_.empty() ? base::ASCIIToUTF16("Amex") - : server_nickname_) + - base::UTF8ToUTF16(" ") + server_card.ObfuscatedLastFourDigits(), - (local_nickname_.empty() ? base::ASCIIToUTF16("Amex") - : local_nickname_) + - base::UTF8ToUTF16(" ") + local_card.ObfuscatedLastFourDigits())); + (server_nickname_.empty() ? u"Amex" : server_nickname_) + u" " + + server_card.ObfuscatedLastFourDigits(), + (local_nickname_.empty() ? u"Amex" : local_nickname_) + u" " + + local_card.ObfuscatedLastFourDigits())); } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/test_autofill_client.cc b/chromium/components/autofill/core/browser/test_autofill_client.cc index 98beaeb88a0..a9a3deccf41 100644 --- a/chromium/components/autofill/core/browser/test_autofill_client.cc +++ b/chromium/components/autofill/core/browser/test_autofill_client.cc @@ -151,7 +151,7 @@ void TestAutofillClient::ConfirmMigrateLocalCardToCloud( void TestAutofillClient::ShowLocalCardMigrationResults( const bool has_server_error, - const base::string16& tip_message, + const std::u16string& tip_message, const std::vector<MigratableCreditCard>& migratable_credit_cards, MigrationDeleteCardCallback delete_local_card_callback) {} void TestAutofillClient::ShowWebauthnOfferDialog( @@ -176,19 +176,19 @@ void TestAutofillClient::OfferVirtualCardOptions( #else // defined(OS_ANDROID) || defined(OS_IOS) void TestAutofillClient::ConfirmAccountNameFixFlow( - base::OnceCallback<void(const base::string16&)> callback) { + base::OnceCallback<void(const std::u16string&)> callback) { credit_card_name_fix_flow_bubble_was_shown_ = true; - std::move(callback).Run(base::string16(base::ASCIIToUTF16("Gaia Name"))); + std::move(callback).Run(std::u16string(u"Gaia Name")); } void TestAutofillClient::ConfirmExpirationDateFixFlow( const CreditCard& card, - base::OnceCallback<void(const base::string16&, const base::string16&)> + base::OnceCallback<void(const std::u16string&, const std::u16string&)> callback) { credit_card_name_fix_flow_bubble_was_shown_ = true; std::move(callback).Run( - base::string16(base::ASCIIToUTF16("03")), - base::string16(base::ASCIIToUTF16(test::NextYear().c_str()))); + std::u16string(u"03"), + std::u16string(base::ASCIIToUTF16(test::NextYear().c_str()))); } #endif @@ -235,8 +235,8 @@ void TestAutofillClient::ShowAutofillPopup( base::WeakPtr<AutofillPopupDelegate> delegate) {} void TestAutofillClient::UpdateAutofillPopupDataListValues( - const std::vector<base::string16>& values, - const std::vector<base::string16>& labels) {} + const std::vector<std::u16string>& values, + const std::vector<std::u16string>& labels) {} base::span<const Suggestion> TestAutofillClient::GetPopupSuggestions() const { return base::span<const Suggestion>(); @@ -262,8 +262,8 @@ void TestAutofillClient::PropagateAutofillPredictions( const std::vector<FormStructure*>& forms) {} void TestAutofillClient::DidFillOrPreviewField( - const base::string16& autofilled_value, - const base::string16& profile_full_name) {} + const std::u16string& autofilled_value, + const std::u16string& profile_full_name) {} bool TestAutofillClient::IsContextSecure() const { // Simplified secure context check for tests. diff --git a/chromium/components/autofill/core/browser/test_autofill_client.h b/chromium/components/autofill/core/browser/test_autofill_client.h index 682274a1759..d04af4ef608 100644 --- a/chromium/components/autofill/core/browser/test_autofill_client.h +++ b/chromium/components/autofill/core/browser/test_autofill_client.h @@ -86,7 +86,7 @@ class TestAutofillClient : public AutofillClient { LocalCardMigrationCallback start_migrating_cards_callback) override; void ShowLocalCardMigrationResults( const bool has_server_error, - const base::string16& tip_message, + const std::u16string& tip_message, const std::vector<MigratableCreditCard>& migratable_credit_cards, MigrationDeleteCardCallback delete_local_card_callback) override; void ShowWebauthnOfferDialog( @@ -103,10 +103,10 @@ class TestAutofillClient : public AutofillClient { base::OnceCallback<void(const std::string&)> callback) override; #else // defined(OS_ANDROID) || defined(OS_IOS) void ConfirmAccountNameFixFlow( - base::OnceCallback<void(const base::string16&)> callback) override; + base::OnceCallback<void(const std::u16string&)> callback) override; void ConfirmExpirationDateFixFlow( const CreditCard& card, - base::OnceCallback<void(const base::string16&, const base::string16&)> + base::OnceCallback<void(const std::u16string&, const std::u16string&)> callback) override; #endif void ConfirmSaveCreditCardLocally( @@ -131,8 +131,8 @@ class TestAutofillClient : public AutofillClient { const AutofillClient::PopupOpenArgs& open_args, base::WeakPtr<AutofillPopupDelegate> delegate) override; void UpdateAutofillPopupDataListValues( - const std::vector<base::string16>& values, - const std::vector<base::string16>& labels) override; + const std::vector<std::u16string>& values, + const std::vector<std::u16string>& labels) override; base::span<const Suggestion> GetPopupSuggestions() const override; void PinPopupView() override; AutofillClient::PopupOpenArgs GetReopenPopupArgs() const override; @@ -143,8 +143,8 @@ class TestAutofillClient : public AutofillClient { void PropagateAutofillPredictions( content::RenderFrameHost* rfh, const std::vector<FormStructure*>& forms) override; - void DidFillOrPreviewField(const base::string16& autofilled_value, - const base::string16& profile_full_name) override; + void DidFillOrPreviewField(const std::u16string& autofilled_value, + const std::u16string& profile_full_name) override; // By default, TestAutofillClient will report that the context is // secure. This can be adjusted by calling set_form_origin() with an // http:// URL. diff --git a/chromium/components/autofill/core/browser/test_autofill_driver.cc b/chromium/components/autofill/core/browser/test_autofill_driver.cc index 8a515f8f101..1577b463e7f 100644 --- a/chromium/components/autofill/core/browser/test_autofill_driver.cc +++ b/chromium/components/autofill/core/browser/test_autofill_driver.cc @@ -71,8 +71,8 @@ void TestAutofillDriver::SendAutofillTypePredictionsToRenderer( } void TestAutofillDriver::RendererShouldAcceptDataListSuggestion( - const base::string16& value) { -} + const FieldGlobalId& field, + const std::u16string& value) {} void TestAutofillDriver::RendererShouldClearFilledSection() {} @@ -80,14 +80,15 @@ void TestAutofillDriver::RendererShouldClearPreviewedForm() { } void TestAutofillDriver::RendererShouldFillFieldWithValue( - const base::string16& value) { -} + const FieldGlobalId& field, + const std::u16string& value) {} void TestAutofillDriver::RendererShouldPreviewFieldWithValue( - const base::string16& value) { -} + const FieldGlobalId& field, + const std::u16string& value) {} void TestAutofillDriver::RendererShouldSetSuggestionAvailability( + const FieldGlobalId& field, const mojom::AutofillState state) {} void TestAutofillDriver::PopupHidden() { diff --git a/chromium/components/autofill/core/browser/test_autofill_driver.h b/chromium/components/autofill/core/browser/test_autofill_driver.h index 09405053603..0f43f44eca2 100644 --- a/chromium/components/autofill/core/browser/test_autofill_driver.h +++ b/chromium/components/autofill/core/browser/test_autofill_driver.h @@ -49,13 +49,17 @@ class TestAutofillDriver : public ContentAutofillDriver { void SendAutofillTypePredictionsToRenderer( const std::vector<FormStructure*>& forms) override; void RendererShouldAcceptDataListSuggestion( - const base::string16& value) override; + const FieldGlobalId& field, + const std::u16string& value) override; void RendererShouldClearFilledSection() override; void RendererShouldClearPreviewedForm() override; - void RendererShouldFillFieldWithValue(const base::string16& value) override; + void RendererShouldFillFieldWithValue(const FieldGlobalId& field, + const std::u16string& value) override; void RendererShouldPreviewFieldWithValue( - const base::string16& value) override; + const FieldGlobalId& field, + const std::u16string& value) override; void RendererShouldSetSuggestionAvailability( + const FieldGlobalId& field, const mojom::AutofillState state) override; void PopupHidden() override; gfx::RectF TransformBoundingBoxToViewportCoordinates( diff --git a/chromium/components/autofill/core/browser/test_autofill_manager.cc b/chromium/components/autofill/core/browser/test_autofill_manager.cc index ca610fc8d93..82fe61d895a 100644 --- a/chromium/components/autofill/core/browser/test_autofill_manager.cc +++ b/chromium/components/autofill/core/browser/test_autofill_manager.cc @@ -103,7 +103,7 @@ void TestAutofillManager::AddSeenForm( const std::vector<ServerFieldType>& server_types) { FormData empty_form = form; for (size_t i = 0; i < empty_form.fields.size(); ++i) { - empty_form.fields[i].value = base::string16(); + empty_form.fields[i].value = std::u16string(); } std::unique_ptr<TestFormStructure> form_structure = @@ -117,8 +117,8 @@ void TestAutofillManager::AddSeenForm( void TestAutofillManager::AddSeenFormStructure( std::unique_ptr<FormStructure> form_structure) { - const auto renderer_id = form_structure->unique_renderer_id(); - (*mutable_form_structures())[renderer_id] = std::move(form_structure); + const auto id = form_structure->global_id(); + (*mutable_form_structures())[id] = std::move(form_structure); } void TestAutofillManager::ClearFormStructures() { diff --git a/chromium/components/autofill/core/browser/ui/accessory_sheet_data.cc b/chromium/components/autofill/core/browser/ui/accessory_sheet_data.cc index 89675db21d3..17e3910630c 100644 --- a/chromium/components/autofill/core/browser/ui/accessory_sheet_data.cc +++ b/chromium/components/autofill/core/browser/ui/accessory_sheet_data.cc @@ -11,8 +11,8 @@ namespace autofill { -UserInfo::Field::Field(base::string16 display_text, - base::string16 a11y_description, +UserInfo::Field::Field(std::u16string display_text, + std::u16string a11y_description, bool is_obfuscated, bool selectable) : display_text_(std::move(display_text)), @@ -23,8 +23,8 @@ UserInfo::Field::Field(base::string16 display_text, base::trace_event::EstimateMemoryUsage(display_text_) + base::trace_event::EstimateMemoryUsage(a11y_description_)) {} -UserInfo::Field::Field(base::string16 display_text, - base::string16 a11y_description, +UserInfo::Field::Field(std::u16string display_text, + std::u16string a11y_description, std::string id, bool is_obfuscated, bool selectable) @@ -108,7 +108,7 @@ std::ostream& operator<<(std::ostream& os, const UserInfo& user_info) { return os << "]"; } -FooterCommand::FooterCommand(base::string16 display_text, +FooterCommand::FooterCommand(std::u16string display_text, autofill::AccessoryAction action) : display_text_(std::move(display_text)), accessory_action_(action), @@ -141,7 +141,7 @@ std::ostream& operator<<(std::ostream& os, const FooterCommand& fc) { << "action: " << static_cast<int>(fc.accessory_action()) << ")"; } -OptionToggle::OptionToggle(base::string16 display_text, +OptionToggle::OptionToggle(std::u16string display_text, bool enabled, autofill::AccessoryAction action) : display_text_(display_text), @@ -196,11 +196,11 @@ std::ostream& operator<<(std::ostream& os, const AccessoryTabType& type) { } AccessorySheetData::AccessorySheetData(AccessoryTabType sheet_type, - base::string16 title) - : AccessorySheetData(sheet_type, std::move(title), base::string16()) {} + std::u16string title) + : AccessorySheetData(sheet_type, std::move(title), std::u16string()) {} AccessorySheetData::AccessorySheetData(AccessoryTabType sheet_type, - base::string16 title, - base::string16 warning) + std::u16string title, + std::u16string warning) : sheet_type_(sheet_type), title_(std::move(title)), warning_(std::move(warning)) {} @@ -256,25 +256,25 @@ std::ostream& operator<<(std::ostream& os, const AccessorySheetData& data) { } AccessorySheetData::Builder::Builder(AccessoryTabType type, - base::string16 title) + std::u16string title) : accessory_sheet_data_(type, std::move(title)) {} AccessorySheetData::Builder::~Builder() = default; AccessorySheetData::Builder&& AccessorySheetData::Builder::SetWarning( - base::string16 warning) && { - // Calls SetWarning(base::string16 warning)()& since |this| is an lvalue. + std::u16string warning) && { + // Calls SetWarning(std::u16string warning)()& since |this| is an lvalue. return std::move(SetWarning(std::move(warning))); } AccessorySheetData::Builder& AccessorySheetData::Builder::SetWarning( - base::string16 warning) & { + std::u16string warning) & { accessory_sheet_data_.set_warning(std::move(warning)); return *this; } AccessorySheetData::Builder&& AccessorySheetData::Builder::SetOptionToggle( - base::string16 display_text, + std::u16string display_text, bool enabled, autofill::AccessoryAction action) && { // Calls SetOptionToggle(...)& since |this| is an lvalue. @@ -282,7 +282,7 @@ AccessorySheetData::Builder&& AccessorySheetData::Builder::SetOptionToggle( } AccessorySheetData::Builder& AccessorySheetData::Builder::SetOptionToggle( - base::string16 display_text, + std::u16string display_text, bool enabled, autofill::AccessoryAction action) & { accessory_sheet_data_.set_option_toggle( @@ -306,22 +306,22 @@ AccessorySheetData::Builder& AccessorySheetData::Builder::AddUserInfo( } AccessorySheetData::Builder&& AccessorySheetData::Builder::AppendSimpleField( - base::string16 text) && { + std::u16string text) && { // Calls AppendSimpleField(...)& since |this| is an lvalue. return std::move(AppendSimpleField(std::move(text))); } AccessorySheetData::Builder& AccessorySheetData::Builder::AppendSimpleField( - base::string16 text) & { - base::string16 display_text = text; - base::string16 a11y_description = std::move(text); + std::u16string text) & { + std::u16string display_text = text; + std::u16string a11y_description = std::move(text); return AppendField(std::move(display_text), std::move(a11y_description), false, true); } AccessorySheetData::Builder&& AccessorySheetData::Builder::AppendField( - base::string16 display_text, - base::string16 a11y_description, + std::u16string display_text, + std::u16string a11y_description, bool is_obfuscated, bool selectable) && { // Calls AppendField(...)& since |this| is an lvalue. @@ -331,8 +331,8 @@ AccessorySheetData::Builder&& AccessorySheetData::Builder::AppendField( } AccessorySheetData::Builder& AccessorySheetData::Builder::AppendField( - base::string16 display_text, - base::string16 a11y_description, + std::u16string display_text, + std::u16string a11y_description, bool is_obfuscated, bool selectable) & { accessory_sheet_data_.mutable_user_info_list().back().add_field( @@ -342,8 +342,8 @@ AccessorySheetData::Builder& AccessorySheetData::Builder::AppendField( } AccessorySheetData::Builder&& AccessorySheetData::Builder::AppendField( - base::string16 display_text, - base::string16 a11y_description, + std::u16string display_text, + std::u16string a11y_description, std::string id, bool is_obfuscated, bool selectable) && { @@ -354,8 +354,8 @@ AccessorySheetData::Builder&& AccessorySheetData::Builder::AppendField( } AccessorySheetData::Builder& AccessorySheetData::Builder::AppendField( - base::string16 display_text, - base::string16 a11y_description, + std::u16string display_text, + std::u16string a11y_description, std::string id, bool is_obfuscated, bool selectable) & { @@ -366,14 +366,14 @@ AccessorySheetData::Builder& AccessorySheetData::Builder::AppendField( } AccessorySheetData::Builder&& AccessorySheetData::Builder::AppendFooterCommand( - base::string16 display_text, + std::u16string display_text, autofill::AccessoryAction action) && { // Calls AppendFooterCommand(...)& since |this| is an lvalue. return std::move(AppendFooterCommand(std::move(display_text), action)); } AccessorySheetData::Builder& AccessorySheetData::Builder::AppendFooterCommand( - base::string16 display_text, + std::u16string display_text, autofill::AccessoryAction action) & { accessory_sheet_data_.add_footer_command( FooterCommand(std::move(display_text), action)); diff --git a/chromium/components/autofill/core/browser/ui/accessory_sheet_data.h b/chromium/components/autofill/core/browser/ui/accessory_sheet_data.h index 38408e17550..80c900b067c 100644 --- a/chromium/components/autofill/core/browser/ui/accessory_sheet_data.h +++ b/chromium/components/autofill/core/browser/ui/accessory_sheet_data.h @@ -5,11 +5,11 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_UI_ACCESSORY_SHEET_DATA_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_ACCESSORY_SHEET_DATA_H_ +#include <string> #include <utility> #include <vector> #include "base/optional.h" -#include "base/strings/string16.h" #include "base/types/strong_alias.h" #include "components/autofill/core/browser/ui/accessory_sheet_enums.h" @@ -27,12 +27,12 @@ class UserInfo { // number. class Field { public: - Field(base::string16 display_text, - base::string16 a11y_description, + Field(std::u16string display_text, + std::u16string a11y_description, bool is_obfuscated, bool selectable); - Field(base::string16 display_text, - base::string16 a11y_description, + Field(std::u16string display_text, + std::u16string a11y_description, std::string id, bool is_obfuscated, bool selectable); @@ -44,9 +44,9 @@ class UserInfo { Field& operator=(const Field& field); Field& operator=(Field&& field); - const base::string16& display_text() const { return display_text_; } + const std::u16string& display_text() const { return display_text_; } - const base::string16& a11y_description() const { return a11y_description_; } + const std::u16string& a11y_description() const { return a11y_description_; } const std::string& id() const { return id_; } @@ -63,8 +63,8 @@ class UserInfo { private: // IMPORTANT(https://crbug.com/1169167): Add the size of newly added strings // to the memory estimation member! - base::string16 display_text_; - base::string16 a11y_description_; + std::u16string display_text_; + std::u16string a11y_description_; std::string id_; // Optional, if needed to complete filling. bool is_obfuscated_; bool selectable_; @@ -115,7 +115,7 @@ std::ostream& operator<<(std::ostream& out, const UserInfo& user_info); // Represents a command below the suggestions, such as "Manage password...". class FooterCommand { public: - FooterCommand(base::string16 display_text, autofill::AccessoryAction action); + FooterCommand(std::u16string display_text, autofill::AccessoryAction action); FooterCommand(const FooterCommand& footer_command); FooterCommand(FooterCommand&& footer_command); @@ -124,7 +124,7 @@ class FooterCommand { FooterCommand& operator=(const FooterCommand& footer_command); FooterCommand& operator=(FooterCommand&& footer_command); - const base::string16& display_text() const { return display_text_; } + const std::u16string& display_text() const { return display_text_; } autofill::AccessoryAction accessory_action() const { return accessory_action_; @@ -139,7 +139,7 @@ class FooterCommand { private: // IMPORTANT(https://crbug.com/1169167): Add the size of newly added strings // to the memory estimation member! - base::string16 display_text_; + std::u16string display_text_; autofill::AccessoryAction accessory_action_; size_t estimated_memory_use_by_strings_ = 0; }; @@ -152,7 +152,7 @@ std::ostream& operator<<(std::ostream& out, const AccessoryTabType& type); // for example, to turn password saving on for the current origin. class OptionToggle { public: - OptionToggle(base::string16 display_text, + OptionToggle(std::u16string display_text, bool enabled, AccessoryAction accessory_action); OptionToggle(const OptionToggle& option_toggle); @@ -163,7 +163,7 @@ class OptionToggle { OptionToggle& operator=(const OptionToggle& option_toggle); OptionToggle& operator=(OptionToggle&& option_toggle); - const base::string16& display_text() const { return display_text_; } + const std::u16string& display_text() const { return display_text_; } bool is_enabled() const { return enabled_; } @@ -178,7 +178,7 @@ class OptionToggle { private: // IMPORTANT(https://crbug.com/1169167): Add the size of newly added strings // to the memory estimation member! - base::string16 display_text_; + std::u16string display_text_; bool enabled_; autofill::AccessoryAction accessory_action_; size_t estimated_memory_use_by_strings_ = 0; @@ -190,10 +190,10 @@ class AccessorySheetData { public: class Builder; - AccessorySheetData(AccessoryTabType sheet_type, base::string16 title); + AccessorySheetData(AccessoryTabType sheet_type, std::u16string title); AccessorySheetData(AccessoryTabType sheet_type, - base::string16 title, - base::string16 warning); + std::u16string title, + std::u16string warning); AccessorySheetData(const AccessorySheetData& data); AccessorySheetData(AccessorySheetData&& data); @@ -202,11 +202,11 @@ class AccessorySheetData { AccessorySheetData& operator=(const AccessorySheetData& data); AccessorySheetData& operator=(AccessorySheetData&& data); - const base::string16& title() const { return title_; } + const std::u16string& title() const { return title_; } AccessoryTabType get_sheet_type() const { return sheet_type_; } - const base::string16& warning() const { return warning_; } - void set_warning(base::string16 warning) { warning_ = std::move(warning); } + const std::u16string& warning() const { return warning_; } + void set_warning(std::u16string warning) { warning_ = std::move(warning); } void set_option_toggle(OptionToggle toggle) { option_toggle_ = std::move(toggle); @@ -241,8 +241,8 @@ class AccessorySheetData { private: AccessoryTabType sheet_type_; - base::string16 title_; - base::string16 warning_; + std::u16string title_; + std::u16string warning_; base::Optional<OptionToggle> option_toggle_; std::vector<UserInfo> user_info_list_; std::vector<FooterCommand> footer_commands_; @@ -265,18 +265,18 @@ std::ostream& operator<<(std::ostream& out, const AccessorySheetData& data); // .Build(); class AccessorySheetData::Builder { public: - Builder(AccessoryTabType type, base::string16 title); + Builder(AccessoryTabType type, std::u16string title); ~Builder(); // Adds a warning string to the accessory sheet. - Builder&& SetWarning(base::string16 warning) &&; - Builder& SetWarning(base::string16 warning) &; + Builder&& SetWarning(std::u16string warning) &&; + Builder& SetWarning(std::u16string warning) &; // Sets the option toggle in the accessory sheet. - Builder&& SetOptionToggle(base::string16 display_text, + Builder&& SetOptionToggle(std::u16string display_text, bool enabled, autofill::AccessoryAction action) &&; - Builder& SetOptionToggle(base::string16 display_text, + Builder& SetOptionToggle(std::u16string display_text, bool enabled, autofill::AccessoryAction action) &; @@ -289,34 +289,34 @@ class AccessorySheetData::Builder { UserInfo::IsPslMatch is_psl_match = UserInfo::IsPslMatch(false)) &; // Appends a selectable, non-obfuscated field to the last UserInfo object. - Builder&& AppendSimpleField(base::string16 text) &&; - Builder& AppendSimpleField(base::string16 text) &; + Builder&& AppendSimpleField(std::u16string text) &&; + Builder& AppendSimpleField(std::u16string text) &; // Appends a field to the last UserInfo object. - Builder&& AppendField(base::string16 display_text, - base::string16 a11y_description, + Builder&& AppendField(std::u16string display_text, + std::u16string a11y_description, bool is_obfuscated, bool selectable) &&; - Builder& AppendField(base::string16 display_text, - base::string16 a11y_description, + Builder& AppendField(std::u16string display_text, + std::u16string a11y_description, bool is_obfuscated, bool selectable) &; - Builder&& AppendField(base::string16 display_text, - base::string16 a11y_description, + Builder&& AppendField(std::u16string display_text, + std::u16string a11y_description, std::string id, bool is_obfuscated, bool selectable) &&; - Builder& AppendField(base::string16 display_text, - base::string16 a11y_description, + Builder& AppendField(std::u16string display_text, + std::u16string a11y_description, std::string id, bool is_obfuscated, bool selectable) &; // Appends a new footer command to |accessory_sheet_data_|. - Builder&& AppendFooterCommand(base::string16 display_text, + Builder&& AppendFooterCommand(std::u16string display_text, autofill::AccessoryAction action) &&; - Builder& AppendFooterCommand(base::string16 display_text, + Builder& AppendFooterCommand(std::u16string display_text, autofill::AccessoryAction action) &; // This class returns the constructed AccessorySheetData object. Since this diff --git a/chromium/components/autofill/core/browser/ui/address_combobox_model.cc b/chromium/components/autofill/core/browser/ui/address_combobox_model.cc index 89c03f9c433..2f33fb3f5e1 100644 --- a/chromium/components/autofill/core/browser/ui/address_combobox_model.cc +++ b/chromium/components/autofill/core/browser/ui/address_combobox_model.cc @@ -46,7 +46,7 @@ int AddressComboboxModel::GetItemCount() const { return addresses_.size() + kNbHeaderEntries; } -base::string16 AddressComboboxModel::GetItemAt(int index) const { +std::u16string AddressComboboxModel::GetItemAt(int index) const { DCHECK_GE(index, 0); // A special entry is always added at index 0 and a separator at index 1. DCHECK_LT(static_cast<size_t>(index), addresses_.size() + kNbHeaderEntries); @@ -61,7 +61,7 @@ base::string16 AddressComboboxModel::GetItemAt(int index) const { // Always show the "Select" entry at the top, default selection position. if (index == 1) - return base::ASCIIToUTF16("---"); + return u"---"; return addresses_[index - kNbHeaderEntries].second; } @@ -117,7 +117,7 @@ int AddressComboboxModel::GetIndexOfIdentifier( void AddressComboboxModel::UpdateAddresses() { addresses_.clear(); - std::vector<base::string16> labels; + std::vector<std::u16string> labels; // CreateDifferentiatingLabels is expecting a pointer vector and we keep // profiles as unique_ptr. std::vector<AutofillProfile*> profiles; diff --git a/chromium/components/autofill/core/browser/ui/address_combobox_model.h b/chromium/components/autofill/core/browser/ui/address_combobox_model.h index deb54889c04..f3067494387 100644 --- a/chromium/components/autofill/core/browser/ui/address_combobox_model.h +++ b/chromium/components/autofill/core/browser/ui/address_combobox_model.h @@ -12,7 +12,6 @@ #include "base/macros.h" #include "base/observer_list.h" -#include "base/strings/string16.h" #include "ui/base/models/combobox_model.h" namespace autofill { @@ -35,7 +34,7 @@ class AddressComboboxModel : public ui::ComboboxModel { // ui::ComboboxModel implementation: int GetItemCount() const override; - base::string16 GetItemAt(int index) const override; + std::u16string GetItemAt(int index) const override; bool IsItemSeparatorAt(int index) const override; int GetDefaultIndex() const override; void AddObserver(ui::ComboboxModelObserver* observer) override; @@ -59,7 +58,7 @@ class AddressComboboxModel : public ui::ComboboxModel { // List of <id, user visible string> pairs for the addresses extracted from // the |personal_data_manager| passed in the constructor. - std::vector<std::pair<std::string, base::string16>> addresses_; + std::vector<std::pair<std::string, std::u16string>> addresses_; // A cached copy of all profiles to allow rebuilding the differentiating // labels when new profiles are added. diff --git a/chromium/components/autofill/core/browser/ui/address_contact_form_label_formatter.cc b/chromium/components/autofill/core/browser/ui/address_contact_form_label_formatter.cc index 61fe081b4a5..f74623d44e5 100644 --- a/chromium/components/autofill/core/browser/ui/address_contact_form_label_formatter.cc +++ b/chromium/components/autofill/core/browser/ui/address_contact_form_label_formatter.cc @@ -29,10 +29,10 @@ AddressContactFormLabelFormatter::~AddressContactFormLabelFormatter() {} // Note that the order in which parts of the label are added--name, street // address, phone, and email--ensures that the label is formatted correctly for // |focused_group|, |focused_field_type_|, and this kind of formatter. -base::string16 AddressContactFormLabelFormatter::GetLabelForProfile( +std::u16string AddressContactFormLabelFormatter::GetLabelForProfile( const AutofillProfile& profile, FieldTypeGroup focused_group) const { - std::vector<base::string16> label_parts; + std::vector<std::u16string> label_parts; bool street_address_is_focused = focused_group == FieldTypeGroup::kAddressHome && diff --git a/chromium/components/autofill/core/browser/ui/address_contact_form_label_formatter.h b/chromium/components/autofill/core/browser/ui/address_contact_form_label_formatter.h index d59e63ce451..8b92a5e7445 100644 --- a/chromium/components/autofill/core/browser/ui/address_contact_form_label_formatter.h +++ b/chromium/components/autofill/core/browser/ui/address_contact_form_label_formatter.h @@ -8,7 +8,6 @@ #include <string> #include <vector> -#include "base/strings/string16.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" #include "components/autofill/core/browser/field_types.h" #include "components/autofill/core/browser/ui/label_formatter.h" @@ -28,7 +27,7 @@ class AddressContactFormLabelFormatter : public LabelFormatter { ~AddressContactFormLabelFormatter() override; - base::string16 GetLabelForProfile( + std::u16string GetLabelForProfile( const AutofillProfile& profile, FieldTypeGroup focused_group) const override; diff --git a/chromium/components/autofill/core/browser/ui/address_contact_form_label_formatter_unittest.cc b/chromium/components/autofill/core/browser/ui/address_contact_form_label_formatter_unittest.cc index 746e5b77479..cb8521200e3 100644 --- a/chromium/components/autofill/core/browser/ui/address_contact_form_label_formatter_unittest.cc +++ b/chromium/components/autofill/core/browser/ui/address_contact_form_label_formatter_unittest.cc @@ -9,7 +9,6 @@ #include <vector> #include "base/guid.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_test_utils.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" @@ -86,18 +85,12 @@ TEST(AddressContactFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre( - ConstructLabelLine({base::ASCIIToUTF16("19 North Sq"), - base::ASCIIToUTF16("(617) 523-2338"), - base::ASCIIToUTF16("sarah.revere@aol.com")}), - ConstructLabelLine({base::ASCIIToUTF16("151 Irving Ave"), - base::ASCIIToUTF16("(617) 514-1600")}), - ConstructLabelLine({base::ASCIIToUTF16("19 North Sq"), - base::ASCIIToUTF16("paul1775@gmail.com")}), - ConstructLabelLine({base::ASCIIToUTF16("(617) 324-0000"), - base::ASCIIToUTF16("deborah@mit.edu")}), - base::ASCIIToUTF16("Old North Church, 193 Salem St"), - base::string16())); + ElementsAre(ConstructLabelLine({u"19 North Sq", u"(617) 523-2338", + u"sarah.revere@aol.com"}), + ConstructLabelLine({u"151 Irving Ave", u"(617) 514-1600"}), + ConstructLabelLine({u"19 North Sq", u"paul1775@gmail.com"}), + ConstructLabelLine({u"(617) 324-0000", u"deborah@mit.edu"}), + u"Old North Church, 193 Salem St", std::u16string())); } TEST(AddressContactFormLabelFormatterTest, @@ -142,18 +135,13 @@ TEST(AddressContactFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre( - ConstructLabelLine({base::ASCIIToUTF16("Sarah Revere"), - base::ASCIIToUTF16("(617) 523-2338"), - base::ASCIIToUTF16("sarah.revere@aol.com")}), - ConstructLabelLine({base::ASCIIToUTF16("Jackie L Kennedy"), - base::ASCIIToUTF16("(617) 514-1600")}), - ConstructLabelLine({base::ASCIIToUTF16("Paul Revere"), - base::ASCIIToUTF16("paul1775@gmail.com")}), - ConstructLabelLine({base::ASCIIToUTF16("Deborah Katabi"), - base::ASCIIToUTF16("(617) 324-0000"), - base::ASCIIToUTF16("deborah@mit.edu")}), - base::ASCIIToUTF16(""), base::string16())); + ElementsAre(ConstructLabelLine({u"Sarah Revere", u"(617) 523-2338", + u"sarah.revere@aol.com"}), + ConstructLabelLine({u"Jackie L Kennedy", u"(617) 514-1600"}), + ConstructLabelLine({u"Paul Revere", u"paul1775@gmail.com"}), + ConstructLabelLine({u"Deborah Katabi", u"(617) 324-0000", + u"deborah@mit.edu"}), + u"", std::u16string())); } TEST(AddressContactFormLabelFormatterTest, @@ -198,18 +186,12 @@ TEST(AddressContactFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre( - ConstructLabelLine({base::ASCIIToUTF16("19 North Sq"), - base::ASCIIToUTF16("(617) 523-2338"), - base::ASCIIToUTF16("sarah.revere@aol.com")}), - ConstructLabelLine({base::ASCIIToUTF16("151 Irving Ave"), - base::ASCIIToUTF16("(617) 514-1600")}), - ConstructLabelLine({base::ASCIIToUTF16("19 North Sq"), - base::ASCIIToUTF16("paul1775@gmail.com")}), - ConstructLabelLine({base::ASCIIToUTF16("(617) 324-0000"), - base::ASCIIToUTF16("deborah@mit.edu")}), - base::ASCIIToUTF16("Old North Church, 193 Salem St"), - base::string16())); + ElementsAre(ConstructLabelLine({u"19 North Sq", u"(617) 523-2338", + u"sarah.revere@aol.com"}), + ConstructLabelLine({u"151 Irving Ave", u"(617) 514-1600"}), + ConstructLabelLine({u"19 North Sq", u"paul1775@gmail.com"}), + ConstructLabelLine({u"(617) 324-0000", u"deborah@mit.edu"}), + u"Old North Church, 193 Salem St", std::u16string())); } TEST(AddressContactFormLabelFormatterTest, @@ -254,18 +236,13 @@ TEST(AddressContactFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("Sarah Revere"), - base::ASCIIToUTF16("19 North Sq"), - base::ASCIIToUTF16("(617) 523-2338")}), - ConstructLabelLine({base::ASCIIToUTF16("Jackie L Kennedy"), - base::ASCIIToUTF16("151 Irving Ave"), - base::ASCIIToUTF16("(617) 514-1600")}), - ConstructLabelLine({base::ASCIIToUTF16("Paul Revere"), - base::ASCIIToUTF16("19 North Sq")}), - ConstructLabelLine({base::ASCIIToUTF16("Deborah Katabi"), - base::ASCIIToUTF16("(617) 324-0000")}), - base::ASCIIToUTF16("Old North Church, 193 Salem St"), - base::string16())); + ElementsAre(ConstructLabelLine( + {u"Sarah Revere", u"19 North Sq", u"(617) 523-2338"}), + ConstructLabelLine({u"Jackie L Kennedy", u"151 Irving Ave", + u"(617) 514-1600"}), + ConstructLabelLine({u"Paul Revere", u"19 North Sq"}), + ConstructLabelLine({u"Deborah Katabi", u"(617) 324-0000"}), + u"Old North Church, 193 Salem St", std::u16string())); } TEST(AddressContactFormLabelFormatterTest, @@ -310,19 +287,13 @@ TEST(AddressContactFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre( - ConstructLabelLine({base::ASCIIToUTF16("Sarah Revere"), - base::ASCIIToUTF16("19 North Sq"), - base::ASCIIToUTF16("sarah.revere@aol.com")}), - ConstructLabelLine({base::ASCIIToUTF16("Jackie L Kennedy"), - base::ASCIIToUTF16("151 Irving Ave")}), - ConstructLabelLine({base::ASCIIToUTF16("Paul Revere"), - base::ASCIIToUTF16("19 North Sq"), - base::ASCIIToUTF16("paul1775@gmail.com")}), - ConstructLabelLine({base::ASCIIToUTF16("Deborah Katabi"), - base::ASCIIToUTF16("deborah@mit.edu")}), - base::ASCIIToUTF16("Old North Church, 193 Salem St"), - base::string16())); + ElementsAre(ConstructLabelLine({u"Sarah Revere", u"19 North Sq", + u"sarah.revere@aol.com"}), + ConstructLabelLine({u"Jackie L Kennedy", u"151 Irving Ave"}), + ConstructLabelLine( + {u"Paul Revere", u"19 North Sq", u"paul1775@gmail.com"}), + ConstructLabelLine({u"Deborah Katabi", u"deborah@mit.edu"}), + u"Old North Church, 193 Salem St", std::u16string())); } TEST(AddressContactFormLabelFormatterTest, @@ -348,13 +319,10 @@ TEST(AddressContactFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), ElementsAre( - ConstructLabelLine( - {base::UTF8ToUTF16("Av. Pedro Álvares Cabral, 1301"), - base::ASCIIToUTF16("(11) 2648-0254"), - base::ASCIIToUTF16("tarsila@aol.com")}), - ConstructLabelLine({base::UTF8ToUTF16("Estr. Dona Castorina, 110"), - base::ASCIIToUTF16("(21) 98765-0000"), - base::ASCIIToUTF16("aavila@uol.com.br")}))); + ConstructLabelLine({u"Av. Pedro Álvares Cabral, 1301", + u"(11) 2648-0254", u"tarsila@aol.com"}), + ConstructLabelLine({u"Estr. Dona Castorina, 110", u"(21) 98765-0000", + u"aavila@uol.com.br"}))); } TEST(AddressContactFormLabelFormatterTest, @@ -379,13 +347,10 @@ TEST(AddressContactFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre( - ConstructLabelLine({base::ASCIIToUTF16("Tarsila do Amaral"), - base::ASCIIToUTF16("(11) 2648-0254"), - base::ASCIIToUTF16("tarsila@aol.com")}), - ConstructLabelLine({base::ASCIIToUTF16("Artur Avila"), - base::ASCIIToUTF16("(21) 98765-0000"), - base::ASCIIToUTF16("aavila@uol.com.br")}))); + ElementsAre(ConstructLabelLine({u"Tarsila do Amaral", u"(11) 2648-0254", + u"tarsila@aol.com"}), + ConstructLabelLine({u"Artur Avila", u"(21) 98765-0000", + u"aavila@uol.com.br"}))); } TEST(AddressContactFormLabelFormatterTest, @@ -411,13 +376,10 @@ TEST(AddressContactFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), ElementsAre( - ConstructLabelLine( - {base::UTF8ToUTF16("Av. Pedro Álvares Cabral, 1301"), - base::ASCIIToUTF16("(11) 2648-0254"), - base::ASCIIToUTF16("tarsila@aol.com")}), - ConstructLabelLine({base::ASCIIToUTF16("Estr. Dona Castorina, 110"), - base::ASCIIToUTF16("(21) 98765-0000"), - base::ASCIIToUTF16("aavila@uol.com.br")}))); + ConstructLabelLine({u"Av. Pedro Álvares Cabral, 1301", + u"(11) 2648-0254", u"tarsila@aol.com"}), + ConstructLabelLine({u"Estr. Dona Castorina, 110", u"(21) 98765-0000", + u"aavila@uol.com.br"}))); } TEST(AddressContactFormLabelFormatterTest, @@ -440,16 +402,13 @@ TEST(AddressContactFormLabelFormatterTest, const std::unique_ptr<LabelFormatter> formatter = LabelFormatter::Create(profiles, "pt-BR", EMAIL_ADDRESS, GetFieldTypes()); - EXPECT_THAT( - formatter->GetLabels(), - ElementsAre( - ConstructLabelLine( - {base::ASCIIToUTF16("Tarsila do Amaral"), - base::UTF8ToUTF16("Av. Pedro Álvares Cabral, 1301"), - base::ASCIIToUTF16("(11) 2648-0254")}), - ConstructLabelLine({base::ASCIIToUTF16("Artur Avila"), - base::UTF8ToUTF16("Estr. Dona Castorina, 110"), - base::ASCIIToUTF16("(21) 98765-0000")}))); + EXPECT_THAT(formatter->GetLabels(), + ElementsAre(ConstructLabelLine({u"Tarsila do Amaral", + u"Av. Pedro Álvares Cabral, 1301", + u"(11) 2648-0254"}), + ConstructLabelLine({u"Artur Avila", + u"Estr. Dona Castorina, 110", + u"(21) 98765-0000"}))); } TEST(AddressContactFormLabelFormatterTest, @@ -472,16 +431,13 @@ TEST(AddressContactFormLabelFormatterTest, const std::unique_ptr<LabelFormatter> formatter = LabelFormatter::Create( profiles, "pt-BR", PHONE_BILLING_WHOLE_NUMBER, GetFieldTypes()); - EXPECT_THAT( - formatter->GetLabels(), - ElementsAre( - ConstructLabelLine( - {base::ASCIIToUTF16("Tarsila do Amaral"), - base::UTF8ToUTF16("Av. Pedro Álvares Cabral, 1301"), - base::ASCIIToUTF16("tarsila@aol.com")}), - ConstructLabelLine({base::ASCIIToUTF16("Artur Avila"), - base::UTF8ToUTF16("Estr. Dona Castorina, 110"), - base::ASCIIToUTF16("aavila@uol.com.br")}))); + EXPECT_THAT(formatter->GetLabels(), + ElementsAre(ConstructLabelLine({u"Tarsila do Amaral", + u"Av. Pedro Álvares Cabral, 1301", + u"tarsila@aol.com"}), + ConstructLabelLine({u"Artur Avila", + u"Estr. Dona Castorina, 110", + u"aavila@uol.com.br"}))); } TEST(AddressContactFormLabelFormatterTest, @@ -499,10 +455,8 @@ TEST(AddressContactFormLabelFormatterTest, ADDRESS_BILLING_ZIP, PHONE_BILLING_WHOLE_NUMBER}); // Checks that only address fields in the form are shown in the label. - EXPECT_THAT( - formatter->GetLabels(), - ElementsAre(ConstructLabelLine( - {base::ASCIIToUTF16("Sarah Revere"), base::ASCIIToUTF16("02113")}))); + EXPECT_THAT(formatter->GetLabels(), + ElementsAre(ConstructLabelLine({u"Sarah Revere", u"02113"}))); } TEST(AddressContactFormLabelFormatterTest, @@ -520,8 +474,7 @@ TEST(AddressContactFormLabelFormatterTest, // Checks that the name is not in the label and that the phone number is for // a unique profile. - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("(617) 523-2338"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"(617) 523-2338")); profiles = {&profile1, &profile1}; formatter = @@ -532,8 +485,7 @@ TEST(AddressContactFormLabelFormatterTest, // Checks that the name is not in the label and that the phone number is for // multiple profiles with the same phone number and email address. EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("(617) 523-2338"), - base::ASCIIToUTF16("(617) 523-2338"))); + ElementsAre(u"(617) 523-2338", u"(617) 523-2338")); AutofillProfile profile2 = AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin); @@ -549,8 +501,7 @@ TEST(AddressContactFormLabelFormatterTest, // Checks that the name is not in the label and that the email address is // shown because the profiles' email addresses are different. EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("sarah.revere@aol.com"), - base::ASCIIToUTF16("sarah@gmail.com"))); + ElementsAre(u"sarah.revere@aol.com", u"sarah@gmail.com")); } } // namespace diff --git a/chromium/components/autofill/core/browser/ui/address_email_form_label_formatter.cc b/chromium/components/autofill/core/browser/ui/address_email_form_label_formatter.cc index df9e38e2f7a..e0bff943d06 100644 --- a/chromium/components/autofill/core/browser/ui/address_email_form_label_formatter.cc +++ b/chromium/components/autofill/core/browser/ui/address_email_form_label_formatter.cc @@ -24,7 +24,7 @@ AddressEmailFormLabelFormatter::AddressEmailFormLabelFormatter( AddressEmailFormLabelFormatter::~AddressEmailFormLabelFormatter() {} -base::string16 AddressEmailFormLabelFormatter::GetLabelForProfile( +std::u16string AddressEmailFormLabelFormatter::GetLabelForProfile( const AutofillProfile& profile, FieldTypeGroup focused_group) const { return focused_group == FieldTypeGroup::kAddressHome && @@ -40,11 +40,11 @@ base::string16 AddressEmailFormLabelFormatter::GetLabelForProfile( // Note that the order--name, address, and email--in which parts of the label // are added ensures that the label is formatted correctly for |focused_group|, // |focused_field_type_| and for this kind of formatter. -base::string16 AddressEmailFormLabelFormatter:: +std::u16string AddressEmailFormLabelFormatter:: GetLabelForProfileOnFocusedNameEmailOrStreetAddress( const AutofillProfile& profile, FieldTypeGroup focused_group) const { - std::vector<base::string16> label_parts; + std::vector<std::u16string> label_parts; if (focused_group != FieldTypeGroup::kName && data_util::ContainsName(groups())) { diff --git a/chromium/components/autofill/core/browser/ui/address_email_form_label_formatter.h b/chromium/components/autofill/core/browser/ui/address_email_form_label_formatter.h index 1311f021d9f..d1aab3a457c 100644 --- a/chromium/components/autofill/core/browser/ui/address_email_form_label_formatter.h +++ b/chromium/components/autofill/core/browser/ui/address_email_form_label_formatter.h @@ -8,7 +8,6 @@ #include <string> #include <vector> -#include "base/strings/string16.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" #include "components/autofill/core/browser/field_types.h" #include "components/autofill/core/browser/ui/label_formatter.h" @@ -28,7 +27,7 @@ class AddressEmailFormLabelFormatter : public LabelFormatter { ~AddressEmailFormLabelFormatter() override; - base::string16 GetLabelForProfile( + std::u16string GetLabelForProfile( const AutofillProfile& profile, FieldTypeGroup focused_group) const override; @@ -37,7 +36,7 @@ class AddressEmailFormLabelFormatter : public LabelFormatter { // other than a non-street-address field type. For example, // |focused_field_type_| could be last name, home street address, or email // address. - base::string16 GetLabelForProfileOnFocusedNameEmailOrStreetAddress( + std::u16string GetLabelForProfileOnFocusedNameEmailOrStreetAddress( const AutofillProfile& profile, FieldTypeGroup focused_group) const; diff --git a/chromium/components/autofill/core/browser/ui/address_email_form_label_formatter_unittest.cc b/chromium/components/autofill/core/browser/ui/address_email_form_label_formatter_unittest.cc index 732076e9d33..a4d3b82341a 100644 --- a/chromium/components/autofill/core/browser/ui/address_email_form_label_formatter_unittest.cc +++ b/chromium/components/autofill/core/browser/ui/address_email_form_label_formatter_unittest.cc @@ -9,7 +9,6 @@ #include <vector> #include "base/guid.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_test_utils.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" @@ -72,10 +71,8 @@ TEST(AddressEmailFormLabelFormatterTest, GetLabelsForUSProfilesAndFocusedName) { EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("333 Washington St"), - base::ASCIIToUTF16("jfk@gmail.com")}), - base::ASCIIToUTF16("151 Irving Ave"), - base::ASCIIToUTF16("paul1775@gmail.com"), base::string16())); + ElementsAre(ConstructLabelLine({u"333 Washington St", u"jfk@gmail.com"}), + u"151 Irving Ave", u"paul1775@gmail.com", std::u16string())); } TEST(AddressEmailFormLabelFormatterTest, @@ -109,10 +106,8 @@ TEST(AddressEmailFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("John F Kennedy"), - base::ASCIIToUTF16("jfk@gmail.com")}), - base::ASCIIToUTF16("Jackie Kennedy"), - base::ASCIIToUTF16("paul1775@gmail.com"), base::string16())); + ElementsAre(ConstructLabelLine({u"John F Kennedy", u"jfk@gmail.com"}), + u"Jackie Kennedy", u"paul1775@gmail.com", std::u16string())); } TEST(AddressEmailFormLabelFormatterTest, @@ -146,10 +141,8 @@ TEST(AddressEmailFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("333 Washington St"), - base::ASCIIToUTF16("jfk@gmail.com")}), - base::ASCIIToUTF16("151 Irving Ave"), - base::ASCIIToUTF16("paul1775@gmail.com"), base::string16())); + ElementsAre(ConstructLabelLine({u"333 Washington St", u"jfk@gmail.com"}), + u"151 Irving Ave", u"paul1775@gmail.com", std::u16string())); } TEST(AddressEmailFormLabelFormatterTest, @@ -182,10 +175,8 @@ TEST(AddressEmailFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("John F Kennedy"), - base::ASCIIToUTF16("333 Washington St")}), - base::ASCIIToUTF16("Jackie Kennedy"), base::string16(), - base::ASCIIToUTF16("141 Franklin St"))); + ElementsAre(ConstructLabelLine({u"John F Kennedy", u"333 Washington St"}), + u"Jackie Kennedy", std::u16string(), u"141 Franklin St")); } TEST(AddressEmailFormLabelFormatterTest, GetLabelsForBRProfilesAndFocusedName) { @@ -207,14 +198,11 @@ TEST(AddressEmailFormLabelFormatterTest, GetLabelsForBRProfilesAndFocusedName) { const std::unique_ptr<LabelFormatter> formatter = LabelFormatter::Create( profiles, "pt-BR", NAME_BILLING_FULL, GetFieldTypes()); - EXPECT_THAT( - formatter->GetLabels(), - ElementsAre( - ConstructLabelLine( - {base::UTF8ToUTF16("Av. Pedro Álvares Cabral, 1301"), - base::ASCIIToUTF16("tarsila@aol.com")}), - ConstructLabelLine({base::ASCIIToUTF16("Estr. Dona Castorina, 110"), - base::ASCIIToUTF16("aavila@uol.com.br")}))); + EXPECT_THAT(formatter->GetLabels(), + ElementsAre(ConstructLabelLine({u"Av. Pedro Álvares Cabral, 1301", + u"tarsila@aol.com"}), + ConstructLabelLine({u"Estr. Dona Castorina, 110", + u"aavila@uol.com.br"}))); } TEST(AddressEmailFormLabelFormatterTest, @@ -240,10 +228,8 @@ TEST(AddressEmailFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), ElementsAre( - ConstructLabelLine({base::ASCIIToUTF16("Tarsila do Amaral"), - base::ASCIIToUTF16("tarsila@aol.com")}), - ConstructLabelLine({base::ASCIIToUTF16("Artur Avila"), - base::ASCIIToUTF16("aavila@uol.com.br")}))); + ConstructLabelLine({u"Tarsila do Amaral", u"tarsila@aol.com"}), + ConstructLabelLine({u"Artur Avila", u"aavila@uol.com.br"}))); } TEST(AddressEmailFormLabelFormatterTest, @@ -266,14 +252,11 @@ TEST(AddressEmailFormLabelFormatterTest, const std::unique_ptr<LabelFormatter> formatter = LabelFormatter::Create( profiles, "pt-BR", ADDRESS_BILLING_DEPENDENT_LOCALITY, GetFieldTypes()); - EXPECT_THAT( - formatter->GetLabels(), - ElementsAre( - ConstructLabelLine( - {base::UTF8ToUTF16("Av. Pedro Álvares Cabral, 1301"), - base::ASCIIToUTF16("tarsila@aol.com")}), - ConstructLabelLine({base::ASCIIToUTF16("Estr. Dona Castorina, 110"), - base::ASCIIToUTF16("aavila@uol.com.br")}))); + EXPECT_THAT(formatter->GetLabels(), + ElementsAre(ConstructLabelLine({u"Av. Pedro Álvares Cabral, 1301", + u"tarsila@aol.com"}), + ConstructLabelLine({u"Estr. Dona Castorina, 110", + u"aavila@uol.com.br"}))); } TEST(AddressEmailFormLabelFormatterTest, @@ -298,12 +281,10 @@ TEST(AddressEmailFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine( - {base::ASCIIToUTF16("Tarsila do Amaral"), - base::UTF8ToUTF16("Av. Pedro Álvares Cabral, 1301")}), - ConstructLabelLine( - {base::ASCIIToUTF16("Artur Avila"), - base::ASCIIToUTF16("Estr. Dona Castorina, 110")}))); + ElementsAre( + ConstructLabelLine( + {u"Tarsila do Amaral", u"Av. Pedro Álvares Cabral, 1301"}), + ConstructLabelLine({u"Artur Avila", u"Estr. Dona Castorina, 110"}))); } TEST(AddressEmailFormLabelFormatterTest, @@ -323,8 +304,7 @@ TEST(AddressEmailFormLabelFormatterTest, // Checks that only address fields in the form are shown in the label. EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("John F Kennedy"), - base::ASCIIToUTF16("Brookline, MA")}))); + ElementsAre(ConstructLabelLine({u"John F Kennedy", u"Brookline, MA"}))); } TEST(AddressEmailFormLabelFormatterTest, GetLabelsForFormWithoutName) { @@ -340,8 +320,7 @@ TEST(AddressEmailFormLabelFormatterTest, GetLabelsForFormWithoutName) { {ADDRESS_BILLING_LINE1, ADDRESS_BILLING_ZIP, EMAIL_ADDRESS}); // Checks that the name does not appear in the labels. - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("sarah.revere@aol.com"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"sarah.revere@aol.com")); } } // namespace diff --git a/chromium/components/autofill/core/browser/ui/address_form_label_formatter.cc b/chromium/components/autofill/core/browser/ui/address_form_label_formatter.cc index 4b958ea3157..137ee21bd90 100644 --- a/chromium/components/autofill/core/browser/ui/address_form_label_formatter.cc +++ b/chromium/components/autofill/core/browser/ui/address_form_label_formatter.cc @@ -24,14 +24,14 @@ AddressFormLabelFormatter::AddressFormLabelFormatter( AddressFormLabelFormatter::~AddressFormLabelFormatter() {} -base::string16 AddressFormLabelFormatter::GetLabelForProfile( +std::u16string AddressFormLabelFormatter::GetLabelForProfile( const AutofillProfile& profile, FieldTypeGroup focused_group) const { if (focused_group != FieldTypeGroup::kAddressHome) { return GetLabelNationalAddress(field_types_for_labels(), profile, app_locale()); } else { - std::vector<base::string16> label_parts; + std::vector<std::u16string> label_parts; if (data_util::ContainsName(groups())) { AddLabelPartIfNotEmpty( diff --git a/chromium/components/autofill/core/browser/ui/address_form_label_formatter.h b/chromium/components/autofill/core/browser/ui/address_form_label_formatter.h index e85f3cccd53..ef308917b5e 100644 --- a/chromium/components/autofill/core/browser/ui/address_form_label_formatter.h +++ b/chromium/components/autofill/core/browser/ui/address_form_label_formatter.h @@ -8,7 +8,6 @@ #include <string> #include <vector> -#include "base/strings/string16.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" #include "components/autofill/core/browser/field_types.h" #include "components/autofill/core/browser/ui/label_formatter.h" @@ -27,7 +26,7 @@ class AddressFormLabelFormatter : public LabelFormatter { ~AddressFormLabelFormatter() override; - base::string16 GetLabelForProfile( + std::u16string GetLabelForProfile( const AutofillProfile& profile, FieldTypeGroup focused_group) const override; diff --git a/chromium/components/autofill/core/browser/ui/address_form_label_formatter_unittest.cc b/chromium/components/autofill/core/browser/ui/address_form_label_formatter_unittest.cc index 3315629512b..c77fd7f0888 100644 --- a/chromium/components/autofill/core/browser/ui/address_form_label_formatter_unittest.cc +++ b/chromium/components/autofill/core/browser/ui/address_form_label_formatter_unittest.cc @@ -4,10 +4,10 @@ #include "components/autofill/core/browser/ui/address_form_label_formatter.h" +#include <string> #include <vector> #include "base/guid.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_test_utils.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" @@ -65,12 +65,10 @@ TEST(AddressFormLabelFormatterTest, const std::unique_ptr<LabelFormatter> formatter = LabelFormatter::Create( profiles, "en-US", ADDRESS_HOME_LINE1, GetFieldTypes()); - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(ConstructLabelLine( - {base::ASCIIToUTF16("John Kennedy"), - base::ASCIIToUTF16("Brookline, MA 02445")}), - base::ASCIIToUTF16("Hyannis, MA"), - base::ASCIIToUTF16("Paul Revere"), base::string16())); + EXPECT_THAT( + formatter->GetLabels(), + ElementsAre(ConstructLabelLine({u"John Kennedy", u"Brookline, MA 02445"}), + u"Hyannis, MA", u"Paul Revere", std::u16string())); } TEST(AddressFormLabelFormatterTest, @@ -104,10 +102,8 @@ TEST(AddressFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("John Kennedy"), - base::ASCIIToUTF16("333 Washington St")}), - base::ASCIIToUTF16("151 Irving Ave"), - base::ASCIIToUTF16("Paul Revere"), base::string16())); + ElementsAre(ConstructLabelLine({u"John Kennedy", u"333 Washington St"}), + u"151 Irving Ave", u"Paul Revere", std::u16string())); } TEST(AddressFormLabelFormatterTest, GetLabelsForUSProfilesAndFocusedName) { @@ -127,10 +123,9 @@ TEST(AddressFormLabelFormatterTest, GetLabelsForUSProfilesAndFocusedName) { const std::unique_ptr<LabelFormatter> formatter = LabelFormatter::Create(profiles, "en-US", NAME_FIRST, GetFieldTypes()); - EXPECT_THAT( - formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("333 Washington St, Brookline, MA 02445"), - base::ASCIIToUTF16("151 Irving Ave, Hyannis, MA 02601"))); + EXPECT_THAT(formatter->GetLabels(), + ElementsAre(u"333 Washington St, Brookline, MA 02445", + u"151 Irving Ave, Hyannis, MA 02601")); } TEST(AddressFormLabelFormatterTest, @@ -148,8 +143,7 @@ TEST(AddressFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), ElementsAre(ConstructLabelLine( - {base::ASCIIToUTF16("Tarsila Amaral"), - base::UTF8ToUTF16("Vila Mariana, São Paulo-SP, 04094-050")}))); + {u"Tarsila Amaral", u"Vila Mariana, São Paulo-SP, 04094-050"}))); } TEST(AddressFormLabelFormatterTest, @@ -166,8 +160,7 @@ TEST(AddressFormLabelFormatterTest, EXPECT_THAT(formatter->GetLabels(), ElementsAre(ConstructLabelLine( - {base::ASCIIToUTF16("Tarsila Amaral"), - base::UTF8ToUTF16("Av. Pedro Álvares Cabral, 1301")}))); + {u"Tarsila Amaral", u"Av. Pedro Álvares Cabral, 1301"}))); } TEST(AddressFormLabelFormatterTest, GetLabelsForBRProfilesAndFocusedName) { @@ -201,8 +194,7 @@ TEST(AddressFormLabelFormatterTest, GetLabelsForFormWithoutName) { ADDRESS_HOME_ZIP}); // Checks that the name does not appear in the labels. - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("Boston, MA 02113"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"Boston, MA 02113")); } } // namespace diff --git a/chromium/components/autofill/core/browser/ui/address_phone_form_label_formatter.cc b/chromium/components/autofill/core/browser/ui/address_phone_form_label_formatter.cc index e39cf7ec209..ba29fe760ba 100644 --- a/chromium/components/autofill/core/browser/ui/address_phone_form_label_formatter.cc +++ b/chromium/components/autofill/core/browser/ui/address_phone_form_label_formatter.cc @@ -24,7 +24,7 @@ AddressPhoneFormLabelFormatter::AddressPhoneFormLabelFormatter( AddressPhoneFormLabelFormatter::~AddressPhoneFormLabelFormatter() {} -base::string16 AddressPhoneFormLabelFormatter::GetLabelForProfile( +std::u16string AddressPhoneFormLabelFormatter::GetLabelForProfile( const AutofillProfile& profile, FieldTypeGroup focused_group) const { return focused_group == FieldTypeGroup::kAddressHome && @@ -40,11 +40,11 @@ base::string16 AddressPhoneFormLabelFormatter::GetLabelForProfile( // Note that the order--name, phone, and address--in which parts of the label // are added ensures that the label is formatted correctly for |focused_group|, // |focused_field_type_| and for this kind of formatter. -base::string16 AddressPhoneFormLabelFormatter:: +std::u16string AddressPhoneFormLabelFormatter:: GetLabelForProfileOnFocusedNamePhoneOrStreetAddress( const AutofillProfile& profile, FieldTypeGroup focused_group) const { - std::vector<base::string16> label_parts; + std::vector<std::u16string> label_parts; if (focused_group != FieldTypeGroup::kName && data_util::ContainsName(groups())) { AddLabelPartIfNotEmpty( diff --git a/chromium/components/autofill/core/browser/ui/address_phone_form_label_formatter.h b/chromium/components/autofill/core/browser/ui/address_phone_form_label_formatter.h index e4dba69bcff..2b2a4977c1b 100644 --- a/chromium/components/autofill/core/browser/ui/address_phone_form_label_formatter.h +++ b/chromium/components/autofill/core/browser/ui/address_phone_form_label_formatter.h @@ -8,7 +8,6 @@ #include <string> #include <vector> -#include "base/strings/string16.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" #include "components/autofill/core/browser/field_types.h" #include "components/autofill/core/browser/ui/label_formatter.h" @@ -28,7 +27,7 @@ class AddressPhoneFormLabelFormatter : public LabelFormatter { ~AddressPhoneFormLabelFormatter() override; - base::string16 GetLabelForProfile( + std::u16string GetLabelForProfile( const AutofillProfile& profile, FieldTypeGroup focused_group) const override; @@ -36,7 +35,7 @@ class AddressPhoneFormLabelFormatter : public LabelFormatter { // Returns a label to show the user when |focused_field_type_| is a type // other than a non-street-address field type. For example, // |focused_field_type_| could be first name, address line 1, or phone number. - base::string16 GetLabelForProfileOnFocusedNamePhoneOrStreetAddress( + std::u16string GetLabelForProfileOnFocusedNamePhoneOrStreetAddress( const AutofillProfile& profile, FieldTypeGroup focused_group) const; diff --git a/chromium/components/autofill/core/browser/ui/address_phone_form_label_formatter_unittest.cc b/chromium/components/autofill/core/browser/ui/address_phone_form_label_formatter_unittest.cc index 1804a01cb79..fd0569e4c3a 100644 --- a/chromium/components/autofill/core/browser/ui/address_phone_form_label_formatter_unittest.cc +++ b/chromium/components/autofill/core/browser/ui/address_phone_form_label_formatter_unittest.cc @@ -9,7 +9,6 @@ #include <vector> #include "base/guid.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_test_utils.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" @@ -66,10 +65,8 @@ TEST(AddressPhoneFormLabelFormatterTest, GetLabelsForUSProfilesAndFocusedName) { EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("(617) 730-2000"), - base::ASCIIToUTF16("333 Washington St")}), - base::ASCIIToUTF16("151 Irving Ave"), - base::ASCIIToUTF16("(617) 523-2338"), base::string16())); + ElementsAre(ConstructLabelLine({u"(617) 730-2000", u"333 Washington St"}), + u"151 Irving Ave", u"(617) 523-2338", std::u16string())); } TEST(AddressPhoneFormLabelFormatterTest, @@ -103,10 +100,8 @@ TEST(AddressPhoneFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("John F Kennedy"), - base::ASCIIToUTF16("(617) 730-2000")}), - base::ASCIIToUTF16("Jackie Kennedy"), - base::ASCIIToUTF16("(617) 523-2338"), base::string16())); + ElementsAre(ConstructLabelLine({u"John F Kennedy", u"(617) 730-2000"}), + u"Jackie Kennedy", u"(617) 523-2338", std::u16string())); } TEST(AddressPhoneFormLabelFormatterTest, @@ -140,10 +135,8 @@ TEST(AddressPhoneFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("333 Washington St"), - base::ASCIIToUTF16("(617) 730-2000")}), - base::ASCIIToUTF16("151 Irving Ave"), - base::ASCIIToUTF16("(617) 523-2338"), base::string16())); + ElementsAre(ConstructLabelLine({u"333 Washington St", u"(617) 730-2000"}), + u"151 Irving Ave", u"(617) 523-2338", std::u16string())); } TEST(AddressPhoneFormLabelFormatterTest, @@ -177,11 +170,9 @@ TEST(AddressPhoneFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("John F Kennedy"), - base::ASCIIToUTF16("333 Washington St")}), - base::ASCIIToUTF16("Jackie Kennedy"), - base::ASCIIToUTF16("Paul Revere House, 19 North Square"), - base::string16())); + ElementsAre(ConstructLabelLine({u"John F Kennedy", u"333 Washington St"}), + u"Jackie Kennedy", u"Paul Revere House, 19 North Square", + std::u16string())); } TEST(AddressPhoneFormLabelFormatterTest, GetLabelsForBRProfilesAndFocusedName) { @@ -206,11 +197,9 @@ TEST(AddressPhoneFormLabelFormatterTest, GetLabelsForBRProfilesAndFocusedName) { EXPECT_THAT( formatter->GetLabels(), ElementsAre(ConstructLabelLine( - {base::ASCIIToUTF16("(11) 2648-0254"), - base::UTF8ToUTF16("Av. Pedro Álvares Cabral, 1301")}), + {u"(11) 2648-0254", u"Av. Pedro Álvares Cabral, 1301"}), ConstructLabelLine( - {base::ASCIIToUTF16("(21) 98765-0000"), - base::ASCIIToUTF16("Estr. Dona Castorina, 110")}))); + {u"(21) 98765-0000", u"Estr. Dona Castorina, 110"}))); } TEST(AddressPhoneFormLabelFormatterTest, @@ -235,10 +224,8 @@ TEST(AddressPhoneFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("Tarsila do Amaral"), - base::ASCIIToUTF16("(11) 2648-0254")}), - ConstructLabelLine({base::ASCIIToUTF16("Artur Avila"), - base::ASCIIToUTF16("(21) 98765-0000")}))); + ElementsAre(ConstructLabelLine({u"Tarsila do Amaral", u"(11) 2648-0254"}), + ConstructLabelLine({u"Artur Avila", u"(21) 98765-0000"}))); } TEST(AddressPhoneFormLabelFormatterTest, @@ -261,14 +248,11 @@ TEST(AddressPhoneFormLabelFormatterTest, const std::unique_ptr<LabelFormatter> formatter = LabelFormatter::Create( profiles, "pt-BR", ADDRESS_HOME_ZIP, GetFieldTypes()); - EXPECT_THAT( - formatter->GetLabels(), - ElementsAre( - ConstructLabelLine( - {base::UTF8ToUTF16("Av. Pedro Álvares Cabral, 1301"), - base::ASCIIToUTF16("(11) 2648-0254")}), - ConstructLabelLine({base::ASCIIToUTF16("Estr. Dona Castorina, 110"), - base::ASCIIToUTF16("(21) 98765-0000")}))); + EXPECT_THAT(formatter->GetLabels(), + ElementsAre(ConstructLabelLine({u"Av. Pedro Álvares Cabral, 1301", + u"(11) 2648-0254"}), + ConstructLabelLine({u"Estr. Dona Castorina, 110", + u"(21) 98765-0000"}))); } TEST(AddressPhoneFormLabelFormatterTest, @@ -293,12 +277,10 @@ TEST(AddressPhoneFormLabelFormatterTest, EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine( - {base::ASCIIToUTF16("Tarsila do Amaral"), - base::UTF8ToUTF16("Av. Pedro Álvares Cabral, 1301")}), - ConstructLabelLine( - {base::ASCIIToUTF16("Artur Avila"), - base::ASCIIToUTF16("Estr. Dona Castorina, 110")}))); + ElementsAre( + ConstructLabelLine( + {u"Tarsila do Amaral", u"Av. Pedro Álvares Cabral, 1301"}), + ConstructLabelLine({u"Artur Avila", u"Estr. Dona Castorina, 110"}))); } TEST(AddressPhoneFormLabelFormatterTest, @@ -315,10 +297,8 @@ TEST(AddressPhoneFormLabelFormatterTest, {NAME_FULL, PHONE_HOME_WHOLE_NUMBER, ADDRESS_HOME_ZIP}); // Checks that only address fields in the form are shown in the label. - EXPECT_THAT( - formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("John F Kennedy"), - base::ASCIIToUTF16("02445")}))); + EXPECT_THAT(formatter->GetLabels(), + ElementsAre(ConstructLabelLine({u"John F Kennedy", u"02445"}))); } TEST(AddressPhoneFormLabelFormatterTest, GetLabelsForFormWithoutName) { @@ -334,8 +314,7 @@ TEST(AddressPhoneFormLabelFormatterTest, GetLabelsForFormWithoutName) { {ADDRESS_BILLING_LINE1, ADDRESS_BILLING_ZIP, PHONE_HOME_WHOLE_NUMBER}); // Checks that the name does not appear in the labels. - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("(617) 523-2338"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"(617) 523-2338")); } } // namespace diff --git a/chromium/components/autofill/core/browser/ui/autofill_popup_delegate.h b/chromium/components/autofill/core/browser/ui/autofill_popup_delegate.h index c51ad87c887..1b5931c83a9 100644 --- a/chromium/components/autofill/core/browser/ui/autofill_popup_delegate.h +++ b/chromium/components/autofill/core/browser/ui/autofill_popup_delegate.h @@ -5,8 +5,9 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_UI_AUTOFILL_POPUP_DELEGATE_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_AUTOFILL_POPUP_DELEGATE_H_ +#include <string> + #include "base/callback_forward.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/ui/popup_types.h" namespace autofill { @@ -27,24 +28,24 @@ class AutofillPopupDelegate { // Called when the autofill suggestion indicated by |identifier| has been // temporarily selected (e.g., hovered). - virtual void DidSelectSuggestion(const base::string16& value, + virtual void DidSelectSuggestion(const std::u16string& value, int identifier) = 0; // Inform the delegate that a row in the popup has been chosen. - virtual void DidAcceptSuggestion(const base::string16& value, + virtual void DidAcceptSuggestion(const std::u16string& value, int identifier, int position) = 0; // Returns whether the given value can be deleted, and if true, // fills out |title| and |body|. - virtual bool GetDeletionConfirmationText(const base::string16& value, + virtual bool GetDeletionConfirmationText(const std::u16string& value, int identifier, - base::string16* title, - base::string16* body) = 0; + std::u16string* title, + std::u16string* body) = 0; // Delete the described suggestion. Returns true if something was deleted, // or false if deletion is not allowed. - virtual bool RemoveSuggestion(const base::string16& value, + virtual bool RemoveSuggestion(const std::u16string& value, int identifier) = 0; // Informs the delegate that the Autofill previewed form should be cleared. diff --git a/chromium/components/autofill/core/browser/ui/contact_form_label_formatter.cc b/chromium/components/autofill/core/browser/ui/contact_form_label_formatter.cc index 90fbf0c7033..0fec69376d7 100644 --- a/chromium/components/autofill/core/browser/ui/contact_form_label_formatter.cc +++ b/chromium/components/autofill/core/browser/ui/contact_form_label_formatter.cc @@ -26,10 +26,10 @@ ContactFormLabelFormatter::~ContactFormLabelFormatter() {} // Note that the order--name, phone, and email--in which parts of the label // are possibly added ensures that the label is formatted correctly for // |focused_group| and for this kind of formatter. -base::string16 ContactFormLabelFormatter::GetLabelForProfile( +std::u16string ContactFormLabelFormatter::GetLabelForProfile( const AutofillProfile& profile, FieldTypeGroup focused_group) const { - std::vector<base::string16> label_parts; + std::vector<std::u16string> label_parts; if (focused_group != FieldTypeGroup::kName && data_util::ContainsName(groups())) { AddLabelPartIfNotEmpty( @@ -48,18 +48,18 @@ base::string16 ContactFormLabelFormatter::GetLabelForProfile( return ConstructLabelLine(label_parts); } -base::string16 ContactFormLabelFormatter::MaybeGetEmail( +std::u16string ContactFormLabelFormatter::MaybeGetEmail( const AutofillProfile& profile) const { return data_util::ContainsEmail(groups()) ? GetLabelEmail(profile, app_locale()) - : base::string16(); + : std::u16string(); } -base::string16 ContactFormLabelFormatter::MaybeGetPhone( +std::u16string ContactFormLabelFormatter::MaybeGetPhone( const AutofillProfile& profile) const { return data_util::ContainsPhone(groups()) ? GetLabelPhone(profile, app_locale()) - : base::string16(); + : std::u16string(); } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/ui/contact_form_label_formatter.h b/chromium/components/autofill/core/browser/ui/contact_form_label_formatter.h index cc06181a782..3bfee6353fe 100644 --- a/chromium/components/autofill/core/browser/ui/contact_form_label_formatter.h +++ b/chromium/components/autofill/core/browser/ui/contact_form_label_formatter.h @@ -8,7 +8,6 @@ #include <string> #include <vector> -#include "base/strings/string16.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" #include "components/autofill/core/browser/field_types.h" #include "components/autofill/core/browser/ui/label_formatter.h" @@ -27,18 +26,18 @@ class ContactFormLabelFormatter : public LabelFormatter { ~ContactFormLabelFormatter() override; - base::string16 GetLabelForProfile( + std::u16string GetLabelForProfile( const AutofillProfile& profile, FieldTypeGroup focused_group) const override; private: // Returns |profile|'s email address if |profile| has a valid email address // and if this formatter's associated form has an email field. - base::string16 MaybeGetEmail(const AutofillProfile& profile) const; + std::u16string MaybeGetEmail(const AutofillProfile& profile) const; // Returns |profile|'s phone number if |profile| has a phone number and if // this formatter's associated form has a phone field. - base::string16 MaybeGetPhone(const AutofillProfile& profile) const; + std::u16string MaybeGetPhone(const AutofillProfile& profile) const; }; } // namespace autofill diff --git a/chromium/components/autofill/core/browser/ui/contact_form_label_formatter_unittest.cc b/chromium/components/autofill/core/browser/ui/contact_form_label_formatter_unittest.cc index d84c1e7a8ba..8c4104c6d9c 100644 --- a/chromium/components/autofill/core/browser/ui/contact_form_label_formatter_unittest.cc +++ b/chromium/components/autofill/core/browser/ui/contact_form_label_formatter_unittest.cc @@ -9,7 +9,6 @@ #include <vector> #include "base/guid.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_test_utils.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" @@ -65,10 +64,8 @@ TEST(ContactFormLabelFormatterTest, GetLabelsForUSProfilesAndFocusedName) { EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("(617) 730-2000"), - base::ASCIIToUTF16("jfk@gmail.com")}), - base::ASCIIToUTF16("jackie@outlook.com"), - base::ASCIIToUTF16("(617) 523-2338"), base::string16())); + ElementsAre(ConstructLabelLine({u"(617) 730-2000", u"jfk@gmail.com"}), + u"jackie@outlook.com", u"(617) 523-2338", std::u16string())); } TEST(ContactFormLabelFormatterTest, GetLabelsForUSProfilesAndFocusedEmail) { @@ -101,12 +98,10 @@ TEST(ContactFormLabelFormatterTest, GetLabelsForUSProfilesAndFocusedEmail) { EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("John Kennedy"), - base::ASCIIToUTF16("(617) 730-2000")}), - base::ASCIIToUTF16("Jackie Kennedy"), - ConstructLabelLine({base::ASCIIToUTF16("Paul Revere"), - base::ASCIIToUTF16("(617) 523-2338")}), - base::string16())); + ElementsAre(ConstructLabelLine({u"John Kennedy", u"(617) 730-2000"}), + u"Jackie Kennedy", + ConstructLabelLine({u"Paul Revere", u"(617) 523-2338"}), + std::u16string())); } TEST(ContactFormLabelFormatterTest, GetLabelsForUSProfilesAndFocusedPhone) { @@ -141,11 +136,9 @@ TEST(ContactFormLabelFormatterTest, GetLabelsForUSProfilesAndFocusedPhone) { EXPECT_THAT( formatter->GetLabels(), ElementsAre( - ConstructLabelLine({base::ASCIIToUTF16("John Kennedy"), - base::ASCIIToUTF16("jfk@gmail.com")}), - ConstructLabelLine({base::ASCIIToUTF16("Jackie Kennedy"), - base::ASCIIToUTF16("jackie@outlook.com")}), - base::ASCIIToUTF16("Paul Revere"), base::string16())); + ConstructLabelLine({u"John Kennedy", u"jfk@gmail.com"}), + ConstructLabelLine({u"Jackie Kennedy", u"jackie@outlook.com"}), + u"Paul Revere", std::u16string())); } TEST(ContactFormLabelFormatterTest, GetLabelsForBRProfilesAndFocusedName) { @@ -170,10 +163,8 @@ TEST(ContactFormLabelFormatterTest, GetLabelsForBRProfilesAndFocusedName) { EXPECT_THAT( formatter->GetLabels(), ElementsAre( - ConstructLabelLine({base::ASCIIToUTF16("(11) 2648-0254"), - base::ASCIIToUTF16("tarsila@aol.com")}), - ConstructLabelLine({base::ASCIIToUTF16("(21) 98765-0000"), - base::ASCIIToUTF16("aavila@uol.com.br")}))); + ConstructLabelLine({u"(11) 2648-0254", u"tarsila@aol.com"}), + ConstructLabelLine({u"(21) 98765-0000", u"aavila@uol.com.br"}))); } TEST(ContactFormLabelFormatterTest, GetLabelsForBRProfilesAndFocusedEmail) { @@ -197,10 +188,8 @@ TEST(ContactFormLabelFormatterTest, GetLabelsForBRProfilesAndFocusedEmail) { EXPECT_THAT( formatter->GetLabels(), - ElementsAre(ConstructLabelLine({base::ASCIIToUTF16("Tarsila Amaral"), - base::ASCIIToUTF16("(11) 2648-0254")}), - ConstructLabelLine({base::ASCIIToUTF16("Artur Avila"), - base::ASCIIToUTF16("(21) 98765-0000")}))); + ElementsAre(ConstructLabelLine({u"Tarsila Amaral", u"(11) 2648-0254"}), + ConstructLabelLine({u"Artur Avila", u"(21) 98765-0000"}))); } TEST(ContactFormLabelFormatterTest, GetLabelsForBRProfilesAndFocusedPhone) { @@ -225,11 +214,8 @@ TEST(ContactFormLabelFormatterTest, GetLabelsForBRProfilesAndFocusedPhone) { EXPECT_THAT( formatter->GetLabels(), - ElementsAre( - ConstructLabelLine({base::ASCIIToUTF16("Tarsila Amaral"), - base::ASCIIToUTF16("tarsila@aol.com")}), - ConstructLabelLine({base::ASCIIToUTF16("Artur Avila"), - base::ASCIIToUTF16("aavila@uol.com.br")}))); + ElementsAre(ConstructLabelLine({u"Tarsila Amaral", u"tarsila@aol.com"}), + ConstructLabelLine({u"Artur Avila", u"aavila@uol.com.br"}))); } TEST(ContactFormLabelFormatterTest, GetLabelsForNameAndPhoneWithFocusedName) { @@ -246,8 +232,7 @@ TEST(ContactFormLabelFormatterTest, GetLabelsForNameAndPhoneWithFocusedName) { // Checks that the email address is excluded when the form does not contain an // email field. - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("(617) 730-2000"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"(617) 730-2000")); } TEST(ContactFormLabelFormatterTest, GetLabelsForNameAndPhoneWithFocusedPhone) { @@ -264,8 +249,7 @@ TEST(ContactFormLabelFormatterTest, GetLabelsForNameAndPhoneWithFocusedPhone) { // Checks that the email address is excluded when the form does not contain an // email field. - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("John Kennedy"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"John Kennedy")); } TEST(ContactFormLabelFormatterTest, GetLabelsForNameAndEmailWithFocusedName) { @@ -281,8 +265,7 @@ TEST(ContactFormLabelFormatterTest, GetLabelsForNameAndEmailWithFocusedName) { // Checks that the phone number is excluded when the form does not contain a // phone field. - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("jfk@gmail.com"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"jfk@gmail.com")); } TEST(ContactFormLabelFormatterTest, GetLabelsForNameAndEmailWithFocusedEmail) { @@ -298,8 +281,7 @@ TEST(ContactFormLabelFormatterTest, GetLabelsForNameAndEmailWithFocusedEmail) { // Checks that the phone number is excluded when the form does not contain a // phone field. - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("John Kennedy"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"John Kennedy")); } TEST(ContactFormLabelFormatterTest, GetLabelsForFormWithoutName) { @@ -315,8 +297,7 @@ TEST(ContactFormLabelFormatterTest, GetLabelsForFormWithoutName) { {EMAIL_ADDRESS, PHONE_HOME_COUNTRY_CODE, PHONE_HOME_CITY_AND_NUMBER}); // Checks that the name does not appear in the labels. - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("sarah.revere@aol.com"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"sarah.revere@aol.com")); } } // namespace diff --git a/chromium/components/autofill/core/browser/ui/country_combobox_model.cc b/chromium/components/autofill/core/browser/ui/country_combobox_model.cc index 11bc1b1b670..2d36c2cb20d 100644 --- a/chromium/components/autofill/core/browser/ui/country_combobox_model.cc +++ b/chromium/components/autofill/core/browser/ui/country_combobox_model.cc @@ -79,14 +79,14 @@ int CountryComboboxModel::GetItemCount() const { return countries_.size(); } -base::string16 CountryComboboxModel::GetItemAt(int index) const { +std::u16string CountryComboboxModel::GetItemAt(int index) const { AutofillCountry* country = countries_[index].get(); if (country) return countries_[index]->name(); // The separator item. Implemented for platforms that don't yet support // IsItemSeparatorAt(). - return base::ASCIIToUTF16("---"); + return u"---"; } bool CountryComboboxModel::IsItemSeparatorAt(int index) const { diff --git a/chromium/components/autofill/core/browser/ui/country_combobox_model.h b/chromium/components/autofill/core/browser/ui/country_combobox_model.h index 712cab208f5..d7f3e3ec18f 100644 --- a/chromium/components/autofill/core/browser/ui/country_combobox_model.h +++ b/chromium/components/autofill/core/browser/ui/country_combobox_model.h @@ -36,7 +36,7 @@ class CountryComboboxModel : public ui::ComboboxModel { // ui::ComboboxModel implementation: int GetItemCount() const override; - base::string16 GetItemAt(int index) const override; + std::u16string GetItemAt(int index) const override; bool IsItemSeparatorAt(int index) const override; // The list of countries always has the default country at the top as well as diff --git a/chromium/components/autofill/core/browser/ui/label_formatter.cc b/chromium/components/autofill/core/browser/ui/label_formatter.cc index 3044f0f6685..5e3b6201f69 100644 --- a/chromium/components/autofill/core/browser/ui/label_formatter.cc +++ b/chromium/components/autofill/core/browser/ui/label_formatter.cc @@ -70,8 +70,8 @@ LabelFormatter::LabelFormatter(const std::vector<AutofillProfile*>& profiles, LabelFormatter::~LabelFormatter() = default; -std::vector<base::string16> LabelFormatter::GetLabels() const { - std::vector<base::string16> labels; +std::vector<std::u16string> LabelFormatter::GetLabels() const { + std::vector<std::u16string> labels; for (const AutofillProfile* profile : profiles_) { labels.push_back(GetLabelForProfile(*profile, GetFocusedNonBillingGroup())); } diff --git a/chromium/components/autofill/core/browser/ui/label_formatter.h b/chromium/components/autofill/core/browser/ui/label_formatter.h index ab19f4fc103..cf66bfb3a66 100644 --- a/chromium/components/autofill/core/browser/ui/label_formatter.h +++ b/chromium/components/autofill/core/browser/ui/label_formatter.h @@ -9,7 +9,6 @@ #include <string> #include <vector> -#include "base/strings/string16.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" #include "components/autofill/core/browser/field_types.h" @@ -31,7 +30,7 @@ class LabelFormatter { // Returns a collection of labels formed by extracting useful disambiguating // information from |profiles_|. - std::vector<base::string16> GetLabels() const; + std::vector<std::u16string> GetLabels() const; // Creates a form-specific LabelFormatter according to |field_types|. This // formatter has the ability to build labels with disambiguating information @@ -46,7 +45,7 @@ class LabelFormatter { // Returns a label to show the user. The elements of the label and their // ordering depend on the kind of LabelFormatter, the data in |profile|, // |focused_group|, and |focused_field_type_|. - virtual base::string16 GetLabelForProfile( + virtual std::u16string GetLabelForProfile( const AutofillProfile& profile, FieldTypeGroup focused_group) const = 0; diff --git a/chromium/components/autofill/core/browser/ui/label_formatter_utils.cc b/chromium/components/autofill/core/browser/ui/label_formatter_utils.cc index 36fb2647450..f7d0ced2e08 100644 --- a/chromium/components/autofill/core/browser/ui/label_formatter_utils.cc +++ b/chromium/components/autofill/core/browser/ui/label_formatter_utils.cc @@ -37,18 +37,18 @@ namespace { bool HaveSameData( const std::vector<AutofillProfile*>& profiles, const std::string& app_locale, - base::RepeatingCallback<base::string16(const AutofillProfile&, + base::RepeatingCallback<std::u16string(const AutofillProfile&, const std::string&)> get_data, - base::RepeatingCallback<bool(const base::string16& str1, - const base::string16& str2)> matches) { + base::RepeatingCallback<bool(const std::u16string& str1, + const std::u16string& str2)> matches) { if (profiles.size() <= 1) { return true; } - const base::string16 first_profile_data = + const std::u16string first_profile_data = get_data.Run(*profiles[0], app_locale); for (size_t i = 1; i < profiles.size(); ++i) { - const base::string16 current_profile_data = + const std::u16string current_profile_data = get_data.Run(*profiles[i], app_locale); if (!matches.Run(first_profile_data, current_profile_data)) { return false; @@ -59,26 +59,26 @@ bool HaveSameData( // Used to avoid having the same lambda in HaveSameEmailAddresses, // HaveSameFirstNames, HaveSameStreetAddresses. -bool Equals(const base::string16& str1, const base::string16& str2) { +bool Equals(const std::u16string& str1, const std::u16string& str2) { return str1 == str2; } } // namespace -void AddLabelPartIfNotEmpty(const base::string16& part, - std::vector<base::string16>* parts) { +void AddLabelPartIfNotEmpty(const std::u16string& part, + std::vector<std::u16string>* parts) { if (!part.empty()) { parts->push_back(part); } } -base::string16 ConstructLabelLine(const std::vector<base::string16>& parts) { +std::u16string ConstructLabelLine(const std::vector<std::u16string>& parts) { return base::JoinString(parts, l10n_util::GetStringUTF16( IDS_AUTOFILL_SUGGESTION_LABEL_SEPARATOR)); } -base::string16 ConstructMobileLabelLine( - const std::vector<base::string16>& parts) { +std::u16string ConstructMobileLabelLine( + const std::vector<std::u16string>& parts) { return base::JoinString( parts, l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_SUMMARY_SEPARATOR)); } @@ -167,7 +167,7 @@ AutofillProfile MakeTrimmedProfile(const AutofillProfile& profile, trimmed_profile.set_language_code(profile.language_code()); const AutofillType country_code_type(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE); - const base::string16 country_code = + const std::u16string country_code = profile.GetInfo(country_code_type, app_locale); trimmed_profile.SetInfo(country_code_type, country_code, app_locale); @@ -178,7 +178,7 @@ AutofillProfile MakeTrimmedProfile(const AutofillProfile& profile, return trimmed_profile; } -base::string16 GetLabelForFocusedAddress( +std::u16string GetLabelForFocusedAddress( ServerFieldType focused_field_type, bool form_has_street_address, const AutofillProfile& profile, @@ -189,7 +189,7 @@ base::string16 GetLabelForFocusedAddress( profile, app_locale, types); } -base::string16 GetLabelAddress(bool use_street_address, +std::u16string GetLabelAddress(bool use_street_address, const AutofillProfile& profile, const std::string& app_locale, const std::vector<ServerFieldType>& types) { @@ -202,7 +202,7 @@ base::string16 GetLabelAddress(bool use_street_address, profile, app_locale); } -base::string16 GetLabelNationalAddress( +std::u16string GetLabelNationalAddress( const std::vector<ServerFieldType>& types, const AutofillProfile& profile, const std::string& app_locale) { @@ -216,7 +216,7 @@ base::string16 GetLabelNationalAddress( return base::UTF8ToUTF16(address_line); } -base::string16 GetLabelStreetAddress(const std::vector<ServerFieldType>& types, +std::u16string GetLabelStreetAddress(const std::vector<ServerFieldType>& types, const AutofillProfile& profile, const std::string& app_locale) { std::unique_ptr<::i18n::addressinput::AddressData> address_data = @@ -229,13 +229,13 @@ base::string16 GetLabelStreetAddress(const std::vector<ServerFieldType>& types, return base::UTF8ToUTF16(address_line); } -base::string16 GetLabelForProfileOnFocusedNonStreetAddress( +std::u16string GetLabelForProfileOnFocusedNonStreetAddress( bool form_has_street_address, const AutofillProfile& profile, const std::string& app_locale, const std::vector<ServerFieldType>& types, - const base::string16& contact_info) { - std::vector<base::string16> label_parts; + const std::u16string& contact_info) { + std::vector<std::u16string> label_parts; AddLabelPartIfNotEmpty( GetLabelAddress(form_has_street_address, profile, app_locale, types), &label_parts); @@ -243,7 +243,7 @@ base::string16 GetLabelForProfileOnFocusedNonStreetAddress( return ConstructLabelLine(label_parts); } -base::string16 GetLabelName(const std::vector<ServerFieldType>& types, +std::u16string GetLabelName(const std::vector<ServerFieldType>& types, const AutofillProfile& profile, const std::string& app_locale) { bool has_first_name = false; @@ -268,11 +268,11 @@ base::string16 GetLabelName(const std::vector<ServerFieldType>& types, } if (has_first_name && has_last_name) { - std::vector<base::string16> name_parts; + std::vector<std::u16string> name_parts; AddLabelPartIfNotEmpty(GetLabelFirstName(profile, app_locale), &name_parts); AddLabelPartIfNotEmpty(profile.GetInfo(AutofillType(NAME_LAST), app_locale), &name_parts); - return base::JoinString(name_parts, base::ASCIIToUTF16(" ")); + return base::JoinString(name_parts, u" "); } if (has_first_name) { @@ -291,27 +291,27 @@ base::string16 GetLabelName(const std::vector<ServerFieldType>& types, return profile.GetInfo(AutofillType(type), app_locale); } } - return base::string16(); + return std::u16string(); } -base::string16 GetLabelFirstName(const AutofillProfile& profile, +std::u16string GetLabelFirstName(const AutofillProfile& profile, const std::string& app_locale) { return profile.GetInfo(AutofillType(NAME_FIRST), app_locale); } -base::string16 GetLabelEmail(const AutofillProfile& profile, +std::u16string GetLabelEmail(const AutofillProfile& profile, const std::string& app_locale) { - const base::string16 email = + const std::u16string email = profile.GetInfo(AutofillType(EMAIL_ADDRESS), app_locale); - return IsValidEmailAddress(email) ? email : base::string16(); + return IsValidEmailAddress(email) ? email : std::u16string(); } -base::string16 GetLabelPhone(const AutofillProfile& profile, +std::u16string GetLabelPhone(const AutofillProfile& profile, const std::string& app_locale) { const std::string unformatted_phone = base::UTF16ToUTF8( profile.GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), app_locale)); return unformatted_phone.empty() - ? base::string16() + ? std::u16string() : base::UTF8ToUTF16(i18n::FormatPhoneNationallyForDisplay( unformatted_phone, data_util::GetCountryCodeWithFallback(profile, app_locale))); @@ -346,8 +346,8 @@ bool HaveSamePhoneNumbers(const std::vector<AutofillProfile*>& profiles, const std::string& app_locale) { // Note that the same country code is used in all comparisons. auto equals = [](const std::string& country_code, - const std::string& app_locale, const base::string16& phone1, - const base::string16& phone2) -> bool { + const std::string& app_locale, const std::u16string& phone1, + const std::u16string& phone2) -> bool { return (phone1.empty() && phone2.empty()) || i18n::PhoneNumbersMatch(phone1, phone2, country_code, app_locale); }; diff --git a/chromium/components/autofill/core/browser/ui/label_formatter_utils.h b/chromium/components/autofill/core/browser/ui/label_formatter_utils.h index 14b33ac0139..806dd52fe03 100644 --- a/chromium/components/autofill/core/browser/ui/label_formatter_utils.h +++ b/chromium/components/autofill/core/browser/ui/label_formatter_utils.h @@ -9,25 +9,24 @@ #include <string> #include <vector> -#include "base/strings/string16.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" #include "components/autofill/core/browser/field_types.h" namespace autofill { // Adds |part| to the end of |parts| if |part| is not an empty string. -void AddLabelPartIfNotEmpty(const base::string16& part, - std::vector<base::string16>* parts); +void AddLabelPartIfNotEmpty(const std::u16string& part, + std::vector<std::u16string>* parts); // Returns the text to show to the user. If there is more than one element in // |parts|, then a separator, |IDS_AUTOFILL_SUGGESTION_LABEL_SEPARATOR|, is // inserted between them. -base::string16 ConstructLabelLine(const std::vector<base::string16>& parts); +std::u16string ConstructLabelLine(const std::vector<std::u16string>& parts); // Like ConstructLabelLine, but uses |IDS_AUTOFILL_ADDRESS_SUMMARY_SEPARATOR| // instead. -base::string16 ConstructMobileLabelLine( - const std::vector<base::string16>& parts); +std::u16string ConstructMobileLabelLine( + const std::vector<std::u16string>& parts); // Returns true if |type| is associated with an address, but not with a street // address. For example, if the given type is ADDRESS_HOME_ZIP, then true is @@ -77,7 +76,7 @@ AutofillProfile MakeTrimmedProfile(const AutofillProfile& profile, // field and if the state and zip code can be in the label, then MA 01852 is // returned. If there are no other non-street-address fields or if the data is // not present in |profile|, then an empty string is returned. -base::string16 GetLabelForFocusedAddress( +std::u16string GetLabelForFocusedAddress( ServerFieldType focused_field_type, bool form_has_street_address, const AutofillProfile& profile, @@ -90,53 +89,53 @@ base::string16 GetLabelForFocusedAddress( // If |use_street_address| is false and |profile| is associated with address // fields other than street addresses, then returns the non-street- // address-related data corresponding to |types|. -base::string16 GetLabelAddress(bool use_street_address, +std::u16string GetLabelAddress(bool use_street_address, const AutofillProfile& profile, const std::string& app_locale, const std::vector<ServerFieldType>& types); // Returns the national address associated with |profile|, e.g. // 24 Beacon St., Boston, MA 02133. -base::string16 GetLabelNationalAddress( +std::u16string GetLabelNationalAddress( const std::vector<ServerFieldType>& types, const AutofillProfile& profile, const std::string& app_locale); // Returns the street address associated with |profile|, e.g. 24 Beacon St. -base::string16 GetLabelStreetAddress(const std::vector<ServerFieldType>& types, +std::u16string GetLabelStreetAddress(const std::vector<ServerFieldType>& types, const AutofillProfile& profile, const std::string& app_locale); // Returns a label to show the user when |focused_field_type_| is not part of // a street address. For example, city and postal code are non-street-address // field types. -base::string16 GetLabelForProfileOnFocusedNonStreetAddress( +std::u16string GetLabelForProfileOnFocusedNonStreetAddress( bool form_has_street_address, const AutofillProfile& profile, const std::string& app_locale, const std::vector<ServerFieldType>& types, - const base::string16& contact_info); + const std::u16string& contact_info); // Returns a name that is (A) associated with |profile| and (B) found in // |types|; otherwise, returns an empty string. -base::string16 GetLabelName(const std::vector<ServerFieldType>& types, +std::u16string GetLabelName(const std::vector<ServerFieldType>& types, const AutofillProfile& profile, const std::string& app_locale); // Returns the first name associated with |profile|, if any; otherwise, returns // an empty string. -base::string16 GetLabelFirstName(const AutofillProfile& profile, +std::u16string GetLabelFirstName(const AutofillProfile& profile, const std::string& app_locale); // Returns the email address associated with |profile|, if any; otherwise, // returns an empty string. -base::string16 GetLabelEmail(const AutofillProfile& profile, +std::u16string GetLabelEmail(const AutofillProfile& profile, const std::string& app_locale); // Returns the phone number associated with |profile|, if any; otherwise, // returns an empty string. Phone numbers are given in |profile|'s country's // national format, if possible. -base::string16 GetLabelPhone(const AutofillProfile& profile, +std::u16string GetLabelPhone(const AutofillProfile& profile, const std::string& app_locale); // Each HaveSame* function below returns true if all |profiles| have the same diff --git a/chromium/components/autofill/core/browser/ui/label_formatter_utils_unittest.cc b/chromium/components/autofill/core/browser/ui/label_formatter_utils_unittest.cc index e5b6b66b9a0..649085b03ca 100644 --- a/chromium/components/autofill/core/browser/ui/label_formatter_utils_unittest.cc +++ b/chromium/components/autofill/core/browser/ui/label_formatter_utils_unittest.cc @@ -4,8 +4,9 @@ #include "components/autofill/core/browser/ui/label_formatter_utils.h" +#include <string> + #include "base/guid.h" -#include "base/strings/string16.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_test_utils.h" @@ -227,22 +228,18 @@ TEST(LabelFormatterUtilsTest, TEST(LabelFormatterUtilsTest, GetLabelName) { AutofillProfile profile = AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin); - profile.SetInfo(NAME_FULL, base::ASCIIToUTF16("Maria Margaretha Kirch"), - "de"); + profile.SetInfo(NAME_FULL, u"Maria Margaretha Kirch", "de"); profile.FinalizeAfterImport(); - EXPECT_EQ(base::ASCIIToUTF16("Maria Margaretha Kirch"), + EXPECT_EQ(u"Maria Margaretha Kirch", GetLabelName({NAME_SUFFIX, NAME_FULL}, profile, "de")); - EXPECT_EQ(base::ASCIIToUTF16("Maria Kirch"), + EXPECT_EQ(u"Maria Kirch", GetLabelName({NAME_SUFFIX, NAME_FIRST, NAME_LAST}, profile, "de")); - EXPECT_EQ(base::ASCIIToUTF16("Maria"), - GetLabelName({NAME_SUFFIX, NAME_FIRST}, profile, "de")); - EXPECT_EQ(base::ASCIIToUTF16("Kirch"), - GetLabelName({NAME_SUFFIX, NAME_LAST}, profile, "de")); - EXPECT_EQ(base::ASCIIToUTF16("Margaretha"), - GetLabelName({NAME_MIDDLE}, profile, "de")); - EXPECT_EQ(base::string16(), GetLabelName({EMPTY_TYPE}, profile, "de")); - EXPECT_EQ(base::string16(), GetLabelName({}, profile, "de")); + EXPECT_EQ(u"Maria", GetLabelName({NAME_SUFFIX, NAME_FIRST}, profile, "de")); + EXPECT_EQ(u"Kirch", GetLabelName({NAME_SUFFIX, NAME_LAST}, profile, "de")); + EXPECT_EQ(u"Margaretha", GetLabelName({NAME_MIDDLE}, profile, "de")); + EXPECT_EQ(std::u16string(), GetLabelName({EMPTY_TYPE}, profile, "de")); + EXPECT_EQ(std::u16string(), GetLabelName({}, profile, "de")); } } // namespace diff --git a/chromium/components/autofill/core/browser/ui/mobile_label_formatter.cc b/chromium/components/autofill/core/browser/ui/mobile_label_formatter.cc index f9f303009c9..09f00ce40b0 100644 --- a/chromium/components/autofill/core/browser/ui/mobile_label_formatter.cc +++ b/chromium/components/autofill/core/browser/ui/mobile_label_formatter.cc @@ -69,7 +69,7 @@ MobileLabelFormatter::MobileLabelFormatter( MobileLabelFormatter::~MobileLabelFormatter() = default; -base::string16 MobileLabelFormatter::GetLabelForProfile( +std::u16string MobileLabelFormatter::GetLabelForProfile( const AutofillProfile& profile, FieldTypeGroup focused_group) const { std::string label_variant = base::GetFieldTrialParamValueByFeature( @@ -84,14 +84,14 @@ base::string16 MobileLabelFormatter::GetLabelForProfile( } // An unknown parameter was received. NOTREACHED(); - return base::string16(); + return std::u16string(); } // The order in which pieces of data are considered--address, and then, if the // data is not the same across |profiles_|, phone number, email address, and // name--ensures that the label contains the most useful information given the // |focused_group| and the |focused_field_type_|. -base::string16 MobileLabelFormatter::GetLabelForShowOneVariant( +std::u16string MobileLabelFormatter::GetLabelForShowOneVariant( const AutofillProfile& profile, FieldTypeGroup focused_group) const { if (ShowLabelAddress(focused_group)) { @@ -125,7 +125,7 @@ base::string16 MobileLabelFormatter::GetLabelForShowOneVariant( // and email address--ensures that the label is formatted correctly for the // |focused_group|, the |focused_field_type_|, and the non-focused form fields // whose data is not the same across |profiles_|. -base::string16 MobileLabelFormatter::GetLabelForShowAllVariant( +std::u16string MobileLabelFormatter::GetLabelForShowAllVariant( const AutofillProfile& profile, FieldTypeGroup focused_group) const { if (!(could_show_email_ || could_show_name_ || @@ -137,7 +137,7 @@ base::string16 MobileLabelFormatter::GetLabelForShowAllVariant( return GetDefaultLabel(profile, focused_group); } - std::vector<base::string16> label_parts; + std::vector<std::u16string> label_parts; // TODO(crbug.com/961819): Maybe put name after address for some app locales. if (could_show_name_) { @@ -181,7 +181,7 @@ base::string16 MobileLabelFormatter::GetLabelForShowAllVariant( // The order in which pieces of data are considered--address, phone number, // email address, and name--ensures that the label contains the most useful // information given the |focused_group| and the |focused_field_type_|. -base::string16 MobileLabelFormatter::GetDefaultLabel( +std::u16string MobileLabelFormatter::GetDefaultLabel( const AutofillProfile& profile, FieldTypeGroup focused_group) const { if (ShowLabelAddress(focused_group)) { diff --git a/chromium/components/autofill/core/browser/ui/mobile_label_formatter.h b/chromium/components/autofill/core/browser/ui/mobile_label_formatter.h index f38aeeabed2..0c174dfec81 100644 --- a/chromium/components/autofill/core/browser/ui/mobile_label_formatter.h +++ b/chromium/components/autofill/core/browser/ui/mobile_label_formatter.h @@ -8,7 +8,6 @@ #include <string> #include <vector> -#include "base/strings/string16.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" #include "components/autofill/core/browser/field_types.h" #include "components/autofill/core/browser/ui/label_formatter.h" @@ -43,7 +42,7 @@ class MobileLabelFormatter : public LabelFormatter { ~MobileLabelFormatter() override; - base::string16 GetLabelForProfile( + std::u16string GetLabelForProfile( const AutofillProfile& profile, FieldTypeGroup focused_group) const override; @@ -61,7 +60,7 @@ class MobileLabelFormatter : public LabelFormatter { // and (C) this user is interacting with a form that has first name, last // name, and email address fields. If this user clicks on the first name // field, then the suggestion with Joe has an empty string as its label. - base::string16 GetLabelForShowOneVariant(const AutofillProfile& profile, + std::u16string GetLabelForShowOneVariant(const AutofillProfile& profile, FieldTypeGroup focused_group) const; // Returns a label for the kAutofillUseMobileLabelDisambiguation feature when @@ -73,7 +72,7 @@ class MobileLabelFormatter : public LabelFormatter { // // As explained in the comment for GetLabelForShowOneVariant, it is possible // for the label to be an empty string. - base::string16 GetLabelForShowAllVariant(const AutofillProfile& profile, + std::u16string GetLabelForShowAllVariant(const AutofillProfile& profile, FieldTypeGroup focused_group) const; // Returns a label with the most useful piece of data according to the @@ -82,7 +81,7 @@ class MobileLabelFormatter : public LabelFormatter { // It is possible for the label to be an empty string. This can happen when // |profile| is missing data corresponding to a field, e.g. a profile without // a phone number. - base::string16 GetDefaultLabel(const AutofillProfile& profile, + std::u16string GetDefaultLabel(const AutofillProfile& profile, FieldTypeGroup focused_group) const; // Returns true if the label should be an address part, e.g. 4 Oak Rd or diff --git a/chromium/components/autofill/core/browser/ui/mobile_label_formatter_unittest.cc b/chromium/components/autofill/core/browser/ui/mobile_label_formatter_unittest.cc index be4dc7d227c..62d377d0a4e 100644 --- a/chromium/components/autofill/core/browser/ui/mobile_label_formatter_unittest.cc +++ b/chromium/components/autofill/core/browser/ui/mobile_label_formatter_unittest.cc @@ -9,7 +9,6 @@ #include <vector> #include "base/guid.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_test_utils.h" @@ -114,9 +113,8 @@ TEST(MobileLabelFormatterTest, GetLabelsForUnfocusedAddress_ShowOne) { std::unique_ptr<LabelFormatter> formatter = LabelFormatter::Create( profiles, "en-US", NAME_FIRST, GetAddressOnlyFieldTypes()); EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("address1A, address2A"), - base::ASCIIToUTF16("address1B, address2B"), - base::string16())); + ElementsAre(u"address1A, address2A", u"address1B, address2B", + std::u16string())); // Tests that the non street address is shown when the form's only address // fields are non street address fields and the user is not focused on any of @@ -124,16 +122,14 @@ TEST(MobileLabelFormatterTest, GetLabelsForUnfocusedAddress_ShowOne) { formatter = LabelFormatter::Create(profiles, "en-US", NAME_FIRST, {NAME_FIRST, NAME_LAST, ADDRESS_HOME_ZIP}); EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("02113"), - base::ASCIIToUTF16("12224"), base::string16())); + ElementsAre(u"02113", u"12224", std::u16string())); // Like the previous test, but without name. formatter = LabelFormatter::Create( profiles, "en-US", EMAIL_ADDRESS, {ADDRESS_HOME_CITY, ADDRESS_HOME_STATE, EMAIL_ADDRESS}); EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("cityA, MA"), - base::ASCIIToUTF16("cityB, NY"), base::string16())); + ElementsAre(u"cityA, MA", u"cityB, NY", std::u16string())); // Tests that addresses are not shown when the form does not contain an // address field. @@ -141,8 +137,7 @@ TEST(MobileLabelFormatterTest, GetLabelsForUnfocusedAddress_ShowOne) { GetContactOnlyFieldTypes()); EXPECT_THAT( formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("(617) 666-0000"), - base::ASCIIToUTF16("(518) 555-0000"), base::string16())); + ElementsAre(u"(617) 666-0000", u"(518) 555-0000", std::u16string())); } TEST(MobileLabelFormatterTest, @@ -165,17 +160,14 @@ TEST(MobileLabelFormatterTest, std::unique_ptr<LabelFormatter> formatter = LabelFormatter::Create( profiles, "en-US", ADDRESS_HOME_ZIP, GetAddressPlusContactFieldTypes()); EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("address1A, address2A"), - base::ASCIIToUTF16("address1B, address2B"))); + ElementsAre(u"address1A, address2A", u"address1B, address2B")); // Tests that a non street address is shown when a form contains only // non focused street address fields and a focused non street address. formatter = LabelFormatter::Create( profiles, "en-US", ADDRESS_HOME_ZIP, {ADDRESS_HOME_CITY, ADDRESS_HOME_STATE, ADDRESS_HOME_ZIP}); - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("cityA, MA"), - base::ASCIIToUTF16("cityB, NY"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"cityA, MA", u"cityB, NY")); // Tests that a non street address is not shown when a form contains // non focused street address fields and another kind of field and also has a @@ -184,47 +176,41 @@ TEST(MobileLabelFormatterTest, profiles, "en-US", ADDRESS_HOME_CITY, {ADDRESS_HOME_CITY, ADDRESS_HOME_STATE, EMAIL_ADDRESS}); EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("emailA@gmail.com"), - base::ASCIIToUTF16("emailB@gmail.com"))); + ElementsAre(u"emailA@gmail.com", u"emailB@gmail.com")); // Tests that a phone number is shown when the address cannot be shown and // there are different phone numbers. profileB = GetProfileA(); - profileB.SetInfo(PHONE_HOME_WHOLE_NUMBER, base::ASCIIToUTF16("15185550000"), - "en-US"); + profileB.SetInfo(PHONE_HOME_WHOLE_NUMBER, u"15185550000", "en-US"); profiles = {&profileA, &profileB}; formatter = LabelFormatter::Create(profiles, "en-US", ADDRESS_HOME_LINE1, GetAddressPlusContactFieldTypes()); EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("(617) 666-0000"), - base::ASCIIToUTF16("(518) 555-0000"))); + ElementsAre(u"(617) 666-0000", u"(518) 555-0000")); // Tests that an email address is shown when the address cannot be shown and // there are different email addresses. profileB = GetProfileA(); - profileB.SetInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("emailB@gmail.com"), - "en-US"); + profileB.SetInfo(EMAIL_ADDRESS, u"emailB@gmail.com", "en-US"); profiles = {&profileA, &profileB}; formatter = LabelFormatter::Create(profiles, "en-US", ADDRESS_HOME_LINE1, GetAddressPlusContactFieldTypes()); EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("emailA@gmail.com"), - base::ASCIIToUTF16("emailB@gmail.com"))); + ElementsAre(u"emailA@gmail.com", u"emailB@gmail.com")); // Tests that a name is shown when the address cannot be shown and there are // different names. profileB = GetProfileA(); - profileB.SetInfo(NAME_FIRST, base::ASCIIToUTF16("firstB"), "en-US"); - profileB.SetInfo(NAME_LAST, base::ASCIIToUTF16("lastB"), "en-US"); + profileB.SetInfo(NAME_FIRST, u"firstB", "en-US"); + profileB.SetInfo(NAME_LAST, u"lastB", "en-US"); profiles = {&profileA, &profileB}; formatter = LabelFormatter::Create(profiles, "en-US", ADDRESS_HOME_LINE1, GetAddressPlusContactFieldTypes()); EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("firstA lastA"), - base::ASCIIToUTF16("firstB lastB"))); + ElementsAre(u"firstA lastA", u"firstB lastB")); // Tests that a phone number is shown when the address cannot be shown, when // profiles have the same data for unfocused form fields, and when the form @@ -234,8 +220,7 @@ TEST(MobileLabelFormatterTest, formatter = LabelFormatter::Create(profiles, "en-US", ADDRESS_HOME_LINE1, GetAddressPlusContactFieldTypes()); EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("(617) 666-0000"), - base::ASCIIToUTF16("(617) 666-0000"))); + ElementsAre(u"(617) 666-0000", u"(617) 666-0000")); // Tests that an email address is shown when the address cannot be shown, when // profiles have the same data for unfocused form fields, and when the form @@ -245,8 +230,7 @@ TEST(MobileLabelFormatterTest, formatter = LabelFormatter::Create(profiles, "en-US", ADDRESS_HOME_LINE1, GetAddressPlusEmailFieldTypes()); EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("emailA@gmail.com"), - base::ASCIIToUTF16("emailA@gmail.com"))); + ElementsAre(u"emailA@gmail.com", u"emailA@gmail.com")); // Tests that a name is shown when the address cannot be shown, when profiles // have the same data for unfocused form fields, and when the form does not @@ -256,8 +240,7 @@ TEST(MobileLabelFormatterTest, formatter = LabelFormatter::Create(profiles, "en-US", ADDRESS_HOME_LINE1, GetAddressOnlyFieldTypes()); EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("firstA lastA"), - base::ASCIIToUTF16("firstA lastA"))); + ElementsAre(u"firstA lastA", u"firstA lastA")); } TEST(MobileLabelFormatterTest, @@ -278,24 +261,21 @@ TEST(MobileLabelFormatterTest, // most important piece cannot be shown. std::unique_ptr<LabelFormatter> formatter = LabelFormatter::Create( profiles, "en-US", ADDRESS_HOME_LINE1, GetAddressPlusContactFieldTypes()); - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("(617) 666-0000"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"(617) 666-0000")); // Tests that the third most important piece of data, email, is shown when // the form has an unfocused form field corresponding to this data and the // two most important pieces of data cannot be shown. formatter = LabelFormatter::Create(profiles, "en-US", ADDRESS_HOME_LINE1, GetAddressPlusEmailFieldTypes()); - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("emailA@gmail.com"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"emailA@gmail.com")); // Tests that the least important piece of data, name, is shown when the form // has an unfocused form field corresponding to this data and the more // important pieces of data cannot be shown. formatter = LabelFormatter::Create(profiles, "en-US", ADDRESS_HOME_LINE1, GetAddressOnlyFieldTypes()); - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("firstA lastA"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"firstA lastA")); } TEST(MobileLabelFormatterTest, GetLabels_DistinctProfiles_ShowAll) { @@ -325,7 +305,7 @@ TEST(MobileLabelFormatterTest, GetLabels_DistinctProfiles_ShowAll) { "address1A, address2A, (617) 666-0000, emailA@gmail.com"), base::ASCIIToUTF16( "address1B, address2B, (518) 555-0000, emailB@gmail.com"), - base::string16())); + std::u16string())); // Like the previous test, but focuses on an address field rather than a name // field to check that the name is correctly added to the label. @@ -333,27 +313,22 @@ TEST(MobileLabelFormatterTest, GetLabels_DistinctProfiles_ShowAll) { GetAddressPlusContactFieldTypes()); EXPECT_THAT( formatter->GetLabels(), - ElementsAre( - base::ASCIIToUTF16("firstA, (617) 666-0000, emailA@gmail.com"), - base::ASCIIToUTF16("firstB, (518) 555-0000, emailB@gmail.com"), - base::ASCIIToUTF16("firstC"))); + ElementsAre(u"firstA, (617) 666-0000, emailA@gmail.com", + u"firstB, (518) 555-0000, emailB@gmail.com", u"firstC")); // Tests that unfocused data that is not the same across profiles is shown in // the label for forms with non street addresses and without street addresses. formatter = LabelFormatter::Create(profiles, "en-US", NAME_FIRST, {NAME_FIRST, NAME_LAST, ADDRESS_HOME_ZIP}); EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("02113"), - base::ASCIIToUTF16("12224"), base::string16())); + ElementsAre(u"02113", u"12224", std::u16string())); // Like the previous test, but focuses on an address field rather than a name // field to check that the name is correctly added to the label. formatter = LabelFormatter::Create(profiles, "en-US", ADDRESS_HOME_ZIP, {NAME_FIRST, NAME_LAST, ADDRESS_HOME_ZIP}); - EXPECT_THAT( - formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("firstA"), base::ASCIIToUTF16("firstB"), - base::ASCIIToUTF16("firstC"))); + EXPECT_THAT(formatter->GetLabels(), + ElementsAre(u"firstA", u"firstB", u"firstC")); // Tests that unfocused data that is not the same across profiles is shown in // the label for forms without addresses. @@ -361,18 +336,16 @@ TEST(MobileLabelFormatterTest, GetLabels_DistinctProfiles_ShowAll) { GetContactOnlyFieldTypes()); EXPECT_THAT( formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("(617) 666-0000, emailA@gmail.com"), - base::ASCIIToUTF16("(518) 555-0000, emailB@gmail.com"), - base::string16())); + ElementsAre(u"(617) 666-0000, emailA@gmail.com", + u"(518) 555-0000, emailB@gmail.com", std::u16string())); // Like the previous test, but focuses on a phone field rather than a name // field to check that the name is correctly added to the label. formatter = LabelFormatter::Create(profiles, "en-US", PHONE_HOME_WHOLE_NUMBER, GetContactOnlyFieldTypes()); EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("firstA, emailA@gmail.com"), - base::ASCIIToUTF16("firstB, emailB@gmail.com"), - base::ASCIIToUTF16("firstC"))); + ElementsAre(u"firstA, emailA@gmail.com", + u"firstB, emailB@gmail.com", u"firstC")); } TEST(MobileLabelFormatterTest, GetDefaultLabel_ShowAll) { @@ -391,30 +364,27 @@ TEST(MobileLabelFormatterTest, GetDefaultLabel_ShowAll) { // form has an unfocused form field corresponding to this data. std::unique_ptr<LabelFormatter> formatter = LabelFormatter::Create( profiles, "en-US", NAME_FIRST, GetAddressPlusContactFieldTypes()); - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("address1A, address2A"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"address1A, address2A")); // Tests that the most important piece of data, address, is shown when the // form has an unfocused form field corresponding to this data. formatter = LabelFormatter::Create(profiles, "en-US", NAME_FIRST, {NAME_FIRST, NAME_LAST, ADDRESS_HOME_ZIP}); - EXPECT_THAT(formatter->GetLabels(), ElementsAre(base::ASCIIToUTF16("02113"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"02113")); // Tests that the second most important piece of data, phone, is shown when // the form has an unfocused form field corresponding to this data and the // most important piece cannot be shown. formatter = LabelFormatter::Create(profiles, "en-US", ADDRESS_HOME_LINE1, GetAddressPlusContactFieldTypes()); - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("(617) 666-0000"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"(617) 666-0000")); // Tests that the third most important piece of data, email, is shown when // the form has an unfocused form field corresponding to this data and the // two more important pieces of data cannot be shown. formatter = LabelFormatter::Create(profiles, "en-US", PHONE_HOME_WHOLE_NUMBER, GetContactOnlyFieldTypes()); - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("emailA@gmail.com"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"emailA@gmail.com")); // Tests that the least important piece of data, name, is shown when // the form has an unfocused form field corresponding to this data and the @@ -422,16 +392,14 @@ TEST(MobileLabelFormatterTest, GetDefaultLabel_ShowAll) { formatter = LabelFormatter::Create(profiles, "en-US", PHONE_HOME_WHOLE_NUMBER, {NAME_FIRST, NAME_LAST, PHONE_HOME_WHOLE_NUMBER}); - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("firstA lastA"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"firstA lastA")); // Tests that a non street address is shown when a form contains only // non focused street address fields and a focused non street address. formatter = LabelFormatter::Create( profiles, "en-US", ADDRESS_HOME_ZIP, {ADDRESS_HOME_CITY, ADDRESS_HOME_STATE, ADDRESS_HOME_ZIP}); - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("cityA, MA"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"cityA, MA")); // Tests that a non street address is not shown when a form contains // non focused street address fields and another kind of field and also has a @@ -439,8 +407,7 @@ TEST(MobileLabelFormatterTest, GetDefaultLabel_ShowAll) { formatter = LabelFormatter::Create( profiles, "en-US", ADDRESS_HOME_CITY, {ADDRESS_HOME_CITY, ADDRESS_HOME_STATE, EMAIL_ADDRESS}); - EXPECT_THAT(formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16("emailA@gmail.com"))); + EXPECT_THAT(formatter->GetLabels(), ElementsAre(u"emailA@gmail.com")); } } // namespace diff --git a/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller.h b/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller.h index 5598240b3b7..f7902447eff 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller.h +++ b/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller.h @@ -6,10 +6,10 @@ #define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_CONTROLLER_H_ #include <memory> +#include <string> #include "base/callback.h" #include "base/macros.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/autofill_metrics.h" #include "components/autofill/core/browser/data_model/credit_card.h" @@ -22,20 +22,20 @@ class CardExpirationDateFixFlowController { virtual ~CardExpirationDateFixFlowController() {} // Interaction. - virtual void OnAccepted(const base::string16& month, - const base::string16& year) = 0; + virtual void OnAccepted(const std::u16string& month, + const std::u16string& year) = 0; virtual void OnDismissed() = 0; virtual void OnDialogClosed() = 0; // State. virtual int GetIconId() const = 0; - virtual base::string16 GetTitleText() const = 0; - virtual base::string16 GetSaveButtonLabel() const = 0; - virtual base::string16 GetCardLabel() const = 0; - virtual base::string16 GetCancelButtonLabel() const = 0; - virtual base::string16 GetInputLabel() const = 0; - virtual base::string16 GetDateSeparator() const = 0; - virtual base::string16 GetInvalidDateError() const = 0; + virtual std::u16string GetTitleText() const = 0; + virtual std::u16string GetSaveButtonLabel() const = 0; + virtual std::u16string GetCardLabel() const = 0; + virtual std::u16string GetCancelButtonLabel() const = 0; + virtual std::u16string GetInputLabel() const = 0; + virtual std::u16string GetDateSeparator() const = 0; + virtual std::u16string GetInvalidDateError() const = 0; }; } // namespace autofill diff --git a/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl.cc b/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl.cc index 84de5925de8..63a79f1b7c6 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl.cc +++ b/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl.cc @@ -36,7 +36,7 @@ CardExpirationDateFixFlowControllerImpl:: void CardExpirationDateFixFlowControllerImpl::Show( CardExpirationDateFixFlowView* card_expiration_date_fix_flow_view, const CreditCard& card, - base::OnceCallback<void(const base::string16&, const base::string16&)> + base::OnceCallback<void(const std::u16string&, const std::u16string&)> callback) { DCHECK(!callback.is_null()); DCHECK(card_expiration_date_fix_flow_view); @@ -55,8 +55,8 @@ void CardExpirationDateFixFlowControllerImpl::Show( } void CardExpirationDateFixFlowControllerImpl::OnAccepted( - const base::string16& month, - const base::string16& year) { + const std::u16string& month, + const std::u16string& year) { AutofillMetrics::LogExpirationDateFixFlowPromptEvent( AutofillMetrics::ExpirationDateFixFlowPromptEvent:: EXPIRATION_DATE_FIX_FLOW_PROMPT_ACCEPTED); @@ -83,37 +83,37 @@ int CardExpirationDateFixFlowControllerImpl::GetIconId() const { #endif } -base::string16 CardExpirationDateFixFlowControllerImpl::GetTitleText() const { +std::u16string CardExpirationDateFixFlowControllerImpl::GetTitleText() const { return l10n_util::GetStringUTF16( IDS_AUTOFILL_SAVE_CARD_UPDATE_EXPIRATION_DATE_TITLE); } -base::string16 CardExpirationDateFixFlowControllerImpl::GetSaveButtonLabel() +std::u16string CardExpirationDateFixFlowControllerImpl::GetSaveButtonLabel() const { return l10n_util::GetStringUTF16( IDS_AUTOFILL_FIX_FLOW_PROMPT_SAVE_CARD_LABEL); } -base::string16 CardExpirationDateFixFlowControllerImpl::GetCardLabel() const { +std::u16string CardExpirationDateFixFlowControllerImpl::GetCardLabel() const { return card_label_; } -base::string16 CardExpirationDateFixFlowControllerImpl::GetCancelButtonLabel() +std::u16string CardExpirationDateFixFlowControllerImpl::GetCancelButtonLabel() const { return l10n_util::GetStringUTF16(IDS_CANCEL); } -base::string16 CardExpirationDateFixFlowControllerImpl::GetInputLabel() const { +std::u16string CardExpirationDateFixFlowControllerImpl::GetInputLabel() const { return l10n_util::GetStringUTF16( IDS_AUTOFILL_SAVE_CARD_UPDATE_EXPIRATION_DATE_TOOLTIP); } -base::string16 CardExpirationDateFixFlowControllerImpl::GetDateSeparator() +std::u16string CardExpirationDateFixFlowControllerImpl::GetDateSeparator() const { return l10n_util::GetStringUTF16(IDS_AUTOFILL_EXPIRATION_DATE_SEPARATOR); } -base::string16 CardExpirationDateFixFlowControllerImpl::GetInvalidDateError() +std::u16string CardExpirationDateFixFlowControllerImpl::GetInvalidDateError() const { return l10n_util::GetStringUTF16( IDS_AUTOFILL_SAVE_CARD_UPDATE_EXPIRATION_DATE_ERROR_TRY_AGAIN); diff --git a/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl.h b/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl.h index 61c6c6120ad..18611ccc481 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl.h +++ b/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl.h @@ -6,10 +6,10 @@ #define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_CONTROLLER_IMPL_H_ #include <memory> +#include <string> #include "base/callback.h" #include "base/macros.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/autofill_metrics.h" #include "components/autofill/core/browser/data_model/credit_card.h" #include "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller.h" @@ -30,22 +30,22 @@ class CardExpirationDateFixFlowControllerImpl void Show(CardExpirationDateFixFlowView* card_expiration_date_fix_flow_view, const CreditCard& card, - base::OnceCallback<void(const base::string16&, - const base::string16&)> callback); + base::OnceCallback<void(const std::u16string&, + const std::u16string&)> callback); // CardExpirationDateFixFlowController implementation. - void OnAccepted(const base::string16& month, - const base::string16& year) override; + void OnAccepted(const std::u16string& month, + const std::u16string& year) override; void OnDismissed() override; void OnDialogClosed() override; int GetIconId() const override; - base::string16 GetTitleText() const override; - base::string16 GetSaveButtonLabel() const override; - base::string16 GetCardLabel() const override; - base::string16 GetCancelButtonLabel() const override; - base::string16 GetInputLabel() const override; - base::string16 GetDateSeparator() const override; - base::string16 GetInvalidDateError() const override; + std::u16string GetTitleText() const override; + std::u16string GetSaveButtonLabel() const override; + std::u16string GetCardLabel() const override; + std::u16string GetCancelButtonLabel() const override; + std::u16string GetInputLabel() const override; + std::u16string GetDateSeparator() const override; + std::u16string GetInvalidDateError() const override; private: // View that displays the fix flow prompt. @@ -53,7 +53,7 @@ class CardExpirationDateFixFlowControllerImpl // The callback to save the credit card to Google Payments once user accepts // fix flow. - base::OnceCallback<void(const base::string16&, const base::string16&)> + base::OnceCallback<void(const std::u16string&, const std::u16string&)> upload_save_card_callback_; // Whether the prompt was shown to the user. @@ -63,7 +63,7 @@ class CardExpirationDateFixFlowControllerImpl bool had_user_interaction_ = false; // Label of the card describing the network and the last four digits. - base::string16 card_label_; + std::u16string card_label_; DISALLOW_COPY_AND_ASSIGN(CardExpirationDateFixFlowControllerImpl); }; diff --git a/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl_unittest.cc b/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl_unittest.cc index 49a051467f7..7311e96d216 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl_unittest.cc +++ b/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_controller_impl_unittest.cc @@ -42,13 +42,13 @@ class CardExpirationDateFixFlowControllerImplGenericTest { std::unique_ptr<TestCardExpirationDateFixFlowView> test_card_expiration_date_fix_flow_view_; std::unique_ptr<CardExpirationDateFixFlowControllerImpl> controller_; - base::string16 accepted_month_; - base::string16 accepted_year_; + std::u16string accepted_month_; + std::u16string accepted_year_; base::WeakPtrFactory<CardExpirationDateFixFlowControllerImplGenericTest> weak_ptr_factory_{this}; private: - void OnAccepted(const base::string16& month, const base::string16& year) { + void OnAccepted(const std::u16string& month, const std::u16string& year) { accepted_month_ = month; accepted_year_ = year; } @@ -84,10 +84,10 @@ TEST_F(CardExpirationDateFixFlowControllerImplTest, LogShown) { TEST_F(CardExpirationDateFixFlowControllerImplTest, LogAccepted) { base::HistogramTester histogram_tester; ShowPrompt(); - controller_->OnAccepted(base::ASCIIToUTF16("11"), base::ASCIIToUTF16("30")); + controller_->OnAccepted(u"11", u"30"); - ASSERT_EQ(accepted_month_, base::ASCIIToUTF16("11")); - ASSERT_EQ(accepted_year_, base::ASCIIToUTF16("30")); + ASSERT_EQ(accepted_month_, u"11"); + ASSERT_EQ(accepted_year_, u"30"); histogram_tester.ExpectBucketCount( "Autofill.ExpirationDateFixFlowPrompt.Events", AutofillMetrics::ExpirationDateFixFlowPromptEvent:: @@ -109,7 +109,7 @@ TEST_F(CardExpirationDateFixFlowControllerImplTest, LogDismissed) { TEST_F(CardExpirationDateFixFlowControllerImplTest, CardIdentifierString) { CreditCard card = test::GetCreditCard(); - card.SetNickname(base::ASCIIToUTF16("nickname")); + card.SetNickname(u"nickname"); ShowPrompt(card); EXPECT_EQ(controller_->GetCardLabel(), diff --git a/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_view.h b/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_view.h index 90ac826b1e3..62ffd492f9a 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_view.h +++ b/chromium/components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_view.h @@ -5,8 +5,9 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_VIEW_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_EXPIRATION_DATE_FIX_FLOW_VIEW_H_ +#include <string> + #include "base/macros.h" -#include "base/strings/string16.h" namespace autofill { diff --git a/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller.h b/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller.h index 96d9faeb47f..382be67e765 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller.h +++ b/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller.h @@ -5,7 +5,8 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_NAME_FIX_FLOW_CONTROLLER_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_NAME_FIX_FLOW_CONTROLLER_H_ -#include "base/strings/string16.h" +#include <string> + namespace autofill { @@ -17,18 +18,18 @@ class CardNameFixFlowController { // Interaction. virtual void OnConfirmNameDialogClosed() = 0; - virtual void OnNameAccepted(const base::string16& name) = 0; + virtual void OnNameAccepted(const std::u16string& name) = 0; virtual void OnDismissed() = 0; // State. virtual int GetIconId() const = 0; - virtual base::string16 GetCancelButtonLabel() const = 0; - virtual base::string16 GetInferredCardholderName() const = 0; - virtual base::string16 GetInferredNameTooltipText() const = 0; - virtual base::string16 GetInputLabel() const = 0; - virtual base::string16 GetInputPlaceholderText() const = 0; - virtual base::string16 GetSaveButtonLabel() const = 0; - virtual base::string16 GetTitleText() const = 0; + virtual std::u16string GetCancelButtonLabel() const = 0; + virtual std::u16string GetInferredCardholderName() const = 0; + virtual std::u16string GetInferredNameTooltipText() const = 0; + virtual std::u16string GetInputLabel() const = 0; + virtual std::u16string GetInputPlaceholderText() const = 0; + virtual std::u16string GetSaveButtonLabel() const = 0; + virtual std::u16string GetTitleText() const = 0; }; } // namespace autofill diff --git a/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl.cc b/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl.cc index df41801e892..c07b08564c2 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl.cc +++ b/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl.cc @@ -35,8 +35,8 @@ CardNameFixFlowControllerImpl::~CardNameFixFlowControllerImpl() { void CardNameFixFlowControllerImpl::Show( CardNameFixFlowView* card_name_fix_flow_view, - const base::string16& inferred_cardholder_name, - base::OnceCallback<void(const base::string16&)> name_accepted_callback) { + const std::u16string& inferred_cardholder_name, + base::OnceCallback<void(const std::u16string&)> name_accepted_callback) { DCHECK(!name_accepted_callback.is_null()); DCHECK(card_name_fix_flow_view); @@ -60,13 +60,13 @@ void CardNameFixFlowControllerImpl::OnConfirmNameDialogClosed() { card_name_fix_flow_view_ = nullptr; } -void CardNameFixFlowControllerImpl::OnNameAccepted(const base::string16& name) { +void CardNameFixFlowControllerImpl::OnNameAccepted(const std::u16string& name) { AutofillMetrics::LogCardholderNameFixFlowPromptEvent( AutofillMetrics::CARDHOLDER_NAME_FIX_FLOW_PROMPT_ACCEPTED); had_user_interaction_ = true; AutofillMetrics::LogSaveCardCardholderNameWasEdited( inferred_cardholder_name_ != name); - base::string16 trimmed_name; + std::u16string trimmed_name; base::TrimWhitespace(name, base::TRIM_ALL, &trimmed_name); std::move(name_accepted_callback_).Run(trimmed_name); } @@ -85,32 +85,32 @@ int CardNameFixFlowControllerImpl::GetIconId() const { #endif } -base::string16 CardNameFixFlowControllerImpl::GetCancelButtonLabel() const { +std::u16string CardNameFixFlowControllerImpl::GetCancelButtonLabel() const { return l10n_util::GetStringUTF16(IDS_CANCEL); } -base::string16 CardNameFixFlowControllerImpl::GetInferredCardholderName() +std::u16string CardNameFixFlowControllerImpl::GetInferredCardholderName() const { return inferred_cardholder_name_; } -base::string16 CardNameFixFlowControllerImpl::GetInferredNameTooltipText() +std::u16string CardNameFixFlowControllerImpl::GetInferredNameTooltipText() const { return l10n_util::GetStringUTF16( IDS_AUTOFILL_SAVE_CARD_PROMPT_CARDHOLDER_NAME_TOOLTIP); } -base::string16 CardNameFixFlowControllerImpl::GetInputLabel() const { +std::u16string CardNameFixFlowControllerImpl::GetInputLabel() const { return l10n_util::GetStringUTF16( IDS_AUTOFILL_SAVE_CARD_PROMPT_CARDHOLDER_NAME); } -base::string16 CardNameFixFlowControllerImpl::GetInputPlaceholderText() const { +std::u16string CardNameFixFlowControllerImpl::GetInputPlaceholderText() const { return l10n_util::GetStringUTF16( IDS_AUTOFILL_SAVE_CARD_PROMPT_CARDHOLDER_NAME); } -base::string16 CardNameFixFlowControllerImpl::GetSaveButtonLabel() const { +std::u16string CardNameFixFlowControllerImpl::GetSaveButtonLabel() const { #if defined(OS_IOS) return l10n_util::GetStringUTF16(IDS_SAVE); #else @@ -119,7 +119,7 @@ base::string16 CardNameFixFlowControllerImpl::GetSaveButtonLabel() const { #endif } -base::string16 CardNameFixFlowControllerImpl::GetTitleText() const { +std::u16string CardNameFixFlowControllerImpl::GetTitleText() const { return l10n_util::GetStringUTF16( IDS_AUTOFILL_SAVE_CARD_CARDHOLDER_NAME_FIX_FLOW_HEADER); } diff --git a/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl.h b/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl.h index e9f4d9ba72a..6cc34fc15a4 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl.h +++ b/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl.h @@ -9,7 +9,6 @@ #include "base/callback.h" #include "base/macros.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/ui/payments/card_name_fix_flow_controller.h" namespace autofill { @@ -22,31 +21,31 @@ class CardNameFixFlowControllerImpl : public CardNameFixFlowController { ~CardNameFixFlowControllerImpl() override; void Show(CardNameFixFlowView* card_name_fix_flow_view, - const base::string16& inferred_cardholder_name, - base::OnceCallback<void(const base::string16&)> name_callback); + const std::u16string& inferred_cardholder_name, + base::OnceCallback<void(const std::u16string&)> name_callback); // CardNameFixFlowController implementation. void OnConfirmNameDialogClosed() override; - void OnNameAccepted(const base::string16& name) override; + void OnNameAccepted(const std::u16string& name) override; void OnDismissed() override; int GetIconId() const override; - base::string16 GetCancelButtonLabel() const override; - base::string16 GetInferredCardholderName() const override; - base::string16 GetInferredNameTooltipText() const override; - base::string16 GetInputLabel() const override; - base::string16 GetInputPlaceholderText() const override; - base::string16 GetSaveButtonLabel() const override; - base::string16 GetTitleText() const override; + std::u16string GetCancelButtonLabel() const override; + std::u16string GetInferredCardholderName() const override; + std::u16string GetInferredNameTooltipText() const override; + std::u16string GetInputLabel() const override; + std::u16string GetInputPlaceholderText() const override; + std::u16string GetSaveButtonLabel() const override; + std::u16string GetTitleText() const override; private: // Inferred cardholder name from Gaia account. - base::string16 inferred_cardholder_name_; + std::u16string inferred_cardholder_name_; // View that displays the fix flow prompt. CardNameFixFlowView* card_name_fix_flow_view_ = nullptr; // The callback to call once user confirms their name through the fix flow. - base::OnceCallback<void(const base::string16&)> name_accepted_callback_; + base::OnceCallback<void(const std::u16string&)> name_accepted_callback_; // Whether the prompt was shown to the user. bool shown_ = false; diff --git a/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl_unittest.cc b/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl_unittest.cc index c6dc583e35b..0a424d2dc78 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl_unittest.cc +++ b/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl_unittest.cc @@ -29,31 +29,29 @@ class CardNameFixFlowControllerImplGenericTest { CardNameFixFlowControllerImplGenericTest() {} void ShowPromptWithInferredName() { - inferred_name_ = base::ASCIIToUTF16("John Doe"); + inferred_name_ = u"John Doe"; ShowPrompt(); } void ShowPromptWithoutInferredName() { - inferred_name_ = base::ASCIIToUTF16(""); + inferred_name_ = u""; ShowPrompt(); } void AcceptWithInferredName() { controller_->OnNameAccepted(inferred_name_); } - void AcceptWithEditedName() { - controller_->OnNameAccepted(base::ASCIIToUTF16("Edited Name")); - } + void AcceptWithEditedName() { controller_->OnNameAccepted(u"Edited Name"); } protected: std::unique_ptr<TestCardNameFixFlowView> test_card_name_fix_flow_view_; std::unique_ptr<CardNameFixFlowControllerImpl> controller_; - base::string16 inferred_name_; - base::string16 accepted_name_; + std::u16string inferred_name_; + std::u16string accepted_name_; base::WeakPtrFactory<CardNameFixFlowControllerImplGenericTest> weak_ptr_factory_{this}; private: - void OnNameAccepted(const base::string16& name) { accepted_name_ = name; } + void OnNameAccepted(const std::u16string& name) { accepted_name_ = name; } void ShowPrompt() { controller_->Show( diff --git a/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_view.h b/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_view.h index f9bf6cea366..2d8dd0ad6aa 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_view.h +++ b/chromium/components/autofill/core/browser/ui/payments/card_name_fix_flow_view.h @@ -5,8 +5,9 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_NAME_FIX_FLOW_VIEW_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_NAME_FIX_FLOW_VIEW_H_ +#include <string> + #include "base/macros.h" -#include "base/strings/string16.h" namespace autofill { diff --git a/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller.h b/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller.h index dc6b23dbef7..46a0cbe6e59 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller.h +++ b/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller.h @@ -5,7 +5,8 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_UNMASK_PROMPT_CONTROLLER_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_UNMASK_PROMPT_CONTROLLER_H_ -#include "base/strings/string16.h" +#include <string> + #include "build/build_config.h" #include "components/autofill/core/browser/autofill_client.h" @@ -19,17 +20,17 @@ class CardUnmaskPromptController { public: // Interaction. virtual void OnUnmaskDialogClosed() = 0; - virtual void OnUnmaskPromptAccepted(const base::string16& cvc, - const base::string16& exp_month, - const base::string16& exp_year, + virtual void OnUnmaskPromptAccepted(const std::u16string& cvc, + const std::u16string& exp_month, + const std::u16string& exp_year, bool should_store_pan, bool enable_fido_auth) = 0; virtual void NewCardLinkClicked() = 0; // State. - virtual base::string16 GetWindowTitle() const = 0; - virtual base::string16 GetInstructionsMessage() const = 0; - virtual base::string16 GetOkButtonLabel() const = 0; + virtual std::u16string GetWindowTitle() const = 0; + virtual std::u16string GetInstructionsMessage() const = 0; + virtual std::u16string GetOkButtonLabel() const = 0; virtual int GetCvcImageRid() const = 0; virtual bool ShouldRequestExpirationDate() const = 0; virtual bool GetStoreLocallyStartState() const = 0; @@ -43,9 +44,9 @@ class CardUnmaskPromptController { virtual AutofillClient::PaymentsRpcResult GetVerificationResult() const = 0; // Utilities. - virtual bool InputCvcIsValid(const base::string16& input_text) const = 0; - virtual bool InputExpirationIsValid(const base::string16& month, - const base::string16& year) const = 0; + virtual bool InputCvcIsValid(const std::u16string& input_text) const = 0; + virtual bool InputExpirationIsValid(const std::u16string& month, + const std::u16string& year) const = 0; virtual int GetExpectedCvcLength() const = 0; }; diff --git a/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl.cc b/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl.cc index 5d43b44cf42..8c59acec3fa 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl.cc +++ b/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl.cc @@ -63,7 +63,7 @@ void CardUnmaskPromptControllerImpl::OnVerificationResult( if (!card_unmask_view_) return; - base::string16 error_message; + std::u16string error_message; switch (result) { case AutofillClient::SUCCESS: break; @@ -107,9 +107,9 @@ void CardUnmaskPromptControllerImpl::OnUnmaskDialogClosed() { } void CardUnmaskPromptControllerImpl::OnUnmaskPromptAccepted( - const base::string16& cvc, - const base::string16& exp_month, - const base::string16& exp_year, + const std::u16string& cvc, + const std::u16string& exp_month, + const std::u16string& exp_year, bool should_store_pan, bool enable_fido_auth) { verify_timestamp_ = AutofillClock::Now(); @@ -149,7 +149,7 @@ void CardUnmaskPromptControllerImpl::NewCardLinkClicked() { new_card_link_clicked_ = true; } -base::string16 CardUnmaskPromptControllerImpl::GetWindowTitle() const { +std::u16string CardUnmaskPromptControllerImpl::GetWindowTitle() const { #if defined(OS_IOS) // The iOS UI has less room for the title so it shows a shorter string. return l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_UNMASK_PROMPT_TITLE); @@ -162,7 +162,7 @@ base::string16 CardUnmaskPromptControllerImpl::GetWindowTitle() const { #endif } -base::string16 CardUnmaskPromptControllerImpl::GetInstructionsMessage() const { +std::u16string CardUnmaskPromptControllerImpl::GetInstructionsMessage() const { // The prompt for server cards should reference Google Payments, whereas the // prompt for local cards should not. #if defined(OS_IOS) @@ -195,7 +195,7 @@ base::string16 CardUnmaskPromptControllerImpl::GetInstructionsMessage() const { #endif } -base::string16 CardUnmaskPromptControllerImpl::GetOkButtonLabel() const { +std::u16string CardUnmaskPromptControllerImpl::GetOkButtonLabel() const { return l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_UNMASK_CONFIRM_BUTTON); } @@ -235,15 +235,15 @@ bool CardUnmaskPromptControllerImpl::IsCardLocal() const { #endif bool CardUnmaskPromptControllerImpl::InputCvcIsValid( - const base::string16& input_text) const { - base::string16 trimmed_text; + const std::u16string& input_text) const { + std::u16string trimmed_text; base::TrimWhitespace(input_text, base::TRIM_ALL, &trimmed_text); return IsValidCreditCardSecurityCode(trimmed_text, card_.network()); } bool CardUnmaskPromptControllerImpl::InputExpirationIsValid( - const base::string16& month, - const base::string16& year) const { + const std::u16string& month, + const std::u16string& year) const { if ((month.size() != 2U && month.size() != 1U) || (year.size() != 4U && year.size() != 2U)) { return false; diff --git a/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl.h b/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl.h index 0fcaffcf3f3..800584140fe 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl.h +++ b/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl.h @@ -42,15 +42,15 @@ class CardUnmaskPromptControllerImpl : public CardUnmaskPromptController { // CardUnmaskPromptController implementation. void OnUnmaskDialogClosed() override; - void OnUnmaskPromptAccepted(const base::string16& cvc, - const base::string16& exp_month, - const base::string16& exp_year, + void OnUnmaskPromptAccepted(const std::u16string& cvc, + const std::u16string& exp_month, + const std::u16string& exp_year, bool should_store_pan, bool enable_fido_auth) override; void NewCardLinkClicked() override; - base::string16 GetWindowTitle() const override; - base::string16 GetInstructionsMessage() const override; - base::string16 GetOkButtonLabel() const override; + std::u16string GetWindowTitle() const override; + std::u16string GetInstructionsMessage() const override; + std::u16string GetOkButtonLabel() const override; int GetCvcImageRid() const override; bool ShouldRequestExpirationDate() const override; bool GetStoreLocallyStartState() const override; @@ -60,9 +60,9 @@ class CardUnmaskPromptControllerImpl : public CardUnmaskPromptController { bool GetWebauthnOfferStartState() const override; bool IsCardLocal() const override; #endif - bool InputCvcIsValid(const base::string16& input_text) const override; - bool InputExpirationIsValid(const base::string16& month, - const base::string16& year) const override; + bool InputCvcIsValid(const std::u16string& input_text) const override; + bool InputExpirationIsValid(const std::u16string& month, + const std::u16string& year) const override; int GetExpectedCvcLength() const override; base::TimeDelta GetSuccessMessageDuration() const override; AutofillClient::PaymentsRpcResult GetVerificationResult() const override; diff --git a/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl_unittest.cc b/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl_unittest.cc index f6eec72b843..a42e959f423 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl_unittest.cc +++ b/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl_unittest.cc @@ -61,7 +61,7 @@ class TestCardUnmaskPromptView : public CardUnmaskPromptView { void Show() override {} void ControllerGone() override {} void DisableAndWaitForVerification() override {} - void GotVerificationResult(const base::string16& error_message, + void GotVerificationResult(const std::u16string& error_message, bool allow_retry) override {} }; @@ -94,10 +94,11 @@ class CardUnmaskPromptControllerImplGenericTest { CardUnmaskPromptControllerImplGenericTest() {} void SetUp() { - test_unmask_prompt_view_.reset(new TestCardUnmaskPromptView()); - pref_service_.reset(new TestingPrefServiceSimple()); - controller_.reset(new TestCardUnmaskPromptController(pref_service_.get())); - delegate_.reset(new TestCardUnmaskDelegate()); + test_unmask_prompt_view_ = std::make_unique<TestCardUnmaskPromptView>(); + pref_service_ = std::make_unique<TestingPrefServiceSimple>(); + controller_ = + std::make_unique<TestCardUnmaskPromptController>(pref_service_.get()); + delegate_ = std::make_unique<TestCardUnmaskDelegate>(); } void ShowPrompt() { @@ -111,9 +112,8 @@ class CardUnmaskPromptControllerImplGenericTest { void ShowPromptAndSimulateResponse(bool should_store_pan, bool enable_fido_auth) { ShowPrompt(); - controller_->OnUnmaskPromptAccepted(ASCIIToUTF16("444"), ASCIIToUTF16("01"), - ASCIIToUTF16("2050"), should_store_pan, - enable_fido_auth); + controller_->OnUnmaskPromptAccepted(u"444", u"01", u"2050", + should_store_pan, enable_fido_auth); EXPECT_EQ(should_store_pan, pref_service_->GetBoolean( prefs::kAutofillWalletImportStorageCheckboxState)); @@ -437,8 +437,7 @@ TEST_P(LoggingValidationTestForNickname, LogUnmaskedCardAfterFailure) { ShowPromptAndSimulateResponse(/*should_store_pan=*/false, /*enable_fido_auth=*/false); controller_->OnVerificationResult(AutofillClient::TRY_AGAIN_FAILURE); - controller_->OnUnmaskPromptAccepted(ASCIIToUTF16("444"), ASCIIToUTF16("01"), - ASCIIToUTF16("2050"), + controller_->OnUnmaskPromptAccepted(u"444", u"01", u"2050", /*should_store_pan=*/false, /*enable_fido_auth=*/false); base::HistogramTester histogram_tester; @@ -584,10 +583,9 @@ TEST_P(LoggingValidationTestForNickname, LogDurationUnmaskedCardAfterFailure) { ShowPromptAndSimulateResponse(/*should_store_pan=*/false, /*enable_fido_auth=*/false); controller_->OnVerificationResult(AutofillClient::TRY_AGAIN_FAILURE); - controller_->OnUnmaskPromptAccepted( - base::ASCIIToUTF16("444"), base::ASCIIToUTF16("01"), - base::ASCIIToUTF16("2050"), /*should_store_pan=*/false, - /*enable_fido_auth=*/false); + controller_->OnUnmaskPromptAccepted(u"444", u"01", u"2050", + /*should_store_pan=*/false, + /*enable_fido_auth=*/false); base::HistogramTester histogram_tester; controller_->OnVerificationResult(AutofillClient::SUCCESS); @@ -658,7 +656,7 @@ TEST_P(CvcInputValidationTest, CvcInputValidation) { return; controller_->OnUnmaskPromptAccepted( - ASCIIToUTF16(cvc_case.input), ASCIIToUTF16("1"), ASCIIToUTF16("2050"), + ASCIIToUTF16(cvc_case.input), u"1", u"2050", /*should_store_pan=*/false, /*enable_fido_auth=*/false); EXPECT_EQ(ASCIIToUTF16(cvc_case.canonicalized_input), delegate_->details().cvc); @@ -702,7 +700,7 @@ TEST_P(CvcInputAmexValidationTest, CvcInputValidation) { return; controller_->OnUnmaskPromptAccepted( - ASCIIToUTF16(cvc_case_amex.input), base::string16(), base::string16(), + ASCIIToUTF16(cvc_case_amex.input), std::u16string(), std::u16string(), /*should_store_pan=*/false, /*enable_fido_auth=*/false); EXPECT_EQ(ASCIIToUTF16(cvc_case_amex.canonicalized_input), delegate_->details().cvc); diff --git a/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_view.h b/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_view.h index d0970ccf55e..f5b4b0d48e1 100644 --- a/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_view.h +++ b/chromium/components/autofill/core/browser/ui/payments/card_unmask_prompt_view.h @@ -5,8 +5,9 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_UNMASK_PROMPT_VIEW_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_CARD_UNMASK_PROMPT_VIEW_H_ +#include <string> + #include "base/macros.h" -#include "base/strings/string16.h" namespace autofill { @@ -18,7 +19,7 @@ class CardUnmaskPromptView { virtual void Show() = 0; virtual void ControllerGone() = 0; virtual void DisableAndWaitForVerification() = 0; - virtual void GotVerificationResult(const base::string16& error_message, + virtual void GotVerificationResult(const std::u16string& error_message, bool allow_retry) = 0; protected: diff --git a/chromium/components/autofill/core/browser/ui/payments/local_card_migration_bubble_controller.h b/chromium/components/autofill/core/browser/ui/payments/local_card_migration_bubble_controller.h index 193b3af245d..dc0374e01e2 100644 --- a/chromium/components/autofill/core/browser/ui/payments/local_card_migration_bubble_controller.h +++ b/chromium/components/autofill/core/browser/ui/payments/local_card_migration_bubble_controller.h @@ -5,8 +5,9 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_LOCAL_CARD_MIGRATION_BUBBLE_CONTROLLER_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_LOCAL_CARD_MIGRATION_BUBBLE_CONTROLLER_H_ +#include <string> + #include "base/macros.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/ui/payments/payments_bubble_closed_reasons.h" namespace autofill { diff --git a/chromium/components/autofill/core/browser/ui/payments/local_card_migration_dialog_controller.h b/chromium/components/autofill/core/browser/ui/payments/local_card_migration_dialog_controller.h index 915edea65a2..9fb0316b235 100644 --- a/chromium/components/autofill/core/browser/ui/payments/local_card_migration_dialog_controller.h +++ b/chromium/components/autofill/core/browser/ui/payments/local_card_migration_dialog_controller.h @@ -6,10 +6,10 @@ #define COMPONENTS_AUTOFILL_CORE_BROWSER_UI_PAYMENTS_LOCAL_CARD_MIGRATION_DIALOG_CONTROLLER_H_ #include <memory> +#include <string> #include <vector> #include "base/macros.h" -#include "base/strings/string16.h" #include "components/autofill/core/browser/payments/legal_message_line.h" #include "url/gurl.h" @@ -28,7 +28,7 @@ class LocalCardMigrationDialogController { virtual LocalCardMigrationDialogState GetViewState() const = 0; virtual const std::vector<MigratableCreditCard>& GetCardList() const = 0; virtual const LegalMessageLines& GetLegalMessageLines() const = 0; - virtual const base::string16& GetTipMessage() const = 0; + virtual const std::u16string& GetTipMessage() const = 0; virtual const std::string& GetUserEmail() const = 0; virtual void OnSaveButtonClicked( const std::vector<std::string>& selected_cards_guids) = 0; diff --git a/chromium/components/autofill/core/browser/ui/region_combobox_model.cc b/chromium/components/autofill/core/browser/ui/region_combobox_model.cc index 144e523b838..e17a040aeca 100644 --- a/chromium/components/autofill/core/browser/ui/region_combobox_model.cc +++ b/chromium/components/autofill/core/browser/ui/region_combobox_model.cc @@ -44,7 +44,7 @@ int RegionComboboxModel::GetItemCount() const { return regions_.size(); } -base::string16 RegionComboboxModel::GetItemAt(int index) const { +std::u16string RegionComboboxModel::GetItemAt(int index) const { DCHECK_GE(index, 0); // This might happen because of the asynchronous nature of the data. if (static_cast<size_t>(index) >= regions_.size()) @@ -55,7 +55,7 @@ base::string16 RegionComboboxModel::GetItemAt(int index) const { // The separator item. Implemented for platforms that don't yet support // IsItemSeparatorAt(). - return base::ASCIIToUTF16("---"); + return u"---"; } bool RegionComboboxModel::IsItemSeparatorAt(int index) const { diff --git a/chromium/components/autofill/core/browser/ui/region_combobox_model.h b/chromium/components/autofill/core/browser/ui/region_combobox_model.h index b6dda3b33c6..8d35ad32547 100644 --- a/chromium/components/autofill/core/browser/ui/region_combobox_model.h +++ b/chromium/components/autofill/core/browser/ui/region_combobox_model.h @@ -48,7 +48,7 @@ class RegionComboboxModel : public ui::ComboboxModel { // ui::ComboboxModel implementation: int GetItemCount() const override; - base::string16 GetItemAt(int index) const override; + std::u16string GetItemAt(int index) const override; bool IsItemSeparatorAt(int index) const override; void AddObserver(ui::ComboboxModelObserver* observer) override; void RemoveObserver(ui::ComboboxModelObserver* observer) override; diff --git a/chromium/components/autofill/core/browser/ui/region_combobox_model_unittest.cc b/chromium/components/autofill/core/browser/ui/region_combobox_model_unittest.cc index 5eaf997793c..40f0d28e30f 100644 --- a/chromium/components/autofill/core/browser/ui/region_combobox_model_unittest.cc +++ b/chromium/components/autofill/core/browser/ui/region_combobox_model_unittest.cc @@ -37,7 +37,7 @@ TEST(RegionComboboxModelTest, QuebecOntarioRegions) { test_region_data_loader.SendAsynchronousData(regions); EXPECT_EQ(3, model.GetItemCount()); - EXPECT_EQ(base::ASCIIToUTF16("---"), model.GetItemAt(0)); + EXPECT_EQ(u"---", model.GetItemAt(0)); EXPECT_EQ(base::ASCIIToUTF16(kQuebecName), model.GetItemAt(1)); EXPECT_EQ(base::ASCIIToUTF16(kOntarioName), model.GetItemAt(2)); EXPECT_FALSE(model.failed_to_load_data()); diff --git a/chromium/components/autofill/core/browser/ui/suggestion.cc b/chromium/components/autofill/core/browser/ui/suggestion.cc index 9b250ba7f5e..f344d2a5655 100644 --- a/chromium/components/autofill/core/browser/ui/suggestion.cc +++ b/chromium/components/autofill/core/browser/ui/suggestion.cc @@ -14,7 +14,7 @@ Suggestion::Suggestion() = default; Suggestion::Suggestion(const Suggestion& other) = default; Suggestion::Suggestion(Suggestion&& other) = default; -Suggestion::Suggestion(base::string16 value) : value(std::move(value)) {} +Suggestion::Suggestion(std::u16string value) : value(std::move(value)) {} Suggestion::Suggestion(base::StringPiece value, base::StringPiece label, diff --git a/chromium/components/autofill/core/browser/ui/suggestion.h b/chromium/components/autofill/core/browser/ui/suggestion.h index 8c9c505888d..0f6fadf2c6c 100644 --- a/chromium/components/autofill/core/browser/ui/suggestion.h +++ b/chromium/components/autofill/core/browser/ui/suggestion.h @@ -7,7 +7,6 @@ #include <string> -#include "base/strings/string16.h" #include "base/strings/string_piece.h" #include "base/types/strong_alias.h" #include "ui/gfx/image/image.h" @@ -26,7 +25,7 @@ struct Suggestion { Suggestion(const Suggestion& other); Suggestion(Suggestion&& other); - explicit Suggestion(base::string16 value); + explicit Suggestion(std::u16string value); // Constructor for unit tests. It will convert the strings from UTF-8 to // UTF-16. Suggestion(base::StringPiece value, @@ -48,15 +47,15 @@ struct Suggestion { // (see popup_item_ids.h) have special built-in meanings. int frontend_id = 0; - base::string16 value; - base::string16 label; + std::u16string value; + std::u16string label; // A label to be shown beneath |label| that will display information about any // credit card offers or rewards. - base::string16 offer_label; + std::u16string offer_label; // Used only for passwords to show the password value. // Also used to display an extra line of information if two line // display is enabled. - base::string16 additional_label; + std::u16string additional_label; // Contains an image to display for the suggestion. gfx::Image custom_icon; // TODO(crbug.com/1019660): Identify icons with enum instead of strings. diff --git a/chromium/components/autofill/core/browser/ui/suggestion_selection.cc b/chromium/components/autofill/core/browser/ui/suggestion_selection.cc index fe7e487bd12..34dc7d9a0d9 100644 --- a/chromium/components/autofill/core/browser/ui/suggestion_selection.cc +++ b/chromium/components/autofill/core/browser/ui/suggestion_selection.cc @@ -34,10 +34,10 @@ using ::i18n::addressinput::STREET_ADDRESS; // In addition to just getting the values out of the autocomplete profile, this // function handles formatting of the street address into a single string. -base::string16 GetInfoInOneLine(const AutofillProfile* profile, +std::u16string GetInfoInOneLine(const AutofillProfile* profile, const AutofillType& type, const std::string& app_locale) { - std::vector<base::string16> results; + std::vector<std::u16string> results; AddressField address_field; if (i18n::FieldForType(type.GetStorableType(), &address_field) && @@ -67,8 +67,8 @@ constexpr size_t kMaxPrunedUniqueSuggestionsCount = 3; std::vector<Suggestion> GetPrefixMatchedSuggestions( const AutofillType& type, - const base::string16& raw_field_contents, - const base::string16& field_contents_canon, + const std::u16string& raw_field_contents, + const std::u16string& field_contents_canon, const AutofillProfileComparator& comparator, bool field_is_autofilled, const std::vector<AutofillProfile*>& profiles, @@ -96,13 +96,13 @@ std::vector<Suggestion> GetPrefixMatchedSuggestions( } #endif // defined(OS_ANDROID) || defined(OS_IOS) - base::string16 value = + std::u16string value = GetInfoInOneLine(profile, type, comparator.app_locale()); if (value.empty()) continue; bool prefix_matched_suggestion; - base::string16 suggestion_canon = comparator.NormalizeForComparison(value); + std::u16string suggestion_canon = comparator.NormalizeForComparison(value); if (IsValidSuggestionForFieldContents( suggestion_canon, field_contents_canon, type, /* is_masked_server_card= */ false, &prefix_matched_suggestion)) { @@ -203,8 +203,8 @@ std::vector<Suggestion> GetUniqueSuggestions( return unique_suggestions; } -bool IsValidSuggestionForFieldContents(base::string16 suggestion_canon, - base::string16 field_contents_canon, +bool IsValidSuggestionForFieldContents(std::u16string suggestion_canon, + std::u16string field_contents_canon, const AutofillType& type, bool is_masked_server_card, bool* is_prefix_matched) { @@ -215,7 +215,7 @@ bool IsValidSuggestionForFieldContents(base::string16 suggestion_canon, // prefix match in order to put it at the top of the suggestions. if ((type.group() == FieldTypeGroup::kPhoneHome || type.group() == FieldTypeGroup::kPhoneBilling) && - suggestion_canon.find(field_contents_canon) != base::string16::npos) { + suggestion_canon.find(field_contents_canon) != std::u16string::npos) { return true; } @@ -223,7 +223,7 @@ bool IsValidSuggestionForFieldContents(base::string16 suggestion_canon, // - the number matches any part of the card, or // - it's a masked card and there are 6 or fewer typed so far. if (type.GetStorableType() == CREDIT_CARD_NUMBER) { - if (suggestion_canon.find(field_contents_canon) == base::string16::npos && + if (suggestion_canon.find(field_contents_canon) == std::u16string::npos && (!is_masked_server_card || field_contents_canon.size() >= 6)) { return false; } @@ -238,7 +238,7 @@ bool IsValidSuggestionForFieldContents(base::string16 suggestion_canon, if (IsFeatureSubstringMatchEnabled() && suggestion_canon.length() >= field_contents_canon.length() && GetTextSelectionStart(suggestion_canon, field_contents_canon, false) != - base::string16::npos) { + std::u16string::npos) { *is_prefix_matched = false; return true; } @@ -261,7 +261,7 @@ void RemoveProfilesNotUsedSinceTimestamp( num_profiles_supressed); } -void PrepareSuggestions(const std::vector<base::string16>& labels, +void PrepareSuggestions(const std::vector<std::u16string>& labels, std::vector<Suggestion>* suggestions, const AutofillProfileComparator& comparator) { DCHECK_EQ(suggestions->size(), labels.size()); @@ -270,7 +270,7 @@ void PrepareSuggestions(const std::vector<base::string16>& labels, // example, a Suggestion with the value "John" and the label "400 Oak Rd" has // the normalized text "john400oakrd". This text can only be added to the set // once. - std::unordered_set<base::string16> suggestion_text; + std::unordered_set<std::u16string> suggestion_text; size_t index_to_add_suggestion = 0; // Dedupes Suggestions to show in the dropdown once values and labels have @@ -282,7 +282,7 @@ void PrepareSuggestions(const std::vector<base::string16>& labels, // the normalized text "john400oakrd", and the Suggestion with the lower // ranking should be discarded. for (size_t i = 0; i < labels.size(); ++i) { - base::string16 label = labels[i]; + std::u16string label = labels[i]; bool text_inserted = suggestion_text diff --git a/chromium/components/autofill/core/browser/ui/suggestion_selection.h b/chromium/components/autofill/core/browser/ui/suggestion_selection.h index fb0dd776d66..1b4c650686d 100644 --- a/chromium/components/autofill/core/browser/ui/suggestion_selection.h +++ b/chromium/components/autofill/core/browser/ui/suggestion_selection.h @@ -7,7 +7,6 @@ #include <string> #include <vector> -#include "base/strings/string16.h" #include "base/time/time.h" #include "components/autofill/core/browser/field_types.h" #include "components/autofill/core/browser/ui/suggestion.h" @@ -30,8 +29,8 @@ extern const size_t kMaxPrunedUniqueSuggestionsCount; // |kMaxSuggestedProfilesCount| are returned. std::vector<Suggestion> GetPrefixMatchedSuggestions( const AutofillType& type, - const base::string16& raw_field_contents, - const base::string16& field_contents_canon, + const std::u16string& raw_field_contents, + const std::u16string& field_contents_canon, const AutofillProfileComparator& comparator, bool field_is_autofilled, const std::vector<AutofillProfile*>& profiles, @@ -54,8 +53,8 @@ std::vector<Suggestion> GetUniqueSuggestions( // |field_contents_canon|, the |type| and |is_masked_server_card|. Assigns true // to |is_prefix_matched| if the |field_contents_canon| is a prefix to // |suggestion_canon|, assigns false otherwise. -bool IsValidSuggestionForFieldContents(base::string16 suggestion_canon, - base::string16 field_contents_canon, +bool IsValidSuggestionForFieldContents(std::u16string suggestion_canon, + std::u16string field_contents_canon, const AutofillType& type, bool is_masked_server_card, bool* is_prefix_matched); @@ -72,7 +71,7 @@ void RemoveProfilesNotUsedSinceTimestamp( // // NOTE: |suggestions| are assumed to have already been sorted from most to // least important. -void PrepareSuggestions(const std::vector<base::string16>& labels, +void PrepareSuggestions(const std::vector<std::u16string>& labels, std::vector<Suggestion>* suggestions, const AutofillProfileComparator& comparator); diff --git a/chromium/components/autofill/core/browser/ui/suggestion_selection_unittest.cc b/chromium/components/autofill/core/browser/ui/suggestion_selection_unittest.cc index 0eac1dcbc39..ea318fff451 100644 --- a/chromium/components/autofill/core/browser/ui/suggestion_selection_unittest.cc +++ b/chromium/components/autofill/core/browser/ui/suggestion_selection_unittest.cc @@ -85,7 +85,7 @@ class SuggestionSelectionTest : public testing::Test { return profile_ptr; } - base::string16 GetCanonicalUtf16Content(const char* content) { + std::u16string GetCanonicalUtf16Content(const char* content) { return comparator_.NormalizeForComparison(ASCIIToUTF16(content)); } @@ -115,14 +115,12 @@ TEST_F(SuggestionSelectionTest, std::vector<AutofillProfile*> matched_profiles; auto suggestions = GetPrefixMatchedSuggestions( - AutofillType(NAME_FIRST), ASCIIToUTF16("Mar"), - GetCanonicalUtf16Content("Mar"), comparator_, false, - {profile1.get(), profile2.get()}, &matched_profiles); + AutofillType(NAME_FIRST), u"Mar", GetCanonicalUtf16Content("Mar"), + comparator_, false, {profile1.get(), profile2.get()}, &matched_profiles); ASSERT_EQ(1U, suggestions.size()); ASSERT_EQ(1U, matched_profiles.size()); - EXPECT_THAT(suggestions, - ElementsAre(Field(&Suggestion::value, ASCIIToUTF16("Marion")))); + EXPECT_THAT(suggestions, ElementsAre(Field(&Suggestion::value, u"Marion"))); } TEST_F(SuggestionSelectionTest, GetPrefixMatchedSuggestions_NoMatchingProfile) { @@ -130,10 +128,9 @@ TEST_F(SuggestionSelectionTest, GetPrefixMatchedSuggestions_NoMatchingProfile) { CreateProfileUniquePtr("Bob"); std::vector<AutofillProfile*> matched_profiles; - auto suggestions = - GetPrefixMatchedSuggestions(AutofillType(NAME_FIRST), ASCIIToUTF16("Mar"), - GetCanonicalUtf16Content("Mar"), comparator_, - false, {profile1.get()}, &matched_profiles); + auto suggestions = GetPrefixMatchedSuggestions( + AutofillType(NAME_FIRST), u"Mar", GetCanonicalUtf16Content("Mar"), + comparator_, false, {profile1.get()}, &matched_profiles); ASSERT_TRUE(matched_profiles.empty()); ASSERT_TRUE(suggestions.empty()); @@ -142,10 +139,9 @@ TEST_F(SuggestionSelectionTest, GetPrefixMatchedSuggestions_NoMatchingProfile) { TEST_F(SuggestionSelectionTest, GetPrefixMatchedSuggestions_EmptyProfilesInput) { std::vector<AutofillProfile*> matched_profiles; - auto suggestions = - GetPrefixMatchedSuggestions(AutofillType(NAME_FIRST), ASCIIToUTF16("Mar"), - GetCanonicalUtf16Content("Mar"), comparator_, - false, {}, &matched_profiles); + auto suggestions = GetPrefixMatchedSuggestions( + AutofillType(NAME_FIRST), u"Mar", GetCanonicalUtf16Content("Mar"), + comparator_, false, {}, &matched_profiles); ASSERT_TRUE(matched_profiles.empty()); ASSERT_TRUE(suggestions.empty()); @@ -169,24 +165,22 @@ TEST_F(SuggestionSelectionTest, GetPrefixMatchedSuggestions_LimitProfiles) { }); std::vector<AutofillProfile*> matched_profiles; - auto suggestions = - GetPrefixMatchedSuggestions(AutofillType(NAME_FIRST), ASCIIToUTF16("Mar"), - GetCanonicalUtf16Content("Mar"), comparator_, - false, profiles_pointers, &matched_profiles); + auto suggestions = GetPrefixMatchedSuggestions( + AutofillType(NAME_FIRST), u"Mar", GetCanonicalUtf16Content("Mar"), + comparator_, false, profiles_pointers, &matched_profiles); // Marie should not be found. ASSERT_EQ(kMaxSuggestedProfilesCount, suggestions.size()); ASSERT_EQ(kMaxSuggestedProfilesCount, matched_profiles.size()); - EXPECT_THAT(suggestions, - Each(Field(&Suggestion::value, Not(ASCIIToUTF16("Marie"))))); + EXPECT_THAT(suggestions, Each(Field(&Suggestion::value, Not(u"Marie")))); EXPECT_THAT(matched_profiles, Each(ResultOf( [](const AutofillProfile* profile_ptr) { return profile_ptr->GetRawInfo(NAME_FIRST); }, - Not(ASCIIToUTF16("Marie"))))); + Not(u"Marie")))); } TEST_F(SuggestionSelectionTest, GetPrefixMatchedSuggestions_SkipInvalid) { @@ -210,8 +204,7 @@ TEST_F(SuggestionSelectionTest, GetPrefixMatchedSuggestions_SkipInvalid) { ADDRESS_HOME_STATE, AutofillProfile::INVALID, AutofillProfile::CLIENT); profile_client_invalid_country_empty->SetValidityState( ADDRESS_HOME_STATE, AutofillProfile::INVALID, AutofillProfile::CLIENT); - profile_client_invalid_country_empty->SetRawInfo(ADDRESS_HOME_COUNTRY, - ASCIIToUTF16("")); + profile_client_invalid_country_empty->SetRawInfo(ADDRESS_HOME_COUNTRY, u""); const std::vector<AutofillProfile*> profiles_data = { profile_server_invalid.get(), profile_client_invalid.get(), @@ -219,15 +212,13 @@ TEST_F(SuggestionSelectionTest, GetPrefixMatchedSuggestions_SkipInvalid) { std::vector<AutofillProfile*> matched_profiles; auto suggestions = GetPrefixMatchedSuggestions( - AutofillType(ADDRESS_HOME_STATE), ASCIIToUTF16("C"), - GetCanonicalUtf16Content("C"), comparator_, false, profiles_data, - &matched_profiles); + AutofillType(ADDRESS_HOME_STATE), u"C", GetCanonicalUtf16Content("C"), + comparator_, false, profiles_data, &matched_profiles); ASSERT_EQ(2U, suggestions.size()); ASSERT_EQ(2U, matched_profiles.size()); - EXPECT_THAT(suggestions, - ElementsAre(Field(&Suggestion::value, ASCIIToUTF16("CA")), - Field(&Suggestion::value, ASCIIToUTF16("CA")))); + EXPECT_THAT(suggestions, ElementsAre(Field(&Suggestion::value, u"CA"), + Field(&Suggestion::value, u"CA"))); std::vector<AutofillProfile*> expected_result; expected_result.push_back(profile_valid.get()); @@ -254,7 +245,7 @@ TEST_F(SuggestionSelectionTest, GetUniqueSuggestions_SingleDedupe) { ASSERT_EQ(1U, unique_suggestions.size()); ASSERT_EQ(1U, unique_matched_profiles.size()); EXPECT_THAT(unique_suggestions, - ElementsAre(Field(&Suggestion::value, ASCIIToUTF16("Bob")))); + ElementsAre(Field(&Suggestion::value, u"Bob"))); } TEST_F(SuggestionSelectionTest, GetUniqueSuggestions_MultipleDedupe) { @@ -280,9 +271,9 @@ TEST_F(SuggestionSelectionTest, GetUniqueSuggestions_MultipleDedupe) { ASSERT_EQ(3U, unique_matched_profiles.size()); EXPECT_THAT(unique_suggestions, - ElementsAre(Field(&Suggestion::value, ASCIIToUTF16("Bob")), - Field(&Suggestion::value, ASCIIToUTF16("Bob")), - Field(&Suggestion::value, ASCIIToUTF16("Mary")))); + ElementsAre(Field(&Suggestion::value, u"Bob"), + Field(&Suggestion::value, u"Bob"), + Field(&Suggestion::value, u"Mary"))); } TEST_F(SuggestionSelectionTest, GetUniqueSuggestions_DedupeLimit) { @@ -525,15 +516,13 @@ TEST_F(SuggestionSelectionTest, RemoveProfilesNotUsedSinceTimestamp) { TEST_F(SuggestionSelectionTest, PrepareSuggestions_DiscardDuplicateSuggestions) { - std::vector<Suggestion> suggestions{Suggestion(ASCIIToUTF16("Jon Snow")), - Suggestion(ASCIIToUTF16("Jon Snow")), - Suggestion(ASCIIToUTF16("Jon Snow")), - Suggestion(ASCIIToUTF16("Jon Snow"))}; + std::vector<Suggestion> suggestions{ + Suggestion(u"Jon Snow"), Suggestion(u"Jon Snow"), Suggestion(u"Jon Snow"), + Suggestion(u"Jon Snow")}; - const std::vector<base::string16> labels{ - ASCIIToUTF16("2 Beyond-the-Wall Rd"), ASCIIToUTF16("1 Winterfell Ln"), - ASCIIToUTF16("2 Beyond-the-Wall Rd"), - ASCIIToUTF16("2 Beyond-the-Wall Rd.")}; + const std::vector<std::u16string> labels{ + u"2 Beyond-the-Wall Rd", u"1 Winterfell Ln", u"2 Beyond-the-Wall Rd", + u"2 Beyond-the-Wall Rd."}; PrepareSuggestions(labels, &suggestions, comparator_); @@ -541,48 +530,41 @@ TEST_F(SuggestionSelectionTest, // duplicates with a lower rank are removed. EXPECT_THAT( suggestions, - ElementsAre( - AllOf( - Field(&Suggestion::value, ASCIIToUTF16("Jon Snow")), - Field(&Suggestion::label, ASCIIToUTF16("2 Beyond-the-Wall Rd"))), - AllOf(Field(&Suggestion::value, ASCIIToUTF16("Jon Snow")), - Field(&Suggestion::label, ASCIIToUTF16("1 Winterfell Ln"))))); + ElementsAre(AllOf(Field(&Suggestion::value, u"Jon Snow"), + Field(&Suggestion::label, u"2 Beyond-the-Wall Rd")), + AllOf(Field(&Suggestion::value, u"Jon Snow"), + Field(&Suggestion::label, u"1 Winterfell Ln")))); } TEST_F(SuggestionSelectionTest, PrepareSuggestions_KeepNonDuplicateSuggestions) { - std::vector<Suggestion> suggestions{Suggestion(ASCIIToUTF16("Sansa")), - Suggestion(ASCIIToUTF16("Sansa")), - Suggestion(ASCIIToUTF16("Brienne"))}; + std::vector<Suggestion> suggestions{ + Suggestion(u"Sansa"), Suggestion(u"Sansa"), Suggestion(u"Brienne")}; - const std::vector<base::string16> labels{ASCIIToUTF16("1 Winterfell Ln"), - ASCIIToUTF16(""), - ASCIIToUTF16("1 Winterfell Ln")}; + const std::vector<std::u16string> labels{u"1 Winterfell Ln", u"", + u"1 Winterfell Ln"}; PrepareSuggestions(labels, &suggestions, comparator_); EXPECT_THAT( suggestions, - ElementsAre( - AllOf(Field(&Suggestion::value, ASCIIToUTF16("Sansa")), - Field(&Suggestion::label, ASCIIToUTF16("1 Winterfell Ln"))), - AllOf(Field(&Suggestion::value, ASCIIToUTF16("Sansa")), - Field(&Suggestion::label, ASCIIToUTF16(""))), - AllOf(Field(&Suggestion::value, ASCIIToUTF16("Brienne")), - Field(&Suggestion::label, ASCIIToUTF16("1 Winterfell Ln"))))); + ElementsAre(AllOf(Field(&Suggestion::value, u"Sansa"), + Field(&Suggestion::label, u"1 Winterfell Ln")), + AllOf(Field(&Suggestion::value, u"Sansa"), + Field(&Suggestion::label, u"")), + AllOf(Field(&Suggestion::value, u"Brienne"), + Field(&Suggestion::label, u"1 Winterfell Ln")))); } TEST_F(SuggestionSelectionTest, PrepareSuggestions_SameStringInValueAndLabel) { - std::vector<Suggestion> suggestions{ - Suggestion(base::UTF8ToUTF16("4 Mañana Road"))}; + std::vector<Suggestion> suggestions{Suggestion(u"4 Mañana Road")}; - const std::vector<base::string16> labels{ASCIIToUTF16("4 manana road")}; + const std::vector<std::u16string> labels{u"4 manana road"}; PrepareSuggestions(labels, &suggestions, comparator_); EXPECT_THAT(suggestions, - ElementsAre(AllOf( - Field(&Suggestion::value, base::UTF8ToUTF16("4 Mañana Road")), - Field(&Suggestion::label, base::string16())))); + ElementsAre(AllOf(Field(&Suggestion::value, u"4 Mañana Road"), + Field(&Suggestion::label, std::u16string())))); } } // namespace suggestion_selection diff --git a/chromium/components/autofill/core/browser/ui/suggestion_test_helpers.h b/chromium/components/autofill/core/browser/ui/suggestion_test_helpers.h index 12cffb3cf7d..6bd7417d290 100644 --- a/chromium/components/autofill/core/browser/ui/suggestion_test_helpers.h +++ b/chromium/components/autofill/core/browser/ui/suggestion_test_helpers.h @@ -65,7 +65,7 @@ template <class EltsAreMatcher> inline testing::Matcher<const std::vector<Suggestion>&> SuggestionVectorValuesAre(const EltsAreMatcher& elts_are_matcher) { return testing::MakeMatcher( - new SuggestionVectorMembersAreMatcher<base::string16>( + new SuggestionVectorMembersAreMatcher<std::u16string>( elts_are_matcher, &Suggestion::value)); } @@ -74,7 +74,7 @@ template <class EltsAreMatcher> inline testing::Matcher<const std::vector<Suggestion>&> SuggestionVectorLabelsAre(const EltsAreMatcher& elts_are_matcher) { return testing::MakeMatcher( - new SuggestionVectorMembersAreMatcher<base::string16>( + new SuggestionVectorMembersAreMatcher<std::u16string>( elts_are_matcher, &Suggestion::label)); } diff --git a/chromium/components/autofill/core/browser/validation.cc b/chromium/components/autofill/core/browser/validation.cc index 7eb2b39ff0c..4fc5bd3f1b3 100644 --- a/chromium/components/autofill/core/browser/validation.cc +++ b/chromium/components/autofill/core/browser/validation.cc @@ -50,8 +50,8 @@ bool IsValidCreditCardExpirationYear(int year, const base::Time& now) { return year >= now_exploded.year; } -bool IsValidCreditCardNumber(const base::string16& text) { - const base::string16 number = CreditCard::StripSeparators(text); +bool IsValidCreditCardNumber(const std::u16string& text) { + const std::u16string number = CreditCard::StripSeparators(text); if (!HasCorrectLength(number)) return false; @@ -59,7 +59,7 @@ bool IsValidCreditCardNumber(const base::string16& text) { return PassesLuhnCheck(number); } -bool HasCorrectLength(const base::string16& number) { +bool HasCorrectLength(const std::u16string& number) { // Credit card numbers are at most 19 digits in length, 12 digits seems to // be a fairly safe lower-bound [1]. Specific card issuers have more rigidly // defined sizes. @@ -95,12 +95,12 @@ bool HasCorrectLength(const base::string16& number) { } // TODO(crbug.com/927767): Add unit tests for this function. -bool PassesLuhnCheck(const base::string16& number) { +bool PassesLuhnCheck(const std::u16string& number) { // Use the Luhn formula [3] to validate the number. // [3] http://en.wikipedia.org/wiki/Luhn_algorithm int sum = 0; bool odd = false; - for (base::string16::const_reverse_iterator iter = number.rbegin(); + for (std::u16string::const_reverse_iterator iter = number.rbegin(); iter != number.rend(); ++iter) { if (!base::IsAsciiDigit(*iter)) return false; @@ -118,16 +118,16 @@ bool PassesLuhnCheck(const base::string16& number) { return (sum % 10) == 0; } -bool IsValidCreditCardSecurityCode(const base::string16& code, +bool IsValidCreditCardSecurityCode(const std::u16string& code, const base::StringPiece card_network) { return code.length() == GetCvcLengthForCardNetwork(card_network) && - base::ContainsOnlyChars(code, base::ASCIIToUTF16("0123456789")); + base::ContainsOnlyChars(code, u"0123456789"); } bool IsValidCreditCardNumberForBasicCardNetworks( - const base::string16& text, + const std::u16string& text, const std::set<std::string>& supported_basic_card_networks, - base::string16* error_message) { + std::u16string* error_message) { DCHECK(error_message); // The type check is cheaper than the credit card number check. @@ -149,32 +149,31 @@ bool IsValidCreditCardNumberForBasicCardNetworks( return false; } -bool IsValidEmailAddress(const base::string16& text) { +bool IsValidEmailAddress(const std::u16string& text) { // E-Mail pattern as defined by the WhatWG. (4.10.7.1.5 E-Mail state) - const base::string16 kEmailPattern = base::ASCIIToUTF16( - "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@" - "[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$"); + static constexpr char16_t kEmailPattern[] = + u"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$"; return MatchesPattern(text, kEmailPattern); } -bool IsValidState(const base::string16& text) { +bool IsValidState(const std::u16string& text) { return !state_names::GetAbbreviationForName(text).empty() || !state_names::GetNameForAbbreviation(text).empty(); } -bool IsPossiblePhoneNumber(const base::string16& text, +bool IsPossiblePhoneNumber(const std::u16string& text, const std::string& country_code) { return i18n::IsPossiblePhoneNumber(base::UTF16ToUTF8(text), country_code); } -bool IsValidZip(const base::string16& text) { - const base::string16 kZipPattern = base::ASCIIToUTF16("^\\d{5}(-\\d{4})?$"); +bool IsValidZip(const std::u16string& text) { + static constexpr char16_t kZipPattern[] = u"^\\d{5}(-\\d{4})?$"; return MatchesPattern(text, kZipPattern); } -bool IsSSN(const base::string16& text) { - base::string16 number_string; - base::RemoveChars(text, base::ASCIIToUTF16("- "), &number_string); +bool IsSSN(const std::u16string& text) { + std::u16string number_string; + base::RemoveChars(text, u"- ", &number_string); // A SSN is of the form AAA-GG-SSSS (A = area number, G = group number, S = // serial number). The validation we do here is simply checking if the area, @@ -232,9 +231,9 @@ bool IsSSN(const base::string16& text) { return true; } -bool IsValidForType(const base::string16& value, +bool IsValidForType(const std::u16string& value, ServerFieldType type, - base::string16* error_message) { + std::u16string* error_message) { switch (type) { case CREDIT_CARD_NAME_FULL: if (!value.empty()) @@ -290,10 +289,9 @@ bool IsValidForType(const base::string16& value, case CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR: case CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR: { - const base::string16 pattern = - type == CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR - ? base::UTF8ToUTF16("^[0-9]{1,2}[-/|]?[0-9]{2}$") - : base::UTF8ToUTF16("^[0-9]{1,2}[-/|]?[0-9]{4}$"); + const std::u16string pattern = type == CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR + ? u"^[0-9]{1,2}[-/|]?[0-9]{2}$" + : u"^[0-9]{1,2}[-/|]?[0-9]{4}$"; CreditCard temp; temp.SetExpirationDateFromString(value); @@ -343,23 +341,21 @@ size_t GetCvcLengthForCardNetwork(const base::StringPiece card_network) { return GENERAL_CVC_LENGTH; } -bool IsUPIVirtualPaymentAddress(const base::string16& value) { - return MatchesPattern(value, base::ASCIIToUTF16(kUPIVirtualPaymentAddressRe)); +bool IsUPIVirtualPaymentAddress(const std::u16string& value) { + return MatchesPattern(value, kUPIVirtualPaymentAddressRe); } -bool IsInternationalBankAccountNumber(const base::string16& value) { - base::string16 no_spaces; - base::RemoveChars(value, base::ASCIIToUTF16(" "), &no_spaces); - return MatchesPattern(no_spaces, - base::ASCIIToUTF16(kInternationalBankAccountNumberRe)); +bool IsInternationalBankAccountNumber(const std::u16string& value) { + std::u16string no_spaces; + base::RemoveChars(value, u" ", &no_spaces); + return MatchesPattern(no_spaces, kInternationalBankAccountNumberRe); } -bool IsPlausibleCreditCardCVCNumber(const base::string16& value) { - return MatchesPattern(value, base::ASCIIToUTF16(kCreditCardCVCPattern)); +bool IsPlausibleCreditCardCVCNumber(const std::u16string& value) { + return MatchesPattern(value, kCreditCardCVCPattern); } -bool IsPlausible4DigitExpirationYear(const base::string16& value) { - return MatchesPattern(value, - base::ASCIIToUTF16(kCreditCard4DigitExpYearPattern)); +bool IsPlausible4DigitExpirationYear(const std::u16string& value) { + return MatchesPattern(value, kCreditCard4DigitExpYearPattern); } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/validation.h b/chromium/components/autofill/core/browser/validation.h index e9accf0a681..06b90d55ba4 100644 --- a/chromium/components/autofill/core/browser/validation.h +++ b/chromium/components/autofill/core/browser/validation.h @@ -9,7 +9,6 @@ #include <string> #include <vector> -#include "base/strings/string16.h" #include "base/strings/string_piece_forward.h" #include "components/autofill/core/browser/field_types.h" @@ -35,69 +34,69 @@ bool IsValidCreditCardExpirationYear(int year, const base::Time& now); // Returns true if |text| looks like a valid credit card number. // Uses the Luhn formula to validate the number. -bool IsValidCreditCardNumber(const base::string16& text); +bool IsValidCreditCardNumber(const std::u16string& text); // Returns true if |number| has correct length according to card network. -bool HasCorrectLength(const base::string16& number); +bool HasCorrectLength(const std::u16string& number); // Returns true if |number| passes the validation by Luhn formula. -bool PassesLuhnCheck(const base::string16& number); +bool PassesLuhnCheck(const std::u16string& number); // Returns true if |code| looks like a valid credit card security code // for the given credit card network. -bool IsValidCreditCardSecurityCode(const base::string16& code, +bool IsValidCreditCardSecurityCode(const std::u16string& code, const base::StringPiece card_network); // Returns true if |text| is a supported card type and a valid credit card // number. |error_message| can't be null and will be filled with the appropriate // error message. bool IsValidCreditCardNumberForBasicCardNetworks( - const base::string16& text, + const std::u16string& text, const std::set<std::string>& supported_basic_card_networks, - base::string16* error_message); + std::u16string* error_message); // Returns true if |text| looks like a valid e-mail address. -bool IsValidEmailAddress(const base::string16& text); +bool IsValidEmailAddress(const std::u16string& text); // Returns true if |text| is a valid US state name or abbreviation. It is case // insensitive. Valid for US states only. -bool IsValidState(const base::string16& text); +bool IsValidState(const std::u16string& text); // Returns whether the number contained in |text| is possible phone number, // either in international format, or in the national format associated with // |country_code|. Callers should cache the result as the parsing is expensive. -bool IsPossiblePhoneNumber(const base::string16& text, +bool IsPossiblePhoneNumber(const std::u16string& text, const std::string& country_code); // Returns true if |text| looks like a valid zip code. // Valid for US zip codes only. -bool IsValidZip(const base::string16& text); +bool IsValidZip(const std::u16string& text); // Returns true if |text| looks like an SSN, with or without separators. -bool IsSSN(const base::string16& text); +bool IsSSN(const std::u16string& text); // Returns whether |value| is valid for the given |type|. If not null, // |error_message| is populated when the function returns false. -bool IsValidForType(const base::string16& value, +bool IsValidForType(const std::u16string& value, ServerFieldType type, - base::string16* error_message); + std::u16string* error_message); // Returns the expected CVC length based on the |card_network|. size_t GetCvcLengthForCardNetwork(const base::StringPiece card_network); // Returns true if |value| appears to be a UPI Virtual Payment Address. // https://upipayments.co.in/virtual-payment-address-vpa/ -bool IsUPIVirtualPaymentAddress(const base::string16& value); +bool IsUPIVirtualPaymentAddress(const std::u16string& value); // Returns true if |value| appears to be an International Bank Account Number // (IBAN). See https://en.wikipedia.org/wiki/International_Bank_Account_Number -bool IsInternationalBankAccountNumber(const base::string16& value); +bool IsInternationalBankAccountNumber(const std::u16string& value); // Return true if |value| is a 3 or 4 digit number. -bool IsPlausibleCreditCardCVCNumber(const base::string16& value); +bool IsPlausibleCreditCardCVCNumber(const std::u16string& value); // Returns true if the value is a 4 digit year in this century. -bool IsPlausible4DigitExpirationYear(const base::string16& value); +bool IsPlausible4DigitExpirationYear(const std::u16string& value); } // namespace autofill diff --git a/chromium/components/autofill/core/browser/validation_unittest.cc b/chromium/components/autofill/core/browser/validation_unittest.cc index 21d83c0f89d..5df65f13c75 100644 --- a/chromium/components/autofill/core/browser/validation_unittest.cc +++ b/chromium/components/autofill/core/browser/validation_unittest.cc @@ -6,8 +6,9 @@ #include <stddef.h> +#include <string> + #include "base/macros.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" #include "components/autofill/core/browser/data_model/credit_card.h" @@ -202,7 +203,7 @@ class AutofillTypeValidationTest : public testing::TestWithParam<ValidationCase> {}; TEST_P(AutofillTypeValidationTest, IsValidForType) { - base::string16 error_message; + std::u16string error_message; EXPECT_EQ(GetParam().expected_valid, IsValidForType(ASCIIToUTF16(GetParam().value), GetParam().field_type, &error_message)) @@ -361,7 +362,7 @@ class AutofillCCNumberValidationTest : public testing::TestWithParam<CCNumberCase> {}; TEST_P(AutofillCCNumberValidationTest, IsValidCreditCardNumber) { - base::string16 error_message; + std::u16string error_message; EXPECT_EQ(GetParam().expected_valid, IsValidCreditCardNumberForBasicCardNetworks( ASCIIToUTF16(GetParam().value), @@ -525,14 +526,10 @@ INSTANTIATE_TEST_SUITE_P(UPIVirtualPaymentAddress, "ybl")); TEST(AutofillValidation, IsUPIVirtualPaymentAddress_Others) { - EXPECT_TRUE( - IsUPIVirtualPaymentAddress(ASCIIToUTF16("12345@HDFC0000001.ifsc.npci"))); - EXPECT_TRUE( - IsUPIVirtualPaymentAddress(ASCIIToUTF16("234567890123@aadhaar.npci"))); - EXPECT_TRUE( - IsUPIVirtualPaymentAddress(ASCIIToUTF16("9800011111@mobile.npci"))); - EXPECT_TRUE( - IsUPIVirtualPaymentAddress(ASCIIToUTF16("1234123412341234@rupay.npci"))); + EXPECT_TRUE(IsUPIVirtualPaymentAddress(u"12345@HDFC0000001.ifsc.npci")); + EXPECT_TRUE(IsUPIVirtualPaymentAddress(u"234567890123@aadhaar.npci")); + EXPECT_TRUE(IsUPIVirtualPaymentAddress(u"9800011111@mobile.npci")); + EXPECT_TRUE(IsUPIVirtualPaymentAddress(u"1234123412341234@rupay.npci")); } class AutofillIsInternationalBankAccountNumber diff --git a/chromium/components/autofill/core/browser/webdata/autocomplete_sync_bridge_unittest.cc b/chromium/components/autofill/core/browser/webdata/autocomplete_sync_bridge_unittest.cc index 44fc22b4c55..a92f3ca3166 100644 --- a/chromium/components/autofill/core/browser/webdata/autocomplete_sync_bridge_unittest.cc +++ b/chromium/components/autofill/core/browser/webdata/autocomplete_sync_bridge_unittest.cc @@ -6,6 +6,7 @@ #include <algorithm> #include <map> +#include <memory> #include <utility> #include <vector> @@ -160,8 +161,8 @@ class AutocompleteSyncBridgeTest : public testing::Test { } void ResetBridge() { - bridge_.reset(new AutocompleteSyncBridge( - &backend_, mock_processor_.CreateForwardingProcessor())); + bridge_ = std::make_unique<AutocompleteSyncBridge>( + &backend_, mock_processor_.CreateForwardingProcessor()); } void StartSyncing(const std::vector<AutofillSpecifics>& remote_data = {}) { diff --git a/chromium/components/autofill/core/browser/webdata/autofill_entry.cc b/chromium/components/autofill/core/browser/webdata/autofill_entry.cc index 3a48a50c10e..c95e722f65e 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_entry.cc +++ b/chromium/components/autofill/core/browser/webdata/autofill_entry.cc @@ -13,11 +13,9 @@ namespace autofill { AutofillKey::AutofillKey() {} -AutofillKey::AutofillKey(const base::string16& name, - const base::string16& value) - : name_(name), - value_(value) { -} +AutofillKey::AutofillKey(const std::u16string& name, + const std::u16string& value) + : name_(name), value_(value) {} AutofillKey::AutofillKey(const std::string& name, const std::string& value) diff --git a/chromium/components/autofill/core/browser/webdata/autofill_entry.h b/chromium/components/autofill/core/browser/webdata/autofill_entry.h index a7932fde2cd..bd2f3f7110c 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_entry.h +++ b/chromium/components/autofill/core/browser/webdata/autofill_entry.h @@ -7,7 +7,6 @@ #include <string> -#include "base/strings/string16.h" #include "base/time/time.h" namespace autofill { @@ -15,20 +14,20 @@ namespace autofill { class AutofillKey { public: AutofillKey(); - AutofillKey(const base::string16& name, const base::string16& value); + AutofillKey(const std::u16string& name, const std::u16string& value); AutofillKey(const std::string& name, const std::string& value); AutofillKey(const AutofillKey& key); virtual ~AutofillKey(); - const base::string16& name() const { return name_; } - const base::string16& value() const { return value_; } + const std::u16string& name() const { return name_; } + const std::u16string& value() const { return value_; } bool operator==(const AutofillKey& key) const; bool operator<(const AutofillKey& key) const; private: - base::string16 name_; - base::string16 value_; + std::u16string name_; + std::u16string value_; }; class AutofillEntry { diff --git a/chromium/components/autofill/core/browser/webdata/autofill_profile_sync_bridge_unittest.cc b/chromium/components/autofill/core/browser/webdata/autofill_profile_sync_bridge_unittest.cc index 7c56186a303..ea2ba7b87ce 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_profile_sync_bridge_unittest.cc +++ b/chromium/components/autofill/core/browser/webdata/autofill_profile_sync_bridge_unittest.cc @@ -149,38 +149,36 @@ AutofillProfile ConstructCompleteProfile() { profile.set_use_count(7); profile.set_use_date(base::Time::FromTimeT(1423182152)); - profile.SetRawInfo(NAME_HONORIFIC_PREFIX, ASCIIToUTF16("")); - profile.SetRawInfo(NAME_FULL, ASCIIToUTF16("John K. Doe, Jr.")); - profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - profile.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("K.")); - profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Doe")); - profile.SetRawInfo(NAME_LAST_FIRST, ASCIIToUTF16("D")); - profile.SetRawInfo(NAME_LAST_CONJUNCTION, ASCIIToUTF16("o")); - profile.SetRawInfo(NAME_LAST_SECOND, ASCIIToUTF16("e")); - - profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("user@example.com")); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("1.800.555.1234")); + profile.SetRawInfo(NAME_HONORIFIC_PREFIX, u""); + profile.SetRawInfo(NAME_FULL, u"John K. Doe, Jr."); + profile.SetRawInfo(NAME_FIRST, u"John"); + profile.SetRawInfo(NAME_MIDDLE, u"K."); + profile.SetRawInfo(NAME_LAST, u"Doe"); + profile.SetRawInfo(NAME_LAST_FIRST, u"D"); + profile.SetRawInfo(NAME_LAST_CONJUNCTION, u"o"); + profile.SetRawInfo(NAME_LAST_SECOND, u"e"); + + profile.SetRawInfo(EMAIL_ADDRESS, u"user@example.com"); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"1.800.555.1234"); profile.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("123 Fake St.\n" "Apt. 42")); - EXPECT_EQ(ASCIIToUTF16("123 Fake St."), - profile.GetRawInfo(ADDRESS_HOME_LINE1)); - EXPECT_EQ(ASCIIToUTF16("Apt. 42"), profile.GetRawInfo(ADDRESS_HOME_LINE2)); - - profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Google, Inc.")); - profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Mountain View")); - profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California")); - profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("94043")); - profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); - profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, ASCIIToUTF16("CEDEX")); - profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, - ASCIIToUTF16("Santa Clara")); - profile.SetRawInfo(ADDRESS_HOME_STREET_NAME, ASCIIToUTF16("Street Name")); + EXPECT_EQ(u"123 Fake St.", profile.GetRawInfo(ADDRESS_HOME_LINE1)); + EXPECT_EQ(u"Apt. 42", profile.GetRawInfo(ADDRESS_HOME_LINE2)); + + profile.SetRawInfo(COMPANY_NAME, u"Google, Inc."); + profile.SetRawInfo(ADDRESS_HOME_CITY, u"Mountain View"); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"California"); + profile.SetRawInfo(ADDRESS_HOME_ZIP, u"94043"); + profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US"); + profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, u"CEDEX"); + profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u"Santa Clara"); + profile.SetRawInfo(ADDRESS_HOME_STREET_NAME, u"Street Name"); profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME, - ASCIIToUTF16("Dependent Street Name")); - profile.SetRawInfo(ADDRESS_HOME_HOUSE_NUMBER, ASCIIToUTF16("House Number")); - profile.SetRawInfo(ADDRESS_HOME_SUBPREMISE, ASCIIToUTF16("Subpremise")); - profile.SetRawInfo(ADDRESS_HOME_PREMISE_NAME, ASCIIToUTF16("Premise")); + u"Dependent Street Name"); + profile.SetRawInfo(ADDRESS_HOME_HOUSE_NUMBER, u"House Number"); + profile.SetRawInfo(ADDRESS_HOME_SUBPREMISE, u"Subpremise"); + profile.SetRawInfo(ADDRESS_HOME_PREMISE_NAME, u"Premise"); profile.set_language_code("en"); profile.SetClientValidityFromBitfieldValue(kValidityStateBitfield); profile.FinalizeAfterImport(); @@ -289,8 +287,8 @@ class AutofillProfileSyncBridgeTestBase : public testing::Test { } void ResetBridge() { - bridge_.reset(new AutofillProfileSyncBridge( - mock_processor_.CreateForwardingProcessor(), kLocaleString, &backend_)); + bridge_ = std::make_unique<AutofillProfileSyncBridge>( + mock_processor_.CreateForwardingProcessor(), kLocaleString, &backend_); } void StartSyncing( @@ -415,7 +413,7 @@ TEST_P(AutofillProfileSyncBridgeTest, AutofillProfileChanged_Added) { StartSyncing({}); AutofillProfile local(kGuidA, kHttpsOrigin); - local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Jane")); + local.SetRawInfo(NAME_FIRST, u"Jane"); local.FinalizeAfterImport(); AutofillProfileChange change(AutofillProfileChange::ADD, kGuidA, &local); @@ -472,7 +470,7 @@ TEST_P(AutofillProfileSyncBridgeTest, AutofillProfileChanged_Updated) { StartSyncing({}); AutofillProfile local(kGuidA, kHttpsOrigin); - local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Jane")); + local.SetRawInfo(NAME_FIRST, u"Jane"); AutofillProfileChange change(AutofillProfileChange::UPDATE, kGuidA, &local); EXPECT_CALL( @@ -534,7 +532,7 @@ TEST_P(AutofillProfileSyncBridgeTest, AutofillProfileChanged_Deleted) { StartSyncing({}); AutofillProfile local(kGuidB, kHttpsOrigin); - local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Jane")); + local.SetRawInfo(NAME_FIRST, u"Jane"); AutofillProfileChange change(AutofillProfileChange::REMOVE, kGuidB, &local); EXPECT_CALL(mock_processor(), Delete(kGuidB, _)); // The bridge does not need to commit when reacting to a notification about a @@ -560,12 +558,12 @@ TEST_P(AutofillProfileSyncBridgeTest, TEST_P(AutofillProfileSyncBridgeTest, GetAllDataForDebugging) { AutofillProfile local1 = AutofillProfile(kGuidA, kHttpsOrigin); - local1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - local1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); + local1.SetRawInfo(NAME_FIRST, u"John"); + local1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); local1.FinalizeAfterImport(); AutofillProfile local2 = AutofillProfile(kGuidB, kHttpsOrigin); - local2.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom")); - local2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2nd st")); + local2.SetRawInfo(NAME_FIRST, u"Tom"); + local2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"2 2nd st"); local2.FinalizeAfterImport(); AddAutofillProfilesToTable({local1, local2}); @@ -574,12 +572,12 @@ TEST_P(AutofillProfileSyncBridgeTest, GetAllDataForDebugging) { TEST_P(AutofillProfileSyncBridgeTest, GetData) { AutofillProfile local1 = AutofillProfile(kGuidA, kHttpsOrigin); - local1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - local1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); + local1.SetRawInfo(NAME_FIRST, u"John"); + local1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); local1.FinalizeAfterImport(); AutofillProfile local2 = AutofillProfile(kGuidB, kHttpsOrigin); - local2.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom")); - local2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2nd st")); + local2.SetRawInfo(NAME_FIRST, u"Tom"); + local2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"2 2nd st"); local2.FinalizeAfterImport(); AddAutofillProfilesToTable({local1, local2}); @@ -599,26 +597,26 @@ TEST_P(AutofillProfileSyncBridgeTest, GetData) { TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData) { AutofillProfile local1 = AutofillProfile(kGuidA, kHttpOrigin); - local1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - local1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); + local1.SetRawInfo(NAME_FIRST, u"John"); + local1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); local1.FinalizeAfterImport(); AutofillProfile local2 = AutofillProfile(kGuidB, std::string()); - local2.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom")); - local2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2nd st")); + local2.SetRawInfo(NAME_FIRST, u"Tom"); + local2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"2 2nd st"); local2.FinalizeAfterImport(); AddAutofillProfilesToTable({local1, local2}); AutofillProfile remote1 = AutofillProfile(kGuidC, kHttpOrigin); - remote1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Jane")); + remote1.SetRawInfo(NAME_FIRST, u"Jane"); remote1.FinalizeAfterImport(); AutofillProfile remote2 = AutofillProfile(kGuidD, kSettingsOrigin); - remote2.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Harry")); + remote2.SetRawInfo(NAME_FIRST, u"Harry"); remote2.FinalizeAfterImport(); AutofillProfile remote3 = AutofillProfile(kGuidB, kSettingsOrigin); - remote3.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom Doe")); + remote3.SetRawInfo(NAME_FIRST, u"Tom Doe"); remote3.FinalizeAfterImport(); AutofillProfileSpecifics remote1_specifics = @@ -653,9 +651,9 @@ TEST_P(AutofillProfileSyncBridgeTest, ProfileMigration) { return; AutofillProfile remote1 = AutofillProfile(kGuidC, kHttpOrigin); - remote1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Thomas")); - remote1.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("Neo")); - remote1.SetRawInfo(NAME_LAST, ASCIIToUTF16("Anderson")); + remote1.SetRawInfo(NAME_FIRST, u"Thomas"); + remote1.SetRawInfo(NAME_MIDDLE, u"Neo"); + remote1.SetRawInfo(NAME_LAST, u"Anderson"); AutofillProfileSpecifics remote1_specifics = CreateAutofillProfileSpecifics(remote1); @@ -667,25 +665,22 @@ TEST_P(AutofillProfileSyncBridgeTest, ProfileMigration) { // Create the expected profile after migration. AutofillProfile finalized_profile = AutofillProfile(kGuidC, kHttpOrigin); finalized_profile.SetRawInfoWithVerificationStatus( - NAME_FULL, ASCIIToUTF16("Thomas Neo Anderson"), + NAME_FULL, u"Thomas Neo Anderson", structured_address::VerificationStatus::kFormatted); finalized_profile.SetRawInfoWithVerificationStatus( - NAME_FIRST, ASCIIToUTF16("Thomas"), - structured_address::VerificationStatus::kObserved); + NAME_FIRST, u"Thomas", structured_address::VerificationStatus::kObserved); finalized_profile.SetRawInfoWithVerificationStatus( - NAME_MIDDLE, ASCIIToUTF16("Neo"), - structured_address::VerificationStatus::kObserved); + NAME_MIDDLE, u"Neo", structured_address::VerificationStatus::kObserved); finalized_profile.SetRawInfoWithVerificationStatus( - NAME_LAST, ASCIIToUTF16("Anderson"), + NAME_LAST, u"Anderson", structured_address::VerificationStatus::kObserved); finalized_profile.SetRawInfoWithVerificationStatus( - NAME_LAST_SECOND, ASCIIToUTF16("Anderson"), + NAME_LAST_SECOND, u"Anderson", structured_address::VerificationStatus::kParsed); finalized_profile.SetRawInfoWithVerificationStatus( - NAME_LAST_FIRST, ASCIIToUTF16(""), - structured_address::VerificationStatus::kParsed); + NAME_LAST_FIRST, u"", structured_address::VerificationStatus::kParsed); finalized_profile.SetRawInfoWithVerificationStatus( - NAME_LAST_CONJUNCTION, ASCIIToUTF16(""), + NAME_LAST_CONJUNCTION, u"", structured_address::VerificationStatus::kParsed); EXPECT_THAT(GetAllLocalData(), UnorderedElementsAre(finalized_profile)); @@ -723,19 +718,17 @@ TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_SyncAllFieldsToClient) { TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_IdenticalProfiles) { AutofillProfile local1 = AutofillProfile(kGuidA, kHttpOrigin); local1.SetRawInfoWithVerificationStatus( - NAME_FIRST, ASCIIToUTF16("John"), - structured_address::VerificationStatus::kObserved); + NAME_FIRST, u"John", structured_address::VerificationStatus::kObserved); local1.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"), + ADDRESS_HOME_STREET_ADDRESS, u"1 1st st", structured_address::VerificationStatus::kObserved); local1.FinalizeAfterImport(); AutofillProfile local2 = AutofillProfile(kGuidB, kSettingsOrigin); local2.SetRawInfoWithVerificationStatus( - NAME_FIRST, ASCIIToUTF16("Tom"), - structured_address::VerificationStatus::kObserved); + NAME_FIRST, u"Tom", structured_address::VerificationStatus::kObserved); local2.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2nd st"), + ADDRESS_HOME_STREET_ADDRESS, u"2 2nd st", structured_address::VerificationStatus::kObserved); local2.FinalizeAfterImport(); AddAutofillProfilesToTable({local1, local2}); @@ -744,19 +737,17 @@ TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_IdenticalProfiles) { // are different. AutofillProfile remote1 = AutofillProfile(kGuidC, kHttpsOrigin); remote1.SetRawInfoWithVerificationStatus( - NAME_FIRST, ASCIIToUTF16("John"), - structured_address::VerificationStatus::kObserved); + NAME_FIRST, u"John", structured_address::VerificationStatus::kObserved); remote1.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"), + ADDRESS_HOME_STREET_ADDRESS, u"1 1st st", structured_address::VerificationStatus::kObserved); remote1.FinalizeAfterImport(); AutofillProfile remote2 = AutofillProfile(kGuidD, kHttpsOrigin); remote2.SetRawInfoWithVerificationStatus( - NAME_FIRST, ASCIIToUTF16("Tom"), - structured_address::VerificationStatus::kObserved); + NAME_FIRST, u"Tom", structured_address::VerificationStatus::kObserved); remote2.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2nd st"), + ADDRESS_HOME_STREET_ADDRESS, u"2 2nd st", structured_address::VerificationStatus::kObserved); remote2.FinalizeAfterImport(); @@ -782,10 +773,10 @@ TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_IdenticalProfiles) { TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_NonSimilarProfiles) { AutofillProfile local = ConstructCompleteProfile(); local.set_guid(kGuidA); - local.SetRawInfo(NAME_FULL, ASCIIToUTF16("John K. Doe, Jr.")); - local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - local.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("K.")); - local.SetRawInfo(NAME_LAST, ASCIIToUTF16("Doe")); + local.SetRawInfo(NAME_FULL, u"John K. Doe, Jr."); + local.SetRawInfo(NAME_FIRST, u"John"); + local.SetRawInfo(NAME_MIDDLE, u"K."); + local.SetRawInfo(NAME_LAST, u"Doe"); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); @@ -815,14 +806,14 @@ TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_NonSimilarProfiles) { TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_SimilarProfiles) { AutofillProfile local1 = AutofillProfile(kGuidA, kHttpOrigin); - local1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - local1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); + local1.SetRawInfo(NAME_FIRST, u"John"); + local1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); local1.FinalizeAfterImport(); local1.set_use_count(27); AutofillProfile local2 = AutofillProfile(kGuidB, kSettingsOrigin); - local2.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom")); - local2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2nd st")); + local2.SetRawInfo(NAME_FIRST, u"Tom"); + local2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"2 2nd st"); local2.FinalizeAfterImport(); AddAutofillProfilesToTable({local1, local2}); @@ -830,17 +821,17 @@ TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_SimilarProfiles) { // and use_count values are different. Remote ones have additional company // name which makes them not be identical. AutofillProfile remote1 = AutofillProfile(kGuidC, kHttpOrigin); - remote1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - remote1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); - remote1.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Frobbers, Inc.")); + remote1.SetRawInfo(NAME_FIRST, u"John"); + remote1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); + remote1.SetRawInfo(COMPANY_NAME, u"Frobbers, Inc."); // Note, this populates the full name for structured profiles. remote1.FinalizeAfterImport(); remote1.set_use_count(13); AutofillProfile remote2 = AutofillProfile(kGuidD, kHttpOrigin); - remote2.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom")); - remote2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2nd st")); - remote2.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Fizzbang, LLC.")); + remote2.SetRawInfo(NAME_FIRST, u"Tom"); + remote2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"2 2nd st"); + remote2.SetRawInfo(COMPANY_NAME, u"Fizzbang, LLC."); remote2.FinalizeAfterImport(); remote2.set_use_count(4); @@ -889,7 +880,7 @@ TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_SimilarProfiles_OlderUseDate) { // Different guids, same origin, difference in the phone number. AutofillProfile local(kGuidA, kHttpOrigin); - local.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("650234567")); + local.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"650234567"); local.set_use_date(base::Time::FromTimeT(30)); AddAutofillProfilesToTable({local}); @@ -914,7 +905,7 @@ TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_SimilarProfiles_NewerUseDate) { // Different guids, same origin, difference in the phone number. AutofillProfile local(kGuidA, kHttpOrigin); - local.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("650234567")); + local.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"650234567"); local.set_use_date(base::Time::FromTimeT(30)); AddAutofillProfilesToTable({local}); @@ -938,7 +929,7 @@ TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_SimilarProfiles_NonZeroUseCounts) { // Different guids, same origin, difference in the phone number. AutofillProfile local(kGuidA, kHttpOrigin); - local.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("650234567")); + local.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"650234567"); local.set_use_count(12); AddAutofillProfilesToTable({local}); @@ -961,7 +952,7 @@ TEST_P(AutofillProfileSyncBridgeTest, TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_SimilarProfiles_LocalOriginPreserved) { AutofillProfile local(kGuidA, kHttpsOrigin); - local.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("650234567")); + local.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"650234567"); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); @@ -1006,7 +997,7 @@ TEST_P(AutofillProfileSyncBridgeTest, // Expect the local autofill profile to still have an origin after sync. AutofillProfile merged(local); - merged.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); + merged.SetRawInfo(NAME_FIRST, u"John"); merged.FinalizeAfterImport(); EXPECT_THAT(GetAllLocalData(), ElementsAre(merged)); @@ -1018,13 +1009,13 @@ TEST_P(AutofillProfileSyncBridgeTest, TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_SimilarProfiles_LocalMissingOriginPreserved) { AutofillProfile local = AutofillProfile(kGuidA, std::string()); - local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); + local.SetRawInfo(NAME_FIRST, u"John"); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); // Create a Sync profile identical to |local|, except with no origin set. AutofillProfile remote_profile = AutofillProfile(kGuidA, ""); - remote_profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); + remote_profile.SetRawInfo(NAME_FIRST, u"John"); remote_profile.FinalizeAfterImport(); AutofillProfileSpecifics remote = CreateAutofillProfileSpecifics(remote_profile); @@ -1045,7 +1036,7 @@ TEST_P(AutofillProfileSyncBridgeTest, ApplySyncChanges) { StartSyncing({}); AutofillProfile remote_profile = AutofillProfile(kGuidB, kHttpOrigin); - remote_profile.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("Jane")); + remote_profile.SetRawInfo(NAME_FIRST, u"Jane"); remote_profile.FinalizeAfterImport(); AutofillProfileSpecifics remote = CreateAutofillProfileSpecifics(remote_profile); @@ -1092,9 +1083,8 @@ TEST_P(AutofillProfileSyncBridgeTest, StreetAddress_SplitAutomatically) { AutofillProfile local; local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("123 Example St.\n" "Apt. 42")); - EXPECT_EQ(ASCIIToUTF16("123 Example St."), - local.GetRawInfo(ADDRESS_HOME_LINE1)); - EXPECT_EQ(ASCIIToUTF16("Apt. 42"), local.GetRawInfo(ADDRESS_HOME_LINE2)); + EXPECT_EQ(u"123 Example St.", local.GetRawInfo(ADDRESS_HOME_LINE1)); + EXPECT_EQ(u"Apt. 42", local.GetRawInfo(ADDRESS_HOME_LINE2)); // The same does _not_ work for profile specifics. AutofillProfileSpecifics remote; @@ -1109,8 +1099,8 @@ TEST_P(AutofillProfileSyncBridgeTest, StreetAddress_SplitAutomatically) { // sets the street address. TEST_P(AutofillProfileSyncBridgeTest, StreetAddress_JointAutomatically) { AutofillProfile local; - local.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("123 Example St.")); - local.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("Apt. 42")); + local.SetRawInfo(ADDRESS_HOME_LINE1, u"123 Example St."); + local.SetRawInfo(ADDRESS_HOME_LINE2, u"Apt. 42"); EXPECT_EQ(ASCIIToUTF16("123 Example St.\n" "Apt. 42"), local.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS)); @@ -1149,10 +1139,10 @@ TEST_P(AutofillProfileSyncBridgeTest, "Suite #1337"), structured_address::VerificationStatus::kObserved); local.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_LINE1, ASCIIToUTF16("456 El Camino Real"), + ADDRESS_HOME_LINE1, u"456 El Camino Real", structured_address::VerificationStatus::kObserved); local.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_LINE2, ASCIIToUTF16("Suite #1337"), + ADDRESS_HOME_LINE2, u"Suite #1337", structured_address::VerificationStatus::kObserved); local.FinalizeAfterImport(); EXPECT_THAT(GetAllLocalData(), ElementsAre(local)); @@ -1167,7 +1157,7 @@ TEST_P(AutofillProfileSyncBridgeTest, RemoteWithSameGuid_StreetAddress_NoUpdateToEmptyStreetAddressSyncedUp) { AutofillProfile local(kGuidA, kHttpsOrigin); local.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("123 Example St.\nApt. 42"), + ADDRESS_HOME_STREET_ADDRESS, u"123 Example St.\nApt. 42", structured_address::VerificationStatus::kObserved); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); @@ -1254,7 +1244,7 @@ TEST_P(AutofillProfileSyncBridgeTest, // Remote data does not have a language code value. AutofillProfile remote_profile = AutofillProfile(kGuidA, kHttpsOrigin); - remote_profile.SetRawInfo(NAME_FIRST, base::ASCIIToUTF16("John")); + remote_profile.SetRawInfo(NAME_FIRST, u"John"); remote_profile.FinalizeAfterImport(); AutofillProfileSpecifics remote = CreateAutofillProfileSpecifics(remote_profile); @@ -1262,7 +1252,7 @@ TEST_P(AutofillProfileSyncBridgeTest, // Expect local autofill profile to still have "en" language code after AutofillProfile merged(local); - merged.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); + merged.SetRawInfo(NAME_FIRST, u"John"); merged.FinalizeAfterImport(); // No update to sync, remote language code overwrites the local one. @@ -1349,7 +1339,7 @@ TEST_P(AutofillProfileSyncBridgeTest, // Expect local autofill profile to still have the validity state after. AutofillProfile merged(local); - merged.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); + merged.SetRawInfo(NAME_FIRST, u"John"); merged.FinalizeAfterImport(); // No update to sync, the local validity bitfield should stay untouched. @@ -1364,7 +1354,7 @@ TEST_P(AutofillProfileSyncBridgeTest, RemoteWithSameGuid_FullName_MissingValueNoSync) { // Local autofill profile has an empty full name. AutofillProfile local(kGuidA, kHttpsOrigin); - local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); + local.SetRawInfo(NAME_FIRST, u"John"); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); @@ -1390,7 +1380,7 @@ TEST_P(AutofillProfileSyncBridgeTest, // Local autofill profile has a full name. AutofillProfile local(kGuidA, kHttpsOrigin); local.SetRawInfoWithVerificationStatus( - NAME_FULL, ASCIIToUTF16("John Jacob Smith"), + NAME_FULL, u"John Jacob Smith", structured_address::VerificationStatus::kObserved); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); @@ -1409,14 +1399,11 @@ TEST_P(AutofillProfileSyncBridgeTest, // Remote data does not have a full name value. AutofillProfile remote_profile = AutofillProfile(kGuidA, kHttpsOrigin); remote_profile.SetRawInfoWithVerificationStatus( - NAME_FIRST, base::ASCIIToUTF16("John"), - structured_address::VerificationStatus::kObserved); + NAME_FIRST, u"John", structured_address::VerificationStatus::kObserved); remote_profile.SetRawInfoWithVerificationStatus( - NAME_MIDDLE, base::ASCIIToUTF16("Jacob"), - structured_address::VerificationStatus::kObserved); + NAME_MIDDLE, u"Jacob", structured_address::VerificationStatus::kObserved); remote_profile.SetRawInfoWithVerificationStatus( - NAME_LAST, base::ASCIIToUTF16("Smith"), - structured_address::VerificationStatus::kObserved); + NAME_LAST, u"Smith", structured_address::VerificationStatus::kObserved); remote_profile.FinalizeAfterImport(); AutofillProfileSpecifics remote = CreateAutofillProfileSpecifics(remote_profile); @@ -1428,14 +1415,11 @@ TEST_P(AutofillProfileSyncBridgeTest, // |kParsed| for local and becomes |kObserved| when merged with the remote // profile. merged.SetRawInfoWithVerificationStatus( - NAME_FIRST, base::ASCIIToUTF16("John"), - structured_address::VerificationStatus::kObserved); + NAME_FIRST, u"John", structured_address::VerificationStatus::kObserved); merged.SetRawInfoWithVerificationStatus( - NAME_MIDDLE, base::ASCIIToUTF16("Jacob"), - structured_address::VerificationStatus::kObserved); + NAME_MIDDLE, u"Jacob", structured_address::VerificationStatus::kObserved); merged.SetRawInfoWithVerificationStatus( - NAME_LAST, base::ASCIIToUTF16("Smith"), - structured_address::VerificationStatus::kObserved); + NAME_LAST, u"Smith", structured_address::VerificationStatus::kObserved); // No update to sync, merged changes in local data. EXPECT_CALL(mock_processor(), Put(_, _, _)).Times(0); diff --git a/chromium/components/autofill/core/browser/webdata/autofill_profile_sync_difference_tracker_unittest.cc b/chromium/components/autofill/core/browser/webdata/autofill_profile_sync_difference_tracker_unittest.cc index 6ce404382e4..bc6f729a475 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_profile_sync_difference_tracker_unittest.cc +++ b/chromium/components/autofill/core/browser/webdata/autofill_profile_sync_difference_tracker_unittest.cc @@ -138,13 +138,13 @@ class AutofillProfileSyncDifferenceTrackerTest TEST_F(AutofillProfileSyncDifferenceTrackerTest, IncorporateRemoteProfileShouldOverwriteProfileWithSameKey) { AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpOrigin); - local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); + local.SetRawInfo(NAME_FIRST, u"John"); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); // The remote profile is completely different but it has the same key. AutofillProfile remote = AutofillProfile(kSmallerGuid, kHttpsOrigin); - remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom")); + remote.SetRawInfo(NAME_FIRST, u"Tom"); remote.FinalizeAfterImport(); IncorporateRemoteProfile(remote); @@ -159,13 +159,13 @@ TEST_F(AutofillProfileSyncDifferenceTrackerTest, TEST_F(AutofillProfileSyncDifferenceTrackerTest, IncorporateRemoteProfileShouldOverwriteUnverifiedProfileByVerified) { AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpsOrigin); - local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); + local.SetRawInfo(NAME_FIRST, u"John"); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); // The remote profile has the same key but it is not verified. AutofillProfile remote = AutofillProfile(kSmallerGuid, kSettingsOrigin); - remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom")); + remote.SetRawInfo(NAME_FIRST, u"Tom"); remote.FinalizeAfterImport(); IncorporateRemoteProfile(remote); @@ -180,13 +180,13 @@ TEST_F(AutofillProfileSyncDifferenceTrackerTest, TEST_F(AutofillProfileSyncDifferenceTrackerTest, IncorporateRemoteProfileShouldNotOverwriteVerifiedProfileByUnverified) { AutofillProfile local = AutofillProfile(kSmallerGuid, kSettingsOrigin); - local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); + local.SetRawInfo(NAME_FIRST, u"John"); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); // The remote profile has the same key but it is not verified. AutofillProfile remote = AutofillProfile(kSmallerGuid, kHttpsOrigin); - remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom")); + remote.SetRawInfo(NAME_FIRST, u"Tom"); remote.FinalizeAfterImport(); IncorporateRemoteProfile(remote); @@ -200,16 +200,16 @@ TEST_F(AutofillProfileSyncDifferenceTrackerTest, TEST_F(AutofillProfileSyncDifferenceTrackerTest, IncorporateRemoteProfileShouldNotOverwriteFullNameByEmptyString) { AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpOrigin); - local.SetRawInfo(NAME_FULL, ASCIIToUTF16("John")); + local.SetRawInfo(NAME_FULL, u"John"); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); // The remote profile has the same key. AutofillProfile remote = AutofillProfile(kSmallerGuid, kHttpsOrigin); - remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2st st")); + remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"2 2st st"); AutofillProfile merged(remote); - merged.SetRawInfo(NAME_FULL, ASCIIToUTF16("John")); + merged.SetRawInfo(NAME_FULL, u"John"); merged.FinalizeAfterImport(); IncorporateRemoteProfile(remote); @@ -225,16 +225,16 @@ TEST_F( AutofillProfileSyncDifferenceTrackerTest, IncorporateRemoteProfileShouldKeepRemoteKeyWhenMergingDuplicateProfileWithBiggerKey) { AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpOrigin); - local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); + local.SetRawInfo(NAME_FIRST, u"John"); + local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); // The remote profile is identical to the local one, except that the guids and // origins are different. AutofillProfile remote = AutofillProfile(kBiggerGuid, kHttpsOrigin); - remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); + remote.SetRawInfo(NAME_FIRST, u"John"); + remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); remote.FinalizeAfterImport(); IncorporateRemoteProfile(remote); @@ -251,10 +251,9 @@ TEST_F( IncorporateRemoteProfileShouldKeepRemoteKeyAndLocalOriginWhenMergingDuplicateProfileWithBiggerKey) { AutofillProfile local = AutofillProfile(kSmallerGuid, kSettingsOrigin); local.SetRawInfoWithVerificationStatus( - NAME_FIRST, ASCIIToUTF16("John"), - structured_address::VerificationStatus::kObserved); + NAME_FIRST, u"John", structured_address::VerificationStatus::kObserved); local.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"), + ADDRESS_HOME_STREET_ADDRESS, u"1 1st st", structured_address::VerificationStatus::kObserved); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); @@ -262,10 +261,9 @@ TEST_F( // The remote profile has the same key. AutofillProfile remote = AutofillProfile(kBiggerGuid, kHttpsOrigin); remote.SetRawInfoWithVerificationStatus( - NAME_FIRST, ASCIIToUTF16("John"), - structured_address::VerificationStatus::kObserved); + NAME_FIRST, u"John", structured_address::VerificationStatus::kObserved); remote.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"), + ADDRESS_HOME_STREET_ADDRESS, u"1 1st st", structured_address::VerificationStatus::kObserved); remote.FinalizeAfterImport(); @@ -287,16 +285,16 @@ TEST_F( AutofillProfileSyncDifferenceTrackerTest, IncorporateRemoteProfileShouldKeepLocalKeyWhenMergingDuplicateProfileWithSmallerKey) { AutofillProfile local = AutofillProfile(kBiggerGuid, kHttpOrigin); - local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); + local.SetRawInfo(NAME_FIRST, u"John"); + local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); // The remote profile is identical to the local one, except that the guids and // origins are different. AutofillProfile remote = AutofillProfile(kSmallerGuid, kHttpsOrigin); - remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); + remote.SetRawInfo(NAME_FIRST, u"John"); + remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); remote.FinalizeAfterImport(); IncorporateRemoteProfile(remote); @@ -313,10 +311,10 @@ TEST_F( IncorporateRemoteProfileShouldKeepLocalKeyAndRemoteOriginWhenMergingDuplicateProfileWithSmallerKey) { AutofillProfile local = AutofillProfile(kBiggerGuid, kHttpsOrigin); local.SetRawInfoWithVerificationStatus( - NAME_FIRST, ASCIIToUTF16("John"), + NAME_FIRST, u"John", structured_address::VerificationStatus::kUserVerified); local.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"), + ADDRESS_HOME_STREET_ADDRESS, u"1 1st st", structured_address::VerificationStatus::kUserVerified); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); @@ -324,10 +322,10 @@ TEST_F( // The remote profile has the same key. AutofillProfile remote = AutofillProfile(kSmallerGuid, kSettingsOrigin); remote.SetRawInfoWithVerificationStatus( - NAME_FIRST, ASCIIToUTF16("John"), + NAME_FIRST, u"John", structured_address::VerificationStatus::kUserVerified); remote.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"), + ADDRESS_HOME_STREET_ADDRESS, u"1 1st st", structured_address::VerificationStatus::kUserVerified); remote.FinalizeAfterImport(); @@ -389,7 +387,7 @@ TEST_F(AutofillProfileSyncDifferenceTrackerTest, AddAutofillProfilesToTable({local}); AutofillProfile remote = AutofillProfile(kSmallerGuid, kHttpsOrigin); - remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); + remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); remote.FinalizeAfterImport(); IncorporateRemoteProfile(remote); @@ -426,15 +424,15 @@ class AutofillProfileInitialSyncDifferenceTrackerTest TEST_F(AutofillProfileInitialSyncDifferenceTrackerTest, MergeSimilarEntriesForInitialSyncShouldSyncUpChanges) { AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpOrigin); - local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); + local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); local.set_use_count(27); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); // The remote profile matches the local one (except for origin and use count). AutofillProfile remote = AutofillProfile(kBiggerGuid, kHttpsOrigin); - remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); - remote.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Frobbers, Inc.")); + remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); + remote.SetRawInfo(COMPANY_NAME, u"Frobbers, Inc."); remote.set_use_count(13); remote.FinalizeAfterImport(); // The remote profile wins (as regards the storage key). @@ -457,15 +455,15 @@ TEST_F(AutofillProfileInitialSyncDifferenceTrackerTest, TEST_F(AutofillProfileInitialSyncDifferenceTrackerTest, MergeSimilarEntriesForInitialSyncShouldNotSyncUpWhenNotNeeded) { AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpOrigin); - local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); + local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); local.set_use_count(13); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); // The remote profile matches the local one and has some additional data. AutofillProfile remote = AutofillProfile(kBiggerGuid, kHttpOrigin); - remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); - remote.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Frobbers, Inc.")); + remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); + remote.SetRawInfo(COMPANY_NAME, u"Frobbers, Inc."); // Merging two profile takes their max use count, so use count of 27 is taken. remote.set_use_count(27); remote.FinalizeAfterImport(); @@ -482,15 +480,15 @@ TEST_F(AutofillProfileInitialSyncDifferenceTrackerTest, TEST_F(AutofillProfileInitialSyncDifferenceTrackerTest, MergeSimilarEntriesForInitialSyncNotMatchNonsimilarEntries) { AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpOrigin); - local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); - local.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Frobbers, Inc.")); + local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); + local.SetRawInfo(COMPANY_NAME, u"Frobbers, Inc."); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); // The remote profile has a different street address. AutofillProfile remote = AutofillProfile(kBiggerGuid, kHttpOrigin); - remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2st st")); - remote.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Frobbers, Inc.")); + remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"2 2st st"); + remote.SetRawInfo(COMPANY_NAME, u"Frobbers, Inc."); remote.FinalizeAfterImport(); IncorporateRemoteProfile(remote); MergeSimilarEntriesForInitialSync(); @@ -507,14 +505,14 @@ TEST_F(AutofillProfileInitialSyncDifferenceTrackerTest, MergeSimilarEntriesForInitialSyncDoesNotMatchLocalVerifiedEntry) { // The local entry is verified, should not get merged. AutofillProfile local = AutofillProfile(kSmallerGuid, kSettingsOrigin); - local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); + local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); // The remote profile is similar to the local one. AutofillProfile remote = AutofillProfile(kBiggerGuid, kHttpOrigin); - remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); - remote.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Frobbers, Inc.")); + remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); + remote.SetRawInfo(COMPANY_NAME, u"Frobbers, Inc."); remote.FinalizeAfterImport(); IncorporateRemoteProfile(remote); MergeSimilarEntriesForInitialSync(); @@ -530,15 +528,15 @@ TEST_F(AutofillProfileInitialSyncDifferenceTrackerTest, TEST_F(AutofillProfileInitialSyncDifferenceTrackerTest, MergeSimilarEntriesForInitialSyncDoesNotMatchRemoteVerifiedEntry) { AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpOrigin); - local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); + local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); local.FinalizeAfterImport(); AddAutofillProfilesToTable({local}); // The remote profile is similar to the local one but is verified and thus it // should not get merged. AutofillProfile remote = AutofillProfile(kBiggerGuid, kSettingsOrigin); - remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); - remote.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Frobbers, Inc.")); + remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, u"1 1st st"); + remote.SetRawInfo(COMPANY_NAME, u"Frobbers, Inc."); remote.FinalizeAfterImport(); IncorporateRemoteProfile(remote); MergeSimilarEntriesForInitialSync(); diff --git a/chromium/components/autofill/core/browser/webdata/autofill_table.cc b/chromium/components/autofill/core/browser/webdata/autofill_table.cc index 52ea59d94bb..563a4c9780f 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_table.cc +++ b/chromium/components/autofill/core/browser/webdata/autofill_table.cc @@ -63,8 +63,8 @@ constexpr structured_address::VerificationStatus kNoStatus = // Helper struct for AutofillTable::RemoveFormElementsAddedBetween(). // Contains all the necessary fields to update a row in the 'autofill' table. struct AutofillUpdate { - base::string16 name; - base::string16 value; + std::u16string name; + std::u16string value; time_t date_created; time_t date_last_used; int count; @@ -72,9 +72,9 @@ struct AutofillUpdate { // Returns the |data_model|'s value corresponding to the |type|, trimmed to the // maximum length that can be stored in a column of the Autofill database. -base::string16 GetInfo(const AutofillDataModel& data_model, +std::u16string GetInfo(const AutofillDataModel& data_model, ServerFieldType type) { - base::string16 data = data_model.GetRawInfo(type); + std::u16string data = data_model.GetRawInfo(type); if (data.size() > AutofillTable::kMaxDataLength) return data.substr(0, AutofillTable::kMaxDataLength); @@ -128,7 +128,7 @@ void AddAutofillProfileDetailsFromStatement(const sql::Statement& s, void BindEncryptedCardToColumn(sql::Statement* s, int column_index, - const base::string16& number, + const std::u16string& number, const AutofillTableEncryptor& encryptor) { std::string encrypted_data; encryptor.EncryptString16(number, &encrypted_data); @@ -158,11 +158,11 @@ void BindCreditCardToStatement(const CreditCard& credit_card, s->BindString16(index++, credit_card.nickname()); } -base::string16 UnencryptedCardFromColumn( +std::u16string UnencryptedCardFromColumn( const sql::Statement& s, int column_index, const AutofillTableEncryptor& encryptor) { - base::string16 credit_card_number; + std::u16string credit_card_number; int encrypted_number_len = s.ColumnByteLength(column_index); if (encrypted_number_len) { std::string encrypted_number; @@ -416,24 +416,24 @@ bool AddAutofillProfileAddressesToProfile(sql::Database* db, if (s.Step()) { DCHECK_EQ(profile->guid(), s.ColumnString(0)); - base::string16 street_address = s.ColumnString16(1); - base::string16 dependent_locality = s.ColumnString16(13); - base::string16 city = s.ColumnString16(15); - base::string16 state = s.ColumnString16(17); - base::string16 zip_code = s.ColumnString16(19); - base::string16 sorting_code = s.ColumnString16(21); - base::string16 country = s.ColumnString16(23); - - base::string16 street_address_legacy = + std::u16string street_address = s.ColumnString16(1); + std::u16string dependent_locality = s.ColumnString16(13); + std::u16string city = s.ColumnString16(15); + std::u16string state = s.ColumnString16(17); + std::u16string zip_code = s.ColumnString16(19); + std::u16string sorting_code = s.ColumnString16(21); + std::u16string country = s.ColumnString16(23); + + std::u16string street_address_legacy = profile->GetRawInfo(ADDRESS_HOME_STREET_ADDRESS); - base::string16 dependent_locality_legacy = + std::u16string dependent_locality_legacy = profile->GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY); - base::string16 city_legacy = profile->GetRawInfo(ADDRESS_HOME_CITY); - base::string16 state_legacy = profile->GetRawInfo(ADDRESS_HOME_STATE); - base::string16 zip_code_legacy = profile->GetRawInfo(ADDRESS_HOME_ZIP); - base::string16 sorting_code_legacy = + std::u16string city_legacy = profile->GetRawInfo(ADDRESS_HOME_CITY); + std::u16string state_legacy = profile->GetRawInfo(ADDRESS_HOME_STATE); + std::u16string zip_code_legacy = profile->GetRawInfo(ADDRESS_HOME_ZIP); + std::u16string sorting_code_legacy = profile->GetRawInfo(ADDRESS_HOME_SORTING_CODE); - base::string16 country_legacy = profile->GetRawInfo(ADDRESS_HOME_COUNTRY); + std::u16string country_legacy = profile->GetRawInfo(ADDRESS_HOME_COUNTRY); // At this stage, the unstructured address was already written to // the profile. If the address was changed by a legacy client, the @@ -632,17 +632,17 @@ CreditCard::ServerStatus ServerStatusStringToEnum(const std::string& status) { // Returns |s| with |escaper| in front of each of occurrence of a character // from |special_chars|. Any occurrence of |escaper| in |s| is doubled. For // example, Substitute("hello_world!", "_%", '!'') returns "hello!_world!!". -base::string16 Substitute(const base::string16& s, - const base::string16& special_chars, - const base::char16& escaper) { +std::u16string Substitute(const std::u16string& s, + const std::u16string& special_chars, + const char16_t& escaper) { // Prepend |escaper| to the list of |special_chars|. - base::string16 escape_wildcards(special_chars); + std::u16string escape_wildcards(special_chars); escape_wildcards.insert(escape_wildcards.begin(), escaper); // Prepend the |escaper| just before |special_chars| in |s|. - base::string16 result(s); - for (base::char16 c : escape_wildcards) { - for (size_t pos = 0; (pos = result.find(c, pos)) != base::string16::npos; + std::u16string result(s); + for (char16_t c : escape_wildcards) { + for (size_t pos = 0; (pos = result.find(c, pos)) != std::u16string::npos; pos += 2) { result.insert(result.begin() + pos, escaper); } @@ -802,8 +802,8 @@ bool AutofillTable::AddFormFieldValue(const FormFieldData& element, } bool AutofillTable::GetFormValuesForElementName( - const base::string16& name, - const base::string16& prefix, + const std::u16string& name, + const std::u16string& prefix, std::vector<AutofillEntry>* entries, int limit) { DCHECK(entries); @@ -829,8 +829,8 @@ bool AutofillTable::GetFormValuesForElementName( succeeded = s.Succeeded(); } else { - base::string16 prefix_lower = base::i18n::ToLower(prefix); - base::string16 next_prefix = prefix_lower; + std::u16string prefix_lower = base::i18n::ToLower(prefix); + std::u16string next_prefix = prefix_lower; next_prefix.back()++; sql::Statement s1; @@ -873,8 +873,7 @@ bool AutofillTable::GetFormValuesForElementName( s2.BindString16(0, name); // escaper as L'!' -> 0x21. - s2.BindString16(1, - Substitute(prefix_lower, base::ASCIIToUTF16("_%"), 0x21)); + s2.BindString16(1, Substitute(prefix_lower, u"_%", 0x21)); s2.BindInt(2, limit); while (s2.Step()) { entries->push_back(AutofillEntry( @@ -912,8 +911,8 @@ bool AutofillTable::RemoveFormElementsAddedBetween( std::vector<AutofillUpdate> updates; std::vector<AutofillChange> tentative_changes; while (s.Step()) { - base::string16 name = s.ColumnString16(0); - base::string16 value = s.ColumnString16(1); + std::u16string name = s.ColumnString16(0); + std::u16string value = s.ColumnString16(1); int count = s.ColumnInt(2); time_t date_created_time_t = s.ColumnInt64(3); time_t date_last_used_time_t = s.ColumnInt64(4); @@ -1011,8 +1010,8 @@ bool AutofillTable::RemoveExpiredFormElements( select_for_delete.BindInt64(0, expiration_time.ToTimeT()); std::vector<AutofillChange> tentative_changes; while (select_for_delete.Step()) { - base::string16 name = select_for_delete.ColumnString16(0); - base::string16 value = select_for_delete.ColumnString16(1); + std::u16string name = select_for_delete.ColumnString16(0); + std::u16string value = select_for_delete.ColumnString16(1); tentative_changes.push_back( AutofillChange(change_type, AutofillKey(name, value))); } @@ -1030,8 +1029,8 @@ bool AutofillTable::RemoveExpiredFormElements( return true; } -bool AutofillTable::RemoveFormElement(const base::string16& name, - const base::string16& value) { +bool AutofillTable::RemoveFormElement(const std::u16string& name, + const std::u16string& value) { sql::Statement s(db_->GetUniqueStatement( "DELETE FROM autofill WHERE name = ? AND value= ?")); s.BindString16(0, name); @@ -1066,8 +1065,8 @@ bool AutofillTable::GetAllAutofillEntries(std::vector<AutofillEntry>* entries) { "SELECT name, value, date_created, date_last_used FROM autofill")); while (s.Step()) { - base::string16 name = s.ColumnString16(0); - base::string16 value = s.ColumnString16(1); + std::u16string name = s.ColumnString16(0); + std::u16string value = s.ColumnString16(1); base::Time date_created = base::Time::FromTimeT(s.ColumnInt64(2)); base::Time date_last_used = base::Time::FromTimeT(s.ColumnInt64(3)); entries->push_back( @@ -1077,8 +1076,8 @@ bool AutofillTable::GetAllAutofillEntries(std::vector<AutofillEntry>* entries) { return s.Succeeded(); } -bool AutofillTable::GetAutofillTimestamps(const base::string16& name, - const base::string16& value, +bool AutofillTable::GetAutofillTimestamps(const std::u16string& name, + const std::u16string& value, base::Time* date_created, base::Time* date_last_used) { sql::Statement s(db_->GetUniqueStatement( @@ -1308,7 +1307,7 @@ bool AutofillTable::GetServerProfiles( // here to override the default value of AutofillClock::Now(). profile->set_modification_date(base::Time()); - base::string16 recipient_name = s.ColumnString16(index++); + std::u16string recipient_name = s.ColumnString16(index++); profile->SetRawInfo(COMPANY_NAME, s.ColumnString16(index++)); profile->SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, s.ColumnString16(index++)); profile->SetRawInfo(ADDRESS_HOME_STATE, s.ColumnString16(index++)); @@ -1319,7 +1318,7 @@ bool AutofillTable::GetServerProfiles( profile->SetRawInfo(ADDRESS_HOME_ZIP, s.ColumnString16(index++)); profile->SetRawInfo(ADDRESS_HOME_SORTING_CODE, s.ColumnString16(index++)); profile->SetRawInfo(ADDRESS_HOME_COUNTRY, s.ColumnString16(index++)); - base::string16 phone_number = s.ColumnString16(index++); + std::u16string phone_number = s.ColumnString16(index++); profile->set_language_code(s.ColumnString(index++)); profile->set_has_converted(s.ColumnBool(index++)); @@ -1547,9 +1546,9 @@ bool AutofillTable::GetServerCreditCards( // If the card_number_encrypted field is nonempty, we can assume this card // is a full card, otherwise it's masked. - base::string16 full_card_number = + std::u16string full_card_number = UnencryptedCardFromColumn(s, index++, *autofill_table_encryptor_); - base::string16 last_four = s.ColumnString16(index++); + std::u16string last_four = s.ColumnString16(index++); CreditCard::RecordType record_type = full_card_number.empty() ? CreditCard::MASKED_SERVER_CARD : CreditCard::FULL_SERVER_CARD; @@ -1618,7 +1617,7 @@ void AutofillTable::SetServerCreditCards( } bool AutofillTable::UnmaskServerCreditCard(const CreditCard& masked, - const base::string16& full_number) { + const std::u16string& full_number) { sql::Transaction transaction(db_); if (!transaction.Begin()) return false; @@ -2024,8 +2023,8 @@ bool AutofillTable::GetPaymentsCustomerData( sql::Statement s(db_->GetUniqueStatement( "SELECT customer_id FROM payments_customer_data")); if (s.Step()) { - customer_data->reset( - new PaymentsCustomerData(/*customer_id=*/s.ColumnString(0))); + *customer_data = std::make_unique<PaymentsCustomerData>( + /*customer_id=*/s.ColumnString(0)); } return s.Succeeded(); @@ -2585,11 +2584,11 @@ bool AutofillTable::MigrateToVersion54AddI18nFieldsAndRemoveDeprecatedFields() { "SELECT guid, address_line_1, address_line_2 FROM autofill_profiles")); while (s.Step()) { std::string guid = s.ColumnString(0); - base::string16 line1 = s.ColumnString16(1); - base::string16 line2 = s.ColumnString16(2); - base::string16 street_address = line1; + std::u16string line1 = s.ColumnString16(1); + std::u16string line2 = s.ColumnString16(2); + std::u16string street_address = line1; if (!line2.empty()) - street_address += base::ASCIIToUTF16("\n") + line2; + street_address += u"\n" + line2; sql::Statement s_update(db_->GetUniqueStatement( "UPDATE autofill_profiles_temp SET street_address=? WHERE guid=?")); @@ -2895,7 +2894,7 @@ bool AutofillTable::MigrateToVersion65AddServerMetadataTables() { AutofillProfile profile(AutofillProfile::SERVER_PROFILE, s.ColumnString(index++)); - base::string16 recipient_name = s.ColumnString16(index++); + std::u16string recipient_name = s.ColumnString16(index++); profile.SetRawInfo(COMPANY_NAME, s.ColumnString16(index++)); profile.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, s.ColumnString16(index++)); profile.SetRawInfo(ADDRESS_HOME_STATE, s.ColumnString16(index++)); @@ -2906,7 +2905,7 @@ bool AutofillTable::MigrateToVersion65AddServerMetadataTables() { profile.SetRawInfo(ADDRESS_HOME_ZIP, s.ColumnString16(index++)); profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, s.ColumnString16(index++)); profile.SetRawInfo(ADDRESS_HOME_COUNTRY, s.ColumnString16(index++)); - base::string16 phone_number = s.ColumnString16(index++); + std::u16string phone_number = s.ColumnString16(index++); profile.set_language_code(s.ColumnString(index++)); profile.SetInfo(NAME_FULL, recipient_name, profile.language_code()); profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, phone_number, @@ -3413,7 +3412,7 @@ bool AutofillTable::AddFormFieldValuesTime( // to track this. Add up to |kMaximumUniqueNames| unique entries per // form. const size_t kMaximumUniqueNames = 256; - std::set<base::string16> seen_names; + std::set<std::u16string> seen_names; bool result = true; for (const FormFieldData& element : elements) { if (seen_names.size() >= kMaximumUniqueNames) @@ -3603,7 +3602,7 @@ void AutofillTable::AddMaskedCreditCards( } void AutofillTable::AddUnmaskedCreditCard(const std::string& id, - const base::string16& full_number) { + const std::u16string& full_number) { sql::Statement s( db_->GetUniqueStatement("INSERT INTO unmasked_credit_cards(" "id," diff --git a/chromium/components/autofill/core/browser/webdata/autofill_table.h b/chromium/components/autofill/core/browser/webdata/autofill_table.h index 91b13512f01..518bde702a0 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_table.h +++ b/chromium/components/autofill/core/browser/webdata/autofill_table.h @@ -14,7 +14,6 @@ #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "base/strings/string16.h" #include "components/sync/base/model_type.h" #include "components/sync/model/metadata_batch.h" #include "components/sync/model/sync_metadata_store.h" @@ -438,8 +437,8 @@ class AutofillTable : public WebDatabaseTable, // Retrieves a vector of all values which have been recorded in the autofill // table as the value in a form element with name |name| and which start with // |prefix|. The comparison of the prefix is case insensitive. - bool GetFormValuesForElementName(const base::string16& name, - const base::string16& prefix, + bool GetFormValuesForElementName(const std::u16string& name, + const std::u16string& prefix, std::vector<AutofillEntry>* entries, int limit); @@ -460,8 +459,8 @@ class AutofillTable : public WebDatabaseTable, bool RemoveExpiredFormElements(std::vector<AutofillChange>* changes); // Removes the row from the autofill table for the given |name| |value| pair. - virtual bool RemoveFormElement(const base::string16& name, - const base::string16& value); + virtual bool RemoveFormElement(const std::u16string& name, + const std::u16string& value); // Returns the number of unique values such that for all autofill entries with // that value, the interval between creation date and last usage is entirely @@ -473,8 +472,8 @@ class AutofillTable : public WebDatabaseTable, virtual bool GetAllAutofillEntries(std::vector<AutofillEntry>* entries); // Retrieves a single entry from the autofill table. - virtual bool GetAutofillTimestamps(const base::string16& name, - const base::string16& value, + virtual bool GetAutofillTimestamps(const std::u16string& name, + const std::u16string& value, base::Time* date_created, base::Time* date_last_used); @@ -536,7 +535,7 @@ class AutofillTable : public WebDatabaseTable, // available) or "unmasked" (everything is available). These functions set // that state. bool UnmaskServerCreditCard(const CreditCard& masked, - const base::string16& full_number); + const std::u16string& full_number); bool MaskServerCreditCard(const std::string& id); // Methods to add, update, remove and get the metadata for server cards and @@ -769,7 +768,7 @@ class AutofillTable : public WebDatabaseTable, // Adds to |unmasked_credit_cards|. void AddUnmaskedCreditCard(const std::string& id, - const base::string16& full_number); + const std::u16string& full_number); // Deletes server credit cards by |id|. Returns true if a row was deleted. bool DeleteFromMaskedCreditCards(const std::string& id); diff --git a/chromium/components/autofill/core/browser/webdata/autofill_table_encryptor.h b/chromium/components/autofill/core/browser/webdata/autofill_table_encryptor.h index 2391cd722a2..9a951aa4ba0 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_table_encryptor.h +++ b/chromium/components/autofill/core/browser/webdata/autofill_table_encryptor.h @@ -7,7 +7,6 @@ #include <string> -#include "base/strings/string16.h" namespace autofill { // Encryptor used by Autofill table. @@ -15,10 +14,10 @@ class AutofillTableEncryptor { public: virtual ~AutofillTableEncryptor() = default; - virtual bool EncryptString16(const base::string16& plaintext, + virtual bool EncryptString16(const std::u16string& plaintext, std::string* ciphertext) const = 0; virtual bool DecryptString16(const std::string& ciphertext, - base::string16* plaintext) const = 0; + std::u16string* plaintext) const = 0; }; } // namespace autofill diff --git a/chromium/components/autofill/core/browser/webdata/autofill_table_unittest.cc b/chromium/components/autofill/core/browser/webdata/autofill_table_unittest.cc index 92683da27b8..3e1088216f7 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_table_unittest.cc +++ b/chromium/components/autofill/core/browser/webdata/autofill_table_unittest.cc @@ -5,7 +5,9 @@ #include "components/autofill/core/browser/webdata/autofill_table.h" #include <map> +#include <memory> #include <set> +#include <string> #include <tuple> #include <utility> @@ -14,7 +16,6 @@ #include "base/files/scoped_temp_dir.h" #include "base/guid.h" #include "base/stl_util.h" -#include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" @@ -124,8 +125,8 @@ void CompareAutofillEntrySets(const AutofillEntrySet& actual, EXPECT_EQ(actual.size(), count); } -int GetAutofillEntryCount(const base::string16& name, - const base::string16& value, +int GetAutofillEntryCount(const std::u16string& name, + const std::u16string& value, WebDatabase* db) { sql::Statement s(db->GetSQLConnection()->GetUniqueStatement( "SELECT count FROM autofill WHERE name = ? AND value = ?")); @@ -150,8 +151,8 @@ class AutofillTableTest : public testing::Test { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); file_ = temp_dir_.GetPath().AppendASCII("TestWebDatabase"); - table_.reset(new AutofillTable); - db_.reset(new WebDatabase); + table_ = std::make_unique<AutofillTable>(); + db_ = std::make_unique<WebDatabase>(); db_->AddTable(table_.get()); ASSERT_EQ(sql::INIT_OK, db_->Init(file_)); } @@ -172,71 +173,67 @@ TEST_F(AutofillTableTest, Autofill) { // some more often than others. AutofillChangeList changes; FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; base::Time now = AutofillClock::Now(); base::TimeDelta two_seconds = base::TimeDelta::FromSeconds(2); EXPECT_TRUE(table_->AddFormFieldValue(field, &changes)); std::vector<AutofillEntry> v; for (int i = 0; i < 5; ++i) { - field.value = ASCIIToUTF16("Clark Kent"); + field.value = u"Clark Kent"; EXPECT_TRUE( table_->AddFormFieldValueTime(field, &changes, now + i * two_seconds)); } for (int i = 0; i < 3; ++i) { - field.value = ASCIIToUTF16("Clark Sutter"); + field.value = u"Clark Sutter"; EXPECT_TRUE( table_->AddFormFieldValueTime(field, &changes, now + i * two_seconds)); } for (int i = 0; i < 2; ++i) { - field.name = ASCIIToUTF16("Favorite Color"); - field.value = ASCIIToUTF16("Green"); + field.name = u"Favorite Color"; + field.value = u"Green"; EXPECT_TRUE( table_->AddFormFieldValueTime(field, &changes, now + i * two_seconds)); } // We have added the name Clark Kent 5 times, so count should be 5. - EXPECT_EQ(5, GetAutofillEntryCount(ASCIIToUTF16("Name"), - ASCIIToUTF16("Clark Kent"), db_.get())); + EXPECT_EQ(5, GetAutofillEntryCount(u"Name", u"Clark Kent", db_.get())); // Storing in the data base should be case sensitive, so there should be no // database entry for clark kent lowercase. - EXPECT_EQ(0, GetAutofillEntryCount(ASCIIToUTF16("Name"), - ASCIIToUTF16("clark kent"), db_.get())); + EXPECT_EQ(0, GetAutofillEntryCount(u"Name", u"clark kent", db_.get())); - EXPECT_EQ(2, GetAutofillEntryCount(ASCIIToUTF16("Favorite Color"), - ASCIIToUTF16("Green"), db_.get())); + EXPECT_EQ(2, GetAutofillEntryCount(u"Favorite Color", u"Green", db_.get())); // This is meant to get a list of suggestions for Name. The empty prefix // in the second argument means it should return all suggestions for a name // no matter what they start with. The order that the names occur in the list // should be decreasing order by count. - EXPECT_TRUE(table_->GetFormValuesForElementName(ASCIIToUTF16("Name"), - base::string16(), &v, 6)); + EXPECT_TRUE( + table_->GetFormValuesForElementName(u"Name", std::u16string(), &v, 6)); EXPECT_EQ(3U, v.size()); if (v.size() == 3) { - EXPECT_EQ(ASCIIToUTF16("Clark Kent"), v[0].key().value()); - EXPECT_EQ(ASCIIToUTF16("Clark Sutter"), v[1].key().value()); - EXPECT_EQ(ASCIIToUTF16("Superman"), v[2].key().value()); + EXPECT_EQ(u"Clark Kent", v[0].key().value()); + EXPECT_EQ(u"Clark Sutter", v[1].key().value()); + EXPECT_EQ(u"Superman", v[2].key().value()); } // If we query again limiting the list size to 1, we should only get the most // frequent entry. - EXPECT_TRUE(table_->GetFormValuesForElementName(ASCIIToUTF16("Name"), - base::string16(), &v, 1)); + EXPECT_TRUE( + table_->GetFormValuesForElementName(u"Name", std::u16string(), &v, 1)); EXPECT_EQ(1U, v.size()); if (v.size() == 1) { - EXPECT_EQ(ASCIIToUTF16("Clark Kent"), v[0].key().value()); + EXPECT_EQ(u"Clark Kent", v[0].key().value()); } // Querying for suggestions given a prefix is case-insensitive, so the prefix // "cLa" shoud get suggestions for both Clarks. - EXPECT_TRUE(table_->GetFormValuesForElementName(ASCIIToUTF16("Name"), - ASCIIToUTF16("cLa"), &v, 6)); + EXPECT_TRUE(table_->GetFormValuesForElementName(u"Name", u"cLa", &v, 6)); EXPECT_EQ(2U, v.size()); if (v.size() == 2) { - EXPECT_EQ(ASCIIToUTF16("Clark Kent"), v[0].key().value()); - EXPECT_EQ(ASCIIToUTF16("Clark Sutter"), v[1].key().value()); + EXPECT_EQ(u"Clark Kent", v[0].key().value()); + EXPECT_EQ(u"Clark Sutter", v[1].key().value()); } // Removing all elements since the beginning of this function should remove @@ -245,70 +242,64 @@ TEST_F(AutofillTableTest, Autofill) { EXPECT_TRUE(table_->RemoveFormElementsAddedBetween(t1, Time(), &changes)); const AutofillChange kExpectedChanges[] = { - AutofillChange( - AutofillChange::REMOVE, - AutofillKey(ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"))), - AutofillChange( - AutofillChange::REMOVE, - AutofillKey(ASCIIToUTF16("Name"), ASCIIToUTF16("Clark Kent"))), - AutofillChange( - AutofillChange::REMOVE, - AutofillKey(ASCIIToUTF16("Name"), ASCIIToUTF16("Clark Sutter"))), - AutofillChange( - AutofillChange::REMOVE, - AutofillKey(ASCIIToUTF16("Favorite Color"), ASCIIToUTF16("Green"))), + AutofillChange(AutofillChange::REMOVE, AutofillKey(u"Name", u"Superman")), + AutofillChange(AutofillChange::REMOVE, + AutofillKey(u"Name", u"Clark Kent")), + AutofillChange(AutofillChange::REMOVE, + AutofillKey(u"Name", u"Clark Sutter")), + AutofillChange(AutofillChange::REMOVE, + AutofillKey(u"Favorite Color", u"Green")), }; EXPECT_EQ(base::size(kExpectedChanges), changes.size()); for (size_t i = 0; i < base::size(kExpectedChanges); ++i) { EXPECT_EQ(kExpectedChanges[i], changes[i]); } - EXPECT_EQ(0, GetAutofillEntryCount(ASCIIToUTF16("Name"), - ASCIIToUTF16("Clark Kent"), db_.get())); + EXPECT_EQ(0, GetAutofillEntryCount(u"Name", u"Clark Kent", db_.get())); - EXPECT_TRUE(table_->GetFormValuesForElementName(ASCIIToUTF16("Name"), - base::string16(), &v, 6)); + EXPECT_TRUE( + table_->GetFormValuesForElementName(u"Name", std::u16string(), &v, 6)); EXPECT_EQ(0U, v.size()); // Now add some values with empty strings. - const base::string16 kValue = ASCIIToUTF16(" toto "); - field.name = ASCIIToUTF16("blank"); - field.value = base::string16(); + const std::u16string kValue = u" toto "; + field.name = u"blank"; + field.value = std::u16string(); EXPECT_TRUE(table_->AddFormFieldValue(field, &changes)); - field.name = ASCIIToUTF16("blank"); - field.value = ASCIIToUTF16(" "); + field.name = u"blank"; + field.value = u" "; EXPECT_TRUE(table_->AddFormFieldValue(field, &changes)); - field.name = ASCIIToUTF16("blank"); - field.value = ASCIIToUTF16(" "); + field.name = u"blank"; + field.value = u" "; EXPECT_TRUE(table_->AddFormFieldValue(field, &changes)); - field.name = ASCIIToUTF16("blank"); + field.name = u"blank"; field.value = kValue; EXPECT_TRUE(table_->AddFormFieldValue(field, &changes)); // They should be stored normally as the DB layer does not check for empty // values. v.clear(); - EXPECT_TRUE(table_->GetFormValuesForElementName(ASCIIToUTF16("blank"), - base::string16(), &v, 10)); + EXPECT_TRUE( + table_->GetFormValuesForElementName(u"blank", std::u16string(), &v, 10)); EXPECT_EQ(4U, v.size()); } TEST_F(AutofillTableTest, Autofill_GetEntry_Populated) { AutofillChangeList changes; FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; base::Time now = base::Time::FromDoubleT(1546889367); EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, now)); std::vector<AutofillEntry> prefix_v; - EXPECT_TRUE(table_->GetFormValuesForElementName( - field.name, ASCIIToUTF16("Super"), &prefix_v, 10)); + EXPECT_TRUE( + table_->GetFormValuesForElementName(field.name, u"Super", &prefix_v, 10)); std::vector<AutofillEntry> no_prefix_v; - EXPECT_TRUE(table_->GetFormValuesForElementName(field.name, ASCIIToUTF16(""), - &no_prefix_v, 10)); + EXPECT_TRUE( + table_->GetFormValuesForElementName(field.name, u"", &no_prefix_v, 10)); AutofillEntry expected_entry(AutofillKey(field.name, field.value), now, now); @@ -318,10 +309,10 @@ TEST_F(AutofillTableTest, Autofill_GetEntry_Populated) { // Update date_last_used. base::Time new_time = now + base::TimeDelta::FromSeconds(1000); EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, new_time)); - EXPECT_TRUE(table_->GetFormValuesForElementName( - field.name, ASCIIToUTF16("Super"), &prefix_v, 10)); - EXPECT_TRUE(table_->GetFormValuesForElementName(field.name, ASCIIToUTF16(""), - &no_prefix_v, 10)); + EXPECT_TRUE( + table_->GetFormValuesForElementName(field.name, u"Super", &prefix_v, 10)); + EXPECT_TRUE( + table_->GetFormValuesForElementName(field.name, u"", &no_prefix_v, 10)); expected_entry = AutofillEntry(AutofillKey(field.name, field.value), now, new_time); @@ -402,27 +393,25 @@ TEST_F(AutofillTableTest, Autofill_RemoveBetweenChanges) { AutofillChangeList changes; FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, t1)); EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, t2)); changes.clear(); EXPECT_TRUE(table_->RemoveFormElementsAddedBetween(t1, t2, &changes)); ASSERT_EQ(1U, changes.size()); - EXPECT_EQ(AutofillChange( - AutofillChange::UPDATE, - AutofillKey(ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"))), - changes[0]); + EXPECT_EQ( + AutofillChange(AutofillChange::UPDATE, AutofillKey(u"Name", u"Superman")), + changes[0]); changes.clear(); EXPECT_TRUE( table_->RemoveFormElementsAddedBetween(t2, t2 + one_day, &changes)); ASSERT_EQ(1U, changes.size()); - EXPECT_EQ(AutofillChange( - AutofillChange::REMOVE, - AutofillKey(ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"))), - changes[0]); + EXPECT_EQ( + AutofillChange(AutofillChange::REMOVE, AutofillKey(u"Name", u"Superman")), + changes[0]); } TEST_F(AutofillTableTest, Autofill_AddChanges) { @@ -432,22 +421,20 @@ TEST_F(AutofillTableTest, Autofill_AddChanges) { AutofillChangeList changes; FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, t1)); ASSERT_EQ(1U, changes.size()); - EXPECT_EQ(AutofillChange( - AutofillChange::ADD, - AutofillKey(ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"))), - changes[0]); + EXPECT_EQ( + AutofillChange(AutofillChange::ADD, AutofillKey(u"Name", u"Superman")), + changes[0]); changes.clear(); EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, t2)); ASSERT_EQ(1U, changes.size()); - EXPECT_EQ(AutofillChange( - AutofillChange::UPDATE, - AutofillKey(ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"))), - changes[0]); + EXPECT_EQ( + AutofillChange(AutofillChange::UPDATE, AutofillKey(u"Name", u"Superman")), + changes[0]); } TEST_F(AutofillTableTest, Autofill_UpdateOneWithOneTimestamp) { @@ -456,8 +443,7 @@ TEST_F(AutofillTableTest, Autofill_UpdateOneWithOneTimestamp) { entries.push_back(entry); ASSERT_TRUE(table_->UpdateAutofillEntries(entries)); - EXPECT_EQ(1, GetAutofillEntryCount(ASCIIToUTF16("foo"), ASCIIToUTF16("bar"), - db_.get())); + EXPECT_EQ(1, GetAutofillEntryCount(u"foo", u"bar", db_.get())); std::vector<AutofillEntry> all_entries; ASSERT_TRUE(table_->GetAllAutofillEntries(&all_entries)); @@ -471,8 +457,7 @@ TEST_F(AutofillTableTest, Autofill_UpdateOneWithTwoTimestamps) { entries.push_back(entry); ASSERT_TRUE(table_->UpdateAutofillEntries(entries)); - EXPECT_EQ(2, GetAutofillEntryCount(ASCIIToUTF16("foo"), ASCIIToUTF16("bar"), - db_.get())); + EXPECT_EQ(2, GetAutofillEntryCount(u"foo", u"bar", db_.get())); std::vector<AutofillEntry> all_entries; ASSERT_TRUE(table_->GetAllAutofillEntries(&all_entries)); @@ -487,8 +472,7 @@ TEST_F(AutofillTableTest, Autofill_GetAutofillTimestamps) { ASSERT_TRUE(table_->UpdateAutofillEntries(entries)); Time date_created, date_last_used; - ASSERT_TRUE(table_->GetAutofillTimestamps(ASCIIToUTF16("foo"), - ASCIIToUTF16("bar"), &date_created, + ASSERT_TRUE(table_->GetAutofillTimestamps(u"foo", u"bar", &date_created, &date_last_used)); EXPECT_EQ(Time::FromTimeT(1), date_created); EXPECT_EQ(Time::FromTimeT(2), date_last_used); @@ -502,10 +486,8 @@ TEST_F(AutofillTableTest, Autofill_UpdateTwo) { entries.push_back(entry1); ASSERT_TRUE(table_->UpdateAutofillEntries(entries)); - EXPECT_EQ(1, GetAutofillEntryCount(ASCIIToUTF16("foo"), ASCIIToUTF16("bar0"), - db_.get())); - EXPECT_EQ(2, GetAutofillEntryCount(ASCIIToUTF16("foo"), ASCIIToUTF16("bar1"), - db_.get())); + EXPECT_EQ(1, GetAutofillEntryCount(u"foo", u"bar0", db_.get())); + EXPECT_EQ(2, GetAutofillEntryCount(u"foo", u"bar1", db_.get())); } TEST_F(AutofillTableTest, Autofill_UpdateNullTerminated) { @@ -537,8 +519,8 @@ TEST_F(AutofillTableTest, Autofill_UpdateReplace) { AutofillChangeList changes; // Add a form field. This will be replaced. FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; EXPECT_TRUE(table_->AddFormFieldValue(field, &changes)); AutofillEntry entry(MakeAutofillEntry("Name", "Superman", 1, 2)); @@ -585,20 +567,20 @@ TEST_F(AutofillTableTest, Autofill_AddFormFieldValues) { // http://crbug.com/51727. std::vector<FormFieldData> elements; FormFieldData field; - field.name = ASCIIToUTF16("firstname"); - field.value = ASCIIToUTF16("Joe"); + field.name = u"firstname"; + field.value = u"Joe"; elements.push_back(field); - field.name = ASCIIToUTF16("firstname"); - field.value = ASCIIToUTF16("Jane"); + field.name = u"firstname"; + field.value = u"Jane"; elements.push_back(field); - field.name = ASCIIToUTF16("lastname"); - field.value = ASCIIToUTF16("Smith"); + field.name = u"lastname"; + field.value = u"Smith"; elements.push_back(field); - field.name = ASCIIToUTF16("lastname"); - field.value = ASCIIToUTF16("Jones"); + field.name = u"lastname"; + field.value = u"Jones"; elements.push_back(field); std::vector<AutofillChange> changes; @@ -606,11 +588,9 @@ TEST_F(AutofillTableTest, Autofill_AddFormFieldValues) { ASSERT_EQ(2U, changes.size()); EXPECT_EQ(changes[0], AutofillChange(AutofillChange::ADD, - AutofillKey(ASCIIToUTF16("firstname"), - ASCIIToUTF16("Joe")))); + AutofillKey(u"firstname", u"Joe"))); EXPECT_EQ(changes[1], AutofillChange(AutofillChange::ADD, - AutofillKey(ASCIIToUTF16("lastname"), - ASCIIToUTF16("Smith")))); + AutofillKey(u"lastname", u"Smith"))); std::vector<AutofillEntry> all_entries; ASSERT_TRUE(table_->GetAllAutofillEntries(&all_entries)); @@ -622,8 +602,8 @@ TEST_F(AutofillTableTest, // Add an entry used only before the targetted range. AutofillChangeList changes; FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, base::Time::FromTimeT(10))); EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, @@ -649,8 +629,8 @@ TEST_F(AutofillTableTest, // Add an entry used only after the targetted range. AutofillChangeList changes; FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, base::Time::FromTimeT(50))); EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, @@ -676,8 +656,8 @@ TEST_F(AutofillTableTest, // Add an entry used entirely during the targetted range. AutofillChangeList changes; FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, base::Time::FromTimeT(10))); EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, @@ -706,8 +686,8 @@ TEST_F(AutofillTableTest, // Add an entry used both before and during the targetted range. AutofillChangeList changes; FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, base::Time::FromTimeT(10))); EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, @@ -741,8 +721,8 @@ TEST_F(AutofillTableTest, // Add an entry used both during and after the targetted range. AutofillChangeList changes; FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, base::Time::FromTimeT(50))); EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, @@ -781,12 +761,12 @@ TEST_F(AutofillTableTest, // Add some form field entries. AutofillChangeList changes; FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, kNow)); - field.value = ASCIIToUTF16("Clark Kent"); + field.value = u"Clark Kent"; EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, k29DaysOld)); - field.value = ASCIIToUTF16("Clark Sutter"); + field.value = u"Clark Sutter"; EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, k31DaysOld)); EXPECT_EQ(3U, changes.size()); @@ -796,15 +776,11 @@ TEST_F(AutofillTableTest, &changes)); ASSERT_EQ(1U, changes.size()); EXPECT_EQ(AutofillChange(AutofillChange::REMOVE, - AutofillKey(ASCIIToUTF16("Name"), - ASCIIToUTF16("Clark Sutter"))), + AutofillKey(u"Name", u"Clark Sutter")), changes[0]); - EXPECT_EQ(0, GetAutofillEntryCount(ASCIIToUTF16("Name"), - ASCIIToUTF16("Clark Sutter"), db_.get())); - EXPECT_EQ(1, GetAutofillEntryCount(ASCIIToUTF16("Name"), - ASCIIToUTF16("Superman"), db_.get())); - EXPECT_EQ(1, GetAutofillEntryCount(ASCIIToUTF16("Name"), - ASCIIToUTF16("Clark Kent"), db_.get())); + EXPECT_EQ(0, GetAutofillEntryCount(u"Name", u"Clark Sutter", db_.get())); + EXPECT_EQ(1, GetAutofillEntryCount(u"Name", u"Superman", db_.get())); + EXPECT_EQ(1, GetAutofillEntryCount(u"Name", u"Clark Kent", db_.get())); changes.clear(); } @@ -817,8 +793,8 @@ TEST_F(AutofillTableTest, RemoveExpiredFormElements_Expires_DeleteEntry) { AutofillChangeList changes; FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, k2YearsOld)); changes.clear(); @@ -837,8 +813,8 @@ TEST_F(AutofillTableTest, RemoveExpiredFormElements_NotOldEnough) { AutofillChangeList changes; FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, k2DaysOld)); changes.clear(); @@ -858,59 +834,52 @@ TEST_F(AutofillTableTest, // TODO(crbug.com/1113617): Honorifics are temporally disabled. // structured_name_profile.SetRawInfoWithVerificationStatus( - // NAME_HONORIFIC_PREFIX, ASCIIToUTF16("Dr."), + // NAME_HONORIFIC_PREFIX, u"Dr.", // VerificationStatus::kObserved); structured_name_profile.SetRawInfoWithVerificationStatus( - NAME_FIRST, ASCIIToUTF16("John"), VerificationStatus::kObserved); + NAME_FIRST, u"John", VerificationStatus::kObserved); structured_name_profile.SetRawInfoWithVerificationStatus( - NAME_MIDDLE, ASCIIToUTF16("Q."), VerificationStatus::kObserved); + NAME_MIDDLE, u"Q.", VerificationStatus::kObserved); structured_name_profile.SetRawInfoWithVerificationStatus( - NAME_LAST_FIRST, ASCIIToUTF16("Agent"), VerificationStatus::kParsed); + NAME_LAST_FIRST, u"Agent", VerificationStatus::kParsed); structured_name_profile.SetRawInfoWithVerificationStatus( - NAME_LAST_CONJUNCTION, ASCIIToUTF16("007"), VerificationStatus::kParsed); + NAME_LAST_CONJUNCTION, u"007", VerificationStatus::kParsed); structured_name_profile.SetRawInfoWithVerificationStatus( - NAME_LAST_SECOND, ASCIIToUTF16("Smith"), VerificationStatus::kParsed); + NAME_LAST_SECOND, u"Smith", VerificationStatus::kParsed); structured_name_profile.SetRawInfoWithVerificationStatus( - NAME_LAST, ASCIIToUTF16("Agent 007 Smith"), VerificationStatus::kParsed); + NAME_LAST, u"Agent 007 Smith", VerificationStatus::kParsed); structured_name_profile.SetRawInfoWithVerificationStatus( - NAME_FULL, ASCIIToUTF16("John Q. Agent 007 Smith"), - VerificationStatus::kObserved); + NAME_FULL, u"John Q. Agent 007 Smith", VerificationStatus::kObserved); - structured_name_profile.SetRawInfo(EMAIL_ADDRESS, - ASCIIToUTF16("js@smith.xyz")); + structured_name_profile.SetRawInfo(EMAIL_ADDRESS, u"js@smith.xyz"); - structured_name_profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Google")); + structured_name_profile.SetRawInfo(COMPANY_NAME, u"Google"); - structured_name_profile.SetRawInfo(ADDRESS_HOME_LINE1, - ASCIIToUTF16("1234 Apple Way")); + structured_name_profile.SetRawInfo(ADDRESS_HOME_LINE1, u"1234 Apple Way"); - structured_name_profile.SetRawInfo(ADDRESS_HOME_LINE2, - ASCIIToUTF16("unit 5")); + structured_name_profile.SetRawInfo(ADDRESS_HOME_LINE2, u"unit 5"); structured_name_profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, - ASCIIToUTF16("Beverly Hills")); + u"Beverly Hills"); - structured_name_profile.SetRawInfo(ADDRESS_HOME_CITY, - ASCIIToUTF16("Los Angeles")); + structured_name_profile.SetRawInfo(ADDRESS_HOME_CITY, u"Los Angeles"); - structured_name_profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA")); + structured_name_profile.SetRawInfo(ADDRESS_HOME_STATE, u"CA"); - structured_name_profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90025")); + structured_name_profile.SetRawInfo(ADDRESS_HOME_ZIP, u"90025"); - structured_name_profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, - ASCIIToUTF16("MAGIC ###")); + structured_name_profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, u"MAGIC ###"); - structured_name_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); + structured_name_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US"); - structured_name_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - ASCIIToUTF16("18181234567")); + structured_name_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"18181234567"); structured_name_profile.set_language_code("en"); @@ -944,11 +913,10 @@ TEST_F(AutofillTableTest, // the legacy structure. // TODO(crbug.com/1113617): Honorifics are temporally disabled. EXPECT_EQ(db_legacy_profile->GetRawInfo(NAME_FULL), - ASCIIToUTF16("John Q. Agent 007 Smith")); - EXPECT_EQ(db_legacy_profile->GetRawInfo(NAME_FIRST), ASCIIToUTF16("John")); - EXPECT_EQ(db_legacy_profile->GetRawInfo(NAME_MIDDLE), ASCIIToUTF16("Q.")); - EXPECT_EQ(db_legacy_profile->GetRawInfo(NAME_LAST), - ASCIIToUTF16("Agent 007 Smith")); + u"John Q. Agent 007 Smith"); + EXPECT_EQ(db_legacy_profile->GetRawInfo(NAME_FIRST), u"John"); + EXPECT_EQ(db_legacy_profile->GetRawInfo(NAME_MIDDLE), u"Q."); + EXPECT_EQ(db_legacy_profile->GetRawInfo(NAME_LAST), u"Agent 007 Smith"); EXPECT_TRUE(db_legacy_profile->GetRawInfo(NAME_HONORIFIC_PREFIX).empty()); EXPECT_TRUE(db_legacy_profile->GetRawInfo(NAME_LAST_FIRST).empty()); EXPECT_TRUE(db_legacy_profile->GetRawInfo(NAME_LAST_CONJUNCTION).empty()); @@ -1004,16 +972,15 @@ TEST_F(AutofillTableTest, // the profile is migrated correctly. // TODO(crbug.com/1113617): Honorifics are temporally disabled. EXPECT_EQ(db_migrated_profile->GetRawInfo(NAME_FULL), - ASCIIToUTF16("John Q. Agent 007 Smith")); + u"John Q. Agent 007 Smith"); EXPECT_TRUE(db_migrated_profile->GetRawInfo(NAME_HONORIFIC_PREFIX).empty()); - EXPECT_EQ(db_migrated_profile->GetRawInfo(NAME_FIRST), ASCIIToUTF16("John")); - EXPECT_EQ(db_migrated_profile->GetRawInfo(NAME_MIDDLE), ASCIIToUTF16("Q.")); - EXPECT_EQ(db_migrated_profile->GetRawInfo(NAME_LAST), - ASCIIToUTF16("Agent 007 Smith")); + EXPECT_EQ(db_migrated_profile->GetRawInfo(NAME_FIRST), u"John"); + EXPECT_EQ(db_migrated_profile->GetRawInfo(NAME_MIDDLE), u"Q."); + EXPECT_EQ(db_migrated_profile->GetRawInfo(NAME_LAST), u"Agent 007 Smith"); EXPECT_TRUE(db_migrated_profile->GetRawInfo(NAME_LAST_FIRST).empty()); EXPECT_TRUE(db_migrated_profile->GetRawInfo(NAME_LAST_CONJUNCTION).empty()); EXPECT_EQ(db_migrated_profile->GetRawInfo(NAME_LAST_SECOND), - ASCIIToUTF16("Agent 007 Smith")); + u"Agent 007 Smith"); EXPECT_EQ(db_migrated_profile->GetVerificationStatus(NAME_FULL), VerificationStatus::kObserved); @@ -1047,50 +1014,46 @@ TEST_F(AutofillTableTest, AutofillProfile_StructuredAddresses) { profile.SetRawInfoWithVerificationStatus( ADDRESS_HOME_STREET_ADDRESS, - ASCIIToUTF16("Street Name House Number Premise APT 10 Floor 2"), + u"Street Name House Number Premise APT 10 Floor 2", VerificationStatus::kUserVerified); - profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_STREET_NAME, - ASCIIToUTF16("Street Name"), - VerificationStatus::kFormatted); + profile.SetRawInfoWithVerificationStatus( + ADDRESS_HOME_STREET_NAME, u"Street Name", VerificationStatus::kFormatted); profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_DEPENDENT_LOCALITY, - ASCIIToUTF16("Dependent Locality"), + u"Dependent Locality", VerificationStatus::kObserved); - profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_CITY, ASCIIToUTF16("City"), VerificationStatus::kObserved); + profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_CITY, u"City", + VerificationStatus::kObserved); - profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STATE, ASCIIToUTF16("State"), VerificationStatus::kObserved); + profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_STATE, u"State", + VerificationStatus::kObserved); profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_SORTING_CODE, - ASCIIToUTF16("Sorting Code"), + u"Sorting Code", VerificationStatus::kObserved); - profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_ZIP, ASCIIToUTF16("ZIP"), VerificationStatus::kObserved); + profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_ZIP, u"ZIP", + VerificationStatus::kObserved); - profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE"), VerificationStatus::kObserved); + profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_COUNTRY, u"DE", + VerificationStatus::kObserved); profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_DEPENDENT_STREET_NAME, - ASCIIToUTF16(""), - VerificationStatus::kObserved); + u"", VerificationStatus::kObserved); profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_HOUSE_NUMBER, - ASCIIToUTF16("House Number"), + u"House Number", VerificationStatus::kUserVerified); profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_SUBPREMISE, - ASCIIToUTF16("APT 10 Floor 2"), + u"APT 10 Floor 2", VerificationStatus::kUserVerified); + profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_APT_NUM, u"10", + VerificationStatus::kParsed); + profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_FLOOR, u"2", + VerificationStatus::kParsed); profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_APT_NUM, ASCIIToUTF16("10"), VerificationStatus::kParsed); - profile.SetRawInfoWithVerificationStatus( - ADDRESS_HOME_FLOOR, ASCIIToUTF16("2"), VerificationStatus::kParsed); - profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_PREMISE_NAME, - ASCIIToUTF16("Premise"), - VerificationStatus::kUserVerified); - ASSERT_EQ(profile.GetRawInfo(ADDRESS_HOME_STREET_NAME), - ASCIIToUTF16("Street Name")); + ADDRESS_HOME_PREMISE_NAME, u"Premise", VerificationStatus::kUserVerified); + ASSERT_EQ(profile.GetRawInfo(ADDRESS_HOME_STREET_NAME), u"Street Name"); // Add the profile to the table. EXPECT_TRUE(table_->AddAutofillProfile(profile)); @@ -1140,26 +1103,20 @@ TEST_F(AutofillTableTest, AutofillProfile_StructuredAddresses) { EXPECT_EQ(db_profile->GetVerificationStatus(ADDRESS_HOME_COUNTRY), VerificationStatus::kObserved); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_STREET_NAME), - ASCIIToUTF16("Street Name")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME), - ASCIIToUTF16("")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), - ASCIIToUTF16("House Number")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_SUBPREMISE), - ASCIIToUTF16("APT 10 Floor 2")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_APT_NUM), ASCIIToUTF16("10")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_FLOOR), ASCIIToUTF16("2")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_PREMISE_NAME), - ASCIIToUTF16("Premise")); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_STREET_NAME), u"Street Name"); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME), u""); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), u"House Number"); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_SUBPREMISE), u"APT 10 Floor 2"); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_APT_NUM), u"10"); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_FLOOR), u"2"); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_PREMISE_NAME), u"Premise"); EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY), - ASCIIToUTF16("Dependent Locality")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_CITY), ASCIIToUTF16("City")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_STATE), ASCIIToUTF16("State")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_SORTING_CODE), - ASCIIToUTF16("Sorting Code")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_ZIP), ASCIIToUTF16("ZIP")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("DE")); + u"Dependent Locality"); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_CITY), u"City"); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_STATE), u"State"); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_SORTING_CODE), u"Sorting Code"); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_ZIP), u"ZIP"); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_COUNTRY), u"DE"); EXPECT_EQ(profile, *db_profile); } @@ -1178,25 +1135,21 @@ TEST_F(AutofillTableTest, profile.SetRawInfoWithVerificationStatus( ADDRESS_HOME_STREET_ADDRESS, - ASCIIToUTF16("Street Name House Number Premise Subpremise"), + u"Street Name House Number Premise Subpremise", VerificationStatus::kUserVerified); - profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_STREET_NAME, - ASCIIToUTF16("Street Name"), - VerificationStatus::kFormatted); + profile.SetRawInfoWithVerificationStatus( + ADDRESS_HOME_STREET_NAME, u"Street Name", VerificationStatus::kFormatted); profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_DEPENDENT_STREET_NAME, - ASCIIToUTF16(""), - VerificationStatus::kObserved); + u"", VerificationStatus::kObserved); profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_HOUSE_NUMBER, - ASCIIToUTF16("House Number"), + u"House Number", VerificationStatus::kUserVerified); profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_SUBPREMISE, - ASCIIToUTF16("Subpremise"), - VerificationStatus::kUserVerified); - profile.SetRawInfoWithVerificationStatus(ADDRESS_HOME_PREMISE_NAME, - ASCIIToUTF16("Premise"), + u"Subpremise", VerificationStatus::kUserVerified); - ASSERT_EQ(profile.GetRawInfo(ADDRESS_HOME_STREET_NAME), - ASCIIToUTF16("Street Name")); + profile.SetRawInfoWithVerificationStatus( + ADDRESS_HOME_PREMISE_NAME, u"Premise", VerificationStatus::kUserVerified); + ASSERT_EQ(profile.GetRawInfo(ADDRESS_HOME_STREET_NAME), u"Street Name"); // Add the profile to the table. EXPECT_TRUE(table_->AddAutofillProfile(profile)); @@ -1208,16 +1161,11 @@ TEST_F(AutofillTableTest, // Verify that it is correct. EXPECT_EQ(profile, *db_profile); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_STREET_NAME), - ASCIIToUTF16("Street Name")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME), - ASCIIToUTF16("")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), - ASCIIToUTF16("House Number")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_SUBPREMISE), - ASCIIToUTF16("Subpremise")); - EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_PREMISE_NAME), - ASCIIToUTF16("Premise")); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_STREET_NAME), u"Street Name"); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME), u""); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), u"House Number"); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_SUBPREMISE), u"Subpremise"); + EXPECT_EQ(db_profile->GetRawInfo(ADDRESS_HOME_PREMISE_NAME), u"Premise"); // Deactivate the features. scoped_feature_list_.Reset(); @@ -1231,25 +1179,25 @@ TEST_F(AutofillTableTest, ASSERT_TRUE(legacy_db_profile); EXPECT_EQ(legacy_db_profile->GetRawInfo(ADDRESS_HOME_STREET_NAME), - base::string16()); + std::u16string()); EXPECT_EQ(legacy_db_profile->GetRawInfo(ADDRESS_HOME_DEPENDENT_STREET_NAME), - base::string16()); + std::u16string()); EXPECT_EQ(legacy_db_profile->GetRawInfo(ADDRESS_HOME_HOUSE_NUMBER), - base::string16()); + std::u16string()); EXPECT_EQ(legacy_db_profile->GetRawInfo(ADDRESS_HOME_SUBPREMISE), - base::string16()); + std::u16string()); EXPECT_EQ(legacy_db_profile->GetRawInfo(ADDRESS_HOME_PREMISE_NAME), - base::string16()); + std::u16string()); // Change the street address and update the profile. legacy_db_profile->SetRawInfoWithVerificationStatus( - ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("Other Street Address"), + ADDRESS_HOME_STREET_ADDRESS, u"Other Street Address", VerificationStatus::kUserVerified); table_->UpdateAutofillProfile(*legacy_db_profile); std::unique_ptr<AutofillProfile> changed_db_profile = table_->GetAutofillProfile(profile.guid()); EXPECT_EQ(changed_db_profile->GetRawInfo(ADDRESS_HOME_STREET_ADDRESS), - ASCIIToUTF16("Other Street Address")); + u"Other Street Address"); // Note, this step already removes the structured address entry from the // table. To simulate the behavior of legacy clients, we manually insert it @@ -1258,7 +1206,7 @@ TEST_F(AutofillTableTest, "INSERT INTO autofill_profile_addresses " "(guid, street_address) VALUES (?,?)")); s.BindString(0, profile.guid()); - s.BindString16(1, ASCIIToUTF16("Street Address")); + s.BindString16(1, u"Street Address"); ASSERT_TRUE(s.is_valid()); ASSERT_TRUE(s.Run()); @@ -1309,52 +1257,48 @@ TEST_F(AutofillTableTest, AutofillProfile_StructuredNames) { // TODO(crbug.com/1113617): Honorifics are temporally disabled. // home_profile.SetRawInfoWithVerificationStatus( - // NAME_HONORIFIC_PREFIX, ASCIIToUTF16("Dr."), + // NAME_HONORIFIC_PREFIX, u"Dr.", // VerificationStatus::kObserved); - home_profile.SetRawInfoWithVerificationStatus(NAME_HONORIFIC_PREFIX, - ASCIIToUTF16("Dr."), + home_profile.SetRawInfoWithVerificationStatus(NAME_HONORIFIC_PREFIX, u"Dr.", VerificationStatus::kObserved); - home_profile.SetRawInfoWithVerificationStatus( - NAME_FIRST, ASCIIToUTF16("John"), VerificationStatus::kObserved); + home_profile.SetRawInfoWithVerificationStatus(NAME_FIRST, u"John", + VerificationStatus::kObserved); - home_profile.SetRawInfoWithVerificationStatus(NAME_MIDDLE, ASCIIToUTF16("Q."), + home_profile.SetRawInfoWithVerificationStatus(NAME_MIDDLE, u"Q.", VerificationStatus::kObserved); - home_profile.SetRawInfoWithVerificationStatus( - NAME_LAST_FIRST, ASCIIToUTF16("Agent"), VerificationStatus::kParsed); + home_profile.SetRawInfoWithVerificationStatus(NAME_LAST_FIRST, u"Agent", + VerificationStatus::kParsed); - home_profile.SetRawInfoWithVerificationStatus( - NAME_LAST_CONJUNCTION, ASCIIToUTF16("007"), VerificationStatus::kParsed); + home_profile.SetRawInfoWithVerificationStatus(NAME_LAST_CONJUNCTION, u"007", + VerificationStatus::kParsed); - home_profile.SetRawInfoWithVerificationStatus( - NAME_LAST_SECOND, ASCIIToUTF16("Smith"), VerificationStatus::kParsed); + home_profile.SetRawInfoWithVerificationStatus(NAME_LAST_SECOND, u"Smith", + VerificationStatus::kParsed); - home_profile.SetRawInfoWithVerificationStatus( - NAME_LAST, ASCIIToUTF16("Agent 007 Smith"), VerificationStatus::kParsed); + home_profile.SetRawInfoWithVerificationStatus(NAME_LAST, u"Agent 007 Smith", + VerificationStatus::kParsed); home_profile.SetRawInfoWithVerificationStatus( - NAME_FULL, ASCIIToUTF16("John Q. Agent 007 Smith"), - VerificationStatus::kObserved); + NAME_FULL, u"John Q. Agent 007 Smith", VerificationStatus::kObserved); - home_profile.SetRawInfoWithVerificationStatus( - NAME_FULL_WITH_HONORIFIC_PREFIX, - ASCIIToUTF16("Dr. John Q. Agent 007 Smith"), - VerificationStatus::kObserved); + home_profile.SetRawInfoWithVerificationStatus(NAME_FULL_WITH_HONORIFIC_PREFIX, + u"Dr. John Q. Agent 007 Smith", + VerificationStatus::kObserved); - home_profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("js@smith.xyz")); - home_profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Google")); - home_profile.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("1234 Apple Way")); - home_profile.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("unit 5")); - home_profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, - ASCIIToUTF16("Beverly Hills")); - home_profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Los Angeles")); - home_profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA")); - home_profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90025")); - home_profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, ASCIIToUTF16("MAGIC ###")); - home_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); - home_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567")); + home_profile.SetRawInfo(EMAIL_ADDRESS, u"js@smith.xyz"); + home_profile.SetRawInfo(COMPANY_NAME, u"Google"); + home_profile.SetRawInfo(ADDRESS_HOME_LINE1, u"1234 Apple Way"); + home_profile.SetRawInfo(ADDRESS_HOME_LINE2, u"unit 5"); + home_profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u"Beverly Hills"); + home_profile.SetRawInfo(ADDRESS_HOME_CITY, u"Los Angeles"); + home_profile.SetRawInfo(ADDRESS_HOME_STATE, u"CA"); + home_profile.SetRawInfo(ADDRESS_HOME_ZIP, u"90025"); + home_profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, u"MAGIC ###"); + home_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US"); + home_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"18181234567"); home_profile.set_language_code("en"); home_profile.SetClientValidityFromBitfieldValue(6); home_profile.set_is_client_validity_states_updated(true); @@ -1386,9 +1330,8 @@ TEST_F(AutofillTableTest, AutofillProfile_StructuredNames) { AutofillProfile billing_profile = home_profile; billing_profile.set_guid(base::GenerateGUID()); billing_profile.set_origin("https://www.example.com/"); - billing_profile.SetRawInfo(ADDRESS_HOME_LINE1, - ASCIIToUTF16("5678 Bottom Street")); - billing_profile.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("suite 3")); + billing_profile.SetRawInfo(ADDRESS_HOME_LINE1, u"5678 Bottom Street"); + billing_profile.SetRawInfo(ADDRESS_HOME_LINE2, u"suite 3"); pre_creation_time = AutofillClock::Now(); EXPECT_TRUE(table_->AddAutofillProfile(billing_profile)); @@ -1409,7 +1352,7 @@ TEST_F(AutofillTableTest, AutofillProfile_StructuredNames) { // Update the 'Billing' profile, name only. billing_profile.SetRawInfoWithVerificationStatus( - NAME_FIRST, ASCIIToUTF16("Jane"), VerificationStatus::kObserved); + NAME_FIRST, u"Jane", VerificationStatus::kObserved); Time pre_modification_time = AutofillClock::Now(); EXPECT_TRUE(table_->UpdateAutofillProfile(billing_profile)); Time post_modification_time = AutofillClock::Now(); @@ -1429,30 +1372,28 @@ TEST_F(AutofillTableTest, AutofillProfile_StructuredNames) { // not important. billing_profile.set_origin(kSettingsOrigin); billing_profile.SetRawInfoWithVerificationStatus( - NAME_FIRST, ASCIIToUTF16("Pablo"), VerificationStatus::kObserved); - billing_profile.SetRawInfoWithVerificationStatus( - NAME_MIDDLE, ASCIIToUTF16("Diege"), VerificationStatus::kObserved); - billing_profile.SetRawInfoWithVerificationStatus( - NAME_LAST_FIRST, ASCIIToUTF16("Ruiz"), VerificationStatus::kParsed); - billing_profile.SetRawInfoWithVerificationStatus( - NAME_LAST_CONJUNCTION, ASCIIToUTF16("y"), VerificationStatus::kParsed); - billing_profile.SetRawInfoWithVerificationStatus( - NAME_LAST, ASCIIToUTF16("Ruiz y Picasoo"), VerificationStatus::kParsed); + NAME_FIRST, u"Pablo", VerificationStatus::kObserved); billing_profile.SetRawInfoWithVerificationStatus( - NAME_LAST_SECOND, ASCIIToUTF16("Picasoo"), VerificationStatus::kParsed); - billing_profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("jane@singer.com")); - billing_profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Indy")); - billing_profile.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("Open Road")); - billing_profile.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("Route 66")); - billing_profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, - ASCIIToUTF16("District 9")); - billing_profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("NFA")); - billing_profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("NY")); - billing_profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("10011")); - billing_profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, ASCIIToUTF16("123456")); - billing_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); - billing_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - ASCIIToUTF16("18181230000")); + NAME_MIDDLE, u"Diege", VerificationStatus::kObserved); + billing_profile.SetRawInfoWithVerificationStatus(NAME_LAST_FIRST, u"Ruiz", + VerificationStatus::kParsed); + billing_profile.SetRawInfoWithVerificationStatus(NAME_LAST_CONJUNCTION, u"y", + VerificationStatus::kParsed); + billing_profile.SetRawInfoWithVerificationStatus(NAME_LAST, u"Ruiz y Picasoo", + VerificationStatus::kParsed); + billing_profile.SetRawInfoWithVerificationStatus(NAME_LAST_SECOND, u"Picasoo", + VerificationStatus::kParsed); + billing_profile.SetRawInfo(EMAIL_ADDRESS, u"jane@singer.com"); + billing_profile.SetRawInfo(COMPANY_NAME, u"Indy"); + billing_profile.SetRawInfo(ADDRESS_HOME_LINE1, u"Open Road"); + billing_profile.SetRawInfo(ADDRESS_HOME_LINE2, u"Route 66"); + billing_profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u"District 9"); + billing_profile.SetRawInfo(ADDRESS_HOME_CITY, u"NFA"); + billing_profile.SetRawInfo(ADDRESS_HOME_STATE, u"NY"); + billing_profile.SetRawInfo(ADDRESS_HOME_ZIP, u"10011"); + billing_profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, u"123456"); + billing_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US"); + billing_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"18181230000"); billing_profile.SetClientValidityFromBitfieldValue(54); billing_profile.set_is_client_validity_states_updated(true); @@ -1493,21 +1434,20 @@ TEST_F(AutofillTableTest, AutofillProfile) { // important. AutofillProfile home_profile; home_profile.set_origin(std::string()); - home_profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - home_profile.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("Q.")); - home_profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith")); - home_profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("js@smith.xyz")); - home_profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Google")); - home_profile.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("1234 Apple Way")); - home_profile.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("unit 5")); - home_profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, - ASCIIToUTF16("Beverly Hills")); - home_profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Los Angeles")); - home_profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA")); - home_profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90025")); - home_profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, ASCIIToUTF16("MAGIC ###")); - home_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); - home_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567")); + home_profile.SetRawInfo(NAME_FIRST, u"John"); + home_profile.SetRawInfo(NAME_MIDDLE, u"Q."); + home_profile.SetRawInfo(NAME_LAST, u"Smith"); + home_profile.SetRawInfo(EMAIL_ADDRESS, u"js@smith.xyz"); + home_profile.SetRawInfo(COMPANY_NAME, u"Google"); + home_profile.SetRawInfo(ADDRESS_HOME_LINE1, u"1234 Apple Way"); + home_profile.SetRawInfo(ADDRESS_HOME_LINE2, u"unit 5"); + home_profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u"Beverly Hills"); + home_profile.SetRawInfo(ADDRESS_HOME_CITY, u"Los Angeles"); + home_profile.SetRawInfo(ADDRESS_HOME_STATE, u"CA"); + home_profile.SetRawInfo(ADDRESS_HOME_ZIP, u"90025"); + home_profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, u"MAGIC ###"); + home_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US"); + home_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"18181234567"); home_profile.set_language_code("en"); home_profile.SetClientValidityFromBitfieldValue(6); home_profile.set_is_client_validity_states_updated(true); @@ -1535,9 +1475,8 @@ TEST_F(AutofillTableTest, AutofillProfile) { AutofillProfile billing_profile = home_profile; billing_profile.set_guid(base::GenerateGUID()); billing_profile.set_origin("https://www.example.com/"); - billing_profile.SetRawInfo(ADDRESS_HOME_LINE1, - ASCIIToUTF16("5678 Bottom Street")); - billing_profile.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("suite 3")); + billing_profile.SetRawInfo(ADDRESS_HOME_LINE1, u"5678 Bottom Street"); + billing_profile.SetRawInfo(ADDRESS_HOME_LINE2, u"suite 3"); pre_creation_time = AutofillClock::Now(); EXPECT_TRUE(table_->AddAutofillProfile(billing_profile)); @@ -1557,7 +1496,7 @@ TEST_F(AutofillTableTest, AutofillProfile) { EXPECT_FALSE(s_billing.Step()); // Update the 'Billing' profile, name only. - billing_profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Jane")); + billing_profile.SetRawInfo(NAME_FIRST, u"Jane"); Time pre_modification_time = AutofillClock::Now(); EXPECT_TRUE(table_->UpdateAutofillProfile(billing_profile)); Time post_modification_time = AutofillClock::Now(); @@ -1576,22 +1515,20 @@ TEST_F(AutofillTableTest, AutofillProfile) { // Update the 'Billing' profile with non-default data. The specific values are // not important. billing_profile.set_origin(kSettingsOrigin); - billing_profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Janice")); - billing_profile.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("C.")); - billing_profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Joplin")); - billing_profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("jane@singer.com")); - billing_profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Indy")); - billing_profile.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("Open Road")); - billing_profile.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("Route 66")); - billing_profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, - ASCIIToUTF16("District 9")); - billing_profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("NFA")); - billing_profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("NY")); - billing_profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("10011")); - billing_profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, ASCIIToUTF16("123456")); - billing_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); - billing_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, - ASCIIToUTF16("18181230000")); + billing_profile.SetRawInfo(NAME_FIRST, u"Janice"); + billing_profile.SetRawInfo(NAME_MIDDLE, u"C."); + billing_profile.SetRawInfo(NAME_FIRST, u"Joplin"); + billing_profile.SetRawInfo(EMAIL_ADDRESS, u"jane@singer.com"); + billing_profile.SetRawInfo(COMPANY_NAME, u"Indy"); + billing_profile.SetRawInfo(ADDRESS_HOME_LINE1, u"Open Road"); + billing_profile.SetRawInfo(ADDRESS_HOME_LINE2, u"Route 66"); + billing_profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, u"District 9"); + billing_profile.SetRawInfo(ADDRESS_HOME_CITY, u"NFA"); + billing_profile.SetRawInfo(ADDRESS_HOME_STATE, u"NY"); + billing_profile.SetRawInfo(ADDRESS_HOME_ZIP, u"10011"); + billing_profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, u"123456"); + billing_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US"); + billing_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"18181230000"); billing_profile.SetClientValidityFromBitfieldValue(54); billing_profile.set_is_client_validity_states_updated(true); @@ -1623,14 +1560,11 @@ TEST_F(AutofillTableTest, CreditCard) { // Add a 'Work' credit card. CreditCard work_creditcard; work_creditcard.set_origin("https://www.example.com/"); - work_creditcard.SetRawInfo(CREDIT_CARD_NAME_FULL, - ASCIIToUTF16("Jack Torrance")); - work_creditcard.SetRawInfo(CREDIT_CARD_NUMBER, - ASCIIToUTF16("1234567890123456")); - work_creditcard.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("04")); - work_creditcard.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, - ASCIIToUTF16("2013")); - work_creditcard.SetNickname(ASCIIToUTF16("Corporate card")); + work_creditcard.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Jack Torrance"); + work_creditcard.SetRawInfo(CREDIT_CARD_NUMBER, u"1234567890123456"); + work_creditcard.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"04"); + work_creditcard.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2013"); + work_creditcard.SetNickname(u"Corporate card"); Time pre_creation_time = AutofillClock::Now(); EXPECT_TRUE(table_->AddCreditCard(work_creditcard)); @@ -1655,14 +1589,11 @@ TEST_F(AutofillTableTest, CreditCard) { // Add a 'Target' credit card. CreditCard target_creditcard; target_creditcard.set_origin(std::string()); - target_creditcard.SetRawInfo(CREDIT_CARD_NAME_FULL, - ASCIIToUTF16("Jack Torrance")); - target_creditcard.SetRawInfo(CREDIT_CARD_NUMBER, - ASCIIToUTF16("1111222233334444")); - target_creditcard.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("06")); - target_creditcard.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, - ASCIIToUTF16("2012")); - target_creditcard.SetNickname(ASCIIToUTF16("Grocery card")); + target_creditcard.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Jack Torrance"); + target_creditcard.SetRawInfo(CREDIT_CARD_NUMBER, u"1111222233334444"); + target_creditcard.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"06"); + target_creditcard.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2012"); + target_creditcard.SetNickname(u"Grocery card"); pre_creation_time = AutofillClock::Now(); EXPECT_TRUE(table_->AddCreditCard(target_creditcard)); @@ -1683,9 +1614,8 @@ TEST_F(AutofillTableTest, CreditCard) { // Update the 'Target' credit card. target_creditcard.set_origin("Interactive Autofill dialog"); - target_creditcard.SetRawInfo(CREDIT_CARD_NAME_FULL, - ASCIIToUTF16("Charles Grady")); - target_creditcard.SetNickname(ASCIIToUTF16("Supermarket")); + target_creditcard.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Charles Grady"); + target_creditcard.SetNickname(u"Supermarket"); Time pre_modification_time = AutofillClock::Now(); EXPECT_TRUE(table_->UpdateCreditCard(target_creditcard)); Time post_modification_time = AutofillClock::Now(); @@ -1714,10 +1644,10 @@ TEST_F(AutofillTableTest, AddFullServerCreditCard) { credit_card.set_record_type(CreditCard::FULL_SERVER_CARD); credit_card.set_server_id("server_id"); credit_card.set_origin("https://www.example.com/"); - credit_card.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Jack Torrance")); - credit_card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("1234567890123456")); - credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("04")); - credit_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2013")); + credit_card.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Jack Torrance"); + credit_card.SetRawInfo(CREDIT_CARD_NUMBER, u"1234567890123456"); + credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"04"); + credit_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2013"); EXPECT_TRUE(table_->AddFullServerCreditCard(credit_card)); @@ -1730,18 +1660,18 @@ TEST_F(AutofillTableTest, AddFullServerCreditCard) { TEST_F(AutofillTableTest, UpdateAutofillProfile) { // Add a profile to the db. AutofillProfile profile; - profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - profile.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("Q.")); - profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith")); - profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("js@example.com")); - profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Google")); - profile.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("1234 Apple Way")); - profile.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("unit 5")); - profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Los Angeles")); - profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA")); - profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90025")); - profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567")); + profile.SetRawInfo(NAME_FIRST, u"John"); + profile.SetRawInfo(NAME_MIDDLE, u"Q."); + profile.SetRawInfo(NAME_LAST, u"Smith"); + profile.SetRawInfo(EMAIL_ADDRESS, u"js@example.com"); + profile.SetRawInfo(COMPANY_NAME, u"Google"); + profile.SetRawInfo(ADDRESS_HOME_LINE1, u"1234 Apple Way"); + profile.SetRawInfo(ADDRESS_HOME_LINE2, u"unit 5"); + profile.SetRawInfo(ADDRESS_HOME_CITY, u"Los Angeles"); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"CA"); + profile.SetRawInfo(ADDRESS_HOME_ZIP, u"90025"); + profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US"); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"18181234567"); profile.set_language_code("en"); profile.FinalizeAfterImport(); table_->AddAutofillProfile(profile); @@ -1769,7 +1699,7 @@ TEST_F(AutofillTableTest, UpdateAutofillProfile) { // Now, update the profile and save the update to the database. // The modification date should change to reflect the update. - profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("js@smith.xyz")); + profile.SetRawInfo(EMAIL_ADDRESS, u"js@smith.xyz"); table_->UpdateAutofillProfile(profile); // Get the profile. @@ -1811,10 +1741,10 @@ TEST_F(AutofillTableTest, UpdateAutofillProfile) { TEST_F(AutofillTableTest, UpdateCreditCard) { // Add a credit card to the db. CreditCard credit_card; - credit_card.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Jack Torrance")); - credit_card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("1234567890123456")); - credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("04")); - credit_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2013")); + credit_card.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Jack Torrance"); + credit_card.SetRawInfo(CREDIT_CARD_NUMBER, u"1234567890123456"); + credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"04"); + credit_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2013"); table_->AddCreditCard(credit_card); // Set a mocked value for the credit card's creation time. @@ -1840,7 +1770,7 @@ TEST_F(AutofillTableTest, UpdateCreditCard) { // Now, update the credit card and save the update to the database. // The modification date should change to reflect the update. - credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("01")); + credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"01"); table_->UpdateCreditCard(credit_card); // Get the credit card. @@ -1882,18 +1812,18 @@ TEST_F(AutofillTableTest, UpdateCreditCard) { TEST_F(AutofillTableTest, UpdateProfileOriginOnly) { // Add a profile to the db. AutofillProfile profile; - profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - profile.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("Q.")); - profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith")); - profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("js@example.com")); - profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Google")); - profile.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("1234 Apple Way")); - profile.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("unit 5")); - profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Los Angeles")); - profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA")); - profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90025")); - profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); - profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567")); + profile.SetRawInfo(NAME_FIRST, u"John"); + profile.SetRawInfo(NAME_MIDDLE, u"Q."); + profile.SetRawInfo(NAME_LAST, u"Smith"); + profile.SetRawInfo(EMAIL_ADDRESS, u"js@example.com"); + profile.SetRawInfo(COMPANY_NAME, u"Google"); + profile.SetRawInfo(ADDRESS_HOME_LINE1, u"1234 Apple Way"); + profile.SetRawInfo(ADDRESS_HOME_LINE2, u"unit 5"); + profile.SetRawInfo(ADDRESS_HOME_CITY, u"Los Angeles"); + profile.SetRawInfo(ADDRESS_HOME_STATE, u"CA"); + profile.SetRawInfo(ADDRESS_HOME_ZIP, u"90025"); + profile.SetRawInfo(ADDRESS_HOME_COUNTRY, u"US"); + profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, u"18181234567"); profile.FinalizeAfterImport(); table_->AddAutofillProfile(profile); @@ -1938,10 +1868,10 @@ TEST_F(AutofillTableTest, UpdateProfileOriginOnly) { TEST_F(AutofillTableTest, UpdateCreditCardOriginOnly) { // Add a credit card to the db. CreditCard credit_card; - credit_card.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Jack Torrance")); - credit_card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("1234567890123456")); - credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("04")); - credit_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2013")); + credit_card.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Jack Torrance"); + credit_card.SetRawInfo(CREDIT_CARD_NUMBER, u"1234567890123456"); + credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"04"); + credit_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2013"); table_->AddCreditCard(credit_card); // Set a mocked value for the credit card's creation time. @@ -2355,8 +2285,8 @@ TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_OneResult) { time_t start = 0; std::vector<Time> timestamps1; FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; EXPECT_TRUE( table_->AddFormFieldValueTime(field, &changes, Time::FromTimeT(start))); timestamps1.push_back(Time::FromTimeT(start)); @@ -2365,7 +2295,7 @@ TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_OneResult) { std::pair<std::string, std::vector<Time>>(key1, timestamps1)); AutofillEntrySet expected_entries(CompareAutofillEntries); - AutofillKey ak1(ASCIIToUTF16("Name"), ASCIIToUTF16("Superman")); + AutofillKey ak1(u"Name", u"Superman"); AutofillEntry ae1(ak1, timestamps1.front(), timestamps1.back()); expected_entries.insert(ae1); @@ -2385,8 +2315,8 @@ TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_TwoDistinct) { std::vector<Time> timestamps1; FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; EXPECT_TRUE( table_->AddFormFieldValueTime(field, &changes, Time::FromTimeT(start))); timestamps1.push_back(Time::FromTimeT(start)); @@ -2396,8 +2326,8 @@ TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_TwoDistinct) { ++start; std::vector<Time> timestamps2; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Clark Kent"); + field.name = u"Name"; + field.value = u"Clark Kent"; EXPECT_TRUE( table_->AddFormFieldValueTime(field, &changes, Time::FromTimeT(start))); timestamps2.push_back(Time::FromTimeT(start)); @@ -2406,8 +2336,8 @@ TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_TwoDistinct) { std::pair<std::string, std::vector<Time>>(key2, timestamps2)); AutofillEntrySet expected_entries(CompareAutofillEntries); - AutofillKey ak1(ASCIIToUTF16("Name"), ASCIIToUTF16("Superman")); - AutofillKey ak2(ASCIIToUTF16("Name"), ASCIIToUTF16("Clark Kent")); + AutofillKey ak1(u"Name", u"Superman"); + AutofillKey ak2(u"Name", u"Clark Kent"); AutofillEntry ae1(ak1, timestamps1.front(), timestamps1.back()); AutofillEntry ae2(ak2, timestamps2.front(), timestamps2.back()); @@ -2430,8 +2360,8 @@ TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_TwoSame) { time_t start = 0; for (int i = 0; i < 2; ++i, ++start) { FormFieldData field; - field.name = ASCIIToUTF16("Name"); - field.value = ASCIIToUTF16("Superman"); + field.name = u"Name"; + field.value = u"Superman"; EXPECT_TRUE( table_->AddFormFieldValueTime(field, &changes, Time::FromTimeT(start))); timestamps.push_back(Time::FromTimeT(start)); @@ -2442,7 +2372,7 @@ TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_TwoSame) { std::pair<std::string, std::vector<Time>>(key, timestamps)); AutofillEntrySet expected_entries(CompareAutofillEntries); - AutofillKey ak1(ASCIIToUTF16("Name"), ASCIIToUTF16("Superman")); + AutofillKey ak1(u"Name", u"Superman"); AutofillEntry ae1(ak1, timestamps.front(), timestamps.back()); expected_entries.insert(ae1); @@ -2462,8 +2392,8 @@ TEST_F(AutofillTableTest, AutofillProfileValidityBitfield) { const int kValidityBitfieldValue = 1984; AutofillProfile profile; profile.set_origin(std::string()); - profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith")); + profile.SetRawInfo(NAME_FIRST, u"John"); + profile.SetRawInfo(NAME_LAST, u"Smith"); profile.SetClientValidityFromBitfieldValue(kValidityBitfieldValue); // Add the profile to the table. @@ -2493,8 +2423,8 @@ TEST_F(AutofillTableTest, AutofillProfileValidityBitfield) { TEST_F(AutofillTableTest, AutofillProfileIsClientValidityStatesUpdatedFlag) { AutofillProfile profile; profile.set_origin(std::string()); - profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith")); + profile.SetRawInfo(NAME_FIRST, u"John"); + profile.SetRawInfo(NAME_LAST, u"Smith"); profile.set_is_client_validity_states_updated(true); // Add the profile to the table. @@ -2527,20 +2457,20 @@ TEST_F(AutofillTableTest, AutofillProfileIsClientValidityStatesUpdatedFlag) { TEST_F(AutofillTableTest, SetGetServerCards) { std::vector<CreditCard> inputs; inputs.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "a123")); - inputs[0].SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Paul F. Tompkins")); - inputs[0].SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("1")); - inputs[0].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2020")); - inputs[0].SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111")); + inputs[0].SetRawInfo(CREDIT_CARD_NAME_FULL, u"Paul F. Tompkins"); + inputs[0].SetRawInfo(CREDIT_CARD_EXP_MONTH, u"1"); + inputs[0].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2020"); + inputs[0].SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111"); inputs[0].set_instrument_id(321); inputs.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "b456")); - inputs[1].SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Rick Roman")); - inputs[1].SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("12")); - inputs[1].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("1997")); - inputs[1].SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("1111")); + inputs[1].SetRawInfo(CREDIT_CARD_NAME_FULL, u"Rick Roman"); + inputs[1].SetRawInfo(CREDIT_CARD_EXP_MONTH, u"12"); + inputs[1].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"1997"); + inputs[1].SetRawInfo(CREDIT_CARD_NUMBER, u"1111"); inputs[1].SetNetworkForMaskedCard(kVisaCard); inputs[1].SetServerStatus(CreditCard::EXPIRED); - base::string16 nickname = ASCIIToUTF16("Grocery card"); + std::u16string nickname = u"Grocery card"; inputs[1].SetNickname(nickname); inputs[1].set_card_issuer(CreditCard::Issuer::GOOGLE); inputs[1].set_instrument_id(123); @@ -2721,10 +2651,10 @@ TEST_F(AutofillTableTest, UpdateServerAddressMetadataDoesNotChangeData) { TEST_F(AutofillTableTest, UpdateServerCardMetadataDoesNotChangeData) { std::vector<CreditCard> inputs; inputs.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "a123")); - inputs[0].SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Paul F. Tompkins")); - inputs[0].SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("1")); - inputs[0].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2020")); - inputs[0].SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111")); + inputs[0].SetRawInfo(CREDIT_CARD_NAME_FULL, u"Paul F. Tompkins"); + inputs[0].SetRawInfo(CREDIT_CARD_EXP_MONTH, u"1"); + inputs[0].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2020"); + inputs[0].SetRawInfo(CREDIT_CARD_NUMBER, u"4111111111111111"); test::SetServerCreditCards(table_.get(), inputs); std::vector<std::unique_ptr<CreditCard>> outputs; @@ -2779,13 +2709,13 @@ TEST_F(AutofillTableTest, SetServerCardsData) { // Set a card data. std::vector<CreditCard> inputs; inputs.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "card1")); - inputs[0].SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Rick Roman")); - inputs[0].SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("12")); - inputs[0].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("1997")); - inputs[0].SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("1111")); + inputs[0].SetRawInfo(CREDIT_CARD_NAME_FULL, u"Rick Roman"); + inputs[0].SetRawInfo(CREDIT_CARD_EXP_MONTH, u"12"); + inputs[0].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"1997"); + inputs[0].SetRawInfo(CREDIT_CARD_NUMBER, u"1111"); inputs[0].SetNetworkForMaskedCard(kVisaCard); inputs[0].SetServerStatus(CreditCard::EXPIRED); - inputs[0].SetNickname(ASCIIToUTF16("Grocery card")); + inputs[0].SetNickname(u"Grocery card"); inputs[0].set_instrument_id(1); table_->SetServerCardsData(inputs); @@ -2926,18 +2856,18 @@ TEST_F(AutofillTableTest, RemoveWrongServerAddressMetadata) { } TEST_F(AutofillTableTest, MaskUnmaskServerCards) { - base::string16 masked_number(ASCIIToUTF16("1111")); + std::u16string masked_number(u"1111"); std::vector<CreditCard> inputs; inputs.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "a123")); - inputs[0].SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Jay Johnson")); - inputs[0].SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("1")); - inputs[0].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2020")); + inputs[0].SetRawInfo(CREDIT_CARD_NAME_FULL, u"Jay Johnson"); + inputs[0].SetRawInfo(CREDIT_CARD_EXP_MONTH, u"1"); + inputs[0].SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2020"); inputs[0].SetRawInfo(CREDIT_CARD_NUMBER, masked_number); inputs[0].SetNetworkForMaskedCard(kVisaCard); test::SetServerCreditCards(table_.get(), inputs); // Unmask the number. The full number should be available. - base::string16 full_number(ASCIIToUTF16("4111111111111111")); + std::u16string full_number(u"4111111111111111"); ASSERT_TRUE(table_->UnmaskServerCreditCard(inputs[0], full_number)); std::vector<std::unique_ptr<CreditCard>> outputs; @@ -2963,11 +2893,10 @@ TEST_F(AutofillTableTest, MaskUnmaskServerCards) { TEST_F(AutofillTableTest, SetServerCardModify) { // Add a masked card. CreditCard masked_card(CreditCard::MASKED_SERVER_CARD, "a123"); - masked_card.SetRawInfo(CREDIT_CARD_NAME_FULL, - ASCIIToUTF16("Paul F. Tompkins")); - masked_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("1")); - masked_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2020")); - masked_card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("1111")); + masked_card.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Paul F. Tompkins"); + masked_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"1"); + masked_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2020"); + masked_card.SetRawInfo(CREDIT_CARD_NUMBER, u"1111"); masked_card.SetNetworkForMaskedCard(kVisaCard); std::vector<CreditCard> inputs; @@ -2975,7 +2904,7 @@ TEST_F(AutofillTableTest, SetServerCardModify) { test::SetServerCreditCards(table_.get(), inputs); // Now unmask it. - base::string16 full_number = ASCIIToUTF16("4111111111111111"); + std::u16string full_number = u"4111111111111111"; table_->UnmaskServerCreditCard(masked_card, full_number); // The card should now be unmasked. @@ -3001,10 +2930,10 @@ TEST_F(AutofillTableTest, SetServerCardModify) { // Set inputs that do not include our old card. CreditCard random_card(CreditCard::MASKED_SERVER_CARD, "b456"); - random_card.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Rick Roman")); - random_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("12")); - random_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("1997")); - random_card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("2222")); + random_card.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Rick Roman"); + random_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"12"); + random_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"1997"); + random_card.SetRawInfo(CREDIT_CARD_NUMBER, u"2222"); random_card.SetNetworkForMaskedCard(kVisaCard); inputs[0] = random_card; test::SetServerCreditCards(table_.get(), inputs); @@ -3014,7 +2943,7 @@ TEST_F(AutofillTableTest, SetServerCardModify) { ASSERT_EQ(1u, outputs.size()); EXPECT_TRUE(outputs[0]->record_type() == CreditCard::MASKED_SERVER_CARD); EXPECT_EQ(random_card.server_id(), outputs[0]->server_id()); - EXPECT_EQ(ASCIIToUTF16("2222"), outputs[0]->GetRawInfo(CREDIT_CARD_NUMBER)); + EXPECT_EQ(u"2222", outputs[0]->GetRawInfo(CREDIT_CARD_NUMBER)); outputs.clear(); @@ -3026,7 +2955,7 @@ TEST_F(AutofillTableTest, SetServerCardModify) { ASSERT_EQ(1u, outputs.size()); EXPECT_TRUE(outputs[0]->record_type() == CreditCard::MASKED_SERVER_CARD); EXPECT_EQ(masked_card.server_id(), outputs[0]->server_id()); - EXPECT_EQ(ASCIIToUTF16("1111"), outputs[0]->GetRawInfo(CREDIT_CARD_NUMBER)); + EXPECT_EQ(u"1111", outputs[0]->GetRawInfo(CREDIT_CARD_NUMBER)); outputs.clear(); } @@ -3034,11 +2963,10 @@ TEST_F(AutofillTableTest, SetServerCardModify) { TEST_F(AutofillTableTest, SetServerCardUpdateUsageStatsAndBillingAddress) { // Add a masked card. CreditCard masked_card(CreditCard::MASKED_SERVER_CARD, "a123"); - masked_card.SetRawInfo(CREDIT_CARD_NAME_FULL, - ASCIIToUTF16("Paul F. Tompkins")); - masked_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("1")); - masked_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2020")); - masked_card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("1111")); + masked_card.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Paul F. Tompkins"); + masked_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"1"); + masked_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2020"); + masked_card.SetRawInfo(CREDIT_CARD_NUMBER, u"1111"); masked_card.set_billing_address_id("1"); masked_card.SetNetworkForMaskedCard(kVisaCard); @@ -3174,12 +3102,11 @@ TEST_F(AutofillTableTest, DeleteUnmaskedCard) { base::Time unmasked_time = AutofillClock::Now(); // Add a masked card. - base::string16 masked_number = ASCIIToUTF16("1111"); + std::u16string masked_number = u"1111"; CreditCard masked_card(CreditCard::MASKED_SERVER_CARD, "a123"); - masked_card.SetRawInfo(CREDIT_CARD_NAME_FULL, - ASCIIToUTF16("Paul F. Tompkins")); - masked_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("1")); - masked_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2020")); + masked_card.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Paul F. Tompkins"); + masked_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, u"1"); + masked_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, u"2020"); masked_card.SetRawInfo(CREDIT_CARD_NUMBER, masked_number); masked_card.SetNetworkForMaskedCard(kVisaCard); @@ -3188,7 +3115,7 @@ TEST_F(AutofillTableTest, DeleteUnmaskedCard) { table_->SetServerCreditCards(inputs); // Unmask it. - base::string16 full_number = ASCIIToUTF16("4111111111111111"); + std::u16string full_number = u"4111111111111111"; table_->UnmaskServerCreditCard(masked_card, full_number); // Delete data in a range a year in the future. @@ -3331,8 +3258,8 @@ class GetFormValuesTest : public testing::TestWithParam<GetFormValuesTestCase> { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); file_ = temp_dir_.GetPath().AppendASCII("TestWebDatabase"); - table_.reset(new AutofillTable); - db_.reset(new WebDatabase); + table_ = std::make_unique<AutofillTable>(); + db_ = std::make_unique<WebDatabase>(); db_->AddTable(table_.get()); ASSERT_EQ(sql::INIT_OK, db_->Init(file_)); } @@ -3360,14 +3287,14 @@ TEST_P(GetFormValuesTest, GetFormValuesForElementName_SubstringMatchEnabled) { AutofillChangeList changes; FormFieldData field; for (size_t k = 0; k < kMaxCount; ++k) { - field.name = ASCIIToUTF16("Name"); + field.name = u"Name"; field.value = ASCIIToUTF16(test_case.field_suggestion[k]); table_->AddFormFieldValue(field, &changes); } std::vector<AutofillEntry> v; table_->GetFormValuesForElementName( - ASCIIToUTF16("Name"), ASCIIToUTF16(test_case.field_contents), &v, 6); + u"Name", ASCIIToUTF16(test_case.field_contents), &v, 6); EXPECT_EQ(test_case.expected_suggestion_count, v.size()); for (size_t j = 0; j < test_case.expected_suggestion_count; ++j) { diff --git a/chromium/components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge_unittest.cc b/chromium/components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge_unittest.cc index c0bc6688b43..b26bee02309 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge_unittest.cc +++ b/chromium/components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge_unittest.cc @@ -293,8 +293,8 @@ class AutofillWalletMetadataSyncBridgeTest : public testing::Test { model_type_state.set_cache_guid(kDefaultCacheGuid); EXPECT_TRUE(table()->UpdateModelTypeState(syncer::AUTOFILL_WALLET_METADATA, model_type_state)); - bridge_.reset(new AutofillWalletMetadataSyncBridge( - mock_processor_.CreateForwardingProcessor(), &backend_)); + bridge_ = std::make_unique<AutofillWalletMetadataSyncBridge>( + mock_processor_.CreateForwardingProcessor(), &backend_); } void StopSyncing() { diff --git a/chromium/components/autofill/core/browser/webdata/autofill_wallet_offer_sync_bridge_unittest.cc b/chromium/components/autofill/core/browser/webdata/autofill_wallet_offer_sync_bridge_unittest.cc index c68ffc5acf1..4a115fccd10 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_wallet_offer_sync_bridge_unittest.cc +++ b/chromium/components/autofill/core/browser/webdata/autofill_wallet_offer_sync_bridge_unittest.cc @@ -9,6 +9,7 @@ #include <memory> #include <utility> +#include "base/callback_helpers.h" #include "base/files/scoped_temp_dir.h" #include "base/strings/strcat.h" #include "base/strings/string_number_conversions.h" diff --git a/chromium/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge_unittest.cc b/chromium/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge_unittest.cc index aa7b8cc416e..5a55f0240a0 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge_unittest.cc +++ b/chromium/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge_unittest.cc @@ -853,7 +853,7 @@ TEST_F(AutofillWalletSyncBridgeTest, MergeSyncData_SetsAllWalletAddressData) { TEST_F(AutofillWalletSyncBridgeTest, MergeSyncData_SetsAllWalletCardData) { // Create a card to be synced from the server. CreditCard card = test::GetMaskedServerCard(); - card.SetNickname(base::ASCIIToUTF16("Grocery card")); + card.SetNickname(u"Grocery card"); // Set the card issuer to Google. card.set_card_issuer(CreditCard::Issuer::GOOGLE); AutofillWalletSpecifics card_specifics; diff --git a/chromium/components/autofill/core/browser/webdata/autofill_webdata_backend_impl.cc b/chromium/components/autofill/core/browser/webdata/autofill_webdata_backend_impl.cc index 24f183c48ef..f713cf17449 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_webdata_backend_impl.cc +++ b/chromium/components/autofill/core/browser/webdata/autofill_webdata_backend_impl.cc @@ -4,6 +4,8 @@ #include "components/autofill/core/browser/webdata/autofill_webdata_backend_impl.h" +#include <memory> + #include "base/bind.h" #include "base/check_op.h" #include "base/location.h" @@ -147,7 +149,7 @@ void AutofillWebDataBackendImpl::NotifyThatSyncHasStarted( base::SupportsUserData* AutofillWebDataBackendImpl::GetDBUserData() { DCHECK(owning_task_runner()->RunsTasksInCurrentSequence()); if (!user_data_) - user_data_.reset(new SupportsUserDataAggregatable()); + user_data_ = std::make_unique<SupportsUserDataAggregatable>(); return user_data_.get(); } @@ -177,8 +179,8 @@ WebDatabase::State AutofillWebDataBackendImpl::AddFormElements( std::unique_ptr<WDTypedResult> AutofillWebDataBackendImpl::GetFormValuesForElementName( - const base::string16& name, - const base::string16& prefix, + const std::u16string& name, + const std::u16string& prefix, int limit, WebDatabase* db) { DCHECK(owning_task_runner()->RunsTasksInCurrentSequence()); @@ -211,8 +213,8 @@ WebDatabase::State AutofillWebDataBackendImpl::RemoveFormElementsAddedBetween( } WebDatabase::State AutofillWebDataBackendImpl::RemoveFormValueForElementName( - const base::string16& name, - const base::string16& value, + const std::u16string& name, + const std::u16string& value, WebDatabase* db) { DCHECK(owning_task_runner()->RunsTasksInCurrentSequence()); @@ -476,7 +478,7 @@ std::unique_ptr<WDTypedResult> AutofillWebDataBackendImpl::GetServerCreditCards( WebDatabase::State AutofillWebDataBackendImpl::UnmaskServerCreditCard( const CreditCard& card, - const base::string16& full_number, + const std::u16string& full_number, WebDatabase* db) { DCHECK(owning_task_runner()->RunsTasksInCurrentSequence()); if (AutofillTable::FromWebDatabase(db)->UnmaskServerCreditCard(card, diff --git a/chromium/components/autofill/core/browser/webdata/autofill_webdata_backend_impl.h b/chromium/components/autofill/core/browser/webdata/autofill_webdata_backend_impl.h index 5525d4a8103..58cee22454a 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_webdata_backend_impl.h +++ b/chromium/components/autofill/core/browser/webdata/autofill_webdata_backend_impl.h @@ -91,8 +91,8 @@ class AutofillWebDataBackendImpl // Returns a vector of values which have been entered in form input fields // named |name|. std::unique_ptr<WDTypedResult> GetFormValuesForElementName( - const base::string16& name, - const base::string16& prefix, + const std::u16string& name, + const std::u16string& prefix, int limit, WebDatabase* db); @@ -110,8 +110,8 @@ class AutofillWebDataBackendImpl // Removes the Form-value |value| which has been entered in form input fields // named |name| from the database. - WebDatabase::State RemoveFormValueForElementName(const base::string16& name, - const base::string16& value, + WebDatabase::State RemoveFormValueForElementName(const std::u16string& name, + const std::u16string& value, WebDatabase* db); // Adds an Autofill profile to the web database. Valid only for local @@ -177,7 +177,7 @@ class AutofillWebDataBackendImpl // Server credit cards can be masked (only last 4 digits stored) or unmasked // (all data stored). These toggle between the two states. WebDatabase::State UnmaskServerCreditCard(const CreditCard& card, - const base::string16& full_number, + const std::u16string& full_number, WebDatabase* db); WebDatabase::State MaskServerCreditCard(const std::string& id, WebDatabase* db); diff --git a/chromium/components/autofill/core/browser/webdata/autofill_webdata_backend_util.cc b/chromium/components/autofill/core/browser/webdata/autofill_webdata_backend_util.cc index e931d4cc7f4..cad2ff8e8ed 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_webdata_backend_util.cc +++ b/chromium/components/autofill/core/browser/webdata/autofill_webdata_backend_util.cc @@ -61,7 +61,7 @@ std::string MergeServerAddressesIntoProfilesAndUpdateDb( // Wallet addresses don't have an email address, use the one from the // currently signed-in account. - base::string16 email = base::UTF8ToUTF16(primary_account_email); + std::u16string email = base::UTF8ToUTF16(primary_account_email); if (!email.empty()) existing_profiles->back()->SetRawInfo(EMAIL_ADDRESS, email); diff --git a/chromium/components/autofill/core/browser/webdata/autofill_webdata_service.cc b/chromium/components/autofill/core/browser/webdata/autofill_webdata_service.cc index de0083a0599..fd53c37ec2a 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_webdata_service.cc +++ b/chromium/components/autofill/core/browser/webdata/autofill_webdata_service.cc @@ -82,7 +82,9 @@ void AutofillWebDataService::AddFormFields( } WebDataServiceBase::Handle AutofillWebDataService::GetFormValuesForElementName( - const base::string16& name, const base::string16& prefix, int limit, + const std::u16string& name, + const std::u16string& prefix, + int limit, WebDataServiceConsumer* consumer) { return wdbs_->ScheduleDBTaskWithResult( FROM_HERE, @@ -101,7 +103,8 @@ void AutofillWebDataService::RemoveFormElementsAddedBetween( } void AutofillWebDataService::RemoveFormValueForElementName( - const base::string16& name, const base::string16& value) { + const std::u16string& name, + const std::u16string& value) { wdbs_->ScheduleDBTask( FROM_HERE, base::BindOnce(&AutofillWebDataBackendImpl::RemoveFormValueForElementName, @@ -230,7 +233,7 @@ WebDataServiceBase::Handle AutofillWebDataService::GetServerCreditCards( void AutofillWebDataService::UnmaskServerCreditCard( const CreditCard& credit_card, - const base::string16& full_number) { + const std::u16string& full_number) { wdbs_->ScheduleDBTask( FROM_HERE, base::BindOnce(&AutofillWebDataBackendImpl::UnmaskServerCreditCard, diff --git a/chromium/components/autofill/core/browser/webdata/autofill_webdata_service.h b/chromium/components/autofill/core/browser/webdata/autofill_webdata_service.h index 9165888bc65..d2badf987a7 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_webdata_service.h +++ b/chromium/components/autofill/core/browser/webdata/autofill_webdata_service.h @@ -59,16 +59,16 @@ class AutofillWebDataService : public WebDataServiceBase { // |consumer| gets called back when the request is finished, with the vector // included in the argument |result|. virtual WebDataServiceBase::Handle GetFormValuesForElementName( - const base::string16& name, - const base::string16& prefix, + const std::u16string& name, + const std::u16string& prefix, int limit, WebDataServiceConsumer* consumer); // Removes form elements recorded for Autocomplete from the database. void RemoveFormElementsAddedBetween(const base::Time& delete_begin, const base::Time& delete_end); - void RemoveFormValueForElementName(const base::string16& name, - const base::string16& value); + void RemoveFormValueForElementName(const std::u16string& name, + const std::u16string& value); // Schedules a task to add an Autofill profile to the web database. void AddAutofillProfile(const AutofillProfile& profile); @@ -136,7 +136,7 @@ class AutofillWebDataService : public WebDataServiceBase { // Toggles the record for a server credit card between masked (only last 4 // digits) and full (all digits). void UnmaskServerCreditCard(const CreditCard& card, - const base::string16& full_number); + const std::u16string& full_number); void MaskServerCreditCard(const std::string& id); // Store a UPI ID. diff --git a/chromium/components/autofill/core/browser/webdata/mock_autofill_webdata_service.h b/chromium/components/autofill/core/browser/webdata/mock_autofill_webdata_service.h index 2b26c9eaacd..7c1fa699109 100644 --- a/chromium/components/autofill/core/browser/webdata/mock_autofill_webdata_service.h +++ b/chromium/components/autofill/core/browser/webdata/mock_autofill_webdata_service.h @@ -5,7 +5,8 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_MOCK_AUTOFILL_WEBDATA_SERVICE_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_MOCK_AUTOFILL_WEBDATA_SERVICE_H_ -#include "base/strings/string16.h" +#include <string> + #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/autofill/core/common/form_field_data.h" #include "testing/gmock/include/gmock/gmock.h" @@ -19,8 +20,8 @@ class MockAutofillWebDataService : public AutofillWebDataService { MOCK_METHOD1(AddFormFields, void(const std::vector<FormFieldData>&)); MOCK_METHOD1(CancelRequest, void(int)); MOCK_METHOD4(GetFormValuesForElementName, - WebDataServiceBase::Handle(const base::string16& name, - const base::string16& prefix, + WebDataServiceBase::Handle(const std::u16string& name, + const std::u16string& prefix, int limit, WebDataServiceConsumer* consumer)); MOCK_METHOD1(RemoveExpiredAutocompleteEntries, diff --git a/chromium/components/autofill/core/browser/webdata/system_encryptor.cc b/chromium/components/autofill/core/browser/webdata/system_encryptor.cc index 7b16c089529..a3c605a8045 100644 --- a/chromium/components/autofill/core/browser/webdata/system_encryptor.cc +++ b/chromium/components/autofill/core/browser/webdata/system_encryptor.cc @@ -8,13 +8,13 @@ namespace autofill { -bool SystemEncryptor::EncryptString16(const base::string16& plaintext, +bool SystemEncryptor::EncryptString16(const std::u16string& plaintext, std::string* ciphertext) const { return ::OSCrypt::EncryptString16(plaintext, ciphertext); } bool SystemEncryptor::DecryptString16(const std::string& ciphertext, - base::string16* plaintext) const { + std::u16string* plaintext) const { return ::OSCrypt::DecryptString16(ciphertext, plaintext); } diff --git a/chromium/components/autofill/core/browser/webdata/system_encryptor.h b/chromium/components/autofill/core/browser/webdata/system_encryptor.h index e6efb426c63..beb532280c8 100644 --- a/chromium/components/autofill/core/browser/webdata/system_encryptor.h +++ b/chromium/components/autofill/core/browser/webdata/system_encryptor.h @@ -15,11 +15,11 @@ class SystemEncryptor : public AutofillTableEncryptor { SystemEncryptor() = default; ~SystemEncryptor() override = default; - bool EncryptString16(const base::string16& plaintext, + bool EncryptString16(const std::u16string& plaintext, std::string* ciphertext) const override; bool DecryptString16(const std::string& ciphertext, - base::string16* plaintext) const override; + std::u16string* plaintext) const override; private: DISALLOW_COPY_AND_ASSIGN(SystemEncryptor); diff --git a/chromium/components/autofill/core/browser/webdata/web_data_service_unittest.cc b/chromium/components/autofill/core/browser/webdata/web_data_service_unittest.cc index b637f09bf1d..57a2cd56e98 100644 --- a/chromium/components/autofill/core/browser/webdata/web_data_service_unittest.cc +++ b/chromium/components/autofill/core/browser/webdata/web_data_service_unittest.cc @@ -12,7 +12,6 @@ #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" -#include "base/strings/string16.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/synchronization/waitable_event.h" @@ -144,10 +143,10 @@ class WebDataServiceAutofillTest : public WebDataServiceTest { protected: void SetUp() override { WebDataServiceTest::SetUp(); - name1_ = ASCIIToUTF16("name1"); - name2_ = ASCIIToUTF16("name2"); - value1_ = ASCIIToUTF16("value1"); - value2_ = ASCIIToUTF16("value2"); + name1_ = u"name1"; + name2_ = u"name2"; + value1_ = u"value1"; + value2_ = u"value2"; void (AutofillWebDataService::*add_observer_func)( AutofillWebDataServiceObserverOnDBSequence*) = @@ -167,8 +166,8 @@ class WebDataServiceAutofillTest : public WebDataServiceTest { WebDataServiceTest::TearDown(); } - void AppendFormField(const base::string16& name, - const base::string16& value, + void AppendFormField(const std::u16string& name, + const std::u16string& value, std::vector<FormFieldData>* form_fields) { FormFieldData field; field.name = name; @@ -176,10 +175,10 @@ class WebDataServiceAutofillTest : public WebDataServiceTest { form_fields->push_back(field); } - base::string16 name1_; - base::string16 name2_; - base::string16 value1_; - base::string16 value2_; + std::u16string name1_; + std::u16string name2_; + std::u16string value1_; + std::u16string value2_; int unique_id1_, unique_id2_; const TimeDelta test_timeout_; testing::NiceMock<MockAutofillWebDataServiceObserver> observer_; @@ -208,7 +207,7 @@ TEST_F(WebDataServiceAutofillTest, FormFillAdd) { AutofillWebDataServiceConsumer<std::vector<AutofillEntry>> consumer; WebDataServiceBase::Handle handle; static const int limit = 10; - handle = wds_->GetFormValuesForElementName(name1_, base::string16(), limit, + handle = wds_->GetFormValuesForElementName(name1_, std::u16string(), limit, &consumer); task_environment_.RunUntilIdle(); EXPECT_EQ(handle, consumer.handle()); @@ -332,12 +331,12 @@ TEST_F(WebDataServiceAutofillTest, ProfileUpdate) { // The GUIDs are alphabetical for easier testing. AutofillProfile profile1("6141084B-72D7-4B73-90CF-3D6AC154673B", std::string()); - profile1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Abe")); + profile1.SetRawInfo(NAME_FIRST, u"Abe"); profile1.FinalizeAfterImport(); AutofillProfile profile2("087151C8-6AB1-487C-9095-28E80BE5DA15", std::string()); - profile2.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Alice")); + profile2.SetRawInfo(NAME_FIRST, u"Alice"); profile2.FinalizeAfterImport(); EXPECT_CALL(observer_, AutofillProfileChanged(_)) @@ -359,7 +358,7 @@ TEST_F(WebDataServiceAutofillTest, ProfileUpdate) { EXPECT_EQ(profile1, *consumer.result()[1]); AutofillProfile profile2_changed(profile2); - profile2_changed.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Bill")); + profile2_changed.SetRawInfo(NAME_FIRST, u"Bill"); const AutofillProfileChange expected_change( AutofillProfileChange::UPDATE, profile2.guid(), &profile2_changed); @@ -425,9 +424,9 @@ TEST_F(WebDataServiceAutofillTest, CreditCardRemove) { TEST_F(WebDataServiceAutofillTest, CreditUpdate) { CreditCard card1("E4D2662E-5E16-44F3-AF5A-5A77FAE4A6F3", std::string()); - card1.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Abe")); + card1.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Abe"); CreditCard card2("B9C52112-BD5F-4080-84E1-C651D2CB90E2", std::string()); - card2.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Alice")); + card2.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Alice"); wds_->AddCreditCard(card1); wds_->AddCreditCard(card2); @@ -443,7 +442,7 @@ TEST_F(WebDataServiceAutofillTest, CreditUpdate) { EXPECT_EQ(card1, *consumer.result()[1]); CreditCard card2_changed(card2); - card2_changed.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Bill")); + card2_changed.SetRawInfo(CREDIT_CARD_NAME_FULL, u"Bill"); wds_->UpdateCreditCard(card2_changed); diff --git a/chromium/components/autofill/core/common/BUILD.gn b/chromium/components/autofill/core/common/BUILD.gn index 319e579b989..5f5ebd9505a 100644 --- a/chromium/components/autofill/core/common/BUILD.gn +++ b/chromium/components/autofill/core/common/BUILD.gn @@ -49,11 +49,12 @@ static_library("common") { "password_form_generation_data.h", "password_generation_util.cc", "password_generation_util.h", - "renderer_id.h", "save_password_progress_logger.cc", "save_password_progress_logger.h", "signatures.cc", "signatures.h", + "unique_ids.cc", + "unique_ids.h", ] deps = [ diff --git a/chromium/components/autofill/core/common/autofill_data_validation.cc b/chromium/components/autofill/core/common/autofill_data_validation.cc index 9fb6165979d..84f53285ca9 100644 --- a/chromium/components/autofill/core/common/autofill_data_validation.cc +++ b/chromium/components/autofill/core/common/autofill_data_validation.cc @@ -22,7 +22,7 @@ bool IsValidString(const std::string& str) { return str.size() <= kMaxDataLength; } -bool IsValidString16(const base::string16& str) { +bool IsValidString16(const std::u16string& str) { return str.size() <= kMaxDataLength; } @@ -56,7 +56,7 @@ bool IsValidPasswordFormFillData(const PasswordFormFillData& form) { }); } -bool IsValidString16Vector(const std::vector<base::string16>& v) { +bool IsValidString16Vector(const std::vector<std::u16string>& v) { return v.size() <= kMaxListSize && base::ranges::all_of(v, &IsValidString16); } diff --git a/chromium/components/autofill/core/common/autofill_data_validation.h b/chromium/components/autofill/core/common/autofill_data_validation.h index 98dc5eb77d4..3ee7a2eae1c 100644 --- a/chromium/components/autofill/core/common/autofill_data_validation.h +++ b/chromium/components/autofill/core/common/autofill_data_validation.h @@ -10,7 +10,6 @@ #include <string> #include <vector> -#include "base/strings/string16.h" class GURL; @@ -34,12 +33,12 @@ extern const size_t kMaxListSize; // checks, including being capped to the maximums defined by the constants // above. bool IsValidString(const std::string& str); -bool IsValidString16(const base::string16& str); +bool IsValidString16(const std::u16string& str); bool IsValidGURL(const GURL& url); bool IsValidFormFieldData(const FormFieldData& field); bool IsValidFormData(const FormData& form); bool IsValidPasswordFormFillData(const PasswordFormFillData& form); -bool IsValidString16Vector(const std::vector<base::string16>& v); +bool IsValidString16Vector(const std::vector<std::u16string>& v); bool IsValidFormDataVector(const std::vector<FormData>& v); } // namespace autofill diff --git a/chromium/components/autofill/core/common/autofill_features.cc b/chromium/components/autofill/core/common/autofill_features.cc index 866f6a9274a..0ef82d887be 100644 --- a/chromium/components/autofill/core/common/autofill_features.cc +++ b/chromium/components/autofill/core/common/autofill_features.cc @@ -4,10 +4,11 @@ #include "components/autofill/core/common/autofill_features.h" +#include <string> + #include "base/command_line.h" #include "base/feature_list.h" #include "base/metrics/field_trial_params.h" -#include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" @@ -156,7 +157,7 @@ const base::Feature kAutofillEnableProfileDeduplication{ // TODO(crbug.com/1098943): Remove once launched. const base::Feature kAutofillEnableSupportForMoreStructureInNames{ "AutofillEnableSupportForMoreStructureInNames", - base::FEATURE_DISABLED_BY_DEFAULT}; + base::FEATURE_ENABLED_BY_DEFAULT}; // Controls if Autofill supports new structure in addresses. // TODO(crbug.com/1098943): Remove once launched. @@ -224,7 +225,7 @@ const base::Feature kAutofillPruneSuggestions{ "AutofillPruneSuggestions", base::FEATURE_DISABLED_BY_DEFAULT}; const base::Feature kAutofillMetadataUploads{"AutofillMetadataUploads", - base::FEATURE_DISABLED_BY_DEFAULT}; + base::FEATURE_ENABLED_BY_DEFAULT}; // When enabled, Autofill will load remote patterns via the component updater. // TODO(crbug/1121990): Remove once launched. @@ -274,13 +275,6 @@ const base::Feature kAutofillProfileImportFromUnfocusableFields{ const base::Feature kAutofillProfileServerValidation{ "AutofillProfileServerValidation", base::FEATURE_DISABLED_BY_DEFAULT}; -// Controls whether or not a group of fields not enclosed in a form can be -// considered a form. If this is enabled, unowned fields will only constitute -// a form if there are signals to suggest that this might a checkout page. -const base::Feature kAutofillRestrictUnownedFieldsToFormlessCheckout{ - "AutofillRestrictUnownedFieldsToFormlessCheckout", - base::FEATURE_DISABLED_BY_DEFAULT}; - // Controls whether or not overall prediction are retrieved from the cache. const base::Feature kAutofillRetrieveOverallPredictionsFromCache{ "AutofillRetrieveOverallPredictionsFromCache", diff --git a/chromium/components/autofill/core/common/autofill_features.h b/chromium/components/autofill/core/common/autofill_features.h index 934b73830d6..f4f8e229560 100644 --- a/chromium/components/autofill/core/common/autofill_features.h +++ b/chromium/components/autofill/core/common/autofill_features.h @@ -8,7 +8,6 @@ #include <string> #include "base/feature_list.h" -#include "base/strings/string16.h" #include "build/build_config.h" class PrefService; @@ -67,7 +66,6 @@ extern const base::Feature kAutofillProbableFormSubmissionInBrowser; extern const base::Feature kAutofillProfileClientValidation; extern const base::Feature kAutofillProfileImportFromUnfocusableFields; extern const base::Feature kAutofillProfileServerValidation; -extern const base::Feature kAutofillRestrictUnownedFieldsToFormlessCheckout; extern const base::Feature kAutofillRetrieveOverallPredictionsFromCache; extern const base::Feature kAutofillRichMetadataQueries; extern const base::Feature kAutofillSaveAndFillVPA; diff --git a/chromium/components/autofill/core/common/autofill_l10n_util.cc b/chromium/components/autofill/core/common/autofill_l10n_util.cc index d9644422e07..07a94b1d1ea 100644 --- a/chromium/components/autofill/core/common/autofill_l10n_util.cc +++ b/chromium/components/autofill/core/common/autofill_l10n_util.cc @@ -56,8 +56,8 @@ CaseInsensitiveCompare::CaseInsensitiveCompare(const icu::Locale& locale) CaseInsensitiveCompare::~CaseInsensitiveCompare() { } -bool CaseInsensitiveCompare::StringsEqual(const base::string16& lhs, - const base::string16& rhs) const { +bool CaseInsensitiveCompare::StringsEqual(const std::u16string& lhs, + const std::u16string& rhs) const { if (collator_) { return base::i18n::CompareString16WithCollator(*collator_, lhs, rhs) == UCOL_EQUAL; diff --git a/chromium/components/autofill/core/common/autofill_l10n_util.h b/chromium/components/autofill/core/common/autofill_l10n_util.h index ada5bc7f05a..d430cff7c4a 100644 --- a/chromium/components/autofill/core/common/autofill_l10n_util.h +++ b/chromium/components/autofill/core/common/autofill_l10n_util.h @@ -6,9 +6,9 @@ #define COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_L10N_UTIL_H_ #include <memory> +#include <string> #include "base/macros.h" -#include "base/strings/string16.h" #include "third_party/icu/source/common/unicode/locid.h" #include "third_party/icu/source/i18n/unicode/coll.h" @@ -27,7 +27,7 @@ class CaseInsensitiveCompare { explicit CaseInsensitiveCompare(const icu::Locale& locale); ~CaseInsensitiveCompare(); - bool StringsEqual(const base::string16& lhs, const base::string16& rhs) const; + bool StringsEqual(const std::u16string& lhs, const std::u16string& rhs) const; private: std::unique_ptr<icu::Collator> collator_; diff --git a/chromium/components/autofill/core/common/autofill_payments_features.cc b/chromium/components/autofill/core/common/autofill_payments_features.cc index 1bcfa67eb48..6604f5614e9 100644 --- a/chromium/components/autofill/core/common/autofill_payments_features.cc +++ b/chromium/components/autofill/core/common/autofill_payments_features.cc @@ -4,10 +4,11 @@ #include "components/autofill/core/common/autofill_payments_features.h" +#include <string> + #include "base/command_line.h" #include "base/feature_list.h" #include "base/metrics/field_trial_params.h" -#include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" @@ -53,7 +54,7 @@ const base::Feature kAutofillCreditCardUploadFeedback{ // When enabled, shows the Google Pay logo on CVC prompt on Android. const base::Feature kAutofillDownstreamCvcPromptUseGooglePayLogo{ "AutofillDownstreamCvcPromptUseGooglePayLogo", - base::FEATURE_DISABLED_BY_DEFAULT}; + base::FEATURE_ENABLED_BY_DEFAULT}; // Controls whether we show a Google-issued card in the suggestions list. const base::Feature kAutofillEnableGoogleIssuedCard{ @@ -64,6 +65,12 @@ const base::Feature kAutofillEnableGoogleIssuedCard{ const base::Feature kAutofillEnableOfferNotification{ "AutofillEnableOfferNotification", base::FEATURE_DISABLED_BY_DEFAULT}; +// Controls whether to track the cross-tab-status of the offer notification +// bubble. +const base::Feature kAutofillEnableOfferNotificationCrossTabTracking{ + "AutofillEnableOfferNotificationCrossTabTracking", + base::FEATURE_DISABLED_BY_DEFAULT}; + // When enabled, offers will be displayed in the Clank keyboard accessory during // downstream. const base::Feature kAutofillEnableOffersInClankKeyboardAccessory{ @@ -73,7 +80,7 @@ const base::Feature kAutofillEnableOffersInClankKeyboardAccessory{ // When enabled, offer data will be retrieved during downstream and shown in // the dropdown list. const base::Feature kAutofillEnableOffersInDownstream{ - "kAutofillEnableOffersInDownstream", base::FEATURE_DISABLED_BY_DEFAULT}; + "kAutofillEnableOffersInDownstream", base::FEATURE_ENABLED_BY_DEFAULT}; // When enabled and user is signed in, a footer indicating user's e-mail address // and profile picture will appear at the bottom of SaveCardInfoBar. @@ -91,6 +98,15 @@ const base::Feature kAutofillEnableToolbarStatusChip{ const base::Feature kAutofillEnableVirtualCard{ "AutofillEnableVirtualCard", base::FEATURE_DISABLED_BY_DEFAULT}; +// Controls whether to enable the fix for the offer feature in Incognito mode. +const base::Feature kAutofillFixOfferInIncognito{ + "AutofillFixOfferInIncognito", base::FEATURE_DISABLED_BY_DEFAULT}; + +// When enabled, Autofill will attempt to find merchant promo/coupon/gift code +// fields when parsing forms. +const base::Feature kAutofillParseMerchantPromoCodeFields{ + "AutofillParseMerchantPromoCodeFields", base::FEATURE_DISABLED_BY_DEFAULT}; + // When enabled, the Save Card infobar will be dismissed by a user initiated // navigation other than one caused by submitted form. const base::Feature kAutofillSaveCardDismissOnNavigation{ @@ -105,6 +121,12 @@ const base::Feature kAutofillSortSuggestionsBasedOnOfferPresence{ "AutofillSortSuggestionsBasedOnOfferPresence", base::FEATURE_ENABLED_BY_DEFAULT}; +// When enabled, if the Autofill Assistant is running, credit card save (both +// local and upload) will not be offered. +const base::Feature kAutofillSuppressCreditCardSaveForAssistant{ + "AutofillSuppressCreditCardSaveForAssistant", + base::FEATURE_ENABLED_BY_DEFAULT}; + // Controls offering credit card upload to Google Payments. Cannot ever be // ENABLED_BY_DEFAULT because the feature state depends on the user's country. // There are countries we simply can't turn this on for, and they change over diff --git a/chromium/components/autofill/core/common/autofill_payments_features.h b/chromium/components/autofill/core/common/autofill_payments_features.h index 82c39b64954..3fcd9327e2e 100644 --- a/chromium/components/autofill/core/common/autofill_payments_features.h +++ b/chromium/components/autofill/core/common/autofill_payments_features.h @@ -8,7 +8,6 @@ #include <string> #include "base/feature_list.h" -#include "base/strings/string16.h" #include "build/build_config.h" namespace base { @@ -26,15 +25,19 @@ extern const base::Feature kAutofillCreditCardUploadFeedback; extern const base::Feature kAutofillDownstreamCvcPromptUseGooglePayLogo; extern const base::Feature kAutofillEnableGoogleIssuedCard; extern const base::Feature kAutofillEnableOfferNotification; +extern const base::Feature kAutofillEnableOfferNotificationCrossTabTracking; extern const base::Feature kAutofillEnableOffersInClankKeyboardAccessory; extern const base::Feature kAutofillEnableOffersInDownstream; extern const base::Feature kAutofillEnableSaveCardInfoBarAccountIndicationFooter; extern const base::Feature kAutofillEnableToolbarStatusChip; extern const base::Feature kAutofillEnableVirtualCard; +extern const base::Feature kAutofillFixOfferInIncognito; +extern const base::Feature kAutofillParseMerchantPromoCodeFields; extern const base::Feature kAutofillSaveCardDismissOnNavigation; extern const base::Feature kAutofillSaveCardInfobarEditSupport; extern const base::Feature kAutofillSortSuggestionsBasedOnOfferPresence; +extern const base::Feature kAutofillSuppressCreditCardSaveForAssistant; extern const base::Feature kAutofillUpstream; extern const base::Feature kAutofillUpstreamAllowAllEmailDomains; diff --git a/chromium/components/autofill/core/common/autofill_util.cc b/chromium/components/autofill/core/common/autofill_util.cc index 807dd4458cb..8c12f454c7c 100644 --- a/chromium/components/autofill/core/common/autofill_util.cc +++ b/chromium/components/autofill/core/common/autofill_util.cc @@ -11,6 +11,7 @@ #include "base/i18n/case_conversion.h" #include "base/metrics/field_trial.h" #include "base/metrics/field_trial_params.h" +#include "base/strings/strcat.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" #include "base/strings/string_split.h" @@ -72,8 +73,8 @@ bool IsTouchToFillEnabled() { } bool FieldIsSuggestionSubstringStartingOnTokenBoundary( - const base::string16& suggestion, - const base::string16& field_contents, + const std::u16string& suggestion, + const std::u16string& field_contents, bool case_sensitive) { if (!IsFeatureSubstringMatchEnabled()) { return base::StartsWith(suggestion, field_contents, @@ -84,26 +85,26 @@ bool FieldIsSuggestionSubstringStartingOnTokenBoundary( return suggestion.length() >= field_contents.length() && GetTextSelectionStart(suggestion, field_contents, case_sensitive) != - base::string16::npos; + std::u16string::npos; } -bool IsPrefixOfEmailEndingWithAtSign(const base::string16& full_string, - const base::string16& prefix) { - return base::StartsWith(full_string, prefix + base::UTF8ToUTF16("@"), +bool IsPrefixOfEmailEndingWithAtSign(const std::u16string& full_string, + const std::u16string& prefix) { + return base::StartsWith(full_string, prefix + u"@", base::CompareCase::SENSITIVE); } -size_t GetTextSelectionStart(const base::string16& suggestion, - const base::string16& field_contents, +size_t GetTextSelectionStart(const std::u16string& suggestion, + const std::u16string& field_contents, bool case_sensitive) { - const base::string16 kSplitChars = base::ASCIIToUTF16(kSplitCharacters); + const std::u16string kSplitChars = base::ASCIIToUTF16(kSplitCharacters); // Loop until we find either the |field_contents| is a prefix of |suggestion| // or character right before the match is one of the splitting characters. - for (base::string16::const_iterator it = suggestion.begin(); + for (std::u16string::const_iterator it = suggestion.begin(); (it = std::search( it, suggestion.end(), field_contents.begin(), field_contents.end(), - Compare<base::string16::value_type>(case_sensitive))) != + Compare<std::u16string::value_type>(case_sensitive))) != suggestion.end(); ++it) { if (it == suggestion.begin() || @@ -115,7 +116,7 @@ size_t GetTextSelectionStart(const base::string16& suggestion, } // Unable to find the |field_contents| in |suggestion| text. - return base::string16::npos; + return std::u16string::npos; } bool IsDesktopPlatform() { @@ -156,15 +157,15 @@ std::vector<std::string> LowercaseAndTokenizeAttributeString( base::SPLIT_WANT_NONEMPTY); } -bool SanitizedFieldIsEmpty(const base::string16& value) { +bool SanitizedFieldIsEmpty(const std::u16string& value) { // Some sites enter values such as ____-____-____-____ or (___)-___-____ in // their fields. Check if the field value is empty after the removal of the // formatting characters. - static base::string16 formatting = - (base::ASCIIToUTF16("-_()/") + - base::char16(base::i18n::kRightToLeftMark) + - base::char16(base::i18n::kLeftToRightMark)) - .append(base::kWhitespaceUTF16); + static std::u16string formatting = + base::StrCat({u"-_()/", + {&base::i18n::kRightToLeftMark, 1}, + {&base::i18n::kLeftToRightMark, 1}, + base::kWhitespaceUTF16}); return (value.find_first_not_of(formatting) == base::StringPiece::npos); } diff --git a/chromium/components/autofill/core/common/autofill_util.h b/chromium/components/autofill/core/common/autofill_util.h index f2e0f271c0b..ade30dd21aa 100644 --- a/chromium/components/autofill/core/common/autofill_util.h +++ b/chromium/components/autofill/core/common/autofill_util.h @@ -10,7 +10,6 @@ #include <string> #include <vector> -#include "base/strings/string16.h" #include "components/autofill/core/common/form_field_data.h" #include "components/autofill/core/common/mojom/autofill_types.mojom-shared.h" @@ -44,23 +43,23 @@ bool IsTouchToFillEnabled(); // starting at token boundaries. |field_contents| can span multiple |suggestion| // tokens. bool FieldIsSuggestionSubstringStartingOnTokenBoundary( - const base::string16& suggestion, - const base::string16& field_contents, + const std::u16string& suggestion, + const std::u16string& field_contents, bool case_sensitive); // Currently, a token for the purposes of this method is defined as {'@'}. // Returns true if the |full_string| has a |prefix| as a prefix and the prefix // ends on a token. -bool IsPrefixOfEmailEndingWithAtSign(const base::string16& full_string, - const base::string16& prefix); +bool IsPrefixOfEmailEndingWithAtSign(const std::u16string& full_string, + const std::u16string& prefix); // Finds the first occurrence of a searched substring |field_contents| within // the string |suggestion| starting at token boundaries and returns the index to -// the end of the located substring, or base::string16::npos if the substring is +// the end of the located substring, or std::u16string::npos if the substring is // not found. "preview-on-hover" feature is one such use case where the // substring |field_contents| may not be found within the string |suggestion|. -size_t GetTextSelectionStart(const base::string16& suggestion, - const base::string16& field_contents, +size_t GetTextSelectionStart(const std::u16string& suggestion, + const std::u16string& field_contents, bool case_sensitive); // Returns true if running on a desktop platform. Any platform that is not @@ -82,7 +81,7 @@ std::vector<std::string> LowercaseAndTokenizeAttributeString( // Returns true if and only if the field value has no character except the // formatting characters. This means that the field value is a formatting string // entered by the website and not a real value entered by the user. -bool SanitizedFieldIsEmpty(const base::string16& value); +bool SanitizedFieldIsEmpty(const std::u16string& value); // Returns true if the first suggestion should be autoselected when the autofill // dropdown is shown due to an arrow down event. Enabled on desktop only. diff --git a/chromium/components/autofill/core/common/autofill_util_unittest.cc b/chromium/components/autofill/core/common/autofill_util_unittest.cc index 4f1430a88bd..f67fe9c8bb3 100644 --- a/chromium/components/autofill/core/common/autofill_util_unittest.cc +++ b/chromium/components/autofill/core/common/autofill_util_unittest.cc @@ -36,7 +36,7 @@ TEST_P(FieldIsTokenBoundarySubstringCaseTest, // FieldIsSuggestionSubstringStartingOnTokenBoundary should not work yet // without a flag. EXPECT_FALSE(FieldIsSuggestionSubstringStartingOnTokenBoundary( - base::ASCIIToUTF16("ab@cd.b"), base::ASCIIToUTF16("b"), false)); + u"ab@cd.b", u"b", false)); } base::test::ScopedFeatureList features_enabled; @@ -147,14 +147,14 @@ INSTANTIATE_TEST_SUITE_P( GetTextSelectionStartTest, testing::Values( GetTextSelectionStartCase{"ab@cd.b", "a", false, 1}, - GetTextSelectionStartCase{"ab@cd.b", "A", true, base::string16::npos}, + GetTextSelectionStartCase{"ab@cd.b", "A", true, std::u16string::npos}, GetTextSelectionStartCase{"ab@cd.b", "Ab", false, 2}, - GetTextSelectionStartCase{"ab@cd.b", "Ab", true, base::string16::npos}, + GetTextSelectionStartCase{"ab@cd.b", "Ab", true, std::u16string::npos}, GetTextSelectionStartCase{"ab@cd.b", "cd", false, 5}, GetTextSelectionStartCase{"ab@cd.b", "ab@c", false, 4}, GetTextSelectionStartCase{"ab@cd.b", "cd.b", false, 7}, GetTextSelectionStartCase{"ab@cd.b", "b@cd", false, - base::string16::npos}, + std::u16string::npos}, GetTextSelectionStartCase{"ab@cd.b", "b", false, 7}, GetTextSelectionStartCase{"ba.a.ab", "a.a", false, 6}, GetTextSelectionStartCase{"texample@example.com", "example", false, diff --git a/chromium/components/autofill/core/common/field_data_manager.cc b/chromium/components/autofill/core/common/field_data_manager.cc index 860c8f63c79..32951c679c3 100644 --- a/chromium/components/autofill/core/common/field_data_manager.cc +++ b/chromium/components/autofill/core/common/field_data_manager.cc @@ -20,10 +20,10 @@ bool FieldDataManager::HasFieldData(FieldRendererId id) const { field_value_and_properties_map_.end(); } -base::string16 FieldDataManager::GetUserInput(FieldRendererId id) const { +std::u16string FieldDataManager::GetUserInput(FieldRendererId id) const { DCHECK(HasFieldData(id)); return field_value_and_properties_map_.at(id).first.value_or( - base::string16()); + std::u16string()); } FieldPropertiesMask FieldDataManager::GetFieldPropertiesMask( @@ -32,32 +32,32 @@ FieldPropertiesMask FieldDataManager::GetFieldPropertiesMask( return field_value_and_properties_map_.at(id).second; } -bool FieldDataManager::FindMachedValue(const base::string16& value) const { +bool FieldDataManager::FindMachedValue(const std::u16string& value) const { constexpr size_t kMinMatchSize = 3u; const auto lowercase = base::i18n::ToLower(value); for (const auto& map_key : field_value_and_properties_map_) { - const base::string16 typed_from_key = - map_key.second.first.value_or(base::string16()); + const std::u16string typed_from_key = + map_key.second.first.value_or(std::u16string()); if (typed_from_key.empty()) continue; if (typed_from_key.size() >= kMinMatchSize && lowercase.find(base::i18n::ToLower(typed_from_key)) != - base::string16::npos) + std::u16string::npos) return true; } return false; } void FieldDataManager::UpdateFieldDataMap(FieldRendererId id, - const base::string16& value, + const std::u16string& value, FieldPropertiesMask mask) { if (HasFieldData(id)) { field_value_and_properties_map_.at(id).first = - base::Optional<base::string16>(value); + base::Optional<std::u16string>(value); field_value_and_properties_map_.at(id).second |= mask; } else { field_value_and_properties_map_[id] = - std::make_pair(base::Optional<base::string16>(value), mask); + std::make_pair(base::Optional<std::u16string>(value), mask); } // Reset kUserTyped and kAutofilled flags if the value is empty. if (value.empty()) { diff --git a/chromium/components/autofill/core/common/field_data_manager.h b/chromium/components/autofill/core/common/field_data_manager.h index 5ce658e6099..4eb5c2441e6 100644 --- a/chromium/components/autofill/core/common/field_data_manager.h +++ b/chromium/components/autofill/core/common/field_data_manager.h @@ -6,11 +6,11 @@ #define COMPONENTS_AUTOFILL_CORE_COMMON_FIELD_DATA_MANAGER_H_ #include <map> +#include <string> #include "base/optional.h" -#include "base/strings/string16.h" #include "components/autofill/core/common/form_field_data.h" -#include "components/autofill/core/common/renderer_id.h" +#include "components/autofill/core/common/unique_ids.h" namespace autofill { @@ -20,7 +20,7 @@ class FieldDataManager : public base::RefCounted<FieldDataManager> { public: using FieldDataMap = std::map<FieldRendererId, - std::pair<base::Optional<base::string16>, FieldPropertiesMask>>; + std::pair<base::Optional<std::u16string>, FieldPropertiesMask>>; FieldDataManager(); @@ -32,19 +32,19 @@ class FieldDataManager : public base::RefCounted<FieldDataManager> { // Flags in |mask| are added with bitwise OR operation. // If |value| is empty, kUserTyped and kAutofilled should be cleared. void UpdateFieldDataMap(FieldRendererId id, - const base::string16& value, + const std::u16string& value, FieldPropertiesMask mask); // Only update FieldPropertiesMask when value is null. void UpdateFieldDataMapWithNullValue(FieldRendererId id, FieldPropertiesMask mask); // Returns value that was either typed or manually autofilled into the field. - base::string16 GetUserInput(FieldRendererId id) const; + std::u16string GetUserInput(FieldRendererId id) const; FieldPropertiesMask GetFieldPropertiesMask(FieldRendererId id) const; // Check if the string |value| is saved in |field_value_and_properties_map_|. - bool FindMachedValue(const base::string16& value) const; + bool FindMachedValue(const std::u16string& value) const; bool DidUserType(FieldRendererId id) const; diff --git a/chromium/components/autofill/core/common/field_data_manager_unittest.cc b/chromium/components/autofill/core/common/field_data_manager_unittest.cc index ca525b3a14a..a39152e8829 100644 --- a/chromium/components/autofill/core/common/field_data_manager_unittest.cc +++ b/chromium/components/autofill/core/common/field_data_manager_unittest.cc @@ -5,7 +5,7 @@ #include "components/autofill/core/common/field_data_manager.h" #include "base/strings/utf_string_conversions.h" -#include "components/autofill/core/common/renderer_id.h" +#include "components/autofill/core/common/unique_ids.h" #include "testing/gtest/include/gtest/gtest.h" using autofill::FormFieldData; @@ -18,14 +18,14 @@ class FieldDataManagerTest : public testing::Test { protected: void SetUp() override { FormFieldData field1; - field1.id_attribute = ASCIIToUTF16("name1"); - field1.value = ASCIIToUTF16("first"); + field1.id_attribute = u"name1"; + field1.value = u"first"; field1.form_control_type = "text"; field1.unique_renderer_id = FieldRendererId(1); control_elements_.push_back(field1); FormFieldData field2; - field2.id_attribute = ASCIIToUTF16("name2"); + field2.id_attribute = u"name2"; field2.form_control_type = "password"; field2.unique_renderer_id = FieldRendererId(2); control_elements_.push_back(field2); @@ -44,14 +44,14 @@ TEST_F(FieldDataManagerTest, UpdateFieldDataMap) { FieldPropertiesFlags::kUserTyped); const FieldRendererId id(control_elements_[0].unique_renderer_id); EXPECT_TRUE(field_data_manager->HasFieldData(id)); - EXPECT_EQ(UTF8ToUTF16("first"), field_data_manager->GetUserInput(id)); + EXPECT_EQ(u"first", field_data_manager->GetUserInput(id)); EXPECT_EQ(FieldPropertiesFlags::kUserTyped, field_data_manager->GetFieldPropertiesMask(id)); field_data_manager->UpdateFieldDataMap( - control_elements_[0].unique_renderer_id, UTF8ToUTF16("newvalue"), + control_elements_[0].unique_renderer_id, u"newvalue", FieldPropertiesFlags::kAutofilled); - EXPECT_EQ(UTF8ToUTF16("newvalue"), field_data_manager->GetUserInput(id)); + EXPECT_EQ(u"newvalue", field_data_manager->GetUserInput(id)); FieldPropertiesMask mask = FieldPropertiesFlags::kUserTyped | FieldPropertiesFlags::kAutofilled; EXPECT_EQ(mask, field_data_manager->GetFieldPropertiesMask(id)); @@ -75,14 +75,14 @@ TEST_F(FieldDataManagerTest, UpdateFieldDataMapWithNullValue) { FieldPropertiesFlags::kUserTyped); const FieldRendererId id(control_elements_[0].unique_renderer_id); EXPECT_TRUE(field_data_manager->HasFieldData(id)); - EXPECT_EQ(base::string16(), field_data_manager->GetUserInput(id)); + EXPECT_EQ(std::u16string(), field_data_manager->GetUserInput(id)); EXPECT_EQ(FieldPropertiesFlags::kUserTyped, field_data_manager->GetFieldPropertiesMask(id)); field_data_manager->UpdateFieldDataMapWithNullValue( control_elements_[0].unique_renderer_id, FieldPropertiesFlags::kAutofilled); - EXPECT_EQ(base::string16(), field_data_manager->GetUserInput(id)); + EXPECT_EQ(std::u16string(), field_data_manager->GetUserInput(id)); FieldPropertiesMask mask = FieldPropertiesFlags::kUserTyped | FieldPropertiesFlags::kAutofilled; EXPECT_EQ(mask, field_data_manager->GetFieldPropertiesMask(id)); @@ -90,7 +90,7 @@ TEST_F(FieldDataManagerTest, UpdateFieldDataMapWithNullValue) { field_data_manager->UpdateFieldDataMap( control_elements_[0].unique_renderer_id, control_elements_[0].value, FieldPropertiesFlags::kAutofilled); - EXPECT_EQ(UTF8ToUTF16("first"), field_data_manager->GetUserInput(id)); + EXPECT_EQ(u"first", field_data_manager->GetUserInput(id)); } TEST_F(FieldDataManagerTest, FindMachedValue) { @@ -99,10 +99,8 @@ TEST_F(FieldDataManagerTest, FindMachedValue) { field_data_manager->UpdateFieldDataMap( control_elements_[0].unique_renderer_id, control_elements_[0].value, FieldPropertiesFlags::kUserTyped); - EXPECT_TRUE( - field_data_manager->FindMachedValue(UTF8ToUTF16("first_element"))); - EXPECT_FALSE( - field_data_manager->FindMachedValue(UTF8ToUTF16("second_element"))); + EXPECT_TRUE(field_data_manager->FindMachedValue(u"first_element")); + EXPECT_FALSE(field_data_manager->FindMachedValue(u"second_element")); } } // namespace autofill diff --git a/chromium/components/autofill/core/common/form_data.cc b/chromium/components/autofill/core/common/form_data.cc index dd5ccbc4791..305596643ee 100644 --- a/chromium/components/autofill/core/common/form_data.cc +++ b/chromium/components/autofill/core/common/form_data.cc @@ -18,7 +18,7 @@ namespace autofill { namespace { -const int kFormDataPickleVersion = 6; +const int kFormDataPickleVersion = 7; bool ReadGURL(base::PickleIterator* iter, GURL* url) { std::string spec; @@ -85,7 +85,6 @@ bool FormData::SameFormAs(const FormData& form) const { if (name != form.name || id_attribute != form.id_attribute || name_attribute != form.name_attribute || url != form.url || action != form.action || is_form_tag != form.is_form_tag || - is_formless_checkout != form.is_formless_checkout || fields.size() != form.fields.size()) return false; for (size_t i = 0; i < fields.size(); ++i) { @@ -100,7 +99,6 @@ bool FormData::SimilarFormAs(const FormData& form) const { name_attribute != form.name_attribute || url != form.url || action != form.action || is_action_empty != form.is_action_empty || is_form_tag != form.is_form_tag || - is_formless_checkout != form.is_formless_checkout || fields.size() != form.fields.size()) { return false; } @@ -130,8 +128,7 @@ bool FormData::IdentityComparator::operator()(const FormData& a, // as well. auto tie = [](const FormData& f) { return std::tie(f.unique_renderer_id, f.name, f.id_attribute, - f.name_attribute, f.url, f.action, f.is_form_tag, - f.is_formless_checkout); + f.name_attribute, f.url, f.action, f.is_form_tag); }; if (tie(a) < tie(b)) return true; @@ -155,7 +152,6 @@ bool FormHasNonEmptyPasswordField(const FormData& form) { std::ostream& operator<<(std::ostream& os, const FormData& form) { os << base::UTF16ToUTF8(form.name) << " " << form.url << " " << form.action << " " << form.main_frame_origin << " " << form.is_form_tag << " " - << form.is_formless_checkout << " " << "Fields:"; for (size_t i = 0; i < form.fields.size(); ++i) { os << form.fields[i] << ","; @@ -170,7 +166,6 @@ void SerializeFormData(const FormData& form_data, base::Pickle* pickle) { pickle->WriteString(form_data.action.spec()); SerializeFormFieldDataVector(form_data.fields, pickle); pickle->WriteBool(form_data.is_form_tag); - pickle->WriteBool(form_data.is_formless_checkout); pickle->WriteString(form_data.main_frame_origin.Serialize()); } @@ -193,7 +188,7 @@ bool DeserializeFormData(base::PickleIterator* iter, FormData* form_data) { } if (version == 1) { - base::string16 method; + std::u16string method; if (!iter->ReadString16(&method)) { LogDeserializationError(version); return false; @@ -219,8 +214,9 @@ bool DeserializeFormData(base::PickleIterator* iter, FormData* form_data) { form_data->is_form_tag = true; } - if (version >= 5) { - if (!iter->ReadBool(&temp_form_data.is_formless_checkout)) { + if (version >= 5 && version <= 6) { + bool is_formless_checkout; + if (!iter->ReadBool(&is_formless_checkout)) { LogDeserializationError(version); return false; } diff --git a/chromium/components/autofill/core/common/form_data.h b/chromium/components/autofill/core/common/form_data.h index b57d18df62b..d4cfd250dd5 100644 --- a/chromium/components/autofill/core/common/form_data.h +++ b/chromium/components/autofill/core/common/form_data.h @@ -10,11 +10,10 @@ #include <utility> #include <vector> -#include "base/strings/string16.h" #include "build/build_config.h" #include "components/autofill/core/common/form_field_data.h" #include "components/autofill/core/common/mojom/autofill_types.mojom-shared.h" -#include "components/autofill/core/common/renderer_id.h" +#include "components/autofill/core/common/unique_ids.h" #include "url/gurl.h" #include "url/origin.h" @@ -24,7 +23,7 @@ class LogBuffer; // Pair of a button title (e.g. "Register") and its type (e.g. // INPUT_ELEMENT_SUBMIT_TYPE). -using ButtonTitleInfo = std::pair<base::string16, mojom::ButtonTitleType>; +using ButtonTitleInfo = std::pair<std::u16string, mojom::ButtonTitleType>; // List of button titles of a given form. using ButtonTitleList = std::vector<ButtonTitleInfo>; @@ -44,6 +43,8 @@ struct FormData { FormData& operator=(FormData&&); ~FormData(); + FormGlobalId global_id() const { return {host_frame, unique_renderer_id}; } + // Returns true if two forms are the same, not counting the values of the // form elements. bool SameFormAs(const FormData& other) const; @@ -59,10 +60,10 @@ struct FormData { bool operator<(const FormData& form) const; // The id attribute of the form. - base::string16 id_attribute; + std::u16string id_attribute; // The name attribute of the form. - base::string16 name_attribute; + std::u16string name_attribute; // NOTE: update IdentityComparator when adding new a member. // NOTE: update SameFormAs() if needed when adding new a member. @@ -74,7 +75,7 @@ struct FormData { // priority given to the name_attribute. This value is used when computing // form signatures. // TODO(crbug/896689): remove this and use attributes/unique_id instead. - base::string16 name; + std::u16string name; // Titles of form's buttons. ButtonTitleList button_titles; // The URL (minus query parameters and fragment) containing the form. @@ -91,11 +92,9 @@ struct FormData { url::Origin main_frame_origin; // True if this form is a form tag. bool is_form_tag = true; - // True if the form is made of unowned fields (i.e., not within a <form> tag) - // in what appears to be a checkout flow. This attribute is only calculated - // and used if features::kAutofillRestrictUnownedFieldsToFormlessCheckout is - // enabled, to prevent heuristics from running on formless non-checkout. - bool is_formless_checkout = false; + // Unique ID of the containing frame. A FormData must not be serialized if + // |host_frame| is default-initialized. + LocalFrameToken host_frame; // Unique renderer id returned by WebFormElement::UniqueRendererFormId(). It // is not persistent between page loads, so it is not saved and not used in // comparison in SameFormAs(). diff --git a/chromium/components/autofill/core/common/form_data_unittest.cc b/chromium/components/autofill/core/common/form_data_unittest.cc index eae97e5c202..5dd8c15de3b 100644 --- a/chromium/components/autofill/core/common/form_data_unittest.cc +++ b/chromium/components/autofill/core/common/form_data_unittest.cc @@ -22,7 +22,7 @@ void SerializeInVersion1Format(const FormData& form_data, base::Pickle* pickle) { pickle->WriteInt(1); pickle->WriteString16(form_data.name); - base::string16 method(base::ASCIIToUTF16("POST")); + std::u16string method(u"POST"); pickle->WriteString16(method); pickle->WriteString(form_data.url.spec()); pickle->WriteString(form_data.action.spec()); @@ -84,7 +84,7 @@ void SerializeInVersion5Format(const FormData& form_data, SerializeFormFieldData(form_data.fields[i], pickle); } pickle->WriteBool(form_data.is_form_tag); - pickle->WriteBool(form_data.is_formless_checkout); + pickle->WriteBool(/*is_formless_checkout=*/true); } void SerializeInVersion6Format(const FormData& form_data, @@ -98,7 +98,21 @@ void SerializeInVersion6Format(const FormData& form_data, SerializeFormFieldData(form_data.fields[i], pickle); } pickle->WriteBool(form_data.is_form_tag); - pickle->WriteBool(form_data.is_formless_checkout); + pickle->WriteBool(/*is_formless_checkout=*/true); + pickle->WriteString(form_data.main_frame_origin.Serialize()); +} + +void SerializeInVersion7Format(const FormData& form_data, + base::Pickle* pickle) { + pickle->WriteInt(7); + pickle->WriteString16(form_data.name); + pickle->WriteString(form_data.url.spec()); + pickle->WriteString(form_data.action.spec()); + pickle->WriteInt(static_cast<int>(form_data.fields.size())); + for (size_t i = 0; i < form_data.fields.size(); ++i) { + SerializeFormFieldData(form_data.fields[i], pickle); + } + pickle->WriteBool(form_data.is_form_tag); pickle->WriteString(form_data.main_frame_origin.Serialize()); } @@ -116,18 +130,17 @@ void SerializeIncorrectFormat(const FormData& form_data, base::Pickle* pickle) { } void FillInDummyFormData(FormData* data) { - data->name = base::ASCIIToUTF16("name"); + data->name = u"name"; data->url = GURL("https://example.com"); data->action = GURL("https://example.com/action"); data->main_frame_origin = url::Origin::Create(GURL("https://origin-example.com")); data->is_form_tag = true; // Default value. - data->is_formless_checkout = false; // Default value. FormFieldData field_data; - field_data.label = base::ASCIIToUTF16("label"); - field_data.name = base::ASCIIToUTF16("name"); - field_data.value = base::ASCIIToUTF16("value"); + field_data.label = u"label"; + field_data.name = u"name"; + field_data.value = u"value"; field_data.form_control_type = "password"; field_data.autocomplete_attribute = "off"; field_data.max_length = 200; @@ -136,17 +149,17 @@ void FillInDummyFormData(FormData* data) { field_data.is_focusable = true; field_data.should_autocomplete = false; field_data.text_direction = base::i18n::RIGHT_TO_LEFT; - field_data.option_values.push_back(base::ASCIIToUTF16("First")); - field_data.option_values.push_back(base::ASCIIToUTF16("Second")); - field_data.option_contents.push_back(base::ASCIIToUTF16("First")); - field_data.option_contents.push_back(base::ASCIIToUTF16("Second")); + field_data.option_values.push_back(u"First"); + field_data.option_values.push_back(u"Second"); + field_data.option_contents.push_back(u"First"); + field_data.option_contents.push_back(u"Second"); data->fields.push_back(field_data); // Change a few fields. field_data.max_length = 150; - field_data.option_values.push_back(base::ASCIIToUTF16("Third")); - field_data.option_contents.push_back(base::ASCIIToUTF16("Third")); + field_data.option_values.push_back(u"Third"); + field_data.option_contents.push_back(u"Third"); data->fields.push_back(field_data); } @@ -240,7 +253,6 @@ TEST(FormDataTest, Serialize_v4_Deserialize_vCurrent) { TEST(FormDataTest, Serialize_v5_Deserialize_vCurrent) { FormData data; FillInDummyFormData(&data); - data.is_formless_checkout = true; base::Pickle pickle; SerializeInVersion5Format(data, &pickle); @@ -255,7 +267,6 @@ TEST(FormDataTest, Serialize_v5_Deserialize_vCurrent) { TEST(FormDataTest, Serialize_v6_Deserialize_vCurrent) { FormData data; FillInDummyFormData(&data); - data.is_formless_checkout = true; base::Pickle pickle; SerializeInVersion6Format(data, &pickle); @@ -267,6 +278,20 @@ TEST(FormDataTest, Serialize_v6_Deserialize_vCurrent) { EXPECT_TRUE(actual.SameFormAs(data)); } +TEST(FormDataTest, Serialize_v7_Deserialize_vCurrent) { + FormData data; + FillInDummyFormData(&data); + + base::Pickle pickle; + SerializeInVersion7Format(data, &pickle); + + base::PickleIterator iter(pickle); + FormData actual; + EXPECT_TRUE(DeserializeFormData(&iter, &actual)); + + EXPECT_TRUE(actual.SameFormAs(data)); +} + TEST(FormDataTest, SerializeIncorrectFormatAndDeserialize) { FormData data; FillInDummyFormData(&data); diff --git a/chromium/components/autofill/core/common/form_field_data.cc b/chromium/components/autofill/core/common/form_field_data.cc index 26585e31b65..78c9c493fd3 100644 --- a/chromium/components/autofill/core/common/form_field_data.cc +++ b/chromium/components/autofill/core/common/form_field_data.cc @@ -24,7 +24,7 @@ namespace { // deserialization routine from previous kFormFieldDataPickleVersion format. const int kFormFieldDataPickleVersion = 8; -void AddVectorToPickle(std::vector<base::string16> strings, +void AddVectorToPickle(std::vector<std::u16string> strings, base::Pickle* pickle) { pickle->WriteInt(static_cast<int>(strings.size())); for (size_t i = 0; i < strings.size(); ++i) { @@ -33,12 +33,12 @@ void AddVectorToPickle(std::vector<base::string16> strings, } bool ReadStringVector(base::PickleIterator* iter, - std::vector<base::string16>* strings) { + std::vector<std::u16string>* strings) { int size; if (!iter->ReadInt(&size)) return false; - base::string16 pickle_data; + std::u16string pickle_data; for (int i = 0; i < size; i++) { if (!iter->ReadString16(&pickle_data)) return false; @@ -430,7 +430,7 @@ LogBuffer& operator<<(LogBuffer& buffer, const FormFieldData& field) { buffer << Tr{} << "Name attribute:" << field.name_attribute; buffer << Tr{} << "Id attribute:" << field.id_attribute; constexpr size_t kMaxLabelSize = 100; - const base::string16 truncated_label = + const std::u16string truncated_label = field.label.substr(0, std::min(field.label.length(), kMaxLabelSize)); buffer << Tr{} << "Label:" << truncated_label; buffer << Tr{} << "Form control type:" << field.form_control_type; diff --git a/chromium/components/autofill/core/common/form_field_data.h b/chromium/components/autofill/core/common/form_field_data.h index d9778424a43..cda1f1fb864 100644 --- a/chromium/components/autofill/core/common/form_field_data.h +++ b/chromium/components/autofill/core/common/form_field_data.h @@ -8,14 +8,14 @@ #include <stddef.h> #include <limits> +#include <string> #include <type_traits> #include <vector> #include "base/i18n/rtl.h" -#include "base/strings/string16.h" #include "build/build_config.h" #include "components/autofill/core/common/mojom/autofill_types.mojom-shared.h" -#include "components/autofill/core/common/renderer_id.h" +#include "components/autofill/core/common/unique_ids.h" #include "ui/gfx/geometry/rect_f.h" namespace base { @@ -73,6 +73,8 @@ struct FormFieldData { FormFieldData& operator=(FormFieldData&&); ~FormFieldData(); + FieldGlobalId global_id() const { return {host_frame, unique_renderer_id}; } + // Returns true if both fields are identical, ignoring value- and // parsing related members. // See also SimilarFieldAs(), DynamicallySameFieldAs(). @@ -114,7 +116,7 @@ struct FormFieldData { // // TODO(crbug.com/896689): Expand the logic/application of this to other // platforms and/or merge this concept with |unique_renderer_id|. - base::string16 unique_id; + std::u16string unique_id; #define EXPECT_EQ_UNIQUE_ID(expected, actual) \ EXPECT_EQ((expected).unique_id, (actual).unique_id) #else @@ -131,19 +133,22 @@ struct FormFieldData { // priority given to the name_attribute. This value is used when computing // form signatures. // TODO(crbug/896689): remove this and use attributes/unique_id instead. - base::string16 name; + std::u16string name; - base::string16 id_attribute; - base::string16 name_attribute; - base::string16 label; - base::string16 value; + std::u16string id_attribute; + std::u16string name_attribute; + std::u16string label; + std::u16string value; std::string form_control_type; std::string autocomplete_attribute; - base::string16 placeholder; - base::string16 css_classes; - base::string16 aria_label; - base::string16 aria_description; - + std::u16string placeholder; + std::u16string css_classes; + std::u16string aria_label; + std::u16string aria_description; + + // Unique ID of the containing frame. A FormData must not be serialized if + // |host_frame| is default-initialized. + LocalFrameToken host_frame; // Unique renderer id returned by // WebFormControlElement::UniqueRendererFormId(). It is not persistent between // page loads, so it is not saved and not used in comparison in SameFieldAs(). @@ -175,12 +180,12 @@ struct FormFieldData { bool is_readonly = false; // Contains value that was either manually typed or autofilled on user // trigger. - base::string16 user_input; + std::u16string user_input; // For the HTML snippet |<option value="US">United States</option>|, the // value is "US" and the contents are "United States". - std::vector<base::string16> option_values; - std::vector<base::string16> option_contents; + std::vector<std::u16string> option_values; + std::vector<std::u16string> option_contents; // Password Manager doesn't use labels nor client side nor server side, so // label_source isn't in serialize methods. @@ -196,8 +201,8 @@ struct FormFieldData { // used for field comparison and aren't in serialize methods. // The datalist option is intentionally separated from option_values and // option_contents because they are handled very differently in autofill. - std::vector<base::string16> datalist_values; - std::vector<base::string16> datalist_labels; + std::vector<std::u16string> datalist_values; + std::vector<std::u16string> datalist_labels; }; // Serialize and deserialize FormFieldData. These are used when FormData objects diff --git a/chromium/components/autofill/core/common/form_field_data_unittest.cc b/chromium/components/autofill/core/common/form_field_data_unittest.cc index a3fd064e51d..4c2bb9fa83e 100644 --- a/chromium/components/autofill/core/common/form_field_data_unittest.cc +++ b/chromium/components/autofill/core/common/form_field_data_unittest.cc @@ -15,9 +15,9 @@ namespace autofill { namespace { void FillCommonFields(FormFieldData* data) { - data->label = base::ASCIIToUTF16("label"); - data->name = base::ASCIIToUTF16("name"); - data->value = base::ASCIIToUTF16("value"); + data->label = u"label"; + data->name = u"name"; + data->value = u"value"; data->form_control_type = "password"; data->autocomplete_attribute = "off"; data->max_length = 200; @@ -26,10 +26,10 @@ void FillCommonFields(FormFieldData* data) { data->is_focusable = true; data->should_autocomplete = false; data->text_direction = base::i18n::RIGHT_TO_LEFT; - data->option_values.push_back(base::ASCIIToUTF16("First")); - data->option_values.push_back(base::ASCIIToUTF16("Second")); - data->option_contents.push_back(base::ASCIIToUTF16("First")); - data->option_contents.push_back(base::ASCIIToUTF16("Second")); + data->option_values.push_back(u"First"); + data->option_values.push_back(u"Second"); + data->option_contents.push_back(u"First"); + data->option_contents.push_back(u"Second"); } void FillVersion2Fields(FormFieldData* data) { @@ -37,11 +37,11 @@ void FillVersion2Fields(FormFieldData* data) { } void FillVersion3Fields(FormFieldData* data) { - data->placeholder = base::ASCIIToUTF16("placeholder"); + data->placeholder = u"placeholder"; } void FillVersion5Fields(FormFieldData* data) { - data->css_classes = base::ASCIIToUTF16("class1 class2"); + data->css_classes = u"class1 class2"; } void FillVersion6Fields(FormFieldData* data) { @@ -50,11 +50,11 @@ void FillVersion6Fields(FormFieldData* data) { } void FillVersion7Fields(FormFieldData* data) { - data->id_attribute = base::ASCIIToUTF16("id"); + data->id_attribute = u"id"; } void FillVersion8Fields(FormFieldData* data) { - data->name_attribute = base::ASCIIToUTF16("name"); + data->name_attribute = u"name"; } void WriteSection1(const FormFieldData& data, base::Pickle* pickle) { @@ -372,8 +372,8 @@ TEST(FormFieldDataTest, DeserializeVersion8) { TEST(FormFieldDataTest, DeserializeBadData) { base::Pickle pickle; pickle.WriteInt(255); - pickle.WriteString16(base::ASCIIToUTF16("random")); - pickle.WriteString16(base::ASCIIToUTF16("data")); + pickle.WriteString16(u"random"); + pickle.WriteString16(u"data"); base::PickleIterator iter(pickle); FormFieldData actual; diff --git a/chromium/components/autofill/core/common/logging/log_buffer.cc b/chromium/components/autofill/core/common/logging/log_buffer.cc index 961e66e457b..0020815cf30 100644 --- a/chromium/components/autofill/core/common/logging/log_buffer.cc +++ b/chromium/components/autofill/core/common/logging/log_buffer.cc @@ -238,10 +238,10 @@ LogTableRowBuffer&& operator<<(LogTableRowBuffer&& buf, Attrib&& attrib) { namespace { // Highlights the first |needle| in |haystack| by wrapping it in <b> tags. -template <typename STRING_TYPE> -LogBuffer HighlightValueInternal(base::BasicStringPiece<STRING_TYPE> haystack, - base::BasicStringPiece<STRING_TYPE> needle) { - using StringPieceT = base::BasicStringPiece<STRING_TYPE>; +template <typename CharT> +LogBuffer HighlightValueInternal(base::BasicStringPiece<CharT> haystack, + base::BasicStringPiece<CharT> needle) { + using StringPieceT = base::BasicStringPiece<CharT>; LogBuffer buffer; size_t pos = haystack.find(needle); if (pos == StringPieceT::npos || needle.empty()) { diff --git a/chromium/components/autofill/core/common/logging/log_buffer.h b/chromium/components/autofill/core/common/logging/log_buffer.h index fc782f4f93d..c051d1cd1fa 100644 --- a/chromium/components/autofill/core/common/logging/log_buffer.h +++ b/chromium/components/autofill/core/common/logging/log_buffer.h @@ -10,7 +10,6 @@ #include <vector> #include "base/macros.h" -#include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" #include "base/values.h" diff --git a/chromium/components/autofill/core/common/logging/log_buffer_unittest.cc b/chromium/components/autofill/core/common/logging/log_buffer_unittest.cc index de9126e263b..b1ce2386f2a 100644 --- a/chromium/components/autofill/core/common/logging/log_buffer_unittest.cc +++ b/chromium/components/autofill/core/common/logging/log_buffer_unittest.cc @@ -25,7 +25,7 @@ TEST(LogBuffer, JSONSerializeString) { TEST(LogBuffer, JSONSerializeString16) { LogBuffer buffer; - buffer << base::ASCIIToUTF16("<foo><!--\""); + buffer << u"<foo><!--\""; std::string json; EXPECT_TRUE(base::JSONWriter::Write(buffer.RetrieveResult(), &json)); // JSON takes care of serializing the <, we don't want < as that would then diff --git a/chromium/components/autofill/core/common/mojom/autofill_types.mojom b/chromium/components/autofill/core/common/mojom/autofill_types.mojom index f0a1654c991..ff72e2a7282 100644 --- a/chromium/components/autofill/core/common/mojom/autofill_types.mojom +++ b/chromium/components/autofill/core/common/mojom/autofill_types.mojom @@ -7,6 +7,7 @@ module autofill.mojom; import "mojo/public/mojom/base/text_direction.mojom"; import "mojo/public/mojom/base/time.mojom"; import "mojo/public/mojom/base/string16.mojom"; +import "mojo/public/mojom/base/unguessable_token.mojom"; import "ui/gfx/geometry/mojom/geometry.mojom"; import "url/mojom/origin.mojom"; import "url/mojom/url.mojom"; @@ -66,6 +67,11 @@ enum ButtonTitleType { SPAN = 7 // e.g. <span name='btn'> }; +// autofill::LocalFrameToken +struct LocalFrameToken { + mojo_base.mojom.UnguessableToken token; +}; + // autofill::FormRendererId struct FormRendererId { uint32 id; @@ -118,6 +124,7 @@ struct FormFieldData { mojo_base.mojom.String16 css_classes; mojo_base.mojom.String16 aria_label; mojo_base.mojom.String16 aria_description; + LocalFrameToken host_frame; FieldRendererId unique_renderer_id; uint32 properties_mask; int32 form_control_ax_id; @@ -162,7 +169,7 @@ struct FormData { bool is_action_empty; url.mojom.Origin main_frame_origin; bool is_form_tag; - bool is_formless_checkout; + LocalFrameToken host_frame; FormRendererId unique_renderer_id; SubmissionIndicatorEvent submission_event; array<FormFieldData> fields; diff --git a/chromium/components/autofill/core/common/mojom/autofill_types_mojom_traits.cc b/chromium/components/autofill/core/common/mojom/autofill_types_mojom_traits.cc index 7f9fb938595..ae325977757 100644 --- a/chromium/components/autofill/core/common/mojom/autofill_types_mojom_traits.cc +++ b/chromium/components/autofill/core/common/mojom/autofill_types_mojom_traits.cc @@ -14,6 +14,18 @@ namespace mojo { // static +bool StructTraits<autofill::mojom::LocalFrameTokenDataView, + autofill::LocalFrameToken>:: + Read(autofill::mojom::LocalFrameTokenDataView data, + autofill::LocalFrameToken* out) { + base::UnguessableToken token; + if (!data.ReadToken(&token)) + return false; + *out = autofill::LocalFrameToken(token); + return true; +} + +// static bool StructTraits<autofill::mojom::FormRendererIdDataView, autofill::FormRendererId>:: Read(autofill::mojom::FormRendererIdDataView data, @@ -69,6 +81,9 @@ bool StructTraits< out->properties_mask = data.properties_mask(); + if (!data.ReadHostFrame(&out->host_frame)) + return false; + if (!data.ReadUniqueRendererId(&out->unique_renderer_id)) return false; @@ -143,7 +158,9 @@ bool StructTraits<autofill::mojom::FormDataDataView, autofill::FormData>::Read( return false; out->is_form_tag = data.is_form_tag(); - out->is_formless_checkout = data.is_formless_checkout(); + + if (!data.ReadHostFrame(&out->host_frame)) + return false; if (!data.ReadUniqueRendererId(&out->unique_renderer_id)) return false; diff --git a/chromium/components/autofill/core/common/mojom/autofill_types_mojom_traits.h b/chromium/components/autofill/core/common/mojom/autofill_types_mojom_traits.h index 4863cad0561..3cba85298be 100644 --- a/chromium/components/autofill/core/common/mojom/autofill_types_mojom_traits.h +++ b/chromium/components/autofill/core/common/mojom/autofill_types_mojom_traits.h @@ -11,7 +11,6 @@ #include <vector> #include "base/i18n/rtl.h" -#include "base/strings/string16.h" #include "components/autofill/core/common/form_data.h" #include "components/autofill/core/common/form_data_predictions.h" #include "components/autofill/core/common/form_field_data.h" @@ -20,15 +19,27 @@ #include "components/autofill/core/common/password_form_fill_data.h" #include "components/autofill/core/common/password_form_generation_data.h" #include "components/autofill/core/common/password_generation_util.h" -#include "components/autofill/core/common/renderer_id.h" +#include "components/autofill/core/common/unique_ids.h" #include "mojo/public/cpp/base/text_direction_mojom_traits.h" #include "mojo/public/cpp/bindings/struct_traits.h" +#include "mojo/public/mojom/base/unguessable_token.mojom-shared.h" #include "ui/gfx/geometry/rect_f.h" #include "url/origin.h" namespace mojo { template <> +struct StructTraits<autofill::mojom::LocalFrameTokenDataView, + autofill::LocalFrameToken> { + static base::UnguessableToken token(const autofill::LocalFrameToken& r) { + return r.value(); + } + + static bool Read(autofill::mojom::LocalFrameTokenDataView data, + autofill::LocalFrameToken* out); +}; + +template <> struct StructTraits<autofill::mojom::FormRendererIdDataView, autofill::FormRendererId> { static uint32_t id(autofill::FormRendererId r) { return r.value(); } @@ -49,24 +60,24 @@ struct StructTraits<autofill::mojom::FieldRendererIdDataView, template <> struct StructTraits<autofill::mojom::FormFieldDataDataView, autofill::FormFieldData> { - static const base::string16& label(const autofill::FormFieldData& r) { + static const std::u16string& label(const autofill::FormFieldData& r) { return r.label; } - static const base::string16& name(const autofill::FormFieldData& r) { + static const std::u16string& name(const autofill::FormFieldData& r) { return r.name; } - static const base::string16& id_attribute(const autofill::FormFieldData& r) { + static const std::u16string& id_attribute(const autofill::FormFieldData& r) { return r.id_attribute; } - static const base::string16& name_attribute( + static const std::u16string& name_attribute( const autofill::FormFieldData& r) { return r.name_attribute; } - static const base::string16& value(const autofill::FormFieldData& r) { + static const std::u16string& value(const autofill::FormFieldData& r) { return r.value; } @@ -80,23 +91,28 @@ struct StructTraits<autofill::mojom::FormFieldDataDataView, return r.autocomplete_attribute; } - static const base::string16& placeholder(const autofill::FormFieldData& r) { + static const std::u16string& placeholder(const autofill::FormFieldData& r) { return r.placeholder; } - static const base::string16& css_classes(const autofill::FormFieldData& r) { + static const std::u16string& css_classes(const autofill::FormFieldData& r) { return r.css_classes; } - static const base::string16& aria_label(const autofill::FormFieldData& r) { + static const std::u16string& aria_label(const autofill::FormFieldData& r) { return r.aria_label; } - static const base::string16& aria_description( + static const std::u16string& aria_description( const autofill::FormFieldData& r) { return r.aria_description; } + static autofill::LocalFrameToken host_frame( + const autofill::FormFieldData& r) { + return r.host_frame; + } + static autofill::FieldRendererId unique_renderer_id( const autofill::FormFieldData& r) { return r.unique_renderer_id; @@ -153,16 +169,16 @@ struct StructTraits<autofill::mojom::FormFieldDataDataView, return r.is_readonly; } - static const base::string16& user_input(const autofill::FormFieldData& r) { + static const std::u16string& user_input(const autofill::FormFieldData& r) { return r.user_input; } - static const std::vector<base::string16>& option_values( + static const std::vector<std::u16string>& option_values( const autofill::FormFieldData& r) { return r.option_values; } - static const std::vector<base::string16>& option_contents( + static const std::vector<std::u16string>& option_contents( const autofill::FormFieldData& r) { return r.option_contents; } @@ -176,12 +192,12 @@ struct StructTraits<autofill::mojom::FormFieldDataDataView, return r.bounds; } - static const std::vector<base::string16>& datalist_values( + static const std::vector<std::u16string>& datalist_values( const autofill::FormFieldData& r) { return r.datalist_values; } - static const std::vector<base::string16>& datalist_labels( + static const std::vector<std::u16string>& datalist_labels( const autofill::FormFieldData& r) { return r.datalist_labels; } @@ -193,7 +209,7 @@ struct StructTraits<autofill::mojom::FormFieldDataDataView, template <> struct StructTraits<autofill::mojom::ButtonTitleInfoDataView, autofill::ButtonTitleInfo> { - static const base::string16& title(const autofill::ButtonTitleInfo& r) { + static const std::u16string& title(const autofill::ButtonTitleInfo& r) { return r.first; } @@ -208,15 +224,15 @@ struct StructTraits<autofill::mojom::ButtonTitleInfoDataView, template <> struct StructTraits<autofill::mojom::FormDataDataView, autofill::FormData> { - static const base::string16& id_attribute(const autofill::FormData& r) { + static const std::u16string& id_attribute(const autofill::FormData& r) { return r.id_attribute; } - static const base::string16& name_attribute(const autofill::FormData& r) { + static const std::u16string& name_attribute(const autofill::FormData& r) { return r.name_attribute; } - static const base::string16& name(const autofill::FormData& r) { + static const std::u16string& name(const autofill::FormData& r) { return r.name; } @@ -243,8 +259,8 @@ struct StructTraits<autofill::mojom::FormDataDataView, autofill::FormData> { static bool is_form_tag(const autofill::FormData& r) { return r.is_form_tag; } - static bool is_formless_checkout(const autofill::FormData& r) { - return r.is_formless_checkout; + static autofill::LocalFrameToken host_frame(const autofill::FormData& r) { + return r.host_frame; } static autofill::FormRendererId unique_renderer_id( @@ -337,12 +353,12 @@ struct StructTraits<autofill::mojom::FormDataPredictionsDataView, template <> struct StructTraits<autofill::mojom::PasswordAndMetadataDataView, autofill::PasswordAndMetadata> { - static const base::string16& username( + static const std::u16string& username( const autofill::PasswordAndMetadata& r) { return r.username; } - static const base::string16& password( + static const std::u16string& password( const autofill::PasswordAndMetadata& r) { return r.password; } @@ -442,7 +458,7 @@ struct StructTraits<autofill::mojom::PasswordGenerationUIDataDataView, return r.max_length; } - static const base::string16& generation_element( + static const std::u16string& generation_element( const autofill::password_generation::PasswordGenerationUIData& r) { return r.generation_element; } diff --git a/chromium/components/autofill/core/common/mojom/autofill_types_mojom_traits_unittest.cc b/chromium/components/autofill/core/common/mojom/autofill_types_mojom_traits_unittest.cc index 6e9744467b3..6e9d088c1a9 100644 --- a/chromium/components/autofill/core/common/mojom/autofill_types_mojom_traits_unittest.cc +++ b/chromium/components/autofill/core/common/mojom/autofill_types_mojom_traits_unittest.cc @@ -14,8 +14,8 @@ #include "components/autofill/core/common/form_field_data.h" #include "components/autofill/core/common/mojom/test_autofill_types.mojom.h" #include "components/autofill/core/common/password_generation_util.h" -#include "components/autofill/core/common/renderer_id.h" #include "components/autofill/core/common/signatures.h" +#include "components/autofill/core/common/unique_ids.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/remote.h" @@ -57,15 +57,15 @@ void CreateTestPasswordFormFillData(PasswordFormFillData* fill_data) { fill_data->uses_account_store = true; PasswordAndMetadata pr; - pr.password = base::ASCIIToUTF16("Tom_Password"); + pr.password = u"Tom_Password"; pr.realm = "https://foo.com/"; pr.uses_account_store = false; - pr.username = base::ASCIIToUTF16("Tom"); + pr.username = u"Tom"; fill_data->additional_logins.push_back(pr); - pr.password = base::ASCIIToUTF16("Jerry_Password"); + pr.password = u"Jerry_Password"; pr.realm = "https://bar.com/"; pr.uses_account_store = true; - pr.username = base::ASCIIToUTF16("Jerry"); + pr.username = u"Jerry"; fill_data->additional_logins.push_back(pr); fill_data->wait_for_username = true; @@ -75,7 +75,7 @@ void CreatePasswordGenerationUIData( password_generation::PasswordGenerationUIData* data) { data->bounds = gfx::RectF(1, 1, 200, 100); data->max_length = 20; - data->generation_element = base::ASCIIToUTF16("generation_element"); + data->generation_element = u"generation_element"; data->text_direction = base::i18n::RIGHT_TO_LEFT; data->is_generation_element_password_type = false; test::CreateTestAddressFormData(&data->form_data); @@ -242,13 +242,15 @@ TEST_F(AutofillTypeTraitsTestImpl, PassFormFieldData) { test::CreateTestSelectField("TestLabel", "TestName", "TestValue", kOptions, kOptions, 4, &input); // Set other attributes to check if they are passed correctly. - input.id_attribute = base::ASCIIToUTF16("id"); - input.name_attribute = base::ASCIIToUTF16("name"); + input.host_frame = LocalFrameToken(base::UnguessableToken::Create()); + input.unique_renderer_id = FieldRendererId(1234); + input.id_attribute = u"id"; + input.name_attribute = u"name"; input.autocomplete_attribute = "on"; - input.placeholder = base::ASCIIToUTF16("placeholder"); - input.css_classes = base::ASCIIToUTF16("class1"); - input.aria_label = base::ASCIIToUTF16("aria label"); - input.aria_description = base::ASCIIToUTF16("aria description"); + input.placeholder = u"placeholder"; + input.css_classes = u"class1"; + input.aria_label = u"aria label"; + input.aria_description = u"aria description"; input.max_length = 12345; input.is_autofilled = true; input.check_status = FormFieldData::CheckStatus::kChecked; @@ -256,7 +258,7 @@ TEST_F(AutofillTypeTraitsTestImpl, PassFormFieldData) { input.role = FormFieldData::RoleAttribute::kPresentation; input.text_direction = base::i18n::RIGHT_TO_LEFT; input.properties_mask = FieldPropertiesFlags::kHadFocus; - input.user_input = base::ASCIIToUTF16("TestTypedValue"); + input.user_input = u"TestTypedValue"; input.bounds = gfx::RectF(1, 2, 10, 100); base::RunLoop loop; @@ -272,13 +274,15 @@ TEST_F(AutofillTypeTraitsTestImpl, PassDataListFormFieldData) { test::CreateTestDatalistField("DatalistLabel", "DatalistName", "DatalistValue", kOptions, kOptions, &input); // Set other attributes to check if they are passed correctly. - input.id_attribute = base::ASCIIToUTF16("id"); - input.name_attribute = base::ASCIIToUTF16("name"); + input.host_frame = LocalFrameToken(base::UnguessableToken::Create()); + input.unique_renderer_id = FieldRendererId(1234); + input.id_attribute = u"id"; + input.name_attribute = u"name"; input.autocomplete_attribute = "on"; - input.placeholder = base::ASCIIToUTF16("placeholder"); - input.css_classes = base::ASCIIToUTF16("class1"); - input.aria_label = base::ASCIIToUTF16("aria label"); - input.aria_description = base::ASCIIToUTF16("aria description"); + input.placeholder = u"placeholder"; + input.css_classes = u"class1"; + input.aria_label = u"aria label"; + input.aria_description = u"aria description"; input.max_length = 12345; input.is_autofilled = true; input.check_status = FormFieldData::CheckStatus::kChecked; @@ -286,7 +290,7 @@ TEST_F(AutofillTypeTraitsTestImpl, PassDataListFormFieldData) { input.role = FormFieldData::RoleAttribute::kPresentation; input.text_direction = base::i18n::RIGHT_TO_LEFT; input.properties_mask = FieldPropertiesFlags::kHadFocus; - input.user_input = base::ASCIIToUTF16("TestTypedValue"); + input.user_input = u"TestTypedValue"; input.bounds = gfx::RectF(1, 2, 10, 100); base::RunLoop loop; @@ -302,9 +306,8 @@ TEST_F(AutofillTypeTraitsTestImpl, PassFormData) { input.username_predictions = {autofill::FieldRendererId(1), autofill::FieldRendererId(13), autofill::FieldRendererId(2)}; - input.button_titles.push_back( - std::make_pair(base::ASCIIToUTF16("Sign-up"), - mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)); + input.button_titles.push_back(std::make_pair( + u"Sign-up", mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)); base::RunLoop loop; mojo::Remote<mojom::TypeTraitsTest> remote(GetTypeTraitsTestRemote()); diff --git a/chromium/components/autofill/core/common/password_form_fill_data.h b/chromium/components/autofill/core/common/password_form_fill_data.h index 93081879d5d..3e89a662ae0 100644 --- a/chromium/components/autofill/core/common/password_form_fill_data.h +++ b/chromium/components/autofill/core/common/password_form_fill_data.h @@ -9,7 +9,7 @@ #include <vector> #include "components/autofill/core/common/form_data.h" -#include "components/autofill/core/common/renderer_id.h" +#include "components/autofill/core/common/unique_ids.h" namespace autofill { @@ -29,8 +29,8 @@ struct PasswordAndMetadata { PasswordAndMetadata& operator=(PasswordAndMetadata&&); ~PasswordAndMetadata(); - base::string16 username; - base::string16 password; + std::u16string username; + std::u16string password; std::string realm; bool uses_account_store = false; }; @@ -56,7 +56,7 @@ struct PasswordFormFillData { FormRendererId form_renderer_id; // The name of the form. - base::string16 name; + std::u16string name; // An URL consisting of the scheme, host, port and path; the rest is stripped. GURL url; diff --git a/chromium/components/autofill/core/common/password_form_generation_data.h b/chromium/components/autofill/core/common/password_form_generation_data.h index 7c22909ac82..e919bb8e760 100644 --- a/chromium/components/autofill/core/common/password_form_generation_data.h +++ b/chromium/components/autofill/core/common/password_form_generation_data.h @@ -6,7 +6,7 @@ #define COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_FORM_GENERATION_DATA_H_ #include "build/build_config.h" -#include "components/autofill/core/common/renderer_id.h" +#include "components/autofill/core/common/unique_ids.h" namespace autofill { diff --git a/chromium/components/autofill/core/common/password_generation_util.cc b/chromium/components/autofill/core/common/password_generation_util.cc index d403627befe..8b223f1ca6f 100644 --- a/chromium/components/autofill/core/common/password_generation_util.cc +++ b/chromium/components/autofill/core/common/password_generation_util.cc @@ -15,7 +15,7 @@ namespace password_generation { PasswordGenerationUIData::PasswordGenerationUIData( const gfx::RectF& bounds, int max_length, - const base::string16& generation_element, + const std::u16string& generation_element, FieldRendererId generation_element_id, bool is_generation_element_password_type, base::i18n::TextDirection text_direction, diff --git a/chromium/components/autofill/core/common/password_generation_util.h b/chromium/components/autofill/core/common/password_generation_util.h index abcee73daae..a2a596037cb 100644 --- a/chromium/components/autofill/core/common/password_generation_util.h +++ b/chromium/components/autofill/core/common/password_generation_util.h @@ -5,10 +5,11 @@ #ifndef COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_GENERATION_UTIL_H_ #define COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_GENERATION_UTIL_H_ +#include <string> + #include "base/i18n/rtl.h" -#include "base/strings/string16.h" #include "components/autofill/core/common/form_data.h" -#include "components/autofill/core/common/renderer_id.h" +#include "components/autofill/core/common/unique_ids.h" #include "ui/gfx/geometry/rect_f.h" namespace autofill { @@ -110,7 +111,7 @@ struct PasswordGenerationActions { struct PasswordGenerationUIData { PasswordGenerationUIData(const gfx::RectF& bounds, int max_length, - const base::string16& generation_element, + const std::u16string& generation_element, FieldRendererId generation_element_id, bool is_generation_element_password_type, base::i18n::TextDirection text_direction, @@ -131,7 +132,7 @@ struct PasswordGenerationUIData { int max_length; // Name of the password field to which the generation popup is attached. - base::string16 generation_element; + std::u16string generation_element; // Renderer ID of the generation element. FieldRendererId generation_element_id; diff --git a/chromium/components/autofill/core/common/renderer_id.h b/chromium/components/autofill/core/common/renderer_id.h deleted file mode 100644 index cf3941f2f0e..00000000000 --- a/chromium/components/autofill/core/common/renderer_id.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2020 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_AUTOFILL_CORE_COMMON_RENDERER_ID_H_ -#define COMPONENTS_AUTOFILL_CORE_COMMON_RENDERER_ID_H_ - -#include <stdint.h> -#include <limits> - -#include "base/util/type_safety/id_type.h" - -namespace autofill { - -// A value that can be provided by the renderer in cases when the ID is missing. -constexpr int kNotSetRendererID = -1; - -namespace internal { - -using FormRendererIdType = ::util::IdType<class FormRendererIdMarker, - uint32_t, - std::numeric_limits<uint32_t>::max()>; - -using FieldRendererIdType = - ::util::IdType<class FieldRendererIdMarker, - uint32_t, - std::numeric_limits<uint32_t>::max()>; - -} // namespace internal - -// The below strong aliases are defined as subclasses instead of typedefs in -// order to avoid having to define out-of-line constructors in all structs that -// contain renderer IDs. - -// The FormRendererId of a synthetic form is_null(). A synthetic form is the -// collection of form fields outside of the scope of any <form> tag in a page. -class FormRendererId : public internal::FormRendererIdType { - using internal::FormRendererIdType::IdType; -}; - -class FieldRendererId : public internal::FieldRendererIdType { - using internal::FieldRendererIdType::IdType; -}; - -} // namespace autofill - -#endif // COMPONENTS_AUTOFILL_CORE_COMMON_RENDERER_ID_H_ diff --git a/chromium/components/autofill/core/common/save_password_progress_logger.cc b/chromium/components/autofill/core/common/save_password_progress_logger.cc index 4890a9be31a..06e0b5acd0f 100644 --- a/chromium/components/autofill/core/common/save_password_progress_logger.cc +++ b/chromium/components/autofill/core/common/save_password_progress_logger.cc @@ -5,12 +5,12 @@ #include "components/autofill/core/common/save_password_progress_logger.h" #include <algorithm> +#include <string> #include "base/json/json_writer.h" #include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "base/strings/strcat.h" -#include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" @@ -148,7 +148,7 @@ void SavePasswordProgressLogger::LogValue(StringID label, const Value& log) { // static std::string SavePasswordProgressLogger::ScrubElementID( - const base::string16& element_id) { + const std::u16string& element_id) { return ScrubElementID(base::UTF16ToUTF8(element_id)); } @@ -265,8 +265,10 @@ std::string SavePasswordProgressLogger::GetStringFromID( return "Blocked password due to same origin but insecure scheme"; case SavePasswordProgressLogger::STRING_ON_PASSWORD_FORMS_RENDERED_METHOD: return "PasswordManager::OnPasswordFormsRendered"; - case SavePasswordProgressLogger::STRING_ON_SAME_DOCUMENT_NAVIGATION: - return "PasswordManager::OnSameDocumentNavigation"; + case SavePasswordProgressLogger::STRING_ON_DYNAMIC_FORM_SUBMISSION: + return "PasswordManager::OnDynamicFormSubmission"; + case SavePasswordProgressLogger::STRING_ON_SUBFRAME_FORM_SUBMISSION: + return "PasswordManager::OnSubframeFormSubmission"; case SavePasswordProgressLogger::STRING_ON_ASK_USER_OR_SAVE_PASSWORD: return "PasswordManager::AskUserOrSavePassword"; case SavePasswordProgressLogger::STRING_CAN_PROVISIONAL_MANAGER_SAVE_METHOD: diff --git a/chromium/components/autofill/core/common/save_password_progress_logger.h b/chromium/components/autofill/core/common/save_password_progress_logger.h index aea961ea912..d28e22ebeff 100644 --- a/chromium/components/autofill/core/common/save_password_progress_logger.h +++ b/chromium/components/autofill/core/common/save_password_progress_logger.h @@ -78,7 +78,8 @@ class SavePasswordProgressLogger { STRING_SYNC_CREDENTIAL, STRING_BLOCK_PASSWORD_SAME_ORIGIN_INSECURE_SCHEME, STRING_ON_PASSWORD_FORMS_RENDERED_METHOD, - STRING_ON_SAME_DOCUMENT_NAVIGATION, + STRING_ON_DYNAMIC_FORM_SUBMISSION, + STRING_ON_SUBFRAME_FORM_SUBMISSION, STRING_ON_ASK_USER_OR_SAVE_PASSWORD, STRING_CAN_PROVISIONAL_MANAGER_SAVE_METHOD, STRING_NO_PROVISIONAL_SAVE_MANAGER, @@ -191,7 +192,7 @@ class SavePasswordProgressLogger { // will be still possible to match the scrubbed string to the original ID or // name in the HTML doc. That's good enough for the logging purposes, and // provides some security benefits. - static std::string ScrubElementID(const base::string16& element_id); + static std::string ScrubElementID(const std::u16string& element_id); // The UTF-8 version of the function above. static std::string ScrubElementID(std::string element_id); diff --git a/chromium/components/autofill/core/common/signatures.cc b/chromium/components/autofill/core/common/signatures.cc index b6078f82dc2..bbe321b7f08 100644 --- a/chromium/components/autofill/core/common/signatures.cc +++ b/chromium/components/autofill/core/common/signatures.cc @@ -6,8 +6,12 @@ #include <cctype> +#include "base/containers/span.h" #include "base/hash/sha1.h" +#include "base/strings/strcat.h" #include "base/strings/string_number_conversions.h" +#include "base/strings/string_piece.h" +#include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "components/autofill/core/common/autofill_util.h" @@ -22,25 +26,40 @@ namespace autofill { namespace { // Returns a copy of |input| without >= 5 consecutive digits. -std::string StripDigitsIfRequired(const base::string16& input) { - std::string input_utf8 = UTF16ToUTF8(input); +std::string StripDigitsIfRequired(base::StringPiece input) { + static constexpr auto IsDigit = base::IsAsciiDigit<char>; std::string result; - result.reserve(input_utf8.length()); - - for (size_t i = 0; i < input_utf8.length();) { - if (std::isdigit(input_utf8[i])) { - size_t count = 0; - while (i < input_utf8.length() && std::isdigit(input_utf8[i])) { - i++; - count++; - } - if (count < 5) - result.append(input_utf8, i - count, count); - } else { - result.push_back(input_utf8[i]); - i++; + result.reserve(input.size()); + + for (size_t i = 0; i < input.size();) { + // If `input[i]` is not a digit, append it to `result` and move to the next + // character. + if (!IsDigit(input[i])) { + result.push_back(input[i]); + ++i; + continue; } + + // If `input[i]` is a digit, find the range of consecutive digits starting + // at `i`. If this range is shorter than 5 characters append it to `result`. + auto* end_it = base::ranges::find_if_not(input.substr(i), IsDigit); + base::StringPiece digits = base::MakeStringPiece(input.begin() + i, end_it); + DCHECK(base::ranges::all_of(digits, IsDigit)); + if (digits.size() < 5) + base::StrAppend(&result, {digits}); + i += digits.size(); } + + return result; +} + +template <size_t N> +uint64_t PackBytes(base::span<const uint8_t, N> bytes) { + static_assert(N <= 8u, + "Error: Can't pack more than 8 bytes into a uint64_t."); + uint64_t result = 0; + for (auto byte : bytes) + result = (result << 8) | byte; return result; } @@ -62,44 +81,38 @@ std::string GetDOMFormName(const std::string& form_name) { FormSignature CalculateFormSignature(const FormData& form_data) { const GURL& target_url = form_data.action; const GURL& source_url = form_data.url; - std::string scheme(target_url.scheme()); - std::string host(target_url.host()); + base::StringPiece scheme = target_url.scheme_piece(); + base::StringPiece host = target_url.host_piece(); // If target host or scheme is empty, set scheme and host of source url. // This is done to match the Toolbar's behavior. if (scheme.empty() || host.empty()) { - scheme = source_url.scheme(); - host = source_url.host(); + scheme = source_url.scheme_piece(); + host = source_url.host_piece(); } std::string form_signature_field_names; - auto ShouldSkipField = [](const FormFieldData& field) { - return IsCheckable(field.check_status); - }; - for (const FormFieldData& field : form_data.fields) { - if (!ShouldSkipField(field)) { + if (!IsCheckable(field.check_status)) { // Add all supported form fields (including with empty names) to the // signature. This is a requirement for Autofill servers. - form_signature_field_names.append("&"); - form_signature_field_names.append(StripDigitsIfRequired(field.name)); + base::StrAppend(&form_signature_field_names, + {"&", StripDigitsIfRequired(UTF16ToUTF8(field.name))}); } } std::string form_name = GetDOMFormName(UTF16ToUTF8(form_data.name)); - std::string form_string = - scheme + "://" + host + "&" + form_name + form_signature_field_names; - + std::string form_string = base::StrCat( + {scheme, "://", host, "&", form_name, form_signature_field_names}); return FormSignature(StrToHash64Bit(form_string)); } FieldSignature CalculateFieldSignatureByNameAndType( - const base::string16& field_name, - const std::string& field_type) { - std::string name = UTF16ToUTF8(field_name); - std::string field_string = name + "&" + field_type; - return FieldSignature(StrToHash32Bit(field_string)); + base::StringPiece16 field_name, + base::StringPiece field_type) { + return FieldSignature( + StrToHash32Bit(base::StrCat({UTF16ToUTF8(field_name), "&", field_type}))); } FieldSignature CalculateFieldSignatureForField( @@ -108,31 +121,16 @@ FieldSignature CalculateFieldSignatureForField( field_data.form_control_type); } -uint64_t StrToHash64Bit(const std::string& str) { - std::string hash_bin = base::SHA1HashString(str); - DCHECK_EQ(base::kSHA1Length, hash_bin.length()); - - uint64_t hash64 = (((static_cast<uint64_t>(hash_bin[0])) & 0xFF) << 56) | - (((static_cast<uint64_t>(hash_bin[1])) & 0xFF) << 48) | - (((static_cast<uint64_t>(hash_bin[2])) & 0xFF) << 40) | - (((static_cast<uint64_t>(hash_bin[3])) & 0xFF) << 32) | - (((static_cast<uint64_t>(hash_bin[4])) & 0xFF) << 24) | - (((static_cast<uint64_t>(hash_bin[5])) & 0xFF) << 16) | - (((static_cast<uint64_t>(hash_bin[6])) & 0xFF) << 8) | - ((static_cast<uint64_t>(hash_bin[7])) & 0xFF); - - return hash64; +uint64_t StrToHash64Bit(base::StringPiece str) { + auto bytes = base::as_bytes(base::make_span(str)); + const base::SHA1Digest digest = base::SHA1HashSpan(bytes); + return PackBytes(base::make_span(digest).subspan<0, 8>()); } -uint32_t StrToHash32Bit(const std::string& str) { - std::string hash_bin = base::SHA1HashString(str); - DCHECK_EQ(base::kSHA1Length, hash_bin.length()); - - uint32_t hash32 = ((hash_bin[0] & 0xFF) << 24) | - ((hash_bin[1] & 0xFF) << 16) | ((hash_bin[2] & 0xFF) << 8) | - (hash_bin[3] & 0xFF); - - return hash32; +uint32_t StrToHash32Bit(base::StringPiece str) { + auto bytes = base::as_bytes(base::make_span(str)); + const base::SHA1Digest digest = base::SHA1HashSpan(bytes); + return PackBytes(base::make_span(digest).subspan<0, 4>()); } int64_t HashFormSignature(autofill::FormSignature form_signature) { diff --git a/chromium/components/autofill/core/common/signatures.h b/chromium/components/autofill/core/common/signatures.h index 3db5220ee11..0244be2573f 100644 --- a/chromium/components/autofill/core/common/signatures.h +++ b/chromium/components/autofill/core/common/signatures.h @@ -6,11 +6,11 @@ #define COMPONENTS_AUTOFILL_CORE_COMMON_SIGNATURES_H_ #include <stddef.h> - #include <stdint.h> + #include <string> -#include "base/strings/string16.h" +#include "base/strings/string_piece.h" #include "base/util/type_safety/id_type.h" namespace autofill { @@ -19,13 +19,8 @@ struct FormData; struct FormFieldData; namespace internal { - -using FormSignatureType = - ::util::IdType<class FormSignatureMarker, uint64_t, 0>; - -using FieldSignatureType = - ::util::IdType<class FieldSignatureMarker, uint32_t, 0>; - +using FormSignatureType = ::util::IdTypeU64<class FormSignatureMarker>; +using FieldSignatureType = ::util::IdTypeU32<class FieldSignatureMarker>; } // namespace internal // The below strong aliases are defined as subclasses instead of typedefs in @@ -45,18 +40,18 @@ FormSignature CalculateFormSignature(const FormData& form_data); // Calculates field signature based on |field_name| and |field_type|. FieldSignature CalculateFieldSignatureByNameAndType( - const base::string16& field_name, - const std::string& field_type); + base::StringPiece16 field_name, + base::StringPiece field_type); // Calculates field signature based on |field_data|. This function is a proxy to // |CalculateFieldSignatureByNameAndType|. FieldSignature CalculateFieldSignatureForField(const FormFieldData& field_data); // Returns 64-bit hash of the string. -uint64_t StrToHash64Bit(const std::string& str); +uint64_t StrToHash64Bit(base::StringPiece str); // Returns 32-bit hash of the string. -uint32_t StrToHash32Bit(const std::string& str); +uint32_t StrToHash32Bit(base::StringPiece str); // Reduce FieldSignature space (in UKM) to a small range for privacy reasons. int64_t HashFormSignature(autofill::FormSignature form_signature); diff --git a/chromium/components/autofill/core/common/unique_ids.cc b/chromium/components/autofill/core/common/unique_ids.cc new file mode 100644 index 00000000000..d4e96f4805f --- /dev/null +++ b/chromium/components/autofill/core/common/unique_ids.cc @@ -0,0 +1,43 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/autofill/core/common/unique_ids.h" + +#include "components/autofill/core/common/logging/log_buffer.h" + +namespace autofill { + +std::ostream& operator<<(std::ostream& os, const FormRendererId& form) { + return os << form.value(); +} + +std::ostream& operator<<(std::ostream& os, const FieldRendererId& field) { + return os << field.value(); +} + +std::ostream& operator<<(std::ostream& os, const FormGlobalId& form) { + return os << form.frame_token.ToString() << '_' << form.renderer_id; +} + +std::ostream& operator<<(std::ostream& os, const FieldGlobalId& field) { + return os << field.frame_token.ToString() << '_' << field.renderer_id; +} + +LogBuffer& operator<<(LogBuffer& buffer, const FormRendererId& form) { + return buffer << form.value(); +} + +LogBuffer& operator<<(LogBuffer& buffer, const FieldRendererId& field) { + return buffer << field.value(); +} + +LogBuffer& operator<<(LogBuffer& buffer, const FormGlobalId& form) { + return buffer << form.frame_token.ToString() << '_' << form.renderer_id; +} + +LogBuffer& operator<<(LogBuffer& buffer, const FieldGlobalId& field) { + return buffer << field.frame_token.ToString() << '_' << field.renderer_id; +} + +} // namespace autofill diff --git a/chromium/components/autofill/core/common/unique_ids.h b/chromium/components/autofill/core/common/unique_ids.h new file mode 100644 index 00000000000..ab25f876426 --- /dev/null +++ b/chromium/components/autofill/core/common/unique_ids.h @@ -0,0 +1,98 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_AUTOFILL_CORE_COMMON_UNIQUE_IDS_H_ +#define COMPONENTS_AUTOFILL_CORE_COMMON_UNIQUE_IDS_H_ + +#include <stdint.h> +#include <limits> +#include <ostream> + +#include "base/unguessable_token.h" +#include "base/util/type_safety/id_type.h" + +namespace autofill { + +// LocalFrameToken is a unique identifier of a frame. The type is essentially +// identical to blink::LocalFrameToken, except that the default constructor +// initializes to zero instead of creating a new randomly generated token. +// The purpose of this duplicate is to avoid dependencies on blink here and in +// the mojo code, since iOS depends on the code. +class LocalFrameToken : public base::StrongAlias<class LocalFrameTokenMarker, + base::UnguessableToken> { + public: + using base::StrongAlias<class LocalFrameTokenMarker, + base::UnguessableToken>::StrongAlias; + bool is_empty() const { return value().is_empty(); } + std::string ToString() const { return value().ToString(); } +}; + +namespace internal { + +using FormRendererIdType = ::util::IdTypeU32<class FormRendererIdMarker>; + +using FieldRendererIdType = ::util::IdTypeU32<class FieldRendererIdMarker>; + +template <typename RendererId> +struct GlobalId { + LocalFrameToken frame_token; + RendererId renderer_id; + + // Not all platforms work with multiple frames and set the + // FormData::host_frame and FormFieldData::host_frame yet. + // Therefore, only check |renderer_id|. + explicit constexpr operator bool() const { + return static_cast<bool>(renderer_id); + } +}; + +template <typename RendererId> +bool operator==(const GlobalId<RendererId>& a, const GlobalId<RendererId>& b) { + return a.renderer_id == b.renderer_id && a.frame_token == b.frame_token; +} + +template <typename RendererId> +bool operator!=(const GlobalId<RendererId>& a, const GlobalId<RendererId>& b) { + return !(a == b); +} + +template <typename RendererId> +bool operator<(const GlobalId<RendererId>& a, const GlobalId<RendererId>& b) { + return std::tie(a.frame_token, a.renderer_id) < + std::tie(b.frame_token, b.renderer_id); +} + +} // namespace internal + +// The below strong aliases are defined as subclasses instead of typedefs in +// order to avoid having to define out-of-line constructors in all structs that +// contain renderer IDs. + +// The FormRendererId of a synthetic form is_null(). A synthetic form is the +// collection of form fields outside of the scope of any <form> tag in a page. +class FormRendererId : public internal::FormRendererIdType { + using internal::FormRendererIdType::IdType; +}; + +class FieldRendererId : public internal::FieldRendererIdType { + using internal::FieldRendererIdType::IdType; +}; + +using FormGlobalId = internal::GlobalId<FormRendererId>; +using FieldGlobalId = internal::GlobalId<FieldRendererId>; + +class LogBuffer; + +std::ostream& operator<<(std::ostream& os, const FormRendererId& form); +std::ostream& operator<<(std::ostream& os, const FieldRendererId& field); +std::ostream& operator<<(std::ostream& os, const FormGlobalId& form); +std::ostream& operator<<(std::ostream& os, const FieldGlobalId& field); +LogBuffer& operator<<(LogBuffer& buffer, const FormRendererId& form); +LogBuffer& operator<<(LogBuffer& buffer, const FieldRendererId& field); +LogBuffer& operator<<(LogBuffer& buffer, const FormGlobalId& form); +LogBuffer& operator<<(LogBuffer& buffer, const FieldGlobalId& field); + +} // namespace autofill + +#endif // COMPONENTS_AUTOFILL_CORE_COMMON_UNIQUE_IDS_H_ |