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

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

Issue 654223004: Autofill: Allow forms to have multiple distinct CC number inputs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: update comment, simplify check Created 6 years, 2 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 f82dc063293ba3741b28ca440c6c907e4be366ad..2ba3c1cf5f8374c946ecf8213768bc343fc2967f 100644
--- a/components/autofill/core/browser/credit_card_field.cc
+++ b/components/autofill/core/browser/credit_card_field.cc
@@ -30,7 +30,6 @@ FormField* CreditCardField::Parse(AutofillScanner* scanner) {
scoped_ptr<CreditCardField> credit_card_field(new CreditCardField);
size_t saved_cursor = scanner->SaveCursor();
- bool form_has_valid_card_number_fields = true;
// Credit card fields can appear in many different orders.
// We loop until no more credit card related fields are found, see |break| at
@@ -106,18 +105,13 @@ FormField* CreditCardField::Parse(AutofillScanner* scanner) {
credit_card_field->numbers_.back()->credit_card_number_offset() +
credit_card_field->numbers_.back()->max_length;
- // In some cases, HTML form may have credit card number split across
- // multiple input fields and either one or cumulatively having
- // |max_length| more than |kMaxValidCardNumberSize|, mark these input
- // form fields as invalid and skip autofilling them.
- if (last_number_field_size == 0U ||
- last_number_field_size >= kMaxValidCardNumberSize) {
- // Mark that the credit card number splits are invalid. But keep
- // scanning HTML form so that cursor moves beyond related fields.
- form_has_valid_card_number_fields = false;
- }
-
- start_index = last_number_field_size;
+ // Distinguish between
+ // (a) one card split across multiple fields
+ // (b) multiple fields for multiple cards
+ // Treat this field as a part of the same card as the last field, except
+ // when doing so would cause overflow.
+ if (last_number_field_size < kMaxValidCardNumberSize)
+ start_index = last_number_field_size;
}
current_number_field->set_credit_card_number_offset(start_index);
@@ -191,11 +185,6 @@ FormField* CreditCardField::Parse(AutofillScanner* scanner) {
break;
}
- // Cases where heuristic misinterprets input field as credit card number
- // field, refuse to autofill credit card number fields.
- if (!form_has_valid_card_number_fields)
- credit_card_field->numbers_.clear();
-
// Some pages have a billing address field after the cardholder name field.
// For that case, allow only just the cardholder name field. The remaining
// CC fields will be picked up in a following CreditCardField.
@@ -210,8 +199,7 @@ FormField* CreditCardField::Parse(AutofillScanner* scanner) {
// the number and name were parsed in a separate part of the form. So if
// the cvc and date were found independently they are returned.
if ((!credit_card_field->numbers_.empty() ||
- credit_card_field->verification_ ||
- !form_has_valid_card_number_fields) &&
+ credit_card_field->verification_) &&
(credit_card_field->expiration_date_ ||
(credit_card_field->expiration_month_ &&
credit_card_field->expiration_year_))) {

Powered by Google App Engine
This is Rietveld 408576698