Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Unified Diff: components/autofill/core/browser/credit_card_field.cc

Issue 1694443004: [Autofill] Add credit card first and last name heuristics predictions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/credit_card_field.cc
diff --git a/components/autofill/core/browser/credit_card_field.cc b/components/autofill/core/browser/credit_card_field.cc
index 3ac65c0cfe0fd5cf2eddb630e8ab508dcf32aa88..ea870df43a1d573da4d531d10bf4cfd2714970f9 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 "last.*name" or "name.*last". Since these are dangerously
+ // generic searches, we search for these only after we have found a valid
+ // 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(kLastNameOnCardContextualRe),
+ &credit_card_field->cardholder_last_)) {
+ continue;
+ }
}
// Check for a credit card type (Visa, MasterCard, etc.) field.
@@ -326,8 +336,12 @@ bool CreditCardField::ClassifyField(ServerFieldTypeMap* map) const {
// 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)
+ if (cardholder_last_ == nullptr) {
ok = ok && AddClassification(cardholder_, CREDIT_CARD_NAME, map);
+ } else {
+ ok = ok && AddClassification(cardholder_, CREDIT_CARD_NAME_FIRST, map);
+ ok = ok && AddClassification(cardholder_last_, CREDIT_CARD_NAME_LAST, map);
+ }
if (expiration_date_) {
DCHECK(!expiration_month_);

Powered by Google App Engine
This is Rietveld 408576698