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

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

Issue 622773002: [Autofill] Autofill fails to show suggestions for credit card split across fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit-tests. 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/autofill_field.cc
diff --git a/components/autofill/core/browser/autofill_field.cc b/components/autofill/core/browser/autofill_field.cc
index 8822bd883098f5510d60cc48209e481d71518a1b..e10dfbabe0d889cebcae64c9e99335f595326b4d 100644
--- a/components/autofill/core/browser/autofill_field.cc
+++ b/components/autofill/core/browser/autofill_field.cc
@@ -284,23 +284,6 @@ void FillPhoneNumberField(const AutofillField& field,
AutofillField::GetPhoneNumberValue(field, number, *field_data);
}
-// Set |field_data|'s value to |number|, or possibly an appropriate substring
-// of |number| for cases where credit card number splits across multiple HTML
-// form input fields.
-// The |field| specifies the |credit_card_number_offset_| to the substring
-// within credit card number.
-void FillCreditCardNumberField(const AutofillField& field,
- const base::string16& number,
- FormFieldData* field_data) {
- base::string16 value = number;
-
- // |field|'s max_length truncates credit card number to fit within.
- if (field.credit_card_number_offset() < value.length())
- value = value.substr(field.credit_card_number_offset());
-
- field_data->value = value;
-}
-
// Fills in the select control |field| with |value|. If an exact match is not
// found, falls back to alternate filling strategies based on the |type|.
bool FillSelectControl(const AutofillType& type,
@@ -492,7 +475,7 @@ bool AutofillField::FillFormField(const AutofillField& field,
FillStreetAddress(value, address_language_code, field_data);
return true;
} else if (type.GetStorableType() == CREDIT_CARD_NUMBER) {
- FillCreditCardNumberField(field, value, field_data);
+ field_data->value = AutofillField::GetCreditCardNumberValue(field, value);
ziran.sun 2014/10/08 16:25:55 For consistency it might be worth keeping FillCred
Ilya Sherman 2014/10/08 21:04:38 Alternately, you could inline the FillPhoneNumberF
Pritam Nikam 2014/10/09 06:11:11 Done.
return true;
}
@@ -526,4 +509,18 @@ base::string16 AutofillField::GetPhoneNumberValue(
return number;
}
+// The |field| specifies the |credit_card_number_offset_| to the substring
Ilya Sherman 2014/10/07 21:49:10 nit: "credit_card_number_offset_" -> "credit_card_
Pritam Nikam 2014/10/08 05:17:17 Done.
+// within credit card number.
+base::string16 AutofillField::GetCreditCardNumberValue(
+ const AutofillField& field,
+ const base::string16& number) {
+ base::string16 value = number;
+
+ // |field|'s max_length truncates credit card number to fit within.
+ if (field.credit_card_number_offset() < value.length())
+ value = value.substr(field.credit_card_number_offset());
+
+ return value;
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698