| Index: chrome/browser/autofill/form_structure.cc
|
| diff --git a/chrome/browser/autofill/form_structure.cc b/chrome/browser/autofill/form_structure.cc
|
| index 87c48f07c1eb19f58585f6c88584c1d640212970..87109bfd6addc2816d68ffb3a6519b2f58f6e163 100644
|
| --- a/chrome/browser/autofill/form_structure.cc
|
| +++ b/chrome/browser/autofill/form_structure.cc
|
| @@ -232,10 +232,17 @@ FormStructure::FormStructure(const FormData& form)
|
| for (std::vector<FormFieldData>::const_iterator field =
|
| form.fields.begin();
|
| field != form.fields.end(); 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("&");
|
| - form_signature_field_names_.append(UTF16ToUTF8(field->name));
|
| + // Skipping checkable elements when flag is not set, else these fields will
|
| + // interfere with existing field signatures with autofill servers.
|
| + // TODO(ramankk): Add checkable elements only on whitelisted pages
|
| + if (!field->is_checkable ||
|
| + CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableExperimentalFormFilling)) {
|
| + // Add all supported form fields (including with empty names) to the
|
| + // signature. This is a requirement for Autofill servers.
|
| + form_signature_field_names_.append("&");
|
| + form_signature_field_names_.append(UTF16ToUTF8(field->name));
|
| + }
|
|
|
| // 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
|
| @@ -403,10 +410,10 @@ void FormStructure::ParseQueryResponse(const std::string& response_xml,
|
| metric_logger.LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_RECEIVED);
|
|
|
| // Parse the field types from the server response to the query.
|
| - std::vector<AutofillFieldType> field_types;
|
| + std::vector<AutofillFieldInfo> field_infos;
|
| UploadRequired upload_required;
|
| std::string experiment_id;
|
| - AutofillQueryXmlParser parse_handler(&field_types, &upload_required,
|
| + AutofillQueryXmlParser parse_handler(&field_infos, &upload_required,
|
| &experiment_id);
|
| buzz::XmlParser parser(&parse_handler);
|
| parser.Parse(response_xml.c_str(), response_xml.length(), true);
|
| @@ -420,7 +427,7 @@ void FormStructure::ParseQueryResponse(const std::string& response_xml,
|
| bool query_response_overrode_heuristics = false;
|
|
|
| // Copy the field types into the actual form.
|
| - std::vector<AutofillFieldType>::iterator current_type = field_types.begin();
|
| + std::vector<AutofillFieldInfo>::iterator current_info = field_infos.begin();
|
| for (std::vector<FormStructure*>::const_iterator iter = forms.begin();
|
| iter != forms.end(); ++iter) {
|
| FormStructure* form = *iter;
|
| @@ -428,24 +435,27 @@ void FormStructure::ParseQueryResponse(const std::string& response_xml,
|
| form->server_experiment_id_ = experiment_id;
|
|
|
| for (std::vector<AutofillField*>::iterator field = form->fields_.begin();
|
| - field != form->fields_.end(); ++field, ++current_type) {
|
| + field != form->fields_.end(); ++field, ++current_info) {
|
| // In some cases *successful* response does not return all the fields.
|
| // Quit the update of the types then.
|
| - if (current_type == field_types.end())
|
| + if (current_info == field_infos.end())
|
| break;
|
|
|
| // UNKNOWN_TYPE is reserved for use by the client.
|
| - DCHECK_NE(*current_type, UNKNOWN_TYPE);
|
| + DCHECK_NE(current_info->first, UNKNOWN_TYPE);
|
|
|
| AutofillFieldType heuristic_type = (*field)->type();
|
| if (heuristic_type != UNKNOWN_TYPE)
|
| heuristics_detected_fillable_field = true;
|
|
|
| - (*field)->set_server_type(*current_type);
|
| + (*field)->set_server_type(current_info->first);
|
| if (heuristic_type != (*field)->type())
|
| query_response_overrode_heuristics = true;
|
| - }
|
|
|
| + // Copy default value into the field if available.
|
| + if (!current_info->second.empty())
|
| + (*field)->set_default_value(current_info->second);
|
| + }
|
| form->UpdateAutofillCount();
|
| form->IdentifySections(false);
|
| }
|
| @@ -880,6 +890,11 @@ bool FormStructure::EncodeFormRequest(
|
| encompassing_xml_element->AddElement(field_element);
|
| }
|
| } else {
|
| + // Skip putting checkable fields in the request flag is not set.
|
| + if (field->is_checkable &&
|
| + !CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableExperimentalFormFilling))
|
| + continue;
|
| buzz::XmlElement *field_element = new buzz::XmlElement(
|
| buzz::QName(kXMLElementField));
|
| field_element->SetAttr(buzz::QName(kAttributeSignature),
|
|
|