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

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

Issue 659793005: [Password Generation] Always query password forms via Autofill (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Done Created 6 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 e8fd37a40f564ac0043910473491d1d014010a16..427df7abde75cc677b808186eca0c7dd5c0934f5 100644
--- a/components/autofill/core/browser/form_structure.cc
+++ b/components/autofill/core/browser/form_structure.cc
@@ -352,7 +352,8 @@ FormStructure::FormStructure(const FormData& form)
autofill_count_(0),
active_field_count_(0),
upload_required_(USE_UPLOAD_RATES),
- has_author_specified_types_(false) {
+ has_author_specified_types_(false),
+ has_password_field_(false) {
// Copy the form fields.
std::map<base::string16, size_t> unique_names;
for (std::vector<FormFieldData>::const_iterator field =
@@ -367,6 +368,9 @@ FormStructure::FormStructure(const FormData& form)
++active_field_count_;
}
+ if (field->form_control_type == "password")
+ has_password_field_ = true;
+
// Generate a unique name for this field by appending a counter to the name.
// Make sure to prepend the counter with a non-numeric digit so that we are
// guaranteed to avoid collisions.
@@ -579,20 +583,25 @@ void FormStructure::ParseQueryResponse(
if (current_info == field_infos.end())
break;
- // UNKNOWN_TYPE is reserved for use by the client.
- DCHECK_NE(current_info->field_type, UNKNOWN_TYPE);
+ // If |form->has_author_specified_types| only password fields should be
+ // updated.
+ if (!form->has_author_specified_types_ ||
+ (*field)->form_control_type == "password") {
+ // UNKNOWN_TYPE is reserved for use by the client.
+ DCHECK_NE(current_info->field_type, UNKNOWN_TYPE);
- ServerFieldType heuristic_type = (*field)->heuristic_type();
- if (heuristic_type != UNKNOWN_TYPE)
- heuristics_detected_fillable_field = true;
+ ServerFieldType heuristic_type = (*field)->heuristic_type();
+ if (heuristic_type != UNKNOWN_TYPE)
+ heuristics_detected_fillable_field = true;
- (*field)->set_server_type(current_info->field_type);
- if (heuristic_type != (*field)->Type().GetStorableType())
- query_response_overrode_heuristics = true;
+ (*field)->set_server_type(current_info->field_type);
+ if (heuristic_type != (*field)->Type().GetStorableType())
+ query_response_overrode_heuristics = true;
- // Copy default value into the field if available.
- if (!current_info->default_value.empty())
- (*field)->set_default_value(current_info->default_value);
+ // Copy default value into the field if available.
+ if (!current_info->default_value.empty())
+ (*field)->set_default_value(current_info->default_value);
+ }
++current_info;
}
@@ -706,7 +715,8 @@ bool FormStructure::ShouldBeParsed() const {
}
bool FormStructure::ShouldBeCrowdsourced() const {
- return !has_author_specified_types_ && ShouldBeParsed();
+ return (has_password_field_ || !has_author_specified_types_) &&
+ ShouldBeParsed();
}
void FormStructure::UpdateFromCache(const FormStructure& cached_form) {
« no previous file with comments | « components/autofill/core/browser/form_structure.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