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

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

Issue 1583563003: [Autofill] Parse forms that have autocomplete attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 5dbcde171b0746e6d2123bb9d173fc25176031ff..6a0bbf75643f436f39dada86922f37536447f4ee 100644
--- a/components/autofill/core/browser/form_structure.cc
+++ b/components/autofill/core/browser/form_structure.cc
@@ -366,7 +366,10 @@ HtmlFieldType FieldTypeFromAutocompleteAttributeValue(
if (autocomplete_attribute_value == "email")
return HTML_TYPE_EMAIL;
- return HTML_TYPE_UNKNOWN;
+ if (autocomplete_attribute_value == "")
Mathieu 2016/01/13 01:03:20 this should probably be first in the function, bec
sebsg 2016/01/13 16:05:13 Absolutely, I should have thought of this. Thanks!
+ return HTML_TYPE_UNSPECIFIED;
+
+ return HTML_TYPE_UNRECOGNIZED;
}
std::string StripDigitsIfRequired(const base::string16& input) {
@@ -426,7 +429,7 @@ void FormStructure::DetermineHeuristicTypes() {
if (!was_parsed_for_autocomplete_attributes_)
ParseFieldTypesFromAutocompleteAttributes();
- if (!has_author_specified_types_) {
+ if (active_field_count() >= kRequiredFieldsForPredictionRoutines) {
ServerFieldTypeMap field_type_map;
FormField::ParseFormFields(fields_.get(), is_form_tag_, &field_type_map);
for (size_t i = 0; i < field_count(); ++i) {
@@ -782,8 +785,9 @@ bool FormStructure::ShouldBeParsed() const {
}
bool FormStructure::ShouldBeCrowdsourced() const {
- return (has_password_field_ || !has_author_specified_types_) &&
- ShouldBeParsed();
+ return (has_password_field_ ||
+ active_field_count() >= kRequiredFieldsForPredictionRoutines) &&
+ ShouldBeParsed();
}
void FormStructure::UpdateFromCache(const FormStructure& cached_form) {
@@ -1166,7 +1170,7 @@ void FormStructure::ParseFieldTypesFromAutocompleteAttributes() {
tokens.pop_back();
HtmlFieldType field_type =
FieldTypeFromAutocompleteAttributeValue(field_type_token, *field);
- if (field_type == HTML_TYPE_UNKNOWN)
+ if (field_type == HTML_TYPE_UNSPECIFIED)
Mathieu 2016/01/13 01:03:20 shouldn't we also "continue" if it's unrecognized?
sebsg 2016/01/13 16:05:13 No because if we continue, it's like we give up on
continue;
// The preceding token, if any, may be a type hint.

Powered by Google App Engine
This is Rietveld 408576698