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

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

Issue 16164003: Field's server type mapping (using Autofill server response) for forms with checkable elements/pass… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 7 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/browser/form_structure.cc
diff --git a/components/autofill/browser/form_structure.cc b/components/autofill/browser/form_structure.cc
index cec92b09f11eba2632a3f142afb072487e0b1e07..02a581fb8e709307fd7e389e4c49665badafc0ab 100644
--- a/components/autofill/browser/form_structure.cc
+++ b/components/autofill/browser/form_structure.cc
@@ -305,11 +305,7 @@ FormStructure::FormStructure(const FormData& form,
form.fields.begin();
field != form.fields.end(); field++) {
- // Skip checkable and password elements when Autocheckout is not enabled,
- // else these fields will interfere with existing field signatures with
- // Autofill servers.
- if ((!field->is_checkable && field->form_control_type != "password") ||
- IsAutocheckoutEnabled()) {
+ if (!ShouldSkipField(*field)) {
// Add all supported form fields (including with empty names) to the
// signature. This is a requirement for Autofill servers.
form_signature_field_names_.append("&");
@@ -559,7 +555,10 @@ void FormStructure::ParseQueryResponse(
form->server_experiment_id_ = experiment_id;
for (std::vector<AutofillField*>::iterator field = form->fields_.begin();
- field != form->fields_.end(); ++field, ++current_info) {
+ field != form->fields_.end(); ++field) {
+ if (form->ShouldSkipField(**field))
+ continue;
+
// In some cases *successful* response does not return all the fields.
// Quit the update of the types then.
if (current_info == field_infos.end())
@@ -579,6 +578,8 @@ void FormStructure::ParseQueryResponse(
// Copy default value into the field if available.
if (!current_info->default_value.empty())
(*field)->set_default_value(current_info->default_value);
+
+ ++current_info;
}
form->UpdateAutofillCount();
@@ -657,6 +658,11 @@ bool FormStructure::IsAutocheckoutEnabled() const {
return !autocheckout_url_prefix_.empty();
}
+bool FormStructure::ShouldSkipField(const FormFieldData field) const {
+ return (field.is_checkable || field.form_control_type == "password") &&
+ !IsAutocheckoutEnabled();
+}
+
size_t FormStructure::RequiredFillableFields() const {
return IsAutocheckoutEnabled() ? 0 : kRequiredAutofillFields;
}
@@ -1026,10 +1032,7 @@ bool FormStructure::EncodeFormRequest(
EncodeFieldForUpload(*field, encompassing_xml_element);
break;
case FormStructure::QUERY:
- // Skip putting checkable and password fields in the request if
- // Autocheckout is not enabled.
- if ((field->is_checkable || field->form_control_type == "password") &&
- !IsAutocheckoutEnabled())
+ if (ShouldSkipField(*field))
continue;
EncodeFieldForQuery(*field, encompassing_xml_element);
break;
« no previous file with comments | « components/autofill/browser/form_structure.h ('k') | components/autofill/browser/form_structure_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698