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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 22040002: [Autofill] Add a separate enumeration for HTML field type hints. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add docs Created 7 years, 5 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: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
index 06371a5aa90bcf5b68d5b061f3fb976841e29475..1f73d3231aed221101bd7fe5a81d568466603c58 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -115,19 +115,23 @@ bool InputTypeMatchesFieldType(const DetailInput& input,
const AutofillType& field_type) {
// If any credit card expiration info is asked for, show both month and year
// inputs.
- if (field_type.native_type() == CREDIT_CARD_EXP_4_DIGIT_YEAR ||
- field_type.native_type() == CREDIT_CARD_EXP_2_DIGIT_YEAR ||
- field_type.native_type() == CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR ||
- field_type.native_type() == CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR ||
- field_type.native_type() == CREDIT_CARD_EXP_MONTH) {
+ NativeFieldType native_type = field_type.GetEquivalentNativeType();
+ if (native_type == CREDIT_CARD_EXP_4_DIGIT_YEAR ||
+ native_type == CREDIT_CARD_EXP_2_DIGIT_YEAR ||
+ native_type == CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR ||
+ native_type == CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR ||
+ native_type == CREDIT_CARD_EXP_MONTH) {
return input.type == CREDIT_CARD_EXP_4_DIGIT_YEAR ||
input.type == CREDIT_CARD_EXP_MONTH;
}
- if (field_type.native_type() == CREDIT_CARD_TYPE)
+ if (native_type == CREDIT_CARD_TYPE)
return input.type == CREDIT_CARD_NUMBER;
- return input.type == field_type.native_type();
+ // Check the groups to distinguish billing types from shipping ones.
+ AutofillType input_type = AutofillType(input.type);
+ return input_type.GetEquivalentNativeType() == native_type &&
+ input_type.group() == field_type.group();
}
// Returns true if |input| in the given |section| should be used for a
@@ -138,7 +142,7 @@ bool DetailInputMatchesField(DialogSection section,
AutofillType field_type = field.Type();
// The credit card name is filled from the billing section's data.
- if (field_type.native_type() == CREDIT_CARD_NAME &&
+ if (field_type.GetEquivalentNativeType() == CREDIT_CARD_NAME &&
(section == SECTION_BILLING || section == SECTION_CC_BILLING)) {
return input.type == NAME_BILLING_FULL;
}
@@ -158,7 +162,8 @@ bool DetailInputMatchesShippingField(const DetailInput& input,
// Equivalent billing field type is used to support UseBillingAsShipping
// usecase.
NativeFieldType field_type =
- AutofillType::GetEquivalentBillingFieldType(field.Type().native_type());
+ AutofillType::GetEquivalentBillingFieldType(
+ field.Type().GetEquivalentNativeType());
return InputTypeMatchesFieldType(input, AutofillType(field_type));
}
@@ -534,7 +539,7 @@ void AutofillDialogControllerImpl::Show() {
bool has_types = false;
bool has_sections = false;
form_structure_.ParseFieldTypesFromAutocompleteAttributes(
- FormStructure::PARSE_FOR_AUTOFILL_DIALOG, &has_types, &has_sections);
+ &has_types, &has_sections);
// Fail if the author didn't specify autocomplete types.
if (!has_types) {
@@ -1198,7 +1203,7 @@ const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection(
ui::ComboboxModel* AutofillDialogControllerImpl::ComboboxModelForAutofillType(
NativeFieldType type) {
- switch (AutofillType::GetEquivalentFieldType(type)) {
+ switch (type) {
case CREDIT_CARD_EXP_MONTH:
return &cc_exp_month_combobox_model_;
@@ -1206,6 +1211,7 @@ ui::ComboboxModel* AutofillDialogControllerImpl::ComboboxModelForAutofillType(
return &cc_exp_year_combobox_model_;
case ADDRESS_HOME_COUNTRY:
+ case ADDRESS_BILLING_COUNTRY:
return &country_combobox_model_;
default:
@@ -1569,7 +1575,7 @@ string16 AutofillDialogControllerImpl::InputValidityMessage(
}
}
- switch (AutofillType::GetEquivalentFieldType(type)) {
+ switch (AutofillType(type).GetEquivalentNativeType()) {
case EMAIL_ADDRESS:
if (!value.empty() && !IsValidEmailAddress(value)) {
return l10n_util::GetStringUTF16(
@@ -2322,7 +2328,8 @@ bool AutofillDialogControllerImpl::RequestingCreditCardInfo() const {
DCHECK_GT(form_structure_.field_count(), 0U);
for (size_t i = 0; i < form_structure_.field_count(); ++i) {
- if (IsCreditCardType(form_structure_.field(i)->Type().native_type()))
+ AutofillType type = form_structure_.field(i)->Type();
+ if (IsCreditCardType(type.GetEquivalentNativeType()))
return true;
}
@@ -2787,7 +2794,8 @@ bool AutofillDialogControllerImpl::FormStructureCaresAboutSection(
void AutofillDialogControllerImpl::SetCvcResult(const string16& cvc) {
for (size_t i = 0; i < form_structure_.field_count(); ++i) {
AutofillField* field = form_structure_.field(i);
- if (field->Type().native_type() == CREDIT_CARD_VERIFICATION_CODE) {
+ if (field->Type().GetEquivalentNativeType() ==
+ CREDIT_CARD_VERIFICATION_CODE) {
field->value = cvc;
break;
}

Powered by Google App Engine
This is Rietveld 408576698