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

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

Issue 2830303002: Fix sending autofill votes for sign-in forms. (Closed)
Patch Set: Comments added Created 3 years, 8 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
« no previous file with comments | « components/autofill/core/browser/autofill_manager_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9bff7e2f0bce26d43d28f7c982aec3c56b3efd1a..4695b65b4d228606da0233da13dbb5dcae6d6e53 100644
--- a/components/autofill/core/browser/form_structure.cc
+++ b/components/autofill/core/browser/form_structure.cc
@@ -295,6 +295,19 @@ bool IsCreditCardExpirationType(ServerFieldType type) {
type == CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR;
}
+// Returns true iff all form fields autofill types are in |contained_types|.
+bool AllTypesCaptured(const FormStructure& form,
+ const ServerFieldTypeSet& contained_types) {
+ for (const auto& field : form) {
+ for (const auto& type : field->possible_types()) {
+ if (type != UNKNOWN_TYPE && type != EMPTY_TYPE &&
+ !contained_types.count(type))
+ return false;
+ }
+ }
+ return true;
+}
+
} // namespace
FormStructure::FormStructure(const FormData& form)
@@ -395,15 +408,7 @@ bool FormStructure::EncodeUploadRequest(
bool observed_submission,
AutofillUploadContents* upload) const {
DCHECK(ShouldBeCrowdsourced());
-
- // Verify that |available_field_types| agrees with the possible field types we
- // are uploading.
- for (const auto& field : *this) {
- for (const auto& type : field->possible_types()) {
- DCHECK(type == UNKNOWN_TYPE || type == EMPTY_TYPE ||
- available_field_types.count(type));
- }
- }
+ DCHECK(AllTypesCaptured(*this, available_field_types));
upload->set_submission(observed_submission);
upload->set_client_version(kClientVersion);
« no previous file with comments | « components/autofill/core/browser/autofill_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698