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 8703ff97085ad42b66c8052ec3e64a61e54a22f9..8266e1d0a4746f1a04b7aff58924d5e781ad5d24 100644 |
--- a/components/autofill/core/browser/form_structure.cc |
+++ b/components/autofill/core/browser/form_structure.cc |
@@ -391,6 +391,8 @@ FormStructure::FormStructure(const FormData& form) |
active_field_count_(0), |
upload_required_(USE_UPLOAD_RATES), |
has_author_specified_types_(false), |
+ has_author_specified_sections_(false), |
+ was_parsed_for_autocomplete_attributes_(false), |
has_password_field_(false), |
is_form_tag_(form.is_form_tag) { |
// Copy the form fields. |
@@ -425,9 +427,8 @@ void FormStructure::DetermineHeuristicTypes() { |
// attribute value. If there is at least one form field that specifies an |
// autocomplete type hint, don't try to apply other heuristics to match fields |
// in this form. |
- bool has_author_specified_sections; |
- ParseFieldTypesFromAutocompleteAttributes(&has_author_specified_types_, |
- &has_author_specified_sections); |
+ if (!was_parsed_for_autocomplete_attributes_) |
+ ParseFieldTypesFromAutocompleteAttributes(); |
if (!has_author_specified_types_) { |
ServerFieldTypeMap field_type_map; |
@@ -442,7 +443,7 @@ void FormStructure::DetermineHeuristicTypes() { |
} |
UpdateAutofillCount(); |
- IdentifySections(has_author_specified_sections); |
+ IdentifySections(has_author_specified_sections_); |
if (IsAutofillable()) { |
AutofillMetrics::LogDeveloperEngagementMetric( |
@@ -742,7 +743,8 @@ void FormStructure::UpdateAutofillCount() { |
} |
bool FormStructure::ShouldBeParsed() const { |
- if (active_field_count() < kRequiredAutofillFields) |
+ if (active_field_count() < kRequiredAutofillFields && |
+ !has_author_specified_types_) |
Evan Stade
2015/11/04 17:15:19
curlies
sebsg
2015/11/10 19:04:51
Done.
|
return false; |
// Rule out http(s)://*/search?... |
@@ -1072,14 +1074,15 @@ bool FormStructure::EncodeFormRequest( |
return true; |
} |
-void FormStructure::ParseFieldTypesFromAutocompleteAttributes( |
- bool* found_types, |
- bool* found_sections) { |
+void FormStructure::ParseFieldTypesFromAutocompleteAttributes() { |
const std::string kDefaultSection = "-default"; |
- *found_types = false; |
- *found_sections = false; |
- for (AutofillField* field : fields_) { |
+ has_author_specified_types_ = false; |
+ has_author_specified_sections_ = false; |
+ for (std::vector<AutofillField*>::iterator it = fields_.begin(); |
+ it != fields_.end(); ++it) { |
Evan Stade
2015/11/04 17:15:19
why did you change teh format of this loop
sebsg
2015/11/10 19:04:51
Bad merge on PS#4, good catch!
|
+ AutofillField* field = *it; |
+ |
// To prevent potential section name collisions, add a default suffix for |
// other fields. Without this, 'autocomplete' attribute values |
// "section--shipping street-address" and "shipping street-address" would be |
@@ -1109,7 +1112,7 @@ void FormStructure::ParseFieldTypesFromAutocompleteAttributes( |
// This allows a website's author to specify an attribute like |
// autocomplete="other" on a field to disable all Autofill heuristics for |
// the form. |
- *found_types = true; |
+ has_author_specified_types_ = true; |
// Tokenize the attribute value. Per the spec, the tokens are parsed in |
// reverse order. |
@@ -1172,7 +1175,7 @@ void FormStructure::ParseFieldTypesFromAutocompleteAttributes( |
continue; |
if (section != kDefaultSection) { |
- *found_sections = true; |
+ has_author_specified_sections_ = true; |
field->set_section(section); |
} |
@@ -1180,6 +1183,8 @@ void FormStructure::ParseFieldTypesFromAutocompleteAttributes( |
// Update the |field|'s type based on what was parsed from the attribute. |
field->SetHtmlType(field_type, mode); |
} |
+ |
+ was_parsed_for_autocomplete_attributes_ = true; |
} |
bool FormStructure::FillFields( |