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

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: Rebase 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 89d356351bd6493671cf5d69ea54cf7306f3c0ec..871dcbb046b563683497295dc3f435e8af71c116 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_);
« no previous file with comments | « components/autofill/core/browser/credit_card.cc ('k') | components/autofill/core/browser/credit_card_field_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698