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

Side by Side Diff: chrome/browser/autofill/form_structure.cc

Issue 11953100: Add url prefix to AutofillQuery requests when autocheckout enabled, and set accepts="a" (autochecko… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/autofill/form_structure_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autofill/form_structure.h" 5 #include "chrome/browser/autofill/form_structure.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 22 matching lines...) Expand all
33 const char kFormMethodPost[] = "post"; 33 const char kFormMethodPost[] = "post";
34 34
35 // XML elements and attributes. 35 // XML elements and attributes.
36 const char kAttributeAcceptedFeatures[] = "accepts"; 36 const char kAttributeAcceptedFeatures[] = "accepts";
37 const char kAttributeAutofillUsed[] = "autofillused"; 37 const char kAttributeAutofillUsed[] = "autofillused";
38 const char kAttributeAutofillType[] = "autofilltype"; 38 const char kAttributeAutofillType[] = "autofilltype";
39 const char kAttributeClientVersion[] = "clientversion"; 39 const char kAttributeClientVersion[] = "clientversion";
40 const char kAttributeDataPresent[] = "datapresent"; 40 const char kAttributeDataPresent[] = "datapresent";
41 const char kAttributeFormSignature[] = "formsignature"; 41 const char kAttributeFormSignature[] = "formsignature";
42 const char kAttributeSignature[] = "signature"; 42 const char kAttributeSignature[] = "signature";
43 const char kAcceptedFeatures[] = "e"; // e=experiments 43 const char kAttributeUrlprefix[] = "urlprefix";
44 const char kAcceptedFeatureExperiment[] = "e"; // e=experiments
45 const char kAcceptedFeatureAutocheckout[] = "a"; // a=autocheckout
44 const char kClientVersion[] = "6.1.1715.1442/en (GGLL)"; 46 const char kClientVersion[] = "6.1.1715.1442/en (GGLL)";
45 const char kXMLDeclaration[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; 47 const char kXMLDeclaration[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
46 const char kXMLElementAutofillQuery[] = "autofillquery"; 48 const char kXMLElementAutofillQuery[] = "autofillquery";
47 const char kXMLElementAutofillUpload[] = "autofillupload"; 49 const char kXMLElementAutofillUpload[] = "autofillupload";
48 const char kXMLElementForm[] = "form"; 50 const char kXMLElementForm[] = "form";
49 const char kXMLElementField[] = "field"; 51 const char kXMLElementField[] = "field";
50 52
51 // The number of fillable fields necessary for a form to be fillable. 53 // The number of fillable fields necessary for a form to be fillable.
52 const size_t kRequiredFillableFields = 3; 54 const size_t kRequiredFillableFields = 3;
53 55
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 DCHECK(encoded_xml); 387 DCHECK(encoded_xml);
386 encoded_xml->clear(); 388 encoded_xml->clear();
387 encoded_signatures->clear(); 389 encoded_signatures->clear();
388 encoded_signatures->reserve(forms.size()); 390 encoded_signatures->reserve(forms.size());
389 391
390 // Set up the <autofillquery> element and attributes. 392 // Set up the <autofillquery> element and attributes.
391 buzz::XmlElement autofill_request_xml( 393 buzz::XmlElement autofill_request_xml(
392 (buzz::QName(kXMLElementAutofillQuery))); 394 (buzz::QName(kXMLElementAutofillQuery)));
393 autofill_request_xml.SetAttr(buzz::QName(kAttributeClientVersion), 395 autofill_request_xml.SetAttr(buzz::QName(kAttributeClientVersion),
394 kClientVersion); 396 kClientVersion);
395 autofill_request_xml.SetAttr(buzz::QName(kAttributeAcceptedFeatures),
396 kAcceptedFeatures);
397 397
398 std::string autocheckout_urlprefix;
398 // Some badly formatted web sites repeat forms - detect that and encode only 399 // Some badly formatted web sites repeat forms - detect that and encode only
399 // one form as returned data would be the same for all the repeated forms. 400 // one form as returned data would be the same for all the repeated forms.
400 std::set<std::string> processed_forms; 401 std::set<std::string> processed_forms;
401 for (ScopedVector<FormStructure>::const_iterator it = forms.begin(); 402 for (ScopedVector<FormStructure>::const_iterator it = forms.begin();
402 it != forms.end(); 403 it != forms.end();
403 ++it) { 404 ++it) {
404 std::string signature((*it)->FormSignature()); 405 std::string signature((*it)->FormSignature());
405 if (processed_forms.find(signature) != processed_forms.end()) 406 if (processed_forms.find(signature) != processed_forms.end())
406 continue; 407 continue;
407 processed_forms.insert(signature); 408 processed_forms.insert(signature);
408 scoped_ptr<buzz::XmlElement> encompassing_xml_element( 409 scoped_ptr<buzz::XmlElement> encompassing_xml_element(
409 new buzz::XmlElement(buzz::QName(kXMLElementForm))); 410 new buzz::XmlElement(buzz::QName(kXMLElementForm)));
410 encompassing_xml_element->SetAttr(buzz::QName(kAttributeSignature), 411 encompassing_xml_element->SetAttr(buzz::QName(kAttributeSignature),
411 signature); 412 signature);
412 413
413 if (!(*it)->EncodeFormRequest(FormStructure::QUERY, 414 if (!(*it)->EncodeFormRequest(FormStructure::QUERY,
414 encompassing_xml_element.get())) 415 encompassing_xml_element.get()))
415 continue; // Malformed form, skip it. 416 continue; // Malformed form, skip it.
416 417
418 if ((*it)->autocheckout_enabled_ && autocheckout_urlprefix.empty()) {
419 GURL::Replacements replacements;
420 replacements.ClearQuery();
421 autocheckout_urlprefix = (*it)->source_url()
422 .ReplaceComponents(replacements).spec();
423 }
424
417 autofill_request_xml.AddElement(encompassing_xml_element.release()); 425 autofill_request_xml.AddElement(encompassing_xml_element.release());
418 encoded_signatures->push_back(signature); 426 encoded_signatures->push_back(signature);
419 } 427 }
420 428
421 if (!encoded_signatures->size()) 429 if (!encoded_signatures->size())
422 return false; 430 return false;
423 431
432 if (autocheckout_urlprefix.empty()) {
433 autofill_request_xml.SetAttr(buzz::QName(kAttributeAcceptedFeatures),
434 kAcceptedFeatureExperiment);
435 } else {
436 autofill_request_xml.SetAttr(buzz::QName(kAttributeAcceptedFeatures),
437 kAcceptedFeatureAutocheckout);
Ilya Sherman 2013/01/25 20:37:35 Shouldn't we support both experiments and autochec
benquan 2013/01/29 00:36:09 We use a different form_data in server side, when
Ilya Sherman 2013/01/29 01:49:23 That sounds like something that should be controll
benquan 2013/01/30 19:24:22 Basically autocheckout and experiments are exclusi
Ilya Sherman 2013/01/30 21:12:14 What in the client code makes them necessarily exc
benquan 2013/01/31 03:58:05 Done.
438 autofill_request_xml.SetAttr(buzz::QName(kAttributeUrlprefix),
439 autocheckout_urlprefix);
Ilya Sherman 2013/01/25 20:37:35 What does this attribute accomplish? Why do we on
benquan 2013/01/29 00:36:09 urlprefix tells autofillserver where the forms in
Ilya Sherman 2013/01/29 01:49:23 Ok, that makes some sense -- thanks for the explan
benquan 2013/01/30 19:24:22 The query string is stripped, and we only send thi
Ilya Sherman 2013/01/30 21:12:14 Why not? If the server knows the URL, it can comp
benquan 2013/01/31 03:58:05 Changed to pass down hash code of the url prefix i
440 }
441
424 // Obtain the XML structure as a string. 442 // Obtain the XML structure as a string.
425 *encoded_xml = kXMLDeclaration; 443 *encoded_xml = kXMLDeclaration;
426 *encoded_xml += autofill_request_xml.Str().c_str(); 444 *encoded_xml += autofill_request_xml.Str().c_str();
427 445
428 return true; 446 return true;
429 } 447 }
430 448
431 // static 449 // static
432 void FormStructure::ParseQueryResponse(const std::string& response_xml, 450 void FormStructure::ParseQueryResponse(const std::string& response_xml,
433 const std::vector<FormStructure*>& forms, 451 const std::vector<FormStructure*>& forms,
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 for (std::vector<AutofillField*>::iterator field = fields_.begin(); 1143 for (std::vector<AutofillField*>::iterator field = fields_.begin();
1126 field != fields_.end(); ++field) { 1144 field != fields_.end(); ++field) {
1127 AutofillType::FieldTypeGroup field_type_group = 1145 AutofillType::FieldTypeGroup field_type_group =
1128 AutofillType((*field)->type()).group(); 1146 AutofillType((*field)->type()).group();
1129 if (field_type_group == AutofillType::CREDIT_CARD) 1147 if (field_type_group == AutofillType::CREDIT_CARD)
1130 (*field)->set_section((*field)->section() + "-cc"); 1148 (*field)->set_section((*field)->section() + "-cc");
1131 else 1149 else
1132 (*field)->set_section((*field)->section() + "-default"); 1150 (*field)->set_section((*field)->section() + "-default");
1133 } 1151 }
1134 } 1152 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autofill/form_structure_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698