Chromium Code Reviews| 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 164be8b2394476f68a56cbf5a3a30ced17176799..844243355c0c56eba0b22309311117860bad4023 100644 |
| --- a/components/autofill/core/browser/form_structure.cc |
| +++ b/components/autofill/core/browser/form_structure.cc |
| @@ -389,6 +389,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. |
| @@ -423,9 +425,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; |
| @@ -440,7 +441,7 @@ void FormStructure::DetermineHeuristicTypes() { |
| } |
| UpdateAutofillCount(); |
| - IdentifySections(has_author_specified_sections); |
| + IdentifySections(has_author_specified_sections_); |
| if (IsAutofillable()) { |
| AutofillMetrics::LogDeveloperEngagementMetric( |
| @@ -746,7 +747,8 @@ void FormStructure::UpdateAutofillCount() { |
| } |
| bool FormStructure::ShouldBeParsed() const { |
| - if (active_field_count() < kRequiredAutofillFields) |
| + if (active_field_count() < kRequiredAutofillFields && |
| + !has_author_specified_types_) |
| return false; |
| // Rule out http(s)://*/search?... |
| @@ -1082,13 +1084,11 @@ 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; |
| + has_author_specified_types_ = false; |
| + has_author_specified_sections_ = false; |
| for (std::vector<AutofillField*>::iterator it = fields_.begin(); |
| it != fields_.end(); ++it) { |
| AutofillField* field = *it; |
| @@ -1122,7 +1122,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. |
| @@ -1185,13 +1185,15 @@ void FormStructure::ParseFieldTypesFromAutocompleteAttributes( |
| continue; |
| if (section != kDefaultSection) { |
| - *found_sections = true; |
| + has_author_specified_sections_ = true; |
| field->set_section(section); |
| } |
| // No errors encountered while parsing! |
| // Update the |field|'s type based on what was parsed from the attribute. |
| field->SetHtmlType(field_type, mode); |
| + |
| + was_parsed_for_autocomplete_attributes_ = true; |
|
Mathieu
2015/10/20 21:03:11
should this go one line down, outside the loop?
sebsg
2015/10/21 18:20:50
Done.
|
| } |
| } |