OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/form_structure.h" | 5 #include "components/autofill/core/browser/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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 *encoded_xml = kXMLDeclaration; | 510 *encoded_xml = kXMLDeclaration; |
511 *encoded_xml += autofill_request_xml.Str().c_str(); | 511 *encoded_xml += autofill_request_xml.Str().c_str(); |
512 | 512 |
513 return true; | 513 return true; |
514 } | 514 } |
515 | 515 |
516 // static | 516 // static |
517 bool FormStructure::EncodeQueryRequest( | 517 bool FormStructure::EncodeQueryRequest( |
518 const std::vector<FormStructure*>& forms, | 518 const std::vector<FormStructure*>& forms, |
519 std::vector<std::string>* encoded_signatures, | 519 std::vector<std::string>* encoded_signatures, |
520 std::vector<FormStructure*>* queried_forms, | |
521 std::string* encoded_xml) { | 520 std::string* encoded_xml) { |
522 DCHECK(encoded_signatures); | 521 DCHECK(encoded_signatures); |
523 DCHECK(encoded_xml); | 522 DCHECK(encoded_xml); |
524 encoded_xml->clear(); | 523 encoded_xml->clear(); |
525 encoded_signatures->clear(); | 524 encoded_signatures->clear(); |
526 encoded_signatures->reserve(forms.size()); | 525 encoded_signatures->reserve(forms.size()); |
527 queried_forms->clear(); | |
528 queried_forms->reserve(forms.size()); | |
529 | 526 |
530 // Set up the <autofillquery> element and attributes. | 527 // Set up the <autofillquery> element and attributes. |
531 buzz::XmlElement autofill_request_xml( | 528 buzz::XmlElement autofill_request_xml( |
532 (buzz::QName(kXMLElementAutofillQuery))); | 529 (buzz::QName(kXMLElementAutofillQuery))); |
533 autofill_request_xml.SetAttr(buzz::QName(kAttributeClientVersion), | 530 autofill_request_xml.SetAttr(buzz::QName(kAttributeClientVersion), |
534 kClientVersion); | 531 kClientVersion); |
535 | 532 |
536 // Some badly formatted web sites repeat forms - detect that and encode only | 533 // Some badly formatted web sites repeat forms - detect that and encode only |
537 // one form as returned data would be the same for all the repeated forms. | 534 // one form as returned data would be the same for all the repeated forms. |
538 std::set<std::string> processed_forms; | 535 std::set<std::string> processed_forms; |
539 for (const auto& it : forms) { | 536 for (const auto& it : forms) { |
540 std::string signature(it->FormSignature()); | 537 std::string signature(it->FormSignature()); |
541 if (processed_forms.find(signature) != processed_forms.end()) | 538 if (processed_forms.find(signature) != processed_forms.end()) |
542 continue; | 539 continue; |
543 processed_forms.insert(signature); | 540 processed_forms.insert(signature); |
544 scoped_ptr<buzz::XmlElement> encompassing_xml_element( | 541 scoped_ptr<buzz::XmlElement> encompassing_xml_element( |
545 new buzz::XmlElement(buzz::QName(kXMLElementForm))); | 542 new buzz::XmlElement(buzz::QName(kXMLElementForm))); |
546 encompassing_xml_element->SetAttr(buzz::QName(kAttributeSignature), | 543 encompassing_xml_element->SetAttr(buzz::QName(kAttributeSignature), |
547 signature); | 544 signature); |
548 | 545 |
549 if (!it->EncodeFormRequest(FormStructure::QUERY, | 546 if (!it->EncodeFormRequest(FormStructure::QUERY, |
550 encompassing_xml_element.get())) { | 547 encompassing_xml_element.get())) { |
551 continue; // Malformed form, skip it. | 548 continue; // Malformed form, skip it. |
552 } | 549 } |
553 | 550 |
554 autofill_request_xml.AddElement(encompassing_xml_element.release()); | 551 autofill_request_xml.AddElement(encompassing_xml_element.release()); |
555 encoded_signatures->push_back(signature); | 552 encoded_signatures->push_back(signature); |
556 queried_forms->push_back(it); | |
557 } | 553 } |
558 | 554 |
559 if (!encoded_signatures->size()) | 555 if (!encoded_signatures->size()) |
560 return false; | 556 return false; |
561 | 557 |
562 // Note: Chrome used to also set 'accepts="e"' (where 'e' is for experiments), | 558 // Note: Chrome used to also set 'accepts="e"' (where 'e' is for experiments), |
563 // but no longer sets this because support for experiments is deprecated. If | 559 // but no longer sets this because support for experiments is deprecated. If |
564 // it ever resurfaces, re-add code here to set the attribute accordingly. | 560 // it ever resurfaces, re-add code here to set the attribute accordingly. |
565 | 561 |
566 // Obtain the XML structure as a string. | 562 // Obtain the XML structure as a string. |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 for (AutofillField* field : fields_) { | 1307 for (AutofillField* field : fields_) { |
1312 FieldTypeGroup field_type_group = field->Type().group(); | 1308 FieldTypeGroup field_type_group = field->Type().group(); |
1313 if (field_type_group == CREDIT_CARD) | 1309 if (field_type_group == CREDIT_CARD) |
1314 field->set_section(field->section() + "-cc"); | 1310 field->set_section(field->section() + "-cc"); |
1315 else | 1311 else |
1316 field->set_section(field->section() + "-default"); | 1312 field->set_section(field->section() + "-default"); |
1317 } | 1313 } |
1318 } | 1314 } |
1319 | 1315 |
1320 } // namespace autofill | 1316 } // namespace autofill |
OLD | NEW |