Chromium Code Reviews| Index: chrome/browser/autofill/form_structure.cc |
| diff --git a/chrome/browser/autofill/form_structure.cc b/chrome/browser/autofill/form_structure.cc |
| index eabce870955b6ddc73af019d57418527df0d83c8..3258cc4ac6f45287a73e4054da416fa4d7a78452 100644 |
| --- a/chrome/browser/autofill/form_structure.cc |
| +++ b/chrome/browser/autofill/form_structure.cc |
| @@ -40,7 +40,9 @@ const char kAttributeClientVersion[] = "clientversion"; |
| const char kAttributeDataPresent[] = "datapresent"; |
| const char kAttributeFormSignature[] = "formsignature"; |
| const char kAttributeSignature[] = "signature"; |
| -const char kAcceptedFeatures[] = "e"; // e=experiments |
| +const char kAttributeUrlprefixSignature[] = "urlprefixsignature"; |
| +const char kAcceptedFeaturesExperiment[] = "e"; // e=experiments |
| +const char kAcceptedFeaturesAutocheckoutExperiment[] = "a,e"; // a=autocheckout |
| const char kClientVersion[] = "6.1.1715.1442/en (GGLL)"; |
| const char kXMLDeclaration[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; |
| const char kXMLElementAutofillQuery[] = "autofillquery"; |
| @@ -376,8 +378,20 @@ bool FormStructure::EncodeQueryRequest( |
| (buzz::QName(kXMLElementAutofillQuery))); |
| autofill_request_xml.SetAttr(buzz::QName(kAttributeClientVersion), |
| kClientVersion); |
| - autofill_request_xml.SetAttr(buzz::QName(kAttributeAcceptedFeatures), |
| - kAcceptedFeatures); |
| + |
| + // autocheckout_url_prefix tells autofillserver where the forms in the request |
|
Ilya Sherman
2013/01/31 05:03:28
nit: "tells autofillserver" -> "tells the Autofill
benquan
2013/02/01 02:55:04
Done.
|
| + // came from, and the autofillserver checks internal status and decide to |
| + // enable autocheckout or not and may return autocheckout related data in the |
| + // response accordingly. |
| + // There is no page/frame level object associated with FormStructure that |
| + // we could extract URL prefix from. But, all the forms should come from the |
| + // same frame, so they should have the same autocheckout URL prefix. Thus we |
| + // use URL prefix from the first form with autocheckout enabled. |
| + std::string autocheckout_url_prefix; |
| + |
| + // Strip the query string from the URL as it may contain PII info. |
| + GURL::Replacements replacements; |
| + replacements.ClearQuery(); |
|
Ilya Sherman
2013/01/31 05:03:28
nit: Remove these; they don't seem to be used.
benquan
2013/02/01 02:55:04
Done.
|
| // Some badly formatted web sites repeat forms - detect that and encode only |
| // one form as returned data would be the same for all the repeated forms. |
| @@ -398,6 +412,15 @@ bool FormStructure::EncodeQueryRequest( |
| encompassing_xml_element.get())) |
| continue; // Malformed form, skip it. |
| + if ((*it)->IsAutocheckoutEnabled()) { |
| + if (autocheckout_url_prefix.empty()) { |
| + autocheckout_url_prefix = (*it)->autocheckout_url_prefix_; |
| + } else { |
| + // Making sure all the forms in the request has the same url_prefix. |
| + DCHECK_EQ(autocheckout_url_prefix, (*it)->autocheckout_url_prefix_); |
| + } |
| + } |
| + |
| autofill_request_xml.AddElement(encompassing_xml_element.release()); |
| encoded_signatures->push_back(signature); |
| } |
| @@ -405,6 +428,16 @@ bool FormStructure::EncodeQueryRequest( |
| if (!encoded_signatures->size()) |
| return false; |
| + if (autocheckout_url_prefix.empty()) { |
| + autofill_request_xml.SetAttr(buzz::QName(kAttributeAcceptedFeatures), |
| + kAcceptedFeaturesExperiment); |
| + } else { |
| + autofill_request_xml.SetAttr(buzz::QName(kAttributeAcceptedFeatures), |
| + kAcceptedFeaturesAutocheckoutExperiment); |
| + autofill_request_xml.SetAttr(buzz::QName(kAttributeUrlprefixSignature), |
| + Hash64Bit(autocheckout_url_prefix)); |
| + } |
| + |
| // Obtain the XML structure as a string. |
| *encoded_xml = kXMLDeclaration; |
| *encoded_xml += autofill_request_xml.Str().c_str(); |