diff options
| author | sebsg <sebsg@chromium.org> | 2016-03-01 12:45:03 -0800 |
|---|---|---|
| committer | Commit bot <commit-bot@chromium.org> | 2016-03-01 20:47:05 +0000 |
| commit | 0a8abd1cd85e42b969740ca38e01df01ff244743 (patch) | |
| tree | 398fa1c65f348080b5286962c428a3dc4c4a4fee | |
| parent | c9812c390c829563bfdb5ec7b0effd06f21a1246 (diff) | |
| download | chromium_src-0a8abd1cd85e42b969740ca38e01df01ff244743.zip chromium_src-0a8abd1cd85e42b969740ca38e01df01ff244743.tar.gz chromium_src-0a8abd1cd85e42b969740ca38e01df01ff244743.tar.bz2 | |
Added two new field types : CREDIT_CARD_NAME_FIRST and CREDIT_CARD_NAME_LAST. Modified the heuristics to recognize these two new fields. Added code to be able to fill these new fields with the data already available.
This will fix Keurig.com and sites like this example:
https://f117f41fdbc2c18ce6861c4fac2e807ecf7f1d75.googledrive.com/host/0B3xzZ-vFr2LRU0FlVEhGa09uSDA
Since it's still pretty conservative. It won't fix sites like Cabelas.com where the fields are named "firstname" and "lastname"
The original heuristics predictions on Keurig.com were:
NAME_FIRST | card_firstNameOnCard | First Name*
NAME_LAST | card_lastNameOnCard | Last Name*
UNKNOWN_TYPE | card_accountNumber | Card Number*
UNKNOWN_TYPE | card_cardType | Card Type
UNKNOWN_TYPE | | Please select a card type
UNKNOWN_TYPE | card_expirationMonth | Expiration Date*
UNKNOWN_TYPE | | Month
CREDIT_CARD_EXP_MONTH | card_expirationYear | Expiration Date*
CREDIT_CARD_EXP_4_DIGIT_YEAR | | Year |
CREDIT_CARD_VERIFICATION_CODE | card_cvNumber | Security Code*
TBR=thestig@chromium.org
BUG=579174
TEST=AutofillManagerTest, FormStructureTest
Review URL: https://codereview.chromium.org/1694443004
Cr-Commit-Position: refs/heads/master@{#378551}
78 files changed, 764 insertions, 370 deletions
diff --git a/chrome/browser/autofill/android/personal_data_manager_android.cc b/chrome/browser/autofill/android/personal_data_manager_android.cc index 86f424d..e185c30 100644 --- a/chrome/browser/autofill/android/personal_data_manager_android.cc +++ b/chrome/browser/autofill/android/personal_data_manager_android.cc @@ -131,13 +131,15 @@ ScopedJavaLocalRef<jobject> CreateJavaCreditCardFromNative( ConvertUTF8ToJavaString(env, card.origin()).obj(), card.record_type() == CreditCard::LOCAL_CARD, card.record_type() == CreditCard::FULL_SERVER_CARD, - ConvertUTF16ToJavaString(env, card.GetRawInfo(CREDIT_CARD_NAME)).obj(), + ConvertUTF16ToJavaString(env, card.GetRawInfo(CREDIT_CARD_NAME_FULL)) + .obj(), ConvertUTF16ToJavaString(env, card.GetRawInfo(CREDIT_CARD_NUMBER)).obj(), ConvertUTF16ToJavaString(env, card.TypeAndLastFourDigits()).obj(), ConvertUTF16ToJavaString(env, card.GetRawInfo(CREDIT_CARD_EXP_MONTH)) .obj(), - ConvertUTF16ToJavaString( - env, card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)).obj()); + ConvertUTF16ToJavaString(env, + card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)) + .obj()); } void PopulateNativeCreditCardFromJava( @@ -147,7 +149,7 @@ void PopulateNativeCreditCardFromJava( card->set_origin( ConvertJavaStringToUTF8(Java_CreditCard_getOrigin(env, jcard))); card->SetRawInfo( - CREDIT_CARD_NAME, + CREDIT_CARD_NAME_FULL, ConvertJavaStringToUTF16(Java_CreditCard_getName(env, jcard))); card->SetRawInfo( CREDIT_CARD_NUMBER, diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc index 2e0c077..526b72c 100644 --- a/chrome/browser/autofill/autofill_browsertest.cc +++ b/chrome/browser/autofill/autofill_browsertest.cc @@ -364,7 +364,7 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, FillProfileCrazyCharacters) { std::vector<CreditCard> cards; CreditCard card1; - card1.SetRawInfo(CREDIT_CARD_NAME, + card1.SetRawInfo(CREDIT_CARD_NAME_FULL, WideToUTF16(L"\u751f\u6d3b\u5f88\u6709\u89c4\u5f8b " L"\u4ee5\u73a9\u4e3a\u4e3b")); card1.SetRawInfo(CREDIT_CARD_NUMBER, WideToUTF16(L"6011111111111117")); @@ -373,14 +373,14 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, FillProfileCrazyCharacters) { cards.push_back(card1); CreditCard card2; - card2.SetRawInfo(CREDIT_CARD_NAME, WideToUTF16(L"John Williams")); + card2.SetRawInfo(CREDIT_CARD_NAME_FULL, WideToUTF16(L"John Williams")); card2.SetRawInfo(CREDIT_CARD_NUMBER, WideToUTF16(L"WokoAwesome12345")); card2.SetRawInfo(CREDIT_CARD_EXP_MONTH, WideToUTF16(L"10")); card2.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, WideToUTF16(L"2015")); cards.push_back(card2); CreditCard card3; - card3.SetRawInfo(CREDIT_CARD_NAME, + card3.SetRawInfo(CREDIT_CARD_NAME_FULL, WideToUTF16(L"\u0623\u062d\u0645\u062f\u064a " L"\u0646\u062c\u0627\u062f " L"\u0644\u0645\u062d\u0627\u0648\u0644\u0647 " @@ -396,7 +396,7 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, FillProfileCrazyCharacters) { cards.push_back(card3); CreditCard card4; - card4.SetRawInfo(CREDIT_CARD_NAME, + card4.SetRawInfo(CREDIT_CARD_NAME_FULL, WideToUTF16(L"\u039d\u03ad\u03b5\u03c2 " L"\u03c3\u03c5\u03b3\u03c7\u03c9\u03bd\u03b5" L"\u03cd\u03c3\u03b5\u03b9\u03c2 " diff --git a/chrome/browser/extensions/api/autofill_private/autofill_private_api.cc b/chrome/browser/extensions/api/autofill_private/autofill_private_api.cc index 3bb54eb..10ace1a 100644 --- a/chrome/browser/extensions/api/autofill_private/autofill_private_api.cc +++ b/chrome/browser/extensions/api/autofill_private/autofill_private_api.cc @@ -326,9 +326,8 @@ ExtensionFunction::ResponseAction AutofillPrivateSaveCreditCardFunction::Run() { autofill::CreditCard credit_card(guid, kSettingsOrigin); if (card->name) { - credit_card.SetRawInfo( - autofill::CREDIT_CARD_NAME, - base::UTF8ToUTF16(*card->name)); + credit_card.SetRawInfo(autofill::CREDIT_CARD_NAME_FULL, + base::UTF8ToUTF16(*card->name)); } if (card->card_number) { diff --git a/chrome/browser/extensions/api/autofill_private/autofill_util.cc b/chrome/browser/extensions/api/autofill_private/autofill_util.cc index e4ebbf5..04d5eb1 100644 --- a/chrome/browser/extensions/api/autofill_private/autofill_util.cc +++ b/chrome/browser/extensions/api/autofill_private/autofill_util.cc @@ -119,7 +119,7 @@ scoped_ptr<autofill_private::CreditCardEntry> CreditCardToCreditCardEntry( // Add all credit card fields to the entry. card->guid.reset(new std::string(credit_card.guid())); card->name.reset(new std::string(base::UTF16ToUTF8( - credit_card.GetRawInfo(autofill::CREDIT_CARD_NAME)))); + credit_card.GetRawInfo(autofill::CREDIT_CARD_NAME_FULL)))); card->card_number.reset(new std::string(base::UTF16ToUTF8( credit_card.GetRawInfo(autofill::CREDIT_CARD_NUMBER)))); card->expiration_month.reset(new std::string(base::UTF16ToUTF8( diff --git a/chrome/browser/sync/test/integration/single_client_wallet_sync_test.cc b/chrome/browser/sync/test/integration/single_client_wallet_sync_test.cc index 98836ee..d2ad62fd 100644 --- a/chrome/browser/sync/test/integration/single_client_wallet_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_wallet_sync_test.cc @@ -222,7 +222,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, Download) { ASSERT_EQ(kDefaultCardExpMonth, card->expiration_month()); ASSERT_EQ(kDefaultCardExpYear, card->expiration_year()); ASSERT_EQ(base::UTF8ToUTF16(kDefaultCardName), - card->GetRawInfo(autofill::ServerFieldType::CREDIT_CARD_NAME)); + card->GetRawInfo(autofill::ServerFieldType::CREDIT_CARD_NAME_FULL)); } // Wallet data should get cleared from the database when sync is disabled. diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc index 6d1f30d..6cc9689 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc @@ -899,9 +899,8 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ASSERT_TRUE(controller); const CreditCard& credit_card = test::GetVerifiedCreditCard(); - ASSERT_TRUE( - credit_card.GetRawInfo(CREDIT_CARD_NAME).find(ASCIIToUTF16("zebra")) == - base::string16::npos); + ASSERT_TRUE(credit_card.GetRawInfo(CREDIT_CARD_NAME_FULL) + .find(ASCIIToUTF16("zebra")) == base::string16::npos); AddCreditcardToProfile(controller->profile(), credit_card); AddAutofillProfileToProfile(controller->profile(), test::GetVerifiedProfile()); diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc index ccfe477..5937dc3 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc @@ -1685,7 +1685,7 @@ void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( FillFormGroupFromOutputs(output, &card); // The card holder name comes from the billing address section. - card.SetRawInfo(CREDIT_CARD_NAME, + card.SetRawInfo(CREDIT_CARD_NAME_FULL, GetValueFromSection(SECTION_BILLING, NAME_BILLING_FULL)); if (ShouldSaveDetailsLocally()) { diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc index d10b628..ecee41e 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc @@ -483,7 +483,7 @@ class AutofillDialogControllerTest : public ChromeRenderViewHostTestHarness { EXPECT_FALSE(shipping_country.empty()); EXPECT_EQ(billing_country, shipping_country); - EXPECT_EQ(CREDIT_CARD_NAME, + EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure()->field(1)->Type().GetStorableType()); base::string16 cc_name = form_structure()->field(1)->value; EXPECT_EQ(NAME_FULL, form_structure()->field(6)->Type().GetStorableType()); @@ -984,7 +984,7 @@ TEST_F(AutofillDialogControllerTest, AutofillCreditCards) { // Empty cards are ignored. CreditCard empty_card(base::GenerateGUID(), kSettingsOrigin); - empty_card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("John Doe")); + empty_card.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("John Doe")); controller()->GetTestingManager()->AddTestingCreditCard(&empty_card); EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC)); @@ -1030,7 +1030,7 @@ TEST_F(AutofillDialogControllerTest, DontUseBillingAsShipping) { EXPECT_FALSE(shipping_state.empty()); EXPECT_NE(billing_state, shipping_state); - EXPECT_EQ(CREDIT_CARD_NAME, + EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure()->field(1)->Type().GetStorableType()); base::string16 cc_name = form_structure()->field(1)->value; EXPECT_EQ(NAME_FULL, form_structure()->field(6)->Type().GetStorableType()); @@ -1480,7 +1480,7 @@ TEST_F(AutofillDialogControllerTest, SaveCreditCardIncludesName_NoBilling) { TestPersonalDataManager* test_pdm = controller()->GetTestingManager(); const CreditCard& imported_card = test_pdm->imported_credit_card(); EXPECT_EQ(test_profile.GetInfo(AutofillType(NAME_FULL), "en-US"), - imported_card.GetRawInfo(CREDIT_CARD_NAME)); + imported_card.GetRawInfo(CREDIT_CARD_NAME_FULL)); } TEST_F(AutofillDialogControllerTest, SaveCreditCardIncludesName_WithBilling) { @@ -1499,7 +1499,7 @@ TEST_F(AutofillDialogControllerTest, SaveCreditCardIncludesName_WithBilling) { const CreditCard& imported_card = test_pdm->imported_credit_card(); EXPECT_EQ(test_profile.GetInfo(AutofillType(NAME_FULL), "en-US"), - imported_card.GetRawInfo(CREDIT_CARD_NAME)); + imported_card.GetRawInfo(CREDIT_CARD_NAME_FULL)); controller()->ViewClosed(); } diff --git a/chrome/browser/ui/autofill/data_model_wrapper.cc b/chrome/browser/ui/autofill/data_model_wrapper.cc index 6a71ee3..b00e5da 100644 --- a/chrome/browser/ui/autofill/data_model_wrapper.cc +++ b/chrome/browser/ui/autofill/data_model_wrapper.cc @@ -110,7 +110,7 @@ base::string16 AutofillProfileWrapper::GetInfo(const AutofillType& type) const { // but the AutofillProfile class doesn't know how to fill credit card // fields. So, request for the corresponding profile type instead. AutofillType effective_type = type; - if (type.GetStorableType() == CREDIT_CARD_NAME) + if (type.GetStorableType() == CREDIT_CARD_NAME_FULL) effective_type = AutofillType(NAME_BILLING_FULL); const std::string& app_locale = g_browser_process->GetApplicationLocale(); diff --git a/chrome/browser/ui/webui/options/autofill_options_handler.cc b/chrome/browser/ui/webui/options/autofill_options_handler.cc index 388ad27..df458ba 100644 --- a/chrome/browser/ui/webui/options/autofill_options_handler.cc +++ b/chrome/browser/ui/webui/options/autofill_options_handler.cc @@ -453,8 +453,7 @@ void AutofillOptionsHandler::LoadCreditCardEditor(const base::ListValue* args) { base::DictionaryValue credit_card_data; credit_card_data.SetString("guid", credit_card->guid()); credit_card_data.SetString( - "nameOnCard", - credit_card->GetRawInfo(autofill::CREDIT_CARD_NAME)); + "nameOnCard", credit_card->GetRawInfo(autofill::CREDIT_CARD_NAME_FULL)); credit_card_data.SetString( "creditCardNumber", credit_card->GetRawInfo(autofill::CREDIT_CARD_NUMBER)); @@ -543,7 +542,7 @@ void AutofillOptionsHandler::SetCreditCard(const base::ListValue* args) { base::string16 value; if (args->GetString(1, &value)) - credit_card.SetRawInfo(autofill::CREDIT_CARD_NAME, value); + credit_card.SetRawInfo(autofill::CREDIT_CARD_NAME_FULL, value); if (args->GetString(2, &value)) credit_card.SetRawInfo(autofill::CREDIT_CARD_NUMBER, value); diff --git a/chrome/test/data/autofill/autofill_creditcard_form.html b/chrome/test/data/autofill/autofill_creditcard_form.html index 0ba3649..06ca7d4 100644 --- a/chrome/test/data/autofill/autofill_creditcard_form.html +++ b/chrome/test/data/autofill/autofill_creditcard_form.html @@ -14,7 +14,7 @@ <label for="nameoncard">Name on Card</label> </td> <td> - <input size="40" id="CREDIT_CARD_NAME"/> + <input size="40" id="CREDIT_CARD_NAME_FULL"/> </td> </tr> <tr> diff --git a/chrome/test/data/autofill/heuristics/input/27_checkout_cc_keurig.com.html b/chrome/test/data/autofill/heuristics/input/27_checkout_cc_keurig.com.html new file mode 100644 index 0000000..a57a7b8 --- /dev/null +++ b/chrome/test/data/autofill/heuristics/input/27_checkout_cc_keurig.com.html @@ -0,0 +1,131 @@ + + <form id="silentOrderPostForm" name="silentOrderPostForm" class="payment-container checkoutProcess clearfix" action="/checkout/multi/sop-response" method="POST" onsubmit="usb2cCmCreateConversionEventTagPaypal()" autocomplete="off"> + + <div class="fields" id="cardForm" style="display:block"> + <p class="italic smallCopy reqFields"> + Required Fields<sup>*</sup> + </p> + <div class="field"> + <div class="control-group"> + <label class="control-label " for="card_firstNameOnCard"> + First Name<sup>*</sup> + <span class="errorMsg"></span> + </label> + <div class="controls field"> + <input id="card_firstNameOnCard" name="card_firstNameOnCard" type="text" value=""> + </div> + </div> + </div> + <div class="field"> + <div class="control-group"> + <label class="control-label " for="card_lastNameOnCard"> + Last Name<sup>*</sup> + <span class="errorMsg"></span> + </label> + <div class="controls field"> + <input id="card_lastNameOnCard" name="card_lastNameOnCard" type="text" value=""> + </div> + </div> + </div> + <input id="card_nameOnCard" name="card_nameOnCard" type="hidden" value=""><div class="field"> + <div class="control-group"> + <label class="control-label " for="card_accountNumber"> + Card Number<sup>*</sup> + <span class="errorMsg"></span> + </label> + <div class="controls field"> + <input id="card_accountNumber" name="card_accountNumber" type="text" value=""> + </div> + </div> + </div> + <div class="field with-cc-icons"> + <div class="hidden" id="card_cardType_injected_error"> + Please select a Card Type + </div> + <div class="control-group"> + <label class="control-label " for="card_cardType"> + Card Type<span class="errorMsg"></span> + </label> + <div class="controls field"> + <select id="card_cardType" name="card_cardType" class="selectTagClass dd " style="display: none;"> + <option value="" disabled="disabled" selected="selected">Please select a card type</option> + <option value="003">American Express</option> + <option value="004">Discover</option> + <option value="001">Visa</option> + <option value="002">Mastercard</option> + </select><div class="chosen-container chosen-container-single chosen-container-single-nosearch" style="width: 247px;" title="" id="card_cardType_chosen"><a class="chosen-single" tabindex="-1"><span>Please select a card type</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" readonly=""></div><ul class="chosen-results"></ul></div></div> + </div> + + + + </div> + <div id="cardTypeImage" class="icons-co-credit-cards-container"> + <a class="cc icons-co-visa" data-select-cc="">Visa</a> + <a class="cc icons-co-mc" data-select-cc="">Mastercard</a> + <a class="cc icons-co-amex" data-select-cc="">American Express</a> + <a class="cc icons-co-disc" data-select-cc="">Discover</a> + </div> + </div> + <div class="field expDate clearfix"> + <label>Expiration Date<sup>*</sup></label><br> + <div id="" class="expMp clearfix"> + <div class="control-group"> + <select id="ExpiryMonth" name="card_expirationMonth" class="dd" style="display: none;"> + <option value="" disabled="disabled" selected="selected">Month</option> + <option value="1">01</option> + <option value="2">02</option> + <option value="3">03</option> + <option value="4">04</option> + <option value="5">05</option> + <option value="6">06</option> + <option value="7">07</option> + <option value="8">08</option> + <option value="9">09</option> + <option value="10">10</option> + <option value="11">11</option> + <option value="12">12</option> + </select><div class="chosen-container chosen-container-single" style="width: 150px;" title="" id="ExpiryMonth_chosen"><a class="chosen-single" tabindex="-1"><span>Month</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off"></div><ul class="chosen-results"></ul></div></div> + </div> + </div> + <div id="" class="expYear clearfix"> + <div class="control-group"> + <select id="ExpiryYear" name="card_expirationYear" class="dd" style="display: none;"> + <option value="" disabled="disabled" selected="selected">Year</option> + <option value="2016">2016</option> + <option value="2017">2017</option> + <option value="2018">2018</option> + <option value="2019">2019</option> + <option value="2020">2020</option> + <option value="2021">2021</option> + <option value="2022">2022</option> + <option value="2023">2023</option> + <option value="2024">2024</option> + <option value="2025">2025</option> + <option value="2026">2026</option> + </select><div class="chosen-container chosen-container-single" style="width: 150px;" title="" id="ExpiryYear_chosen"><a class="chosen-single" tabindex="-1"><span>Year</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off"></div><ul class="chosen-results"></ul></div></div> + </div> + </div> + + </div> + <div class="field secCode clearfix"> + <div class="control-group"> + <label class="control-label " for="card_cvNumber"> + Security Code<sup>*</sup> + <span class="errorMsg"></span> + </label> + <div class="controls field"> + <input id="card_cvNumber" name="card_cvNumber" type="text" value=""> + </div> + </div> + <div class="circle-link-image info"> + <span class="hover icons-info"> + <span class="icons-info-over"></span> + </span> + <div class="msg"> + The card security code is located on the back of MasterCard, Visa and Discover credit or debit cards and is typically a separate group of 3 digits to the right of the signature strip. On American Express cards, the card security code is a printed, not embossed, group of four digits on the front towards the right. + </div> + </div> + </div> + + <span id="submit_silentOrderPostForm_Checkout" class="btn-box btn-orange continue">CONTINUE TO REVIEW ORDER</span> + </form>
\ No newline at end of file diff --git a/chrome/test/data/autofill/heuristics/output/000_i18n_de.out b/chrome/test/data/autofill/heuristics/output/000_i18n_de.out index 1bd7de8..99a883f 100644 --- a/chrome/test/data/autofill/heuristics/output/000_i18n_de.out +++ b/chrome/test/data/autofill/heuristics/output/000_i18n_de.out @@ -8,7 +8,7 @@ ADDRESS_HOME_ZIP | zc | Postleitzahl: | | fn_1-default ADDRESS_HOME_STATE | st | Land: | | fn_1-default EMAIL_ADDRESS | em | E-Mail-Adresse: | | fn_1-default PHONE_HOME_WHOLE_NUMBER | ph | Telefonnummer: | | fn_1-default -CREDIT_CARD_NAME | c1 | Karteninhaber: | | fn_1-cc +CREDIT_CARD_NAME_FULL | c1 | Karteninhaber: | | fn_1-cc CREDIT_CARD_NUMBER | c2 | Kartennummer: | | fn_1-cc CREDIT_CARD_EXP_MONTH | c3 | gültig bis monat: | | fn_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | c4 | gültig bis jahr: | | fn_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/001_i18n_de2.out b/chrome/test/data/autofill/heuristics/output/001_i18n_de2.out index 19f3726..14a00c5 100644 --- a/chrome/test/data/autofill/heuristics/output/001_i18n_de2.out +++ b/chrome/test/data/autofill/heuristics/output/001_i18n_de2.out @@ -8,7 +8,7 @@ ADDRESS_HOME_ZIP | zc | Postleitzahl: | | ln_1-default ADDRESS_HOME_STATE | st | Land: | | ln_1-default EMAIL_ADDRESS | em | E-Mail-Adresse: | | ln_1-default PHONE_HOME_WHOLE_NUMBER | ph | Telefonnummer: | | ln_1-default -CREDIT_CARD_NAME | c1 | Karteninhaber: | | ln_1-cc +CREDIT_CARD_NAME_FULL | c1 | Karteninhaber: | | ln_1-cc CREDIT_CARD_NUMBER | c2 | Kartennummer: | | ln_1-cc CREDIT_CARD_EXP_MONTH | c3 | gültig bis monat: | | ln_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | c4 | gültig bis jahr: | | ln_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/002_i18n_en.out b/chrome/test/data/autofill/heuristics/output/002_i18n_en.out index a6f6339..f41aef6 100644 --- a/chrome/test/data/autofill/heuristics/output/002_i18n_en.out +++ b/chrome/test/data/autofill/heuristics/output/002_i18n_en.out @@ -8,7 +8,7 @@ ADDRESS_HOME_ZIP | zc | Zip Code: | | fn_1-default ADDRESS_HOME_STATE | st | State: | | fn_1-default EMAIL_ADDRESS | em | Email: | | fn_1-default PHONE_HOME_WHOLE_NUMBER | ph | Phone Number: | | fn_1-default -CREDIT_CARD_NAME | c1 | Name on card: | | fn_1-cc +CREDIT_CARD_NAME_FULL | c1 | Name on card: | | fn_1-cc CREDIT_CARD_NUMBER | c2 | Card Number: | | fn_1-cc CREDIT_CARD_EXP_MONTH | c3 | Expiration Month: | | fn_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | c4 | Expiration Year: | | fn_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/003_i18n_es.out b/chrome/test/data/autofill/heuristics/output/003_i18n_es.out index d18bd17..a32ef67 100644 --- a/chrome/test/data/autofill/heuristics/output/003_i18n_es.out +++ b/chrome/test/data/autofill/heuristics/output/003_i18n_es.out @@ -8,7 +8,7 @@ ADDRESS_HOME_ZIP | zc | Código Postal: | | fn_1-default ADDRESS_HOME_STATE | st | Provincia: | | fn_1-default EMAIL_ADDRESS | em | E-mail: | | fn_1-default PHONE_HOME_WHOLE_NUMBER | ph | Teléfono: | | fn_1-default -CREDIT_CARD_NAME | c1 | Nombre de Tarjeta: | | fn_1-cc +CREDIT_CARD_NAME_FULL | c1 | Nombre de Tarjeta: | | fn_1-cc CREDIT_CARD_NUMBER | c2 | Número de Tarjeta: | | fn_1-cc CREDIT_CARD_EXP_MONTH | c3 | Fecha de Expiración: | | fn_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | c4 | Fecha de Expiración: | | fn_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/004_i18n_fr.out b/chrome/test/data/autofill/heuristics/output/004_i18n_fr.out index 8ca3a52..2f2baa8 100644 --- a/chrome/test/data/autofill/heuristics/output/004_i18n_fr.out +++ b/chrome/test/data/autofill/heuristics/output/004_i18n_fr.out @@ -8,7 +8,7 @@ ADDRESS_HOME_ZIP | zc | Code postal: | | fn_1-default ADDRESS_HOME_STATE | st | State: | | fn_1-default EMAIL_ADDRESS | em | Email: | | fn_1-default PHONE_HOME_WHOLE_NUMBER | ph | Téléphone Fixe: | | fn_1-default -CREDIT_CARD_NAME | c1 | Nom complet du détenteur de la carte: | | fn_1-cc +CREDIT_CARD_NAME_FULL | c1 | Nom complet du détenteur de la carte: | | fn_1-cc CREDIT_CARD_NUMBER | c2 | Numéro: | | fn_1-cc CREDIT_CARD_EXP_MONTH | c3 | Date d'expiration: | | fn_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | c4 | Date d'expiration: | | fn_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/005_i18n_it.out b/chrome/test/data/autofill/heuristics/output/005_i18n_it.out index 5485bea..b52853b 100644 --- a/chrome/test/data/autofill/heuristics/output/005_i18n_it.out +++ b/chrome/test/data/autofill/heuristics/output/005_i18n_it.out @@ -8,7 +8,7 @@ ADDRESS_HOME_ZIP | zc | CAP: | | fn_1-default ADDRESS_HOME_STATE | st | Provincia: | | fn_1-default EMAIL_ADDRESS | em | E-mail: | | fn_1-default PHONE_HOME_WHOLE_NUMBER | ph | Telefono: | | fn_1-default -CREDIT_CARD_NAME | c1 | Nome titolare carta: | | fn_1-cc +CREDIT_CARD_NAME_FULL | c1 | Nome titolare carta: | | fn_1-cc CREDIT_CARD_NUMBER | c2 | Numero carta di credito: | | fn_1-cc CREDIT_CARD_EXP_MONTH | c3 | Data di scadenza: | | fn_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | c4 | Data di scadenza: | | fn_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/006_i18n_ja.out b/chrome/test/data/autofill/heuristics/output/006_i18n_ja.out index 848edcd..9886922 100644 --- a/chrome/test/data/autofill/heuristics/output/006_i18n_ja.out +++ b/chrome/test/data/autofill/heuristics/output/006_i18n_ja.out @@ -8,7 +8,7 @@ ADDRESS_HOME_ZIP | zc | 郵便番号: | | fn_1-default ADDRESS_HOME_STATE | st | 都道府県: | | fn_1-default EMAIL_ADDRESS | em | メールアドレス: | | fn_1-default PHONE_HOME_WHOLE_NUMBER | ph | 電話番号: | | fn_1-default -CREDIT_CARD_NAME | c1 | 名前(フルネーム): | | fn_1-cc +CREDIT_CARD_NAME_FULL | c1 | 名前(フルネーム): | | fn_1-cc CREDIT_CARD_NUMBER | c2 | カード番号: | | fn_1-cc CREDIT_CARD_EXP_MONTH | c3 | 有効期限: | | fn_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | c4 | 有効期限: | | fn_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/008_i18n_pt.out b/chrome/test/data/autofill/heuristics/output/008_i18n_pt.out index 3c613a7..8da5066 100644 --- a/chrome/test/data/autofill/heuristics/output/008_i18n_pt.out +++ b/chrome/test/data/autofill/heuristics/output/008_i18n_pt.out @@ -8,7 +8,7 @@ ADDRESS_HOME_ZIP | zc | CEP: | | fn_1-default ADDRESS_HOME_STATE | st | Estado: | | fn_1-default EMAIL_ADDRESS | em | email: | | fn_1-default PHONE_HOME_WHOLE_NUMBER | ph | Telefone: | | fn_1-default -CREDIT_CARD_NAME | c1 | Nome do cartão: | | fn_1-cc +CREDIT_CARD_NAME_FULL | c1 | Nome do cartão: | | fn_1-cc CREDIT_CARD_NUMBER | c2 | Número do cartão: | | fn_1-cc CREDIT_CARD_EXP_MONTH | c3 | Data de validade: | | fn_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | c4 | Data de validade: | | fn_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/009_i18n_ru.out b/chrome/test/data/autofill/heuristics/output/009_i18n_ru.out index c4d138a..3a32a32 100644 --- a/chrome/test/data/autofill/heuristics/output/009_i18n_ru.out +++ b/chrome/test/data/autofill/heuristics/output/009_i18n_ru.out @@ -8,7 +8,7 @@ ADDRESS_HOME_ZIP | zc | Почтовый Индекс: | | fn_1-default ADDRESS_HOME_STATE | st | область: | | fn_1-default EMAIL_ADDRESS | em | Электронной Почты: | | fn_1-default PHONE_HOME_WHOLE_NUMBER | ph | телефон: | | fn_1-default -CREDIT_CARD_NAME | c1 | Имя владельца карты: | | fn_1-cc +CREDIT_CARD_NAME_FULL | c1 | Имя владельца карты: | | fn_1-cc CREDIT_CARD_NUMBER | c2 | Номер кредитной карты: | | fn_1-cc CREDIT_CARD_EXP_MONTH | c3 | Срок действия карты : | | fn_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | c4 | Срок действия карты : | | fn_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/010_i18n_zh_cn.out b/chrome/test/data/autofill/heuristics/output/010_i18n_zh_cn.out index 80a2103..6e3575b 100644 --- a/chrome/test/data/autofill/heuristics/output/010_i18n_zh_cn.out +++ b/chrome/test/data/autofill/heuristics/output/010_i18n_zh_cn.out @@ -7,7 +7,7 @@ ADDRESS_HOME_ZIP | zc | 邮编: | | fl_1-default ADDRESS_HOME_STATE | st | 省: | | fl_1-default EMAIL_ADDRESS | em | 邮箱: | | fl_1-default PHONE_HOME_WHOLE_NUMBER | ph | 电话: | | fl_1-default -CREDIT_CARD_NAME | c1 | 持卡人姓名: | | fl_1-cc +CREDIT_CARD_NAME_FULL | c1 | 持卡人姓名: | | fl_1-cc CREDIT_CARD_NUMBER | c2 | 信用卡号码: | | fl_1-cc CREDIT_CARD_EXP_MONTH | c3 | 月: | | fl_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | c4 | 年: | | fl_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/011_i18n_zh_tw.out b/chrome/test/data/autofill/heuristics/output/011_i18n_zh_tw.out index 5b85a4d..f505ba8 100644 --- a/chrome/test/data/autofill/heuristics/output/011_i18n_zh_tw.out +++ b/chrome/test/data/autofill/heuristics/output/011_i18n_zh_tw.out @@ -8,7 +8,7 @@ ADDRESS_HOME_ZIP | zc | 郵遞區號: | | fn_1-default ADDRESS_HOME_STATE | st | 地區: | | fn_1-default EMAIL_ADDRESS | em | 電郵地址: | | fn_1-default PHONE_HOME_WHOLE_NUMBER | ph | 電話: | | fn_1-default -CREDIT_CARD_NAME | c1 | 持卡人姓名: | | fn_1-cc +CREDIT_CARD_NAME_FULL | c1 | 持卡人姓名: | | fn_1-cc CREDIT_CARD_NUMBER | c2 | 信用卡卡號: | | fn_1-cc CREDIT_CARD_EXP_MONTH | c3 | 月: | | fn_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | c4 | 年: | | fn_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/013_autocomplete_attribute_basic.out b/chrome/test/data/autofill/heuristics/output/013_autocomplete_attribute_basic.out index 8b617f2..865984f 100644 --- a/chrome/test/data/autofill/heuristics/output/013_autocomplete_attribute_basic.out +++ b/chrome/test/data/autofill/heuristics/output/013_autocomplete_attribute_basic.out @@ -19,10 +19,10 @@ UNKNOWN_TYPE | al4 | | | na_1-default HTML_TYPE_COUNTRY_CODE | ac | | | na_1-default HTML_TYPE_COUNTRY_NAME | an | | | na_1-default HTML_TYPE_POSTAL_CODE | ap | | | na_1-default -HTML_TYPE_CREDIT_CARD_NAME | cn | | | na_1-cc -UNKNOWN_TYPE | cg | | | na_1-default +HTML_TYPE_CREDIT_CARD_NAME_FULL | cn | | | na_1-cc +HTML_TYPE_CREDIT_CARD_NAME_FIRST | cg | | | na_1-cc UNKNOWN_TYPE | ca | | | na_1-default -UNKNOWN_TYPE | cf | | | na_1-default +HTML_TYPE_CREDIT_CARD_NAME_LAST | cf | | | na_1-cc HTML_TYPE_CREDIT_CARD_NUMBER | cc | | | na_1-cc HTML_TYPE_CREDIT_CARD_EXP | ce | | | na_1-cc HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR | c5 | | | na_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/025_checkout_hsn.com.out b/chrome/test/data/autofill/heuristics/output/025_checkout_hsn.com.out index 2bcfab9..5a4919f 100644 --- a/chrome/test/data/autofill/heuristics/output/025_checkout_hsn.com.out +++ b/chrome/test/data/autofill/heuristics/output/025_checkout_hsn.com.out @@ -30,7 +30,7 @@ UNKNOWN_TYPE | PaymentTypeSelection | Pay with a Credit or Debit Card | 0 | Body CREDIT_CARD_NUMBER | Body$CCNumber | Card Number | | Body$BillingIsShippingCheckboxB_1-cc CREDIT_CARD_EXP_MONTH | Body$CCExpirationDateMonth | Expiration Date | 0 | Body$BillingIsShippingCheckboxB_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | Body$CCExpirationDateYear | Expiration Date | 0 | Body$BillingIsShippingCheckboxB_1-cc -CREDIT_CARD_NAME | Body$CCNameOnCard | Name on Card | | Body$BillingIsShippingCheckboxB_1-cc +CREDIT_CARD_NAME_FULL | Body$CCNameOnCard | Name on Card | | Body$BillingIsShippingCheckboxB_1-cc UNKNOWN_TYPE | IsDebitCard | Yes | 1 | Body$BillingIsShippingCheckboxB_1-default UNKNOWN_TYPE | IsDebitCard | No | 0 | Body$BillingIsShippingCheckboxB_1-default UNKNOWN_TYPE | Body$SaveCC4Later | Save information for future purchases | on | Body$BillingIsShippingCheckboxB_1-default diff --git a/chrome/test/data/autofill/heuristics/output/081_crbug_64569.out b/chrome/test/data/autofill/heuristics/output/081_crbug_64569.out index f559658..1e55975 100644 --- a/chrome/test/data/autofill/heuristics/output/081_crbug_64569.out +++ b/chrome/test/data/autofill/heuristics/output/081_crbug_64569.out @@ -1,6 +1,6 @@ UNKNOWN_TYPE | payment_group | Payment Type We accept Visa, Mastercard, Discover, American Express, and PayPal. | cc | payment_group_1-default UNKNOWN_TYPE | payment_group | Payment Type We accept Visa, Mastercard, Discover, American Express, and PayPal. | paypal | payment_group_1-default -CREDIT_CARD_NAME | ccFullName | (as it appears on the card) | | payment_group_1-cc +CREDIT_CARD_NAME_FULL | ccFullName | (as it appears on the card) | | payment_group_1-cc CREDIT_CARD_NUMBER | ccNumber | (no dashes or spaces) | | payment_group_1-cc CREDIT_CARD_EXP_MONTH | ccExpMonth | Expiration date | 1 | payment_group_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | ccExpYear | Your name (as it appears on the card) Credit card number (no dashes or spaces) Expiration date | 2011 | payment_group_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/084_crbug_93595.out b/chrome/test/data/autofill/heuristics/output/084_crbug_93595.out index 790cd1e..b3fa295 100644 --- a/chrome/test/data/autofill/heuristics/output/084_crbug_93595.out +++ b/chrome/test/data/autofill/heuristics/output/084_crbug_93595.out @@ -1,6 +1,6 @@ CREDIT_CARD_TYPE | payment_method | | Visa | payment_method_1-cc CREDIT_CARD_NUMBER | cc_number | | | payment_method_1-cc -CREDIT_CARD_NAME | cc_name | | | payment_method_1-cc +CREDIT_CARD_NAME_FULL | cc_name | | | payment_method_1-cc CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR | cc_exp | Expiration date (MM/YY) | | payment_method_1-cc CREDIT_CARD_VERIFICATION_CODE | cc_cvv2 | CVV2 / Security Code: | | payment_method_1-cc UNKNOWN_TYPE | field_17 | | Select an option... | payment_method_1-default diff --git a/chrome/test/data/autofill/heuristics/output/085_crbug_98152.out b/chrome/test/data/autofill/heuristics/output/085_crbug_98152.out index d3094ee..3a01199 100644 --- a/chrome/test/data/autofill/heuristics/output/085_crbug_98152.out +++ b/chrome/test/data/autofill/heuristics/output/085_crbug_98152.out @@ -2,7 +2,7 @@ CREDIT_CARD_TYPE | CCForm.cardType | Type of Card | | CCForm.cardType_1-cc CREDIT_CARD_NUMBER | CCForm.cardNumber | Card number | | CCForm.cardType_1-cc CREDIT_CARD_EXP_MONTH | CCForm.expirationMonth | Expiration date | 9 | CCForm.cardType_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | CCForm.expirationYear | Expiration date | 2011 | CCForm.cardType_1-cc -CREDIT_CARD_NAME | CCForm.name | Name as it appears on card | | CCForm.cardType_1-cc +CREDIT_CARD_NAME_FULL | CCForm.name | Name as it appears on card | | CCForm.cardType_1-cc CREDIT_CARD_VERIFICATION_CODE | CCForm.cid | | | CCForm.cardType_1-cc UNKNOWN_TYPE | isBillingAddress | Same as Shipping address | on | CCForm.cardType_1-default COMPANY_NAME | CCForm.companyName | Company Name | | CCForm.cardType_1-default diff --git a/chrome/test/data/autofill/heuristics/output/087_crbug_98286.out b/chrome/test/data/autofill/heuristics/output/087_crbug_98286.out index 1a4aa44..a5e1891 100644 --- a/chrome/test/data/autofill/heuristics/output/087_crbug_98286.out +++ b/chrome/test/data/autofill/heuristics/output/087_crbug_98286.out @@ -1,5 +1,5 @@ CREDIT_CARD_TYPE | drpdwnCardTypes | *Card type: | JCP1 | drpdwnCardTypes_1-cc -CREDIT_CARD_NAME | txtNameOnCreditCard | *Name on the card: | | drpdwnCardTypes_1-cc +CREDIT_CARD_NAME_FULL | txtNameOnCreditCard | *Name on the card: | | drpdwnCardTypes_1-cc CREDIT_CARD_NUMBER | txtCreditCardNumber | *Card number: | | drpdwnCardTypes_1-cc CREDIT_CARD_EXP_MONTH | drpdwnExpirationMonth | *Expiration date: | 00 | drpdwnCardTypes_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | drpdwnExpirationYear | *Expiration date: | 2011 | drpdwnCardTypes_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/092_checkout_alaskaair.com.out b/chrome/test/data/autofill/heuristics/output/092_checkout_alaskaair.com.out index fc3642c..3edf7d3f 100644 --- a/chrome/test/data/autofill/heuristics/output/092_checkout_alaskaair.com.out +++ b/chrome/test/data/autofill/heuristics/output/092_checkout_alaskaair.com.out @@ -9,7 +9,7 @@ UNKNOWN_TYPE | CreditCardInformation.BillingCreditCardEntry.CardTypes_Selected | CREDIT_CARD_NUMBER | CreditCardInformation.BillingCreditCardEntry.CardNumber | Card Number | | MyWalletInformation.UseMyWalletFunds_1-cc CREDIT_CARD_EXP_MONTH | CreditCardInformation.BillingCreditCardEntry.ExpirationMonths_Selected | Expiration* | | MyWalletInformation.UseMyWalletFunds_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | CreditCardInformation.BillingCreditCardEntry.ExpirationYears_Selected | Expiration* | | MyWalletInformation.UseMyWalletFunds_1-cc -CREDIT_CARD_NAME | CreditCardInformation.BillingCreditCardEntry.CardPersonName | Name on Card | | MyWalletInformation.UseMyWalletFunds_1-cc +CREDIT_CARD_NAME_FULL | CreditCardInformation.BillingCreditCardEntry.CardPersonName | Name on Card | | MyWalletInformation.UseMyWalletFunds_1-cc ADDRESS_HOME_COUNTRY | CreditCardInformation.BillingAddressEntry.Countries_Selected | Country | US | MyWalletInformation.UseMyWalletFunds_1-default ADDRESS_HOME_LINE1 | CreditCardInformation.BillingAddressEntry.Address1 | Address | | MyWalletInformation.UseMyWalletFunds_1-default ADDRESS_HOME_LINE2 | CreditCardInformation.BillingAddressEntry.Address2 | Address Line 2 | | MyWalletInformation.UseMyWalletFunds_1-default @@ -26,7 +26,7 @@ UNKNOWN_TYPE | TripInsurance.QuoteID | No, I choose not to protect my purchase. CREDIT_CARD_NUMBER | AncillaryCreditCardInformation.BillingCreditCardEntry.CardNumber | Card Number | | CreditCardInformation.BillingPhoneNumberEntry.CountryCode_Selected_1-cc CREDIT_CARD_EXP_MONTH | AncillaryCreditCardInformation.BillingCreditCardEntry.ExpirationMonths_Selected | Expiration* | | CreditCardInformation.BillingPhoneNumberEntry.CountryCode_Selected_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | AncillaryCreditCardInformation.BillingCreditCardEntry.ExpirationYears_Selected | Expiration* | | CreditCardInformation.BillingPhoneNumberEntry.CountryCode_Selected_1-cc -CREDIT_CARD_NAME | AncillaryCreditCardInformation.BillingCreditCardEntry.CardPersonName | Name on Card | | CreditCardInformation.BillingPhoneNumberEntry.CountryCode_Selected_1-cc +CREDIT_CARD_NAME_FULL | AncillaryCreditCardInformation.BillingCreditCardEntry.CardPersonName | Name on Card | | CreditCardInformation.BillingPhoneNumberEntry.CountryCode_Selected_1-cc ADDRESS_HOME_COUNTRY | AncillaryCreditCardInformation.BillingAddressEntry.Countries_Selected | Country | US | CreditCardInformation.BillingPhoneNumberEntry.CountryCode_Selected_1-default ADDRESS_HOME_LINE1 | AncillaryCreditCardInformation.BillingAddressEntry.Address1 | Address | | CreditCardInformation.BillingPhoneNumberEntry.CountryCode_Selected_1-default ADDRESS_HOME_LINE2 | AncillaryCreditCardInformation.BillingAddressEntry.Address2 | Address Line 2 | | CreditCardInformation.BillingPhoneNumberEntry.CountryCode_Selected_1-default diff --git a/chrome/test/data/autofill/heuristics/output/103_checkout_peapod.com.out b/chrome/test/data/autofill/heuristics/output/103_checkout_peapod.com.out index e12dcb8..68410a9 100644 --- a/chrome/test/data/autofill/heuristics/output/103_checkout_peapod.com.out +++ b/chrome/test/data/autofill/heuristics/output/103_checkout_peapod.com.out @@ -15,4 +15,4 @@ CREDIT_CARD_NUMBER | cardNum | | | _1-cc CREDIT_CARD_VERIFICATION_CODE | cid | | | _1-cc CREDIT_CARD_EXP_MONTH | /peapod/handler/iditarod/CheckoutRegistrationHandler.expirationMonth | Expiration Date: | 0 | _1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | /peapod/handler/iditarod/CheckoutRegistrationHandler.expirationYear | / | 0 | _1-cc -CREDIT_CARD_NAME | cardName | Shorty Nge | Shorty Nge | _1-cc +CREDIT_CARD_NAME_FULL | cardName | Shorty Nge | Shorty Nge | _1-cc diff --git a/chrome/test/data/autofill/heuristics/output/104_checkout_m_kohls.com.out b/chrome/test/data/autofill/heuristics/output/104_checkout_m_kohls.com.out index b96090a..36e2fa9 100644 --- a/chrome/test/data/autofill/heuristics/output/104_checkout_m_kohls.com.out +++ b/chrome/test/data/autofill/heuristics/output/104_checkout_m_kohls.com.out @@ -11,7 +11,7 @@ EMAIL_ADDRESS | email_Txt | Email | | billing_firstname_1-default EMAIL_ADDRESS | re_Email_Txt | Confirm Email Address | | billing_firstname_1-default UNKNOWN_TYPE | emailOutPutStatus | Yes, sign me up for Sale Alerts. (optional) | true | billing_firstname_1-default CREDIT_CARD_TYPE | paymentType | Card Type | | paymentType_1-cc -CREDIT_CARD_NAME | nameOnCard | Name on Card | | paymentType_1-cc +CREDIT_CARD_NAME_FULL | nameOnCard | Name on Card | | paymentType_1-cc CREDIT_CARD_NUMBER | cardNumber | Card Number | | paymentType_1-cc CREDIT_CARD_EXP_MONTH | expMonth | Expiration Month: | | paymentType_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | expYear | Expiration Year: | | paymentType_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/106_checkout_m_amazon.com.out b/chrome/test/data/autofill/heuristics/output/106_checkout_m_amazon.com.out index 805a18e..926fc98 100644 --- a/chrome/test/data/autofill/heuristics/output/106_checkout_m_amazon.com.out +++ b/chrome/test/data/autofill/heuristics/output/106_checkout_m_amazon.com.out @@ -9,7 +9,7 @@ PHONE_HOME_WHOLE_NUMBER | enterAddressPhoneNumber | Phone number | | enterAddre ADDRESS_HOME_COUNTRY | enterAddressCountryCode | | US | enterAddressFullName_1-default UNKNOWN_TYPE | AddressType | Optional Delivery Preferences | OTH | enterAddressFullName_1-default UNKNOWN_TYPE | GateCode | Security Access Code | | enterAddressFullName_1-default -CREDIT_CARD_NAME | name | Name on card | | name_1-cc +CREDIT_CARD_NAME_FULL | name | Name on card | | name_1-cc CREDIT_CARD_NUMBER | addCreditCardNumber | Card number | | name_1-cc CREDIT_CARD_EXP_MONTH | month | Expiration date | 1 | name_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | year | Expiration date | 2014 | name_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/111_checkout_virgin_america.com.out b/chrome/test/data/autofill/heuristics/output/111_checkout_virgin_america.com.out index 15eb1d9..fad188c 100644 --- a/chrome/test/data/autofill/heuristics/output/111_checkout_virgin_america.com.out +++ b/chrome/test/data/autofill/heuristics/output/111_checkout_virgin_america.com.out @@ -1,5 +1,5 @@ UNKNOWN_TYPE | creditCard | American Express Discover | | creditCard_1-default -CREDIT_CARD_NAME | cardholderName | Cardholder's name | | creditCard_1-cc +CREDIT_CARD_NAME_FULL | cardholderName | Cardholder's name | | creditCard_1-cc CREDIT_CARD_EXP_MONTH | expireMonth | Expiration Date | | creditCard_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | expireYear | Expiration Date | | creditCard_1-cc CREDIT_CARD_VERIFICATION_CODE | securityNumber | CVV Number 3 or 4 digit number | | creditCard_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/114_cc_checkout_wayfair.com.out b/chrome/test/data/autofill/heuristics/output/114_cc_checkout_wayfair.com.out index daa5fc8..f2703a7 100644 --- a/chrome/test/data/autofill/heuristics/output/114_cc_checkout_wayfair.com.out +++ b/chrome/test/data/autofill/heuristics/output/114_cc_checkout_wayfair.com.out @@ -4,7 +4,7 @@ CREDIT_CARD_NUMBER | credit_card[card_number] | Card number* | | payment_method CREDIT_CARD_EXP_MONTH | credit_card[expiration_month] | Expiration Month* | 1 | payment_method_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | credit_card[expiration_year] | Expiration Year* | 2016 | payment_method_1-cc CREDIT_CARD_VERIFICATION_CODE | credit_card[security_code] | What is this? | | payment_method_1-cc -CREDIT_CARD_NAME | credit_card[card_holder_name] | Name on card* | Homer Simpson | payment_method_1-cc +CREDIT_CARD_NAME_FULL | credit_card[card_holder_name] | Name on card* | Homer Simpson | payment_method_1-cc UNKNOWN_TYPE | credit_card[b_settle_immediately] | I am using a debit card one time use card | 1 | payment_method_1-default UNKNOWN_TYPE | apply_gift_card_or_promo | Apply a gift card | on | payment_method_1-default UNKNOWN_TYPE | GiftPromo | Enter a gift card number | | payment_method_1-default diff --git a/chrome/test/data/autofill/heuristics/output/117_cc_checkout_macys.com.out b/chrome/test/data/autofill/heuristics/output/117_cc_checkout_macys.com.out index fb33871..1160f83 100644 --- a/chrome/test/data/autofill/heuristics/output/117_cc_checkout_macys.com.out +++ b/chrome/test/data/autofill/heuristics/output/117_cc_checkout_macys.com.out @@ -7,8 +7,8 @@ CREDIT_CARD_EXP_4_DIGIT_YEAR | creditCard.expYear | Expiration date | 2016 | pay CREDIT_CARD_VERIFICATION_CODE | fake-password | Security code | | payment.type_1-cc CREDIT_CARD_VERIFICATION_CODE | creditCard.securityCode | Security code | | payment.type_1-cc UNKNOWN_TYPE | useMyShippingAddress | Use my shipping address | false | payment.type_1-default -CREDIT_CARD_NAME | billingContact.firstName | First name | | payment.type_1-cc -NAME_LAST | billingContact.lastName | Last name | | payment.type_1-default +CREDIT_CARD_NAME_FIRST | billingContact.firstName | First name | | payment.type_1-cc +CREDIT_CARD_NAME_LAST | billingContact.lastName | Last name | | payment.type_1-cc ADDRESS_HOME_LINE1 | billingAddress.addressLine1 | Address line 1 | | payment.type_1-default ADDRESS_HOME_LINE2 | billingAddress.addressLine2 | Address line 2 (optional) | | payment.type_1-default ADDRESS_HOME_CITY | billingAddress.city | City | | payment.type_1-default diff --git a/chrome/test/data/autofill/heuristics/output/118_checkout_cvs.com.out b/chrome/test/data/autofill/heuristics/output/118_checkout_cvs.com.out index 71d83a6..998805d 100644 --- a/chrome/test/data/autofill/heuristics/output/118_checkout_cvs.com.out +++ b/chrome/test/data/autofill/heuristics/output/118_checkout_cvs.com.out @@ -27,8 +27,8 @@ CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR | expfield | Exp | | fname_1-cc UNKNOWN_TYPE | cvvfield | CVV | | fname_1-default CREDIT_CARD_VERIFICATION_CODE | cvvfield | |CVV | | fname_1-cc UNKNOWN_TYPE | chk1 | Use ... as Billing Address. | on | fname_1-default -CREDIT_CARD_NAME | ffname | First Name | | fname_1-cc -NAME_LAST | flname | Last Name | | fname_1-default +CREDIT_CARD_NAME_FIRST | ffname | First Name | | fname_1-cc +CREDIT_CARD_NAME_LAST | flname | Last Name | | fname_1-cc ADDRESS_HOME_LINE1 | fstreetAddr | Street Address | | fname_1-default ADDRESS_HOME_LINE2 | fstreetAddr1 | Apartment, Building, Floor, Etc | | fname_1-default ADDRESS_HOME_CITY | fcity | City | | fname_1-default diff --git a/chrome/test/data/autofill/heuristics/output/127_bug_463986.out b/chrome/test/data/autofill/heuristics/output/127_bug_463986.out index 039977d..d04953f 100644 --- a/chrome/test/data/autofill/heuristics/output/127_bug_463986.out +++ b/chrome/test/data/autofill/heuristics/output/127_bug_463986.out @@ -13,20 +13,20 @@ PHONE_HOME_WHOLE_NUMBER | mobile | Mobile * | | salutation_1-default UNKNOWN_TYPE | paymentMethod | 31.89 USD by | CC | salutation_1-default CREDIT_CARD_TYPE | accountBrandDropDown | Card Brand | VISA | salutation_1-cc CREDIT_CARD_NUMBER | cardNumber | Card Number | | salutation_1-cc -CREDIT_CARD_NAME | ccHolder | Card holder | | salutation_1-cc +CREDIT_CARD_NAME_FULL | ccHolder | Card holder | | salutation_1-cc UNKNOWN_TYPE | identificationValue | CPF/CNPJ | | salutation_1-default CREDIT_CARD_EXP_MONTH | accountExpiryMonth | Expiration Date | - | salutation_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | accountExpiryYear | Expiration Date | - | salutation_1-cc CREDIT_CARD_VERIFICATION_CODE | accountVerification | Verification Number * | | salutation_1-cc UNKNOWN_TYPE | accountBrandDropDown | Card Brand | | salutation_1-default CREDIT_CARD_NUMBER | cardNumber | Card Number | | salutation_1-cc -CREDIT_CARD_NAME | ccHolder | Card holder | | salutation_1-cc +CREDIT_CARD_NAME_FULL | ccHolder | Card holder | | salutation_1-cc CREDIT_CARD_EXP_MONTH | accountExpiryMonth | Expiration Date | - | salutation_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | accountExpiryYear | Expiration Date | - | salutation_1-cc CREDIT_CARD_VERIFICATION_CODE | accountVerification | Verification Number * | | salutation_1-cc CREDIT_CARD_TYPE | accountBrandDropDown | Card Brand | VISA | salutation_1-cc CREDIT_CARD_NUMBER | cardNumber | Card Number | | salutation_1-cc -CREDIT_CARD_NAME | ccHolder | Card holder | | salutation_1-cc +CREDIT_CARD_NAME_FULL | ccHolder | Card holder | | salutation_1-cc CREDIT_CARD_EXP_MONTH | accountExpiryMonth | Expiration Date | - | salutation_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | accountExpiryYear | Expiration Date | - | salutation_1-cc CREDIT_CARD_VERIFICATION_CODE | accountVerification | Verification Number * | | salutation_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/128_bug_464002.out b/chrome/test/data/autofill/heuristics/output/128_bug_464002.out index 0df9a7f..7ad3f34 100644 --- a/chrome/test/data/autofill/heuristics/output/128_bug_464002.out +++ b/chrome/test/data/autofill/heuristics/output/128_bug_464002.out @@ -1,4 +1,4 @@ -CREDIT_CARD_NAME | paymentMethodForm.newCreditCardCustomerName | Name on card* | | paymentMethodForm.newCreditCardCustomerName_1-cc +CREDIT_CARD_NAME_FULL | paymentMethodForm.newCreditCardCustomerName | Name on card* | | paymentMethodForm.newCreditCardCustomerName_1-cc CREDIT_CARD_NUMBER | paymentMethodForm.cardNumber | Card number* | | paymentMethodForm.newCreditCardCustomerName_1-cc CREDIT_CARD_VERIFICATION_CODE | paymentMethodForm.cardVerificationNumber | Security code* | | paymentMethodForm.newCreditCardCustomerName_1-cc CREDIT_CARD_EXP_MONTH | paymentMethodForm.expirationMonth | 04 | | paymentMethodForm.newCreditCardCustomerName_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/129_bug_465053.out b/chrome/test/data/autofill/heuristics/output/129_bug_465053.out index b50748a..7e9a2d4 100644 --- a/chrome/test/data/autofill/heuristics/output/129_bug_465053.out +++ b/chrome/test/data/autofill/heuristics/output/129_bug_465053.out @@ -2,7 +2,7 @@ CREDIT_CARD_NUMBER | | Card number | | _1-cc CREDIT_CARD_EXP_MONTH | | MM | | _1-cc CREDIT_CARD_EXP_2_DIGIT_YEAR | | YY | | _1-cc CREDIT_CARD_VERIFICATION_CODE | | CVC | | _1-cc -CREDIT_CARD_NAME | | Cardholder name | | _1-cc +CREDIT_CARD_NAME_FULL | | Cardholder name | | _1-cc COMPANY_NAME | ORGANIZATION | Business name | | _1-default NAME_FULL | RECIPIENT | Name | | _1-default ADDRESS_HOME_LINE1 | ADDRESS_LINE_1 | Street address | | _1-default diff --git a/chrome/test/data/autofill/heuristics/output/131_bug_465587.out b/chrome/test/data/autofill/heuristics/output/131_bug_465587.out index 504c0fa..bd2b09f 100644 --- a/chrome/test/data/autofill/heuristics/output/131_bug_465587.out +++ b/chrome/test/data/autofill/heuristics/output/131_bug_465587.out @@ -2,7 +2,7 @@ UNKNOWN_TYPE | /bodybuilding/commerce/order/purchase/CardPaymentInfoFormHandler. UNKNOWN_TYPE | /bodybuilding/commerce/order/purchase/CardPaymentInfoFormHandler.billingInfo.paymentType | Paypal | payPalPayment | /bodybuilding/commerce/order/purchase/CardPaymentInfoFormHandler.billingInfo.paymentType_1-default UNKNOWN_TYPE | /bodybuilding/commerce/order/purchase/CardPaymentInfoFormHandler.billingInfo.paymentType | Gift Certificate | giftCertificate | /bodybuilding/commerce/order/purchase/CardPaymentInfoFormHandler.billingInfo.paymentType_1-default CREDIT_CARD_TYPE | /bodybuilding/commerce/order/purchase/CardPaymentInfoFormHandler.billingInfo.creditCard.creditCardType | Credit Card Type | visa | /bodybuilding/commerce/order/purchase/CardPaymentInfoFormHandler.billingInfo.paymentType_1-cc -CREDIT_CARD_NAME | cardholder | Cardholder Name | | /bodybuilding/commerce/order/purchase/CardPaymentInfoFormHandler.billingInfo.paymentType_1-cc +CREDIT_CARD_NAME_FULL | cardholder | Cardholder Name | | /bodybuilding/commerce/order/purchase/CardPaymentInfoFormHandler.billingInfo.paymentType_1-cc CREDIT_CARD_NUMBER | cardnumber | Credit Card Number | | /bodybuilding/commerce/order/purchase/CardPaymentInfoFormHandler.billingInfo.paymentType_1-cc CREDIT_CARD_EXP_MONTH | /bodybuilding/commerce/order/purchase/CardPaymentInfoFormHandler.billingInfo.creditCard.expirationMonth | Expiration Date | 01 | /bodybuilding/commerce/order/purchase/CardPaymentInfoFormHandler.billingInfo.paymentType_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | /bodybuilding/commerce/order/purchase/CardPaymentInfoFormHandler.billingInfo.creditCard.expirationYear | Expiration Date | 2015 | /bodybuilding/commerce/order/purchase/CardPaymentInfoFormHandler.billingInfo.paymentType_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/136_bug_497850.out b/chrome/test/data/autofill/heuristics/output/136_bug_497850.out index 130f32d..b8a9bd8 100644 --- a/chrome/test/data/autofill/heuristics/output/136_bug_497850.out +++ b/chrome/test/data/autofill/heuristics/output/136_bug_497850.out @@ -1,6 +1,6 @@ UNKNOWN_TYPE | ctl01$ctl00$MainContentRegion$MainRegion$ctl00$ipcPayment$ddlCcType | Card type | | ctl01$ctl00$MainContentRegion$MainRegion$ctl00$ipcPayment$ddlCcType_1-default CREDIT_CARD_NUMBER | ctl01$ctl00$MainContentRegion$MainRegion$ctl00$ipcPayment$txtCcNumber | Card number | | ctl01$ctl00$MainContentRegion$MainRegion$ctl00$ipcPayment$ddlCcType_1-cc -CREDIT_CARD_NAME | ctl01$ctl00$MainContentRegion$MainRegion$ctl00$ipcPayment$txtCcHolder | Card holder name | | ctl01$ctl00$MainContentRegion$MainRegion$ctl00$ipcPayment$ddlCcType_1-cc +CREDIT_CARD_NAME_FULL | ctl01$ctl00$MainContentRegion$MainRegion$ctl00$ipcPayment$txtCcHolder | Card holder name | | ctl01$ctl00$MainContentRegion$MainRegion$ctl00$ipcPayment$ddlCcType_1-cc CREDIT_CARD_EXP_MONTH | ctl01$ctl00$MainContentRegion$MainRegion$ctl00$ipcPayment$ddlCcExpiryMonth | Expiry date | MM | ctl01$ctl00$MainContentRegion$MainRegion$ctl00$ipcPayment$ddlCcType_1-cc CREDIT_CARD_EXP_4_DIGIT_YEAR | ctl01$ctl00$MainContentRegion$MainRegion$ctl00$ipcPayment$ddlCcExpiryYear | Expiry date | YYYY | ctl01$ctl00$MainContentRegion$MainRegion$ctl00$ipcPayment$ddlCcType_1-cc CREDIT_CARD_VERIFICATION_CODE | ctl01$ctl00$MainContentRegion$MainRegion$ctl00$ipcPayment$txtCcCvc | Verification Code (CVC) | | ctl01$ctl00$MainContentRegion$MainRegion$ctl00$ipcPayment$ddlCcType_1-cc diff --git a/chrome/test/data/autofill/heuristics/output/137_bug_555010.out b/chrome/test/data/autofill/heuristics/output/137_bug_555010.out index 32a2019..06382e9 100644 --- a/chrome/test/data/autofill/heuristics/output/137_bug_555010.out +++ b/chrome/test/data/autofill/heuristics/output/137_bug_555010.out @@ -1,4 +1,4 @@ -CREDIT_CARD_NAME | cardName | Full Name (First Name Last Name) | | cardName_1-cc +CREDIT_CARD_NAME_FULL | cardName | Full Name (First Name Last Name) | | cardName_1-cc ADDRESS_HOME_LINE1 | id_skCOShipAddress | Shipping Address | | cardName_1-default UNKNOWN_TYPE | id_skCOShipAptBldg | Apt/Bldg (optional) | | cardName_1-default PHONE_HOME_WHOLE_NUMBER | id_skCOPhoneno | Phone | | cardName_1-default @@ -6,7 +6,7 @@ EMAIL_ADDRESS | id_skCOEmail | Email | | cardName_1-default CREDIT_CARD_NUMBER | cardNumber | 1234 5647 8901 2345 | | cardName_1-cc CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR | expirationMonth | EXP | | cardName_1-cc CREDIT_CARD_VERIFICATION_CODE | cvv | CVV | | cardName_1-cc -CREDIT_CARD_NAME | id_skCOName | Card Holder Name | | id_skCOName_1-cc +CREDIT_CARD_NAME_FULL | id_skCOName | Card Holder Name | | id_skCOName_1-cc ADDRESS_HOME_LINE1 | id_skCOShipAddress | Billing Address | | id_skCOName_1-default UNKNOWN_TYPE | id_skCOShipAptBldg | Apt/Bldg (optional) | | id_skCOName_1-default PHONE_HOME_WHOLE_NUMBER | id_skCOPhoneno | Phone | | id_skCOName_1-default @@ -17,6 +17,6 @@ PHONE_HOME_WHOLE_NUMBER | id_skCOPhoneno | Phone | | id_skCOShipAddress_3-defau CREDIT_CARD_NUMBER | cardNumber | 1234 5647 8901 2345 | | id_skCOShipAddress_3-cc CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR | expirationMonth | EXP | | id_skCOShipAddress_3-cc CREDIT_CARD_VERIFICATION_CODE | cvv | CVV | | id_skCOShipAddress_3-cc -CREDIT_CARD_NAME | id_skAltPUName | Name | | id_skCOShipAddress_3-cc +CREDIT_CARD_NAME_FULL | id_skAltPUName | Name | | id_skCOShipAddress_3-cc PHONE_HOME_WHOLE_NUMBER | id_skAltPUPhoneno | Phone | | id_skCOShipAddress_3-default EMAIL_ADDRESS | id_skAltPUEmail | Email | | id_skCOShipAddress_3-default diff --git a/chrome/test/data/autofill/heuristics/output/27_checkout_cc_keurig.com.out b/chrome/test/data/autofill/heuristics/output/27_checkout_cc_keurig.com.out new file mode 100644 index 0000000..ee43f6b --- /dev/null +++ b/chrome/test/data/autofill/heuristics/output/27_checkout_cc_keurig.com.out @@ -0,0 +1,10 @@ +CREDIT_CARD_NAME_FIRST | card_firstNameOnCard | First Name* | | card_firstNameOnCard_1-cc +CREDIT_CARD_NAME_LAST | card_lastNameOnCard | Last Name* | | card_firstNameOnCard_1-cc +CREDIT_CARD_NUMBER | card_accountNumber | Card Number* | | card_firstNameOnCard_1-cc +CREDIT_CARD_TYPE | card_cardType | Card Type | | card_firstNameOnCard_1-cc +UNKNOWN_TYPE | | Please select a card type | | card_firstNameOnCard_1-default +UNKNOWN_TYPE | card_expirationMonth | Expiration Date* | | card_firstNameOnCard_1-default +UNKNOWN_TYPE | | Month | | card_firstNameOnCard_1-default +CREDIT_CARD_EXP_MONTH | card_expirationYear | Expiration Date* | | card_firstNameOnCard_1-cc +CREDIT_CARD_EXP_4_DIGIT_YEAR | | Year | | card_firstNameOnCard_1-cc +CREDIT_CARD_VERIFICATION_CODE | card_cvNumber | Security Code* | | card_firstNameOnCard_1-cc diff --git a/components/autofill.gypi b/components/autofill.gypi index 8c5396d..60a1d56 100644 --- a/components/autofill.gypi +++ b/components/autofill.gypi @@ -115,6 +115,8 @@ 'autofill/core/browser/autofill_country.h', 'autofill/core/browser/autofill_data_model.cc', 'autofill/core/browser/autofill_data_model.h', + 'autofill/core/browser/autofill_data_util.cc', + 'autofill/core/browser/autofill_data_util.h', 'autofill/core/browser/autofill_download_manager.cc', 'autofill/core/browser/autofill_download_manager.h', 'autofill/core/browser/autofill_driver.h', diff --git a/components/autofill/content/browser/wallet/full_wallet.cc b/components/autofill/content/browser/wallet/full_wallet.cc index 43e901a..84e8642 100644 --- a/components/autofill/content/browser/wallet/full_wallet.cc +++ b/components/autofill/content/browser/wallet/full_wallet.cc @@ -72,7 +72,7 @@ base::string16 FullWallet::GetInfo(const std::string& app_locale, case CREDIT_CARD_NUMBER: return base::ASCIIToUTF16(GetPan()); - case CREDIT_CARD_NAME: + case CREDIT_CARD_NAME_FULL: return billing_address()->recipient_name(); case CREDIT_CARD_VERIFICATION_CODE: diff --git a/components/autofill/core/browser/BUILD.gn b/components/autofill/core/browser/BUILD.gn index 014414b..eed6113 100644 --- a/components/autofill/core/browser/BUILD.gn +++ b/components/autofill/core/browser/BUILD.gn @@ -32,6 +32,8 @@ source_set("browser") { "autofill_country.h", "autofill_data_model.cc", "autofill_data_model.h", + "autofill_data_util.cc", + "autofill_data_util.h", "autofill_download_manager.cc", "autofill_download_manager.h", "autofill_driver.h", @@ -263,6 +265,7 @@ source_set("unit_tests") { "autocomplete_history_manager_unittest.cc", "autofill_country_unittest.cc", "autofill_data_model_unittest.cc", + "autofill_data_util_unittest.cc", "autofill_download_manager_unittest.cc", "autofill_external_delegate_unittest.cc", "autofill_field_unittest.cc", diff --git a/components/autofill/core/browser/autofill_data_util.cc b/components/autofill/core/browser/autofill_data_util.cc new file mode 100644 index 0000000..63dc482 --- /dev/null +++ b/components/autofill/core/browser/autofill_data_util.cc @@ -0,0 +1,132 @@ +// Copyright 2016 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_data_util.h" + +#include <vector> + +#include "base/strings/string_split.h" +#include "base/strings/string_util.h" +#include "base/strings/utf_string_conversions.h" + +namespace autofill { +namespace data_util { + +namespace { +const char* const name_prefixes[] = { + "1lt", "1st", "2lt", "2nd", "3rd", "admiral", "capt", + "captain", "col", "cpt", "dr", "gen", "general", "lcdr", + "lt", "ltc", "ltg", "ltjg", "maj", "major", "mg", + "mr", "mrs", "ms", "pastor", "prof", "rep", "reverend", + "rev", "sen", "st"}; + +const char* const name_suffixes[] = {"b.a", "ba", "d.d.s", "dds", "i", "ii", + "iii", "iv", "ix", "jr", "m.a", "m.d", + "ma", "md", "ms", "ph.d", "phd", "sr", + "v", "vi", "vii", "viii", "x"}; + +const char* const family_name_prefixes[] = {"d'", "de", "del", "der", "di", + "la", "le", "mc", "san", "st", + "ter", "van", "von"}; + +// Returns true if |set| contains |element|, modulo a final period. +bool ContainsString(const char* const set[], + size_t set_size, + const base::string16& element) { + if (!base::IsStringASCII(element)) + return false; + + base::string16 trimmed_element; + base::TrimString(element, base::ASCIIToUTF16("."), &trimmed_element); + + for (size_t i = 0; i < set_size; ++i) { + if (base::LowerCaseEqualsASCII(trimmed_element, set[i])) + return true; + } + + return false; +} + +// Removes common name prefixes from |name_tokens|. +void StripPrefixes(std::vector<base::string16>* name_tokens) { + std::vector<base::string16>::iterator iter = name_tokens->begin(); + while (iter != name_tokens->end()) { + if (!ContainsString(name_prefixes, arraysize(name_prefixes), *iter)) + break; + ++iter; + } + + std::vector<base::string16> copy_vector; + copy_vector.assign(iter, name_tokens->end()); + *name_tokens = copy_vector; +} + +// Removes common name suffixes from |name_tokens|. +void StripSuffixes(std::vector<base::string16>* name_tokens) { + while (!name_tokens->empty()) { + if (!ContainsString(name_suffixes, arraysize(name_suffixes), + name_tokens->back())) { + break; + } + name_tokens->pop_back(); + } +} + +} // namespace + +NameParts SplitName(const base::string16& name) { + std::vector<base::string16> name_tokens = + base::SplitString(name, base::ASCIIToUTF16(" ,"), base::KEEP_WHITESPACE, + base::SPLIT_WANT_NONEMPTY); + StripPrefixes(&name_tokens); + + // Don't assume "Ma" is a suffix in John Ma. + if (name_tokens.size() > 2) + StripSuffixes(&name_tokens); + + NameParts parts; + + if (name_tokens.empty()) { + // Bad things have happened; just assume the whole thing is a given name. + parts.given = name; + return parts; + } + + // Only one token, assume given name. + if (name_tokens.size() == 1) { + parts.given = name_tokens[0]; + return parts; + } + + // 2 or more tokens. Grab the family, which is the last word plus any + // recognizable family prefixes. + std::vector<base::string16> reverse_family_tokens; + reverse_family_tokens.push_back(name_tokens.back()); + name_tokens.pop_back(); + while (name_tokens.size() >= 1 && + ContainsString(family_name_prefixes, arraysize(family_name_prefixes), + name_tokens.back())) { + reverse_family_tokens.push_back(name_tokens.back()); + name_tokens.pop_back(); + } + + std::vector<base::string16> family_tokens(reverse_family_tokens.rbegin(), + reverse_family_tokens.rend()); + parts.family = base::JoinString(family_tokens, base::ASCIIToUTF16(" ")); + + // Take the last remaining token as the middle name (if there are at least 2 + // tokens). + if (name_tokens.size() >= 2) { + parts.middle = name_tokens.back(); + name_tokens.pop_back(); + } + + // Remainder is given name. + parts.given = base::JoinString(name_tokens, base::ASCIIToUTF16(" ")); + + return parts; +} + +} // namespace data_util +} // namespace autofill diff --git a/components/autofill/core/browser/autofill_data_util.h b/components/autofill/core/browser/autofill_data_util.h new file mode 100644 index 0000000..1cba1b3 --- /dev/null +++ b/components/autofill/core/browser/autofill_data_util.h @@ -0,0 +1,28 @@ +// Copyright 2016 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_DATA_UTIL_H_ +#define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_ + +#include "base/strings/string16.h" + +namespace autofill { +namespace data_util { + +struct NameParts { + base::string16 given; + base::string16 middle; + base::string16 family; +}; + +// TODO(crbug.com/586510): Investigate the use of app_locale to do better name +// splitting. +// Returns the different name parts (given, middle and family names) of the full +// |name| passed as a parameter. +NameParts SplitName(const base::string16& name); + +} // namespace data_util +} // namespace autofill + +#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_ diff --git a/components/autofill/core/browser/autofill_data_util_unittest.cc b/components/autofill/core/browser/autofill_data_util_unittest.cc new file mode 100644 index 0000000..ebed1f7 --- /dev/null +++ b/components/autofill/core/browser/autofill_data_util_unittest.cc @@ -0,0 +1,46 @@ +// Copyright 2016 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_data_util.h" + +#include "base/strings/utf_string_conversions.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace autofill { +namespace data_util { + +TEST(AutofillDataUtilTest, SplitName) { + typedef struct { + std::string full_name; + std::string given_name; + std::string middle_name; + std::string family_name; + + } TestCase; + + TestCase test_cases[] = { + // Full name including given, middle and family names. + {"Homer Jay Simpson", "Homer", "Jay", "Simpson"}, + // No middle name. + {"Moe Szyslak", "Moe", "", "Szyslak"}, + // Common name prefixes removed. + {"Reverend Timothy Lovejoy", "Timothy", "", "Lovejoy"}, + // Common name suffixes removed. + {"John Frink Phd", "John", "", "Frink"}, + // Exception to the name suffix removal. + {"John Ma", "John", "", "Ma"}, + // Common family name prefixes not considered a middle name. + {"Milhouse Van Houten", "Milhouse", "", "Van Houten"}}; + + for (TestCase test_case : test_cases) { + NameParts name_parts = SplitName(base::UTF8ToUTF16(test_case.full_name)); + + EXPECT_EQ(base::UTF8ToUTF16(test_case.given_name), name_parts.given); + EXPECT_EQ(base::UTF8ToUTF16(test_case.middle_name), name_parts.middle); + EXPECT_EQ(base::UTF8ToUTF16(test_case.family_name), name_parts.family); + } +} + +} // namespace data_util +} // namespace autofill diff --git a/components/autofill/core/browser/autofill_field.cc b/components/autofill/core/browser/autofill_field.cc index 82b80d9e..c2f3e03 100644 --- a/components/autofill/core/browser/autofill_field.cc +++ b/components/autofill/core/browser/autofill_field.cc @@ -513,15 +513,21 @@ AutofillType AutofillField::Type() const { if (server_type_ != NO_SERVER_DATA) { // See http://crbug.com/429236 for background on why we might not always // believe the server. - // See http://crbug.com/441488 for potential improvements to the server - // which may obviate the need for this logic. + // TODO(http://crbug.com/589129) investigate how well the server is doing in + // regard to credit card predictions. bool believe_server = - !(server_type_ == NAME_FULL && heuristic_type_ == CREDIT_CARD_NAME) && - !(server_type_ == CREDIT_CARD_NAME && heuristic_type_ == NAME_FULL) && + !(server_type_ == NAME_FULL && + heuristic_type_ == CREDIT_CARD_NAME_FULL) && + !(server_type_ == CREDIT_CARD_NAME_FULL && + heuristic_type_ == NAME_FULL) && + !(server_type_ == NAME_FIRST && + heuristic_type_ == CREDIT_CARD_NAME_FIRST) && + !(server_type_ == NAME_LAST && + heuristic_type_ == CREDIT_CARD_NAME_LAST) && // CVC is sometimes type="password", which tricks the server. // See http://crbug.com/469007 !(AutofillType(server_type_).group() == PASSWORD_FIELD && - heuristic_type_ == CREDIT_CARD_VERIFICATION_CODE); + heuristic_type_ == CREDIT_CARD_VERIFICATION_CODE); if (believe_server) return AutofillType(server_type_); } diff --git a/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc b/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc index 15874af..508dfa0 100644 --- a/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc +++ b/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc @@ -103,33 +103,33 @@ struct { ServerFieldType field_type; const wchar_t *reg_value_name; } profile_reg_values[] = { - { NAME_FIRST, L"name_first" }, - { NAME_MIDDLE, L"name_middle" }, - { NAME_LAST, L"name_last" }, - { NAME_SUFFIX, L"name_suffix" }, - { EMAIL_ADDRESS, L"email" }, - { COMPANY_NAME, L"company_name" }, - { PHONE_HOME_NUMBER, L"phone_home_number" }, - { PHONE_HOME_CITY_CODE, L"phone_home_city_code" }, - { PHONE_HOME_COUNTRY_CODE, L"phone_home_country_code" }, - { ADDRESS_HOME_LINE1, L"address_home_line1" }, - { ADDRESS_HOME_LINE2, L"address_home_line2" }, - { ADDRESS_HOME_CITY, L"address_home_city" }, - { ADDRESS_HOME_STATE, L"address_home_state" }, - { ADDRESS_HOME_ZIP, L"address_home_zip" }, - { ADDRESS_HOME_COUNTRY, L"address_home_country" }, - { ADDRESS_BILLING_LINE1, L"address_billing_line1" }, - { ADDRESS_BILLING_LINE2, L"address_billing_line2" }, - { ADDRESS_BILLING_CITY, L"address_billing_city" }, - { ADDRESS_BILLING_STATE, L"address_billing_state" }, - { ADDRESS_BILLING_ZIP, L"address_billing_zip" }, - { ADDRESS_BILLING_COUNTRY, L"address_billing_country" }, - { CREDIT_CARD_NAME, L"credit_card_name" }, - { CREDIT_CARD_NUMBER, L"credit_card_number" }, - { CREDIT_CARD_EXP_MONTH, L"credit_card_exp_month" }, - { CREDIT_CARD_EXP_4_DIGIT_YEAR, L"credit_card_exp_4_digit_year" }, - { CREDIT_CARD_TYPE, L"credit_card_type" }, - // We do not import verification code. + {NAME_FIRST, L"name_first"}, + {NAME_MIDDLE, L"name_middle"}, + {NAME_LAST, L"name_last"}, + {NAME_SUFFIX, L"name_suffix"}, + {EMAIL_ADDRESS, L"email"}, + {COMPANY_NAME, L"company_name"}, + {PHONE_HOME_NUMBER, L"phone_home_number"}, + {PHONE_HOME_CITY_CODE, L"phone_home_city_code"}, + {PHONE_HOME_COUNTRY_CODE, L"phone_home_country_code"}, + {ADDRESS_HOME_LINE1, L"address_home_line1"}, + {ADDRESS_HOME_LINE2, L"address_home_line2"}, + {ADDRESS_HOME_CITY, L"address_home_city"}, + {ADDRESS_HOME_STATE, L"address_home_state"}, + {ADDRESS_HOME_ZIP, L"address_home_zip"}, + {ADDRESS_HOME_COUNTRY, L"address_home_country"}, + {ADDRESS_BILLING_LINE1, L"address_billing_line1"}, + {ADDRESS_BILLING_LINE2, L"address_billing_line2"}, + {ADDRESS_BILLING_CITY, L"address_billing_city"}, + {ADDRESS_BILLING_STATE, L"address_billing_state"}, + {ADDRESS_BILLING_ZIP, L"address_billing_zip"}, + {ADDRESS_BILLING_COUNTRY, L"address_billing_country"}, + {CREDIT_CARD_NAME_FULL, L"credit_card_name_full"}, + {CREDIT_CARD_NUMBER, L"credit_card_number"}, + {CREDIT_CARD_EXP_MONTH, L"credit_card_exp_month"}, + {CREDIT_CARD_EXP_4_DIGIT_YEAR, L"credit_card_exp_4_digit_year"}, + {CREDIT_CARD_TYPE, L"credit_card_type"}, + // We do not import verification code. }; typedef std::map<std::wstring, ServerFieldType> RegToFieldMap; diff --git a/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc b/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc index 29bf783..2bf3e45 100644 --- a/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc +++ b/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc @@ -61,14 +61,15 @@ ValueDescription profile2[] = { }; ValueDescription credit_card[] = { - { L"credit_card_name", L"Tommy Gun" }, - // "4111111111111111" encrypted: - { L"credit_card_number", L"\xE53F\x19AB\xC1BF\xC9EB\xECCC\x9BDA\x8515" - L"\xE14D\x6852\x80A8\x50A3\x4375\xFD9F\x1E07" - L"\x790E\x7336\xB773\xAF33\x93EA\xB846\xEC89" - L"\x265C\xD0E6\x4E23\xB75F\x7983" }, - { L"credit_card_exp_month", L"11" }, - { L"credit_card_exp_4_digit_year", L"2011" }, + {L"credit_card_name_full", L"Tommy Gun"}, + // "4111111111111111" encrypted: + {L"credit_card_number", + L"\xE53F\x19AB\xC1BF\xC9EB\xECCC\x9BDA\x8515" + L"\xE14D\x6852\x80A8\x50A3\x4375\xFD9F\x1E07" + L"\x790E\x7336\xB773\xAF33\x93EA\xB846\xEC89" + L"\x265C\xD0E6\x4E23\xB75F\x7983"}, + {L"credit_card_exp_month", L"11"}, + {L"credit_card_exp_4_digit_year", L"2011"}, }; ValueDescription empty_salt = { @@ -186,7 +187,8 @@ TEST_F(AutofillIeToolbarImportTest, TestAutofillImport) { EXPECT_EQ(profile2[3].value, profiles[0].GetRawInfo(COMPANY_NAME)); ASSERT_EQ(1U, credit_cards.size()); - EXPECT_EQ(credit_card[0].value, credit_cards[0].GetRawInfo(CREDIT_CARD_NAME)); + EXPECT_EQ(credit_card[0].value, + credit_cards[0].GetRawInfo(CREDIT_CARD_NAME_FULL)); EXPECT_EQ(L"4111111111111111", credit_cards[0].GetRawInfo(CREDIT_CARD_NUMBER)); EXPECT_EQ(credit_card[2].value, diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc index cbd77b5..de12b8a 100644 --- a/components/autofill/core/browser/autofill_manager.cc +++ b/components/autofill/core/browser/autofill_manager.cc @@ -1083,7 +1083,7 @@ bool AutofillManager::GetProfilesForCreditCardUpload( // requests that are guaranteed to fail. base::string16 verified_name; base::string16 card_name = - card.GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_); + card.GetInfo(AutofillType(CREDIT_CARD_NAME_FULL), app_locale_); if (!card_name.empty()) { verified_name = RemoveMiddleInitial(card_name); } diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc index 8a4e17e..f8e9772 100644 --- a/components/autofill/core/browser/autofill_manager_unittest.cc +++ b/components/autofill/core/browser/autofill_manager_unittest.cc @@ -1982,6 +1982,42 @@ TEST_F(AutofillManagerTest, FillCreditCardFormYearMonth) { kDefaultPageID, false, "2012", "04"); } +// Test that we correctly fill a credit card form with first and last cardholder +// name. +TEST_F(AutofillManagerTest, FillCreditCardFormSplitName) { + // Set up our form data. + FormData form; + form.name = ASCIIToUTF16("MyForm"); + form.origin = GURL("https://myform.com/form.html"); + form.action = GURL("https://myform.com/submit.html"); + + FormFieldData field; + test::CreateTestFormField("Card Name", "cardname", "", "text", &field); + form.fields.push_back(field); + test::CreateTestFormField("Last Name", "cardlastname", "", "text", &field); + form.fields.push_back(field); + test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field); + form.fields.push_back(field); + test::CreateTestFormField("CVC", "cvc", "", "text", &field); + form.fields.push_back(field); + + std::vector<FormData> forms(1, form); + FormsSeen(forms); + + const char guid[] = "00000000-0000-0000-0000-000000000004"; + int response_page_id = 0; + FormData response_data; + FillAutofillFormDataAndSaveResults(kDefaultPageID, form, *form.fields.begin(), + MakeFrontendID(guid, std::string()), + &response_page_id, &response_data); + ExpectFilledField("Card Name", "cardname", "Elvis", "text", + response_data.fields[0]); + ExpectFilledField("Last Name", "cardlastname", "Presley", "text", + response_data.fields[1]); + ExpectFilledField("Card Number", "cardnumber", "4234567890123456", "text", + response_data.fields[2]); +} + // Test that we correctly fill a combined address and credit card form. TEST_F(AutofillManagerTest, FillAddressAndCreditCardForm) { // Set up our form data. @@ -3354,7 +3390,7 @@ TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) { {"2", PHONE_HOME_CITY_CODE}, // Credit card fields matches. - {"Elvis Presley", CREDIT_CARD_NAME}, + {"Elvis Presley", CREDIT_CARD_NAME_FULL}, {"4234-5678-9012-3456", CREDIT_CARD_NUMBER}, {"04", CREDIT_CARD_EXP_MONTH}, {"April", CREDIT_CARD_EXP_MONTH}, diff --git a/components/autofill/core/browser/autofill_metrics.cc b/components/autofill/core/browser/autofill_metrics.cc index 5efe96a..d463edf 100644 --- a/components/autofill/core/browser/autofill_metrics.cc +++ b/components/autofill/core/browser/autofill_metrics.cc @@ -31,7 +31,7 @@ enum FieldTypeGroupForMetrics { GROUP_PHONE, GROUP_FAX, // Deprecated. GROUP_EMAIL, - GROUP_CREDIT_CARD_NAME, + GROUP_CREDIT_CARD_NAME_FULL, GROUP_CREDIT_CARD_NUMBER, GROUP_CREDIT_CARD_DATE, GROUP_CREDIT_CARD_TYPE, @@ -129,8 +129,8 @@ int GetFieldTypeGroupMetric(ServerFieldType field_type, case CREDIT_CARD: switch (field_type) { - case CREDIT_CARD_NAME: - group = GROUP_CREDIT_CARD_NAME; + case CREDIT_CARD_NAME_FULL: + group = GROUP_CREDIT_CARD_NAME_FULL; break; case CREDIT_CARD_NUMBER: group = GROUP_CREDIT_CARD_NUMBER; diff --git a/components/autofill/core/browser/autofill_profile.cc b/components/autofill/core/browser/autofill_profile.cc index e055fa6..a8098d1 100644 --- a/components/autofill/core/browser/autofill_profile.cc +++ b/components/autofill/core/browser/autofill_profile.cc @@ -292,6 +292,7 @@ AutofillProfile& AutofillProfile::operator=(const AutofillProfile& profile) { return *this; } +// TODO(crbug.com/589535): Disambiguate similar field types before uploading. void AutofillProfile::GetMatchingTypes( const base::string16& text, const std::string& app_locale, diff --git a/components/autofill/core/browser/autofill_regex_constants.cc b/components/autofill/core/browser/autofill_regex_constants.cc index db5456f..bd97024 100644 --- a/components/autofill/core/browser/autofill_regex_constants.cc +++ b/components/autofill/core/browser/autofill_regex_constants.cc @@ -124,16 +124,16 @@ const char kStateRe[] = // credit_card_field.cc ///////////////////////////////////////////////////////////////////////////// const char kNameOnCardRe[] = - "card.?(?:holder|owner)|name.*\\bon\\b.*card" + "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 + "|karteninhaber" // de-DE + "|nombre.*tarjeta" // es + "|nom.*carte" // fr-FR + "|nome.*cart" // it-IT + "|名前" // ja-JP + "|Имя.*карты" // ru "|信用卡开户名|开户名|持卡人姓名" // zh-CN - "|持卡人姓名"; // zh-TW + "|持卡人姓名"; // zh-TW const char kNameOnCardContextualRe[] = "name"; const char kCardNumberRe[] = diff --git a/components/autofill/core/browser/autofill_test_utils.cc b/components/autofill/core/browser/autofill_test_utils.cc index 8854b8b..621baa7 100644 --- a/components/autofill/core/browser/autofill_test_utils.cc +++ b/components/autofill/core/browser/autofill_test_utils.cc @@ -280,7 +280,7 @@ void SetProfileInfoWithGuid(AutofillProfile* profile, void SetCreditCardInfo(CreditCard* credit_card, const char* name_on_card, const char* card_number, const char* expiration_month, const char* expiration_year) { - check_and_set(credit_card, CREDIT_CARD_NAME, name_on_card); + check_and_set(credit_card, CREDIT_CARD_NAME_FULL, name_on_card); check_and_set(credit_card, CREDIT_CARD_NUMBER, card_number); check_and_set(credit_card, CREDIT_CARD_EXP_MONTH, expiration_month); check_and_set(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR, expiration_year); diff --git a/components/autofill/core/browser/autofill_type.cc b/components/autofill/core/browser/autofill_type.cc index 71d4955..591220c 100644 --- a/components/autofill/core/browser/autofill_type.cc +++ b/components/autofill/core/browser/autofill_type.cc @@ -102,7 +102,9 @@ FieldTypeGroup AutofillType::group() const { case ADDRESS_BILLING_DEPENDENT_LOCALITY: return ADDRESS_BILLING; - case CREDIT_CARD_NAME: + case CREDIT_CARD_NAME_FULL: + case CREDIT_CARD_NAME_FIRST: + case CREDIT_CARD_NAME_LAST: case CREDIT_CARD_NUMBER: case CREDIT_CARD_EXP_MONTH: case CREDIT_CARD_EXP_2_DIGIT_YEAR: @@ -171,7 +173,9 @@ FieldTypeGroup AutofillType::group() const { case HTML_TYPE_FULL_ADDRESS: return html_mode_ == HTML_MODE_BILLING ? ADDRESS_BILLING : ADDRESS_HOME; - case HTML_TYPE_CREDIT_CARD_NAME: + case HTML_TYPE_CREDIT_CARD_NAME_FULL: + case HTML_TYPE_CREDIT_CARD_NAME_FIRST: + case HTML_TYPE_CREDIT_CARD_NAME_LAST: case HTML_TYPE_CREDIT_CARD_NUMBER: case HTML_TYPE_CREDIT_CARD_EXP: case HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR: @@ -340,8 +344,14 @@ ServerFieldType AutofillType::GetStorableType() const { case HTML_TYPE_FULL_ADDRESS: return UNKNOWN_TYPE; - case HTML_TYPE_CREDIT_CARD_NAME: - return CREDIT_CARD_NAME; + case HTML_TYPE_CREDIT_CARD_NAME_FULL: + return CREDIT_CARD_NAME_FULL; + + case HTML_TYPE_CREDIT_CARD_NAME_FIRST: + return CREDIT_CARD_NAME_FIRST; + + case HTML_TYPE_CREDIT_CARD_NAME_LAST: + return CREDIT_CARD_NAME_LAST; case HTML_TYPE_CREDIT_CARD_NUMBER: return CREDIT_CARD_NUMBER; @@ -570,8 +580,12 @@ std::string AutofillType::ToString() const { return "ADDRESS_BILLING_ZIP"; case ADDRESS_BILLING_COUNTRY: return "ADDRESS_BILLING_COUNTRY"; - case CREDIT_CARD_NAME: - return "CREDIT_CARD_NAME"; + case CREDIT_CARD_NAME_FULL: + return "CREDIT_CARD_NAME_FULL"; + case CREDIT_CARD_NAME_FIRST: + return "CREDIT_CARD_NAME_FIRST"; + case CREDIT_CARD_NAME_LAST: + return "CREDIT_CARD_NAME_LAST"; case CREDIT_CARD_NUMBER: return "CREDIT_CARD_NUMBER"; case CREDIT_CARD_EXP_MONTH: @@ -675,8 +689,12 @@ std::string AutofillType::ToString() const { return "HTML_TYPE_POSTAL_CODE"; case HTML_TYPE_FULL_ADDRESS: return "HTML_TYPE_FULL_ADDRESS"; - case HTML_TYPE_CREDIT_CARD_NAME: - return "HTML_TYPE_CREDIT_CARD_NAME"; + case HTML_TYPE_CREDIT_CARD_NAME_FULL: + return "HTML_TYPE_CREDIT_CARD_NAME_FULL"; + case HTML_TYPE_CREDIT_CARD_NAME_FIRST: + return "HTML_TYPE_CREDIT_CARD_NAME_FIRST"; + case HTML_TYPE_CREDIT_CARD_NAME_LAST: + return "HTML_TYPE_CREDIT_CARD_NAME_LAST"; case HTML_TYPE_CREDIT_CARD_NUMBER: return "HTML_TYPE_CREDIT_CARD_NUMBER"; case HTML_TYPE_CREDIT_CARD_EXP: diff --git a/components/autofill/core/browser/contact_info.cc b/components/autofill/core/browser/contact_info.cc index 9e793b9..8db9fc5 100644 --- a/components/autofill/core/browser/contact_info.cc +++ b/components/autofill/core/browser/contact_info.cc @@ -10,138 +10,14 @@ #include "base/logging.h" #include "base/macros.h" -#include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "components/autofill/core/browser/autofill_data_util.h" #include "components/autofill/core/browser/autofill_type.h" #include "components/autofill/core/common/autofill_l10n_util.h" namespace autofill { -namespace { - -const char* const name_prefixes[] = { - "1lt", "1st", "2lt", "2nd", "3rd", "admiral", "capt", "captain", "col", - "cpt", "dr", "gen", "general", "lcdr", "lt", "ltc", "ltg", "ltjg", "maj", - "major", "mg", "mr", "mrs", "ms", "pastor", "prof", "rep", "reverend", - "rev", "sen", "st" }; - -const char* const name_suffixes[] = { - "b.a", "ba", "d.d.s", "dds", "i", "ii", "iii", "iv", "ix", "jr", "m.a", - "m.d", "ma", "md", "ms", "ph.d", "phd", "sr", "v", "vi", "vii", "viii", - "x" }; - -const char* const family_name_prefixes[] = { - "d'", "de", "del", "der", "di", "la", "le", "mc", "san", "st", "ter", - "van", "von" }; - -// Returns true if |set| contains |element|, modulo a final period. -bool ContainsString(const char* const set[], - size_t set_size, - const base::string16& element) { - if (!base::IsStringASCII(element)) - return false; - - base::string16 trimmed_element; - base::TrimString(element, base::ASCIIToUTF16("."), &trimmed_element); - - for (size_t i = 0; i < set_size; ++i) { - if (base::LowerCaseEqualsASCII(trimmed_element, set[i])) - return true; - } - - return false; -} - -// Removes common name prefixes from |name_tokens|. -void StripPrefixes(std::vector<base::string16>* name_tokens) { - std::vector<base::string16>::iterator iter = name_tokens->begin(); - while(iter != name_tokens->end()) { - if (!ContainsString(name_prefixes, arraysize(name_prefixes), *iter)) - break; - ++iter; - } - - std::vector<base::string16> copy_vector; - copy_vector.assign(iter, name_tokens->end()); - *name_tokens = copy_vector; -} - -// Removes common name suffixes from |name_tokens|. -void StripSuffixes(std::vector<base::string16>* name_tokens) { - while(!name_tokens->empty()) { - if (!ContainsString(name_suffixes, arraysize(name_suffixes), - name_tokens->back())) { - break; - } - name_tokens->pop_back(); - } -} - -struct NameParts { - base::string16 given; - base::string16 middle; - base::string16 family; -}; - -// TODO(estade): This does Western name splitting. It should do different -// splitting based on the app locale. -NameParts SplitName(const base::string16& name) { - std::vector<base::string16> name_tokens = base::SplitString( - name, base::ASCIIToUTF16(" ,"), base::KEEP_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - StripPrefixes(&name_tokens); - - // Don't assume "Ma" is a suffix in John Ma. - if (name_tokens.size() > 2) - StripSuffixes(&name_tokens); - - NameParts parts; - - if (name_tokens.empty()) { - // Bad things have happened; just assume the whole thing is a given name. - parts.given = name; - return parts; - } - - // Only one token, assume given name. - if (name_tokens.size() == 1) { - parts.given = name_tokens[0]; - return parts; - } - - // 2 or more tokens. Grab the family, which is the last word plus any - // recognizable family prefixes. - std::vector<base::string16> reverse_family_tokens; - reverse_family_tokens.push_back(name_tokens.back()); - name_tokens.pop_back(); - while (name_tokens.size() >= 1 && - ContainsString(family_name_prefixes, - arraysize(family_name_prefixes), - name_tokens.back())) { - reverse_family_tokens.push_back(name_tokens.back()); - name_tokens.pop_back(); - } - - std::vector<base::string16> family_tokens(reverse_family_tokens.rbegin(), - reverse_family_tokens.rend()); - parts.family = base::JoinString(family_tokens, base::ASCIIToUTF16(" ")); - - // Take the last remaining token as the middle name (if there are at least 2 - // tokens). - if (name_tokens.size() >= 2) { - parts.middle = name_tokens.back(); - name_tokens.pop_back(); - } - - // Remainder is given name. - parts.given = base::JoinString(name_tokens, base::ASCIIToUTF16(" ")); - - return parts; -} - -} // namespace - NameInfo::NameInfo() {} NameInfo::NameInfo(const NameInfo& info) : FormGroup() { @@ -283,7 +159,7 @@ void NameInfo::SetFullName(const base::string16& full) { if (full.empty()) return; - NameParts parts = SplitName(full); + data_util::NameParts parts = data_util::SplitName(full); given_ = parts.given; middle_ = parts.middle; family_ = parts.family; diff --git a/components/autofill/core/browser/credit_card.cc b/components/autofill/core/browser/credit_card.cc index 9083b40..29f0101 100644 --- a/components/autofill/core/browser/credit_card.cc +++ b/components/autofill/core/browser/credit_card.cc @@ -22,6 +22,7 @@ #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" #include "build/build_config.h" +#include "components/autofill/core/browser/autofill_data_util.h" #include "components/autofill/core/browser/autofill_field.h" #include "components/autofill/core/browser/autofill_type.h" #include "components/autofill/core/browser/validation.h" @@ -264,9 +265,15 @@ CreditCard::ServerStatus CreditCard::GetServerStatus() const { base::string16 CreditCard::GetRawInfo(ServerFieldType type) const { DCHECK_EQ(CREDIT_CARD, AutofillType(type).group()); switch (type) { - case CREDIT_CARD_NAME: + case CREDIT_CARD_NAME_FULL: return name_on_card_; + case CREDIT_CARD_NAME_FIRST: + return data_util::SplitName(name_on_card_).given; + + case CREDIT_CARD_NAME_LAST: + return data_util::SplitName(name_on_card_).family; + case CREDIT_CARD_EXP_MONTH: return ExpirationMonthAsString(); @@ -312,7 +319,7 @@ void CreditCard::SetRawInfo(ServerFieldType type, const base::string16& value) { DCHECK_EQ(CREDIT_CARD, AutofillType(type).group()); switch (type) { - case CREDIT_CARD_NAME: + case CREDIT_CARD_NAME_FULL: name_on_card_ = value; break; @@ -552,10 +559,9 @@ int CreditCard::Compare(const CreditCard& credit_card) const { // The following CreditCard field types are the only types we store in the // WebDB so far, so we're only concerned with matching these types in the // credit card. - const ServerFieldType types[] = { CREDIT_CARD_NAME, - CREDIT_CARD_NUMBER, - CREDIT_CARD_EXP_MONTH, - CREDIT_CARD_EXP_4_DIGIT_YEAR }; + const ServerFieldType types[] = {CREDIT_CARD_NAME_FULL, CREDIT_CARD_NUMBER, + CREDIT_CARD_EXP_MONTH, + CREDIT_CARD_EXP_4_DIGIT_YEAR}; for (size_t i = 0; i < arraysize(types); ++i) { int comparison = GetRawInfo(types[i]).compare(credit_card.GetRawInfo(types[i])); @@ -633,8 +639,9 @@ bool CreditCard::IsValid() const { expiration_year_, expiration_month_, base::Time::Now()); } +// TODO(crbug.com/589536): Upload new credit card types to the server. void CreditCard::GetSupportedTypes(ServerFieldTypeSet* supported_types) const { - supported_types->insert(CREDIT_CARD_NAME); + supported_types->insert(CREDIT_CARD_NAME_FULL); supported_types->insert(CREDIT_CARD_NUMBER); supported_types->insert(CREDIT_CARD_TYPE); supported_types->insert(CREDIT_CARD_EXP_MONTH); @@ -763,23 +770,17 @@ bool CreditCard::ConvertMonth(const base::string16& month, // So we can compare CreditCards with EXPECT_EQ(). std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card) { - return os - << base::UTF16ToUTF8(credit_card.Label()) - << " " - << credit_card.guid() - << " " - << credit_card.origin() - << " " - << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NAME)) - << " " - << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_TYPE)) - << " " - << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NUMBER)) - << " " - << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_EXP_MONTH)) - << " " - << base::UTF16ToUTF8( - credit_card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); + return os << base::UTF16ToUTF8(credit_card.Label()) << " " + << credit_card.guid() << " " << credit_card.origin() << " " + << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NAME_FULL)) + << " " + << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_TYPE)) + << " " + << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NUMBER)) + << " " + << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_EXP_MONTH)) + << " " << base::UTF16ToUTF8( + credit_card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); } // These values must match the values in WebKitPlatformSupportImpl in diff --git a/components/autofill/core/browser/credit_card_field.cc b/components/autofill/core/browser/credit_card_field.cc index 89d3563..871dcbb 100644 --- a/components/autofill/core/browser/credit_card_field.cc +++ b/components/autofill/core/browser/credit_card_field.cc @@ -111,6 +111,16 @@ scoped_ptr<FormField> CreditCardField::Parse(AutofillScanner* scanner) { &credit_card_field->cardholder_)) { continue; } + } else if (!credit_card_field->cardholder_last_) { + // Search for a last name. Since this is a dangerously generic search, we + // execute it only after we have found a valid credit card (first) name + // 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), + &credit_card_field->cardholder_last_)) { + continue; + } } // Check for a credit card type (Visa, MasterCard, etc.) field. @@ -328,9 +338,15 @@ void CreditCardField::AddClassifications( // then ignore both fields. Putting them into separate fields is probably // wrong, because the credit card can also contain a middle name or middle // initial. - if (cardholder_last_ == nullptr) - AddClassification(cardholder_, CREDIT_CARD_NAME, kBaseCreditCardParserScore, - field_candidates); + if (cardholder_last_ == nullptr) { + AddClassification(cardholder_, CREDIT_CARD_NAME_FULL, + kBaseCreditCardParserScore, field_candidates); + } else { + AddClassification(cardholder_, CREDIT_CARD_NAME_FIRST, + kBaseCreditCardParserScore, field_candidates); + AddClassification(cardholder_last_, CREDIT_CARD_NAME_LAST, + kBaseCreditCardParserScore, field_candidates); + } if (expiration_date_) { DCHECK(!expiration_month_); diff --git a/components/autofill/core/browser/credit_card_field_unittest.cc b/components/autofill/core/browser/credit_card_field_unittest.cc index a68c668..263505f 100644 --- a/components/autofill/core/browser/credit_card_field_unittest.cc +++ b/components/autofill/core/browser/credit_card_field_unittest.cc @@ -156,7 +156,7 @@ TEST_F(CreditCardFieldTest, ParseFullCreditCard) { field_candidates_map_[ASCIIToUTF16("type")].BestHeuristicType()); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("name")) != field_candidates_map_.end()); - EXPECT_EQ(CREDIT_CARD_NAME, + EXPECT_EQ(CREDIT_CARD_NAME_FULL, field_candidates_map_[ASCIIToUTF16("name")].BestHeuristicType()); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("number")) != field_candidates_map_.end()); @@ -201,7 +201,7 @@ TEST_F(CreditCardFieldTest, ParseExpMonthYear) { AddClassifications(); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("name1")) != field_candidates_map_.end()); - EXPECT_EQ(CREDIT_CARD_NAME, + EXPECT_EQ(CREDIT_CARD_NAME_FULL, field_candidates_map_[ASCIIToUTF16("name1")].BestHeuristicType()); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("number2")) != field_candidates_map_.end()); @@ -242,7 +242,7 @@ TEST_F(CreditCardFieldTest, ParseExpMonthYear2) { AddClassifications(); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("name1")) != field_candidates_map_.end()); - EXPECT_EQ(CREDIT_CARD_NAME, + EXPECT_EQ(CREDIT_CARD_NAME_FULL, field_candidates_map_[ASCIIToUTF16("name1")].BestHeuristicType()); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("number2")) != field_candidates_map_.end()); @@ -279,7 +279,7 @@ TEST_F(CreditCardFieldTest, ParseExpField) { AddClassifications(); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("name1")) != field_candidates_map_.end()); - EXPECT_EQ(CREDIT_CARD_NAME, + EXPECT_EQ(CREDIT_CARD_NAME_FULL, field_candidates_map_[ASCIIToUTF16("name1")].BestHeuristicType()); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("number2")) != field_candidates_map_.end()); @@ -312,7 +312,7 @@ TEST_F(CreditCardFieldTest, ParseExpField2DigitYear) { AddClassifications(); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("name1")) != field_candidates_map_.end()); - EXPECT_EQ(CREDIT_CARD_NAME, + EXPECT_EQ(CREDIT_CARD_NAME_FULL, field_candidates_map_[ASCIIToUTF16("name1")].BestHeuristicType()); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("number2")) != field_candidates_map_.end()); @@ -346,7 +346,7 @@ TEST_F(CreditCardFieldTest, ParseExpField2DigitYearDueToMaxLength) { AddClassifications(); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("name1")) != field_candidates_map_.end()); - EXPECT_EQ(CREDIT_CARD_NAME, + EXPECT_EQ(CREDIT_CARD_NAME_FULL, field_candidates_map_[ASCIIToUTF16("name1")].BestHeuristicType()); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("number2")) != field_candidates_map_.end()); @@ -379,7 +379,7 @@ TEST_F(CreditCardFieldTest, ParseExpField4DigitYear) { AddClassifications(); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("name1")) != field_candidates_map_.end()); - EXPECT_EQ(CREDIT_CARD_NAME, + EXPECT_EQ(CREDIT_CARD_NAME_FULL, field_candidates_map_[ASCIIToUTF16("name1")].BestHeuristicType()); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("number2")) != field_candidates_map_.end()); @@ -404,7 +404,7 @@ TEST_F(CreditCardFieldTest, ParseCreditCardHolderNameWithCCFullName) { AddClassifications(); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("name1")) != field_candidates_map_.end()); - EXPECT_EQ(CREDIT_CARD_NAME, + EXPECT_EQ(CREDIT_CARD_NAME_FULL, field_candidates_map_[ASCIIToUTF16("name1")].BestHeuristicType()); } @@ -573,7 +573,7 @@ TEST_F(CreditCardFieldTest, ParseMultipleCreditCardNumbers) { ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("name1")) != field_candidates_map_.end()); - EXPECT_EQ(CREDIT_CARD_NAME, + EXPECT_EQ(CREDIT_CARD_NAME_FULL, field_candidates_map_[ASCIIToUTF16("name1")].BestHeuristicType()); ASSERT_TRUE(field_candidates_map_.find(ASCIIToUTF16("number2")) != field_candidates_map_.end()); diff --git a/components/autofill/core/browser/credit_card_unittest.cc b/components/autofill/core/browser/credit_card_unittest.cc index 135d487..10fa35f 100644 --- a/components/autofill/core/browser/credit_card_unittest.cc +++ b/components/autofill/core/browser/credit_card_unittest.cc @@ -301,23 +301,24 @@ TEST(CreditCardTest, UpdateFromImportedCard) { CreditCard b = a; b.set_guid(base::GenerateGUID()); b.set_origin("https://www.example.org"); - b.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("J. Dillinger")); + 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("2019")); EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US")); EXPECT_EQ("https://www.example.org", a.origin()); - EXPECT_EQ(ASCIIToUTF16("J. Dillinger"), a.GetRawInfo(CREDIT_CARD_NAME)); + EXPECT_EQ(ASCIIToUTF16("J. Dillinger"), a.GetRawInfo(CREDIT_CARD_NAME_FULL)); EXPECT_EQ(ASCIIToUTF16("08"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH)); EXPECT_EQ(ASCIIToUTF16("2019"), a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); // Try again, but with no name set for |b|. a = original_card; - b.SetRawInfo(CREDIT_CARD_NAME, base::string16()); + b.SetRawInfo(CREDIT_CARD_NAME_FULL, base::string16()); EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US")); EXPECT_EQ("https://www.example.org", a.origin()); - EXPECT_EQ(ASCIIToUTF16("John Dillinger"), a.GetRawInfo(CREDIT_CARD_NAME)); + EXPECT_EQ(ASCIIToUTF16("John Dillinger"), + a.GetRawInfo(CREDIT_CARD_NAME_FULL)); EXPECT_EQ(ASCIIToUTF16("08"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH)); EXPECT_EQ(ASCIIToUTF16("2019"), a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); @@ -325,11 +326,12 @@ TEST(CreditCardTest, UpdateFromImportedCard) { // |a| should be unchanged. a = original_card; a.set_origin("Chrome settings"); - b.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("J. Dillinger")); + b.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("J. Dillinger")); EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US")); EXPECT_EQ("Chrome settings", a.origin()); - EXPECT_EQ(ASCIIToUTF16("John Dillinger"), a.GetRawInfo(CREDIT_CARD_NAME)); + 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)); @@ -339,7 +341,7 @@ TEST(CreditCardTest, UpdateFromImportedCard) { EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US")); EXPECT_EQ("Chrome settings", a.origin()); - EXPECT_EQ(ASCIIToUTF16("J. Dillinger"), a.GetRawInfo(CREDIT_CARD_NAME)); + EXPECT_EQ(ASCIIToUTF16("J. Dillinger"), a.GetRawInfo(CREDIT_CARD_NAME_FULL)); EXPECT_EQ(ASCIIToUTF16("08"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH)); EXPECT_EQ(ASCIIToUTF16("2019"), a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); @@ -350,7 +352,7 @@ TEST(CreditCardTest, UpdateFromImportedCard) { EXPECT_TRUE(a.UpdateFromImportedCard(b, "en-US")); EXPECT_EQ("Chrome settings", a.origin()); - EXPECT_EQ(ASCIIToUTF16("J. Dillinger"), a.GetRawInfo(CREDIT_CARD_NAME)); + EXPECT_EQ(ASCIIToUTF16("J. Dillinger"), a.GetRawInfo(CREDIT_CARD_NAME_FULL)); EXPECT_EQ(ASCIIToUTF16("08"), a.GetRawInfo(CREDIT_CARD_EXP_MONTH)); EXPECT_EQ(ASCIIToUTF16("2019"), a.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); @@ -366,7 +368,7 @@ TEST(CreditCardTest, UpdateFromImportedCard) { TEST(CreditCardTest, IsComplete) { CreditCard card(base::GenerateGUID(), "https://www.example.com/"); EXPECT_FALSE(card.IsComplete()); - card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Wally T. Walrus")); + card.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Wally T. Walrus")); EXPECT_FALSE(card.IsComplete()); card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("01")); EXPECT_FALSE(card.IsComplete()); diff --git a/components/autofill/core/browser/field_types.h b/components/autofill/core/browser/field_types.h index 4edce98..63410fe 100644 --- a/components/autofill/core/browser/field_types.h +++ b/components/autofill/core/browser/field_types.h @@ -72,7 +72,7 @@ enum ServerFieldType { // ADDRESS_SHIPPING values [44,50] are deprecated. - CREDIT_CARD_NAME = 51, + CREDIT_CARD_NAME_FULL = 51, CREDIT_CARD_NUMBER = 52, CREDIT_CARD_EXP_MONTH = 53, CREDIT_CARD_EXP_2_DIGIT_YEAR = 54, @@ -149,10 +149,14 @@ enum ServerFieldType { PROBABLY_NEW_PASSWORD = 89, NOT_NEW_PASSWORD = 90, + // Additional field types for credit card fields. + CREDIT_CARD_NAME_FIRST = 91, + CREDIT_CARD_NAME_LAST = 92, + // No new types can be added without a corresponding change to the Autofill // server. - MAX_VALID_FIELD_TYPE = 91, + MAX_VALID_FIELD_TYPE = 93, }; // The list of all HTML autocomplete field type hints supported by Chrome. @@ -184,7 +188,9 @@ enum HtmlFieldType { HTML_TYPE_FULL_ADDRESS, // The complete address, formatted for display. // Credit card types. - HTML_TYPE_CREDIT_CARD_NAME, + HTML_TYPE_CREDIT_CARD_NAME_FULL, + HTML_TYPE_CREDIT_CARD_NAME_FIRST, + HTML_TYPE_CREDIT_CARD_NAME_LAST, HTML_TYPE_CREDIT_CARD_NUMBER, HTML_TYPE_CREDIT_CARD_EXP, HTML_TYPE_CREDIT_CARD_EXP_MONTH, diff --git a/components/autofill/core/browser/form_structure.cc b/components/autofill/core/browser/form_structure.cc index 5260c12..2b1a312 100644 --- a/components/autofill/core/browser/form_structure.cc +++ b/components/autofill/core/browser/form_structure.cc @@ -209,7 +209,13 @@ HtmlFieldType FieldTypeFromAutocompleteAttributeValue( } if (autocomplete_attribute_value == "cc-name") - return HTML_TYPE_CREDIT_CARD_NAME; + return HTML_TYPE_CREDIT_CARD_NAME_FULL; + + if (autocomplete_attribute_value == "cc-given-name") + return HTML_TYPE_CREDIT_CARD_NAME_FIRST; + + if (autocomplete_attribute_value == "cc-family-name") + return HTML_TYPE_CREDIT_CARD_NAME_LAST; if (autocomplete_attribute_value == "cc-number") return HTML_TYPE_CREDIT_CARD_NUMBER; diff --git a/components/autofill/core/browser/form_structure_unittest.cc b/components/autofill/core/browser/form_structure_unittest.cc index 4162781..fcf555a 100644 --- a/components/autofill/core/browser/form_structure_unittest.cc +++ b/components/autofill/core/browser/form_structure_unittest.cc @@ -1280,7 +1280,7 @@ TEST_F(FormStructureTest, HeuristicsCreditCardInfo) { ASSERT_EQ(5U, form_structure->autofill_count()); // Credit card name. - EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(0)->heuristic_type()); + EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type()); // Credit card number. EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(1)->heuristic_type()); // Credit card expiration month. @@ -1340,7 +1340,7 @@ TEST_F(FormStructureTest, HeuristicsCreditCardInfoWithUnknownCardField) { ASSERT_EQ(5U, form_structure->autofill_count()); // Credit card name. - EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(0)->heuristic_type()); + EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type()); // Credit card type. This is an unknown type but related to the credit card. EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); // Credit card number. @@ -1703,7 +1703,7 @@ TEST_F(FormStructureTest, HeuristicsInfernoCC) { EXPECT_EQ(5U, form_structure->autofill_count()); // Name on Card. - EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(0)->heuristic_type()); + EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type()); // Address. EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(1)->heuristic_type()); // Card Number. @@ -1715,7 +1715,9 @@ TEST_F(FormStructureTest, HeuristicsInfernoCC) { form_structure->field(4)->heuristic_type()); } -TEST_F(FormStructureTest, CVCCodeClash) { +// Tests that the heuristics detect split credit card names if they appear in +// the middle of the form. +TEST_F(FormStructureTest, HeuristicsInferCCNames_NamesNotFirst) { scoped_ptr<FormStructure> form_structure; FormData form; @@ -1751,15 +1753,73 @@ TEST_F(FormStructureTest, CVCCodeClash) { EXPECT_TRUE(form_structure->IsAutofillable()); // Expect the correct number of fields. - EXPECT_EQ(6U, form_structure->field_count()); - EXPECT_EQ(6U, form_structure->autofill_count()); + ASSERT_EQ(6U, form_structure->field_count()); + ASSERT_EQ(6U, form_structure->autofill_count()); // Card Number. EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(0)->heuristic_type()); - // First name, taken as name on card. - EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(1)->heuristic_type()); - // Last name is picked up by the name parser. - EXPECT_EQ(NAME_LAST, form_structure->field(2)->heuristic_type()); + // First name. + EXPECT_EQ(CREDIT_CARD_NAME_FIRST, form_structure->field(1)->heuristic_type()); + // Last name. + EXPECT_EQ(CREDIT_CARD_NAME_LAST, form_structure->field(2)->heuristic_type()); + // Expiration Date. + EXPECT_EQ(CREDIT_CARD_EXP_MONTH, form_structure->field(3)->heuristic_type()); + // Expiration Year. + EXPECT_EQ(CREDIT_CARD_EXP_4_DIGIT_YEAR, + form_structure->field(4)->heuristic_type()); + // CVC code. + EXPECT_EQ(CREDIT_CARD_VERIFICATION_CODE, + form_structure->field(5)->heuristic_type()); +} + +// Tests that the heuristics detect split credit card names if they appear at +// the beginning of the form. The first name has to contains some credit card +// keyword. +TEST_F(FormStructureTest, HeuristicsInferCCNames_NamesFirst) { + scoped_ptr<FormStructure> form_structure; + FormData form; + + FormFieldData field; + field.form_control_type = "text"; + + field.label = ASCIIToUTF16("Cardholder Name"); + field.name = ASCIIToUTF16("cc_first_name"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Last name"); + field.name = ASCIIToUTF16("last_name"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Card number"); + field.name = ASCIIToUTF16("ccnumber"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Expiration date"); + field.name = ASCIIToUTF16("ccexpiresmonth"); + form.fields.push_back(field); + + field.label = base::string16(); + field.name = ASCIIToUTF16("ccexpiresyear"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("cvc number"); + field.name = ASCIIToUTF16("csc"); + form.fields.push_back(field); + + form_structure.reset(new FormStructure(form)); + form_structure->DetermineHeuristicTypes(); + EXPECT_TRUE(form_structure->IsAutofillable()); + + // Expect the correct number of fields. + ASSERT_EQ(6U, form_structure->field_count()); + ASSERT_EQ(6U, form_structure->autofill_count()); + + // First name. + EXPECT_EQ(CREDIT_CARD_NAME_FIRST, form_structure->field(0)->heuristic_type()); + // Last name. + EXPECT_EQ(CREDIT_CARD_NAME_LAST, form_structure->field(1)->heuristic_type()); + // Card Number. + EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(2)->heuristic_type()); // Expiration Date. EXPECT_EQ(CREDIT_CARD_EXP_MONTH, form_structure->field(3)->heuristic_type()); // Expiration Year. @@ -2753,7 +2813,7 @@ TEST_F(FormStructureTest, CheckDataPresence) { // datapresent should be "0000000000001fc0" == trimmmed(0x0000000000001fc0) == // 0b0000000000000000000000000000000000000000000000000001111111000000 // The set bits are: - // 51 == CREDIT_CARD_NAME + // 51 == CREDIT_CARD_NAME_FULL // 52 == CREDIT_CARD_NUMBER // 53 == CREDIT_CARD_EXP_MONTH // 54 == CREDIT_CARD_EXP_2_DIGIT_YEAR @@ -2761,7 +2821,7 @@ TEST_F(FormStructureTest, CheckDataPresence) { // 56 == CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR // 57 == CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR available_field_types.clear(); - available_field_types.insert(CREDIT_CARD_NAME); + available_field_types.insert(CREDIT_CARD_NAME_FULL); available_field_types.insert(CREDIT_CARD_NUMBER); available_field_types.insert(CREDIT_CARD_EXP_MONTH); available_field_types.insert(CREDIT_CARD_EXP_2_DIGIT_YEAR); @@ -2801,7 +2861,7 @@ TEST_F(FormStructureTest, CheckDataPresence) { // 34 == ADDRESS_HOME_STATE // 35 == ADDRESS_HOME_ZIP // 36 == ADDRESS_HOME_COUNTRY - // 51 == CREDIT_CARD_NAME + // 51 == CREDIT_CARD_NAME_FULL // 52 == CREDIT_CARD_NUMBER // 53 == CREDIT_CARD_EXP_MONTH // 54 == CREDIT_CARD_EXP_2_DIGIT_YEAR @@ -2827,7 +2887,7 @@ TEST_F(FormStructureTest, CheckDataPresence) { available_field_types.insert(ADDRESS_HOME_STATE); available_field_types.insert(ADDRESS_HOME_ZIP); available_field_types.insert(ADDRESS_HOME_COUNTRY); - available_field_types.insert(CREDIT_CARD_NAME); + available_field_types.insert(CREDIT_CARD_NAME_FULL); available_field_types.insert(CREDIT_CARD_NUMBER); available_field_types.insert(CREDIT_CARD_EXP_MONTH); available_field_types.insert(CREDIT_CARD_EXP_2_DIGIT_YEAR); diff --git a/components/autofill/core/browser/payments/payments_client.cc b/components/autofill/core/browser/payments/payments_client.cc index 24c9207..27694ad 100644 --- a/components/autofill/core/browser/payments/payments_client.cc +++ b/components/autofill/core/browser/payments/payments_client.cc @@ -294,9 +294,10 @@ class UploadCardRequest : public PaymentsRequest { context->SetString("language_code", app_locale); request_dict.Set("context", std::move(context)); - request_dict.SetString("cardholder_name", - request_details_.card.GetInfo( - AutofillType(CREDIT_CARD_NAME), app_locale)); + request_dict.SetString( + "cardholder_name", + request_details_.card.GetInfo(AutofillType(CREDIT_CARD_NAME_FULL), + app_locale)); scoped_ptr<base::ListValue> addresses(new base::ListValue()); for (const AutofillProfile& profile : request_details_.profiles) { diff --git a/components/autofill/core/browser/personal_data_manager.cc b/components/autofill/core/browser/personal_data_manager.cc index d2e69a1..3ef8d1d 100644 --- a/components/autofill/core/browser/personal_data_manager.cc +++ b/components/autofill/core/browser/personal_data_manager.cc @@ -820,9 +820,9 @@ std::vector<Suggestion> PersonalDataManager::GetCreditCardSuggestions( suggestion->label = credit_card->GetInfo( AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); } else if (credit_card->number().empty()) { - if (type.GetStorableType() != CREDIT_CARD_NAME) { - suggestion->label = - credit_card->GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_); + if (type.GetStorableType() != CREDIT_CARD_NAME_FULL) { + suggestion->label = credit_card->GetInfo( + AutofillType(CREDIT_CARD_NAME_FULL), app_locale_); } } else { #if defined(OS_ANDROID) diff --git a/components/autofill/core/browser/personal_data_manager_unittest.cc b/components/autofill/core/browser/personal_data_manager_unittest.cc index 28deb80..9964f7a 100644 --- a/components/autofill/core/browser/personal_data_manager_unittest.cc +++ b/components/autofill/core/browser/personal_data_manager_unittest.cc @@ -501,7 +501,7 @@ TEST_F(PersonalDataManagerTest, AddUpdateRemoveCreditCards) { ExpectSameElements(cards, personal_data_->GetCreditCards()); // Update, remove, and add. - credit_card0.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Joe")); + credit_card0.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Joe")); personal_data_->UpdateCreditCard(credit_card0); personal_data_->RemoveByGUID(credit_card1.guid()); personal_data_->AddCreditCard(credit_card2); @@ -585,7 +585,7 @@ TEST_F(PersonalDataManagerTest, UpdateUnverifiedProfilesAndCreditCards) { // Try to update with data changed as well. profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); - credit_card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Joe")); + credit_card.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Joe")); personal_data_->UpdateProfile(profile); personal_data_->UpdateCreditCard(credit_card); @@ -839,17 +839,17 @@ TEST_F(PersonalDataManagerTest, PopulateUniqueIDsOnLoad) { TEST_F(PersonalDataManagerTest, SetUniqueCreditCardLabels) { CreditCard credit_card0(base::GenerateGUID(), "https://www.example.com"); - credit_card0.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("John")); + credit_card0.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("John")); CreditCard credit_card1(base::GenerateGUID(), "https://www.example.com"); - credit_card1.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Paul")); + credit_card1.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Paul")); CreditCard credit_card2(base::GenerateGUID(), "https://www.example.com"); - credit_card2.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Ringo")); + credit_card2.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Ringo")); CreditCard credit_card3(base::GenerateGUID(), "https://www.example.com"); - credit_card3.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Other")); + credit_card3.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Other")); CreditCard credit_card4(base::GenerateGUID(), "https://www.example.com"); - credit_card4.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Ozzy")); + credit_card4.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Ozzy")); CreditCard credit_card5(base::GenerateGUID(), "https://www.example.com"); - credit_card5.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Dio")); + credit_card5.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Dio")); // Add the test credit cards to the database. personal_data_->AddCreditCard(credit_card0); @@ -2520,7 +2520,7 @@ TEST_F(PersonalDataManagerTest, SaveImportedCreditCardWithVerifiedData) { CreditCard new_verified_card = credit_card; new_verified_card.set_guid(base::GenerateGUID()); - new_verified_card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("B. Small")); + new_verified_card.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("B. Small")); EXPECT_TRUE(new_verified_card.IsVerified()); personal_data_->SaveImportedCreditCard(new_verified_card); @@ -2533,7 +2533,8 @@ TEST_F(PersonalDataManagerTest, SaveImportedCreditCardWithVerifiedData) { // Expect that the saved credit card is updated. const std::vector<CreditCard*>& results = personal_data_->GetCreditCards(); ASSERT_EQ(1U, results.size()); - EXPECT_EQ(ASCIIToUTF16("B. Small"), results[0]->GetRawInfo(CREDIT_CARD_NAME)); + EXPECT_EQ(ASCIIToUTF16("B. Small"), + results[0]->GetRawInfo(CREDIT_CARD_NAME_FULL)); } TEST_F(PersonalDataManagerTest, GetNonEmptyTypes) { @@ -2650,7 +2651,7 @@ TEST_F(PersonalDataManagerTest, GetNonEmptyTypes) { EXPECT_TRUE(non_empty_types.count(PHONE_HOME_COUNTRY_CODE)); EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_AND_NUMBER)); EXPECT_TRUE(non_empty_types.count(PHONE_HOME_WHOLE_NUMBER)); - EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NAME)); + EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NAME_FULL)); EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NUMBER)); EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_TYPE)); EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_MONTH)); @@ -2700,27 +2701,29 @@ TEST_F(PersonalDataManagerTest, IncognitoReadOnly) { steve_jobs.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Steve")); personal_data_->SaveImportedProfile(steve_jobs); - bill_gates.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Bill Gates")); + bill_gates.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Bill Gates")); personal_data_->SaveImportedCreditCard(bill_gates); ResetPersonalDataManager(USER_MODE_INCOGNITO); EXPECT_EQ(ASCIIToUTF16("Steven"), personal_data_->GetProfiles()[0]->GetRawInfo(NAME_FIRST)); - EXPECT_EQ(ASCIIToUTF16("William H. Gates"), - personal_data_->GetCreditCards()[0]->GetRawInfo(CREDIT_CARD_NAME)); + EXPECT_EQ( + ASCIIToUTF16("William H. Gates"), + personal_data_->GetCreditCards()[0]->GetRawInfo(CREDIT_CARD_NAME_FULL)); // Updating existing profiles shouldn't work. steve_jobs.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Steve")); personal_data_->UpdateProfile(steve_jobs); - bill_gates.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Bill Gates")); + bill_gates.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Bill Gates")); personal_data_->UpdateCreditCard(bill_gates); ResetPersonalDataManager(USER_MODE_INCOGNITO); EXPECT_EQ(ASCIIToUTF16("Steven"), personal_data_->GetProfiles()[0]->GetRawInfo(NAME_FIRST)); - EXPECT_EQ(ASCIIToUTF16("William H. Gates"), - personal_data_->GetCreditCards()[0]->GetRawInfo(CREDIT_CARD_NAME)); + EXPECT_EQ( + ASCIIToUTF16("William H. Gates"), + personal_data_->GetCreditCards()[0]->GetRawInfo(CREDIT_CARD_NAME_FULL)); // Removing shouldn't work. personal_data_->RemoveByGUID(steve_jobs.guid()); @@ -3025,7 +3028,7 @@ TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_LocalCardsRanking) { // the platform, but the last 4 digits should appear). std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( - AutofillType(CREDIT_CARD_NAME), + AutofillType(CREDIT_CARD_NAME_FULL), /* field_contents= */ base::string16()); ASSERT_EQ(3U, suggestions.size()); @@ -3072,7 +3075,7 @@ TEST_F(PersonalDataManagerTest, std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( - AutofillType(CREDIT_CARD_NAME), + AutofillType(CREDIT_CARD_NAME_FULL), /* field_contents= */ base::string16()); ASSERT_EQ(5U, suggestions.size()); @@ -3171,7 +3174,7 @@ TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_ServerDuplicates) { std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( - AutofillType(CREDIT_CARD_NAME), + AutofillType(CREDIT_CARD_NAME_FULL), /* field_contents= */ base::string16()); ASSERT_EQ(4U, suggestions.size()); EXPECT_EQ(ASCIIToUTF16("John Dillinger"), suggestions[0].value); @@ -3218,7 +3221,7 @@ TEST_F(PersonalDataManagerTest, std::vector<Suggestion> suggestions = personal_data_->GetCreditCardSuggestions( - AutofillType(CREDIT_CARD_NAME), + AutofillType(CREDIT_CARD_NAME_FULL), /* field_contents= */ base::string16()); ASSERT_EQ(3U, suggestions.size()); @@ -3234,7 +3237,8 @@ TEST_F(PersonalDataManagerTest, base::MessageLoop::current()->Run(); suggestions = personal_data_->GetCreditCardSuggestions( - AutofillType(CREDIT_CARD_NAME), /* field_contents= */ base::string16()); + AutofillType(CREDIT_CARD_NAME_FULL), + /* field_contents= */ base::string16()); ASSERT_EQ(3U, suggestions.size()); } diff --git a/components/autofill/core/browser/server_field_types_util.cc b/components/autofill/core/browser/server_field_types_util.cc index 1d004f5..6d27d3e 100644 --- a/components/autofill/core/browser/server_field_types_util.cc +++ b/components/autofill/core/browser/server_field_types_util.cc @@ -51,7 +51,7 @@ bool ServerTypeMatchesField(DialogSection section, AutofillType field_type = field.Type(); // The credit card name is filled from the billing section's data. - if (field_type.GetStorableType() == CREDIT_CARD_NAME && + if (field_type.GetStorableType() == CREDIT_CARD_NAME_FULL && section == SECTION_BILLING) { return type == NAME_BILLING_FULL; } diff --git a/components/autofill/core/browser/webdata/autofill_table.cc b/components/autofill/core/browser/webdata/autofill_table.cc index 07a291c..2b40540 100644 --- a/components/autofill/core/browser/webdata/autofill_table.cc +++ b/components/autofill/core/browser/webdata/autofill_table.cc @@ -140,7 +140,7 @@ void BindCreditCardToStatement(const CreditCard& credit_card, int index = 0; s->BindString(index++, credit_card.guid()); - s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_NAME)); + s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_NAME_FULL)); s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_EXP_MONTH)); s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR)); BindEncryptedCardToColumn(s, index++, @@ -173,7 +173,7 @@ scoped_ptr<CreditCard> CreditCardFromStatement(const sql::Statement& s) { credit_card->set_guid(s.ColumnString(index++)); DCHECK(base::IsValidGUID(credit_card->guid())); - credit_card->SetRawInfo(CREDIT_CARD_NAME, s.ColumnString16(index++)); + credit_card->SetRawInfo(CREDIT_CARD_NAME_FULL, s.ColumnString16(index++)); credit_card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++)); credit_card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(index++)); @@ -1228,7 +1228,7 @@ bool AutofillTable::GetServerCreditCards( } card->SetServerStatus(ServerStatusStringToEnum(s.ColumnString(index++))); - card->SetRawInfo(CREDIT_CARD_NAME, s.ColumnString16(index++)); + card->SetRawInfo(CREDIT_CARD_NAME_FULL, s.ColumnString16(index++)); card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++)); card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(index++)); credit_cards->push_back(card); @@ -1265,7 +1265,7 @@ void AutofillTable::SetServerCreditCards( masked_insert.BindString(1, card.type()); masked_insert.BindString(2, ServerStatusEnumToString(card.GetServerStatus())); - masked_insert.BindString16(3, card.GetRawInfo(CREDIT_CARD_NAME)); + masked_insert.BindString16(3, card.GetRawInfo(CREDIT_CARD_NAME_FULL)); masked_insert.BindString16(4, card.LastFourDigits()); masked_insert.BindString16(5, card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); masked_insert.BindString16(6, diff --git a/components/autofill/core/browser/webdata/autofill_table_unittest.cc b/components/autofill/core/browser/webdata/autofill_table_unittest.cc index 8d36d58..e81c82a 100644 --- a/components/autofill/core/browser/webdata/autofill_table_unittest.cc +++ b/components/autofill/core/browser/webdata/autofill_table_unittest.cc @@ -914,7 +914,8 @@ 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, ASCIIToUTF16("Jack Torrance")); + 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")); @@ -944,7 +945,8 @@ TEST_F(AutofillTableTest, CreditCard) { // Add a 'Target' credit card. CreditCard target_creditcard; target_creditcard.set_origin(std::string()); - target_creditcard.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Jack Torrance")); + 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")); @@ -970,7 +972,8 @@ TEST_F(AutofillTableTest, CreditCard) { // Update the 'Target' credit card. target_creditcard.set_origin("Interactive Autofill dialog"); - target_creditcard.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Charles Grady")); + target_creditcard.SetRawInfo(CREDIT_CARD_NAME_FULL, + ASCIIToUTF16("Charles Grady")); Time pre_modification_time = Time::Now(); EXPECT_TRUE(table_->UpdateCreditCard(target_creditcard)); Time post_modification_time = Time::Now(); @@ -1077,7 +1080,7 @@ TEST_F(AutofillTableTest, UpdateAutofillProfile) { TEST_F(AutofillTableTest, UpdateCreditCard) { // Add a credit card to the db. CreditCard credit_card; - credit_card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Jack Torrance")); + 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")); @@ -1203,7 +1206,7 @@ TEST_F(AutofillTableTest, UpdateProfileOriginOnly) { TEST_F(AutofillTableTest, UpdateCreditCardOriginOnly) { // Add a credit card to the db. CreditCard credit_card; - credit_card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Jack Torrance")); + 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")); @@ -1563,14 +1566,14 @@ TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_TwoSame) { TEST_F(AutofillTableTest, SetGetServerCards) { std::vector<CreditCard> inputs; inputs.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "a123")); - inputs[0].SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Paul F. Tompkins")); + 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.push_back( CreditCard(CreditCard::MASKED_SERVER_CARD, "b456")); - inputs[1].SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Rick Roman")); + 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")); @@ -1608,7 +1611,7 @@ TEST_F(AutofillTableTest, MaskUnmaskServerCards) { base::string16 masked_number(ASCIIToUTF16("1111")); std::vector<CreditCard> inputs; inputs.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "a123")); - inputs[0].SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Jay Johnson")); + 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_NUMBER, masked_number); @@ -1645,7 +1648,8 @@ 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, ASCIIToUTF16("Paul F. Tompkins")); + 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")); @@ -1684,7 +1688,7 @@ 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, ASCIIToUTF16("Rick Roman")); + 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")); @@ -1719,7 +1723,8 @@ TEST_F(AutofillTableTest, SetServerCardModify) { TEST_F(AutofillTableTest, SetServerCardUpdateUsageStats) { // Add a masked card. CreditCard masked_card(CreditCard::MASKED_SERVER_CARD, "a123"); - masked_card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Paul F. Tompkins")); + 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")); @@ -1857,7 +1862,8 @@ TEST_F(AutofillTableTest, DeleteUnmaskedCard) { // Add a masked card. base::string16 masked_number = ASCIIToUTF16("1111"); CreditCard masked_card(CreditCard::MASKED_SERVER_CARD, "a123"); - masked_card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Paul F. Tompkins")); + 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, masked_number); diff --git a/components/autofill/core/browser/webdata/autofill_wallet_syncable_service.cc b/components/autofill/core/browser/webdata/autofill_wallet_syncable_service.cc index 56d54b1..ae584e7 100644 --- a/components/autofill/core/browser/webdata/autofill_wallet_syncable_service.cc +++ b/components/autofill/core/browser/webdata/autofill_wallet_syncable_service.cc @@ -70,7 +70,8 @@ CreditCard CardFromSpecifics(const sync_pb::WalletMaskedCreditCard& card) { result.SetNumber(base::UTF8ToUTF16(card.last_four())); result.SetServerStatus(ServerToLocalStatus(card.status())); result.SetTypeForMaskedCard(CardTypeFromWalletCardType(card.type())); - result.SetRawInfo(CREDIT_CARD_NAME, base::UTF8ToUTF16(card.name_on_card())); + result.SetRawInfo(CREDIT_CARD_NAME_FULL, + base::UTF8ToUTF16(card.name_on_card())); result.SetExpirationMonth(card.exp_month()); result.SetExpirationYear(card.exp_year()); return result; diff --git a/components/autofill/core/browser/webdata/web_data_service_unittest.cc b/components/autofill/core/browser/webdata/web_data_service_unittest.cc index 26c5b64..87545b4 100644 --- a/components/autofill/core/browser/webdata/web_data_service_unittest.cc +++ b/components/autofill/core/browser/webdata/web_data_service_unittest.cc @@ -440,10 +440,10 @@ TEST_F(WebDataServiceAutofillTest, CreditCardRemove) { TEST_F(WebDataServiceAutofillTest, CreditUpdate) { CreditCard card1("E4D2662E-5E16-44F3-AF5A-5A77FAE4A6F3", "https://ejemplo.mx"); - card1.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Abe")); + card1.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Abe")); CreditCard card2("B9C52112-BD5F-4080-84E1-C651D2CB90E2", "https://example.com"); - card2.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Alice")); + card2.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Alice")); wds_->AddCreditCard(card1); wds_->AddCreditCard(card2); @@ -460,7 +460,7 @@ TEST_F(WebDataServiceAutofillTest, CreditUpdate) { STLDeleteElements(&consumer.result()); CreditCard card2_changed(card2); - card2_changed.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Bill")); + card2_changed.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Bill")); wds_->UpdateCreditCard(card2_changed); WaitForDatabaseThread(); diff --git a/components/autofill/ios/browser/credit_card_util.mm b/components/autofill/ios/browser/credit_card_util.mm index 8d4d625..e62b9e8 100644 --- a/components/autofill/ios/browser/credit_card_util.mm +++ b/components/autofill/ios/browser/credit_card_util.mm @@ -13,7 +13,7 @@ namespace autofill { NSString* GetCreditCardName(const CreditCard& credit_card, const std::string& locale) { return base::SysUTF16ToNSString(credit_card.GetInfo( - autofill::AutofillType(autofill::CREDIT_CARD_NAME), locale)); + autofill::AutofillType(autofill::CREDIT_CARD_NAME_FULL), locale)); } NSString* GetCreditCardObfuscatedNumber(const CreditCard& credit_card) { diff --git a/components/components_tests.gyp b/components/components_tests.gyp index f85fe0a..04793f5 100644 --- a/components/components_tests.gyp +++ b/components/components_tests.gyp @@ -29,6 +29,7 @@ 'autofill/core/browser/autocomplete_history_manager_unittest.cc', 'autofill/core/browser/autofill_country_unittest.cc', 'autofill/core/browser/autofill_data_model_unittest.cc', + 'autofill/core/browser/autofill_data_util_unittest.cc', 'autofill/core/browser/autofill_download_manager_unittest.cc', 'autofill/core/browser/autofill_external_delegate_unittest.cc', 'autofill/core/browser/autofill_field_unittest.cc', |
