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

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

Issue 1411363003: [Autofill] Always show available data when encountering autocomplete attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed mathp's comments Created 5 years, 2 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 164be8b2394476f68a56cbf5a3a30ced17176799..ff32790739422ac9fc2f11c950b99f59d0ede6cd 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,7 +1185,7 @@ void FormStructure::ParseFieldTypesFromAutocompleteAttributes(
continue;
if (section != kDefaultSection) {
- *found_sections = true;
+ has_author_specified_sections_ = true;
field->set_section(section);
}
@@ -1193,6 +1193,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(

Powered by Google App Engine
This is Rietveld 408576698