Index: components/autofill/core/browser/form_structure.cc |
diff --git a/components/autofill/core/browser/form_structure.cc b/components/autofill/core/browser/form_structure.cc |
index 164bd71745771d2a82c9398b3cc69397b2de0a43..5d6815fd0c7c17ba142c0ba39e66aac118970b3c 100644 |
--- a/components/autofill/core/browser/form_structure.cc |
+++ b/components/autofill/core/browser/form_structure.cc |
@@ -290,6 +290,14 @@ std::ostream& operator<<( |
return out; |
} |
+bool IsCreditCardExpirationType(ServerFieldType type) { |
+ return type == CREDIT_CARD_EXP_MONTH || |
+ type == CREDIT_CARD_EXP_2_DIGIT_YEAR || |
+ type == CREDIT_CARD_EXP_4_DIGIT_YEAR || |
+ type == CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR || |
+ type == CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR; |
+} |
+ |
} // namespace |
FormStructure::FormStructure(const FormData& form) |
@@ -577,6 +585,22 @@ bool FormStructure::IsAutofillable() const { |
return ShouldBeParsed(); |
} |
+bool FormStructure::IsCompleteCreditCardForm() const { |
+ bool found_cc_number = false; |
+ bool found_cc_expiration = false; |
+ for (const AutofillField* field : fields_) { |
+ ServerFieldType type = field->Type().GetStorableType(); |
+ if (!found_cc_expiration && IsCreditCardExpirationType(type)) { |
+ found_cc_expiration = true; |
+ } else if (!found_cc_number && type == CREDIT_CARD_NUMBER) { |
+ found_cc_number = true; |
+ } |
+ if (found_cc_expiration && found_cc_number) |
+ return true; |
+ } |
+ return false; |
+} |
+ |
void FormStructure::UpdateAutofillCount() { |
autofill_count_ = 0; |
for (const AutofillField* field : *this) { |