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

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: 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..8ed74247f7936effe8228df8109a7de0cd803e55 100644
--- a/components/autofill/browser/form_structure.cc
+++ b/components/autofill/browser/form_structure.cc
@@ -308,8 +308,7 @@ FormStructure::FormStructure(const FormData& form,
// Skip checkable and password elements when Autocheckout is not enabled,
// else these fields will interfere with existing field signatures with
// Autofill servers.
Evan Stade 2013/05/28 19:24:07 I don't think the comment above each call to Shoul
Raman Kakilate 2013/05/28 20:38:44 Done.
- 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 +558,12 @@ 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) {
+ // Skip putting checkable and password fields in the request if
+ // Autocheckout is not enabled.
+ 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 +583,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 +663,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") &&
Evan Stade 2013/05/28 19:24:07 nit: no need for outer parens
Raman Kakilate 2013/05/28 20:38:44 Done.
+ !IsAutocheckoutEnabled());
+}
+
size_t FormStructure::RequiredFillableFields() const {
return IsAutocheckoutEnabled() ? 0 : kRequiredAutofillFields;
}
@@ -1028,8 +1039,7 @@ bool FormStructure::EncodeFormRequest(
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