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

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: Fixed android compile and browser test 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..982ed2ac58ec2ea86a06965c4ecfbf114a3d0563 100644
--- a/components/autofill/core/browser/form_structure.cc
+++ b/components/autofill/core/browser/form_structure.cc
@@ -239,6 +239,9 @@ bool ContactTypeHintMatchesFieldType(const std::string& token,
HtmlFieldType FieldTypeFromAutocompleteAttributeValue(
const std::string& autocomplete_attribute_value,
const AutofillField& field) {
+ if (autocomplete_attribute_value == "")
+ return HTML_TYPE_UNSPECIFIED;
+
if (autocomplete_attribute_value == "name")
return HTML_TYPE_NAME;
@@ -366,7 +369,7 @@ HtmlFieldType FieldTypeFromAutocompleteAttributeValue(
if (autocomplete_attribute_value == "email")
return HTML_TYPE_EMAIL;
- return HTML_TYPE_UNKNOWN;
+ 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)
continue;
// The preceding token, if any, may be a type hint.
« no previous file with comments | « components/autofill/core/browser/field_types.h ('k') | components/autofill/core/browser/form_structure_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698