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

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

Issue 2026353002: [Autofill] Credit Card Assist Infobar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleaning Created 4 years, 4 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/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) {
« no previous file with comments | « components/autofill/core/browser/form_structure.h ('k') | components/autofill/core/browser/form_structure_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698