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

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 comments Created 5 years, 1 month 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 8703ff97085ad42b66c8052ec3e64a61e54a22f9..c7c26181b7f8c8d11b9846d0f24c8fc996056f0d 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(
@@ -727,7 +728,7 @@ bool FormStructure::ShouldSkipField(const FormFieldData& field) const {
}
bool FormStructure::IsAutofillable() const {
- if (autofill_count() < kRequiredAutofillFields)
+ if (autofill_count() < kRequiredFieldsForPredictionRoutines)
return false;
return ShouldBeParsed();
@@ -742,8 +743,10 @@ void FormStructure::UpdateAutofillCount() {
}
bool FormStructure::ShouldBeParsed() const {
- if (active_field_count() < kRequiredAutofillFields)
+ if (active_field_count() < kRequiredFieldsForPredictionRoutines &&
+ !has_author_specified_types_) {
return false;
+ }
// Rule out http(s)://*/search?...
// e.g. http://www.google.com/search?q=...
@@ -911,7 +914,7 @@ void FormStructure::LogQualityMetrics(
AutofillMetrics::LogNumberOfEditedAutofilledFieldsAtSubmission(
num_edited_autofilled_fields);
- if (num_detected_field_types < kRequiredAutofillFields) {
+ if (num_detected_field_types < kRequiredFieldsForPredictionRoutines) {
AutofillMetrics::LogUserHappinessMetric(
AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM);
} else {
@@ -1072,13 +1075,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 (AutofillField* field : fields_) {
// To prevent potential section name collisions, add a default suffix for
// other fields. Without this, 'autocomplete' attribute values
@@ -1109,7 +1110,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 +1173,7 @@ void FormStructure::ParseFieldTypesFromAutocompleteAttributes(
continue;
if (section != kDefaultSection) {
- *found_sections = true;
+ has_author_specified_sections_ = true;
field->set_section(section);
}
@@ -1180,6 +1181,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