| 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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 (buzz::QName(kXMLElementAutofillQuery))); | 517 (buzz::QName(kXMLElementAutofillQuery))); |
| 518 autofill_request_xml.SetAttr(buzz::QName(kAttributeClientVersion), | 518 autofill_request_xml.SetAttr(buzz::QName(kAttributeClientVersion), |
| 519 kClientVersion); | 519 kClientVersion); |
| 520 | 520 |
| 521 // Some badly formatted web sites repeat forms - detect that and encode only | 521 // Some badly formatted web sites repeat forms - detect that and encode only |
| 522 // one form as returned data would be the same for all the repeated forms. | 522 // one form as returned data would be the same for all the repeated forms. |
| 523 std::set<std::string> processed_forms; | 523 std::set<std::string> processed_forms; |
| 524 for (ScopedVector<FormStructure>::const_iterator it = forms.begin(); | 524 for (ScopedVector<FormStructure>::const_iterator it = forms.begin(); |
| 525 it != forms.end(); | 525 it != forms.end(); |
| 526 ++it) { | 526 ++it) { |
| 527 FormStructure* form = *it; | 527 std::string signature((*it)->FormSignature()); |
| 528 std::string signature(form->FormSignature()); | |
| 529 if (processed_forms.find(signature) != processed_forms.end()) | 528 if (processed_forms.find(signature) != processed_forms.end()) |
| 530 continue; | 529 continue; |
| 531 processed_forms.insert(signature); | 530 processed_forms.insert(signature); |
| 532 scoped_ptr<buzz::XmlElement> encompassing_xml_element( | 531 scoped_ptr<buzz::XmlElement> encompassing_xml_element( |
| 533 new buzz::XmlElement(buzz::QName(kXMLElementForm))); | 532 new buzz::XmlElement(buzz::QName(kXMLElementForm))); |
| 534 encompassing_xml_element->SetAttr(buzz::QName(kAttributeSignature), | 533 encompassing_xml_element->SetAttr(buzz::QName(kAttributeSignature), |
| 535 signature); | 534 signature); |
| 536 if (!form->form_name().empty()) { | |
| 537 encompassing_xml_element->SetAttr(buzz::QName(kAttributeName), | |
| 538 base::UTF16ToUTF8(form->form_name())); | |
| 539 } | |
| 540 | 535 |
| 541 if (!form->EncodeFormRequest(FormStructure::QUERY, | 536 if (!(*it)->EncodeFormRequest(FormStructure::QUERY, |
| 542 encompassing_xml_element.get())) | 537 encompassing_xml_element.get())) |
| 543 continue; // Malformed form, skip it. | 538 continue; // Malformed form, skip it. |
| 544 | 539 |
| 545 autofill_request_xml.AddElement(encompassing_xml_element.release()); | 540 autofill_request_xml.AddElement(encompassing_xml_element.release()); |
| 546 encoded_signatures->push_back(signature); | 541 encoded_signatures->push_back(signature); |
| 547 } | 542 } |
| 548 | 543 |
| 549 if (!encoded_signatures->size()) | 544 if (!encoded_signatures->size()) |
| 550 return false; | 545 return false; |
| 551 | 546 |
| 552 // Note: Chrome used to also set 'accepts="e"' (where 'e' is for experiments), | 547 // Note: Chrome used to also set 'accepts="e"' (where 'e' is for experiments), |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1298 for (AutofillField* field : fields_) { | 1293 for (AutofillField* field : fields_) { |
| 1299 FieldTypeGroup field_type_group = field->Type().group(); | 1294 FieldTypeGroup field_type_group = field->Type().group(); |
| 1300 if (field_type_group == CREDIT_CARD) | 1295 if (field_type_group == CREDIT_CARD) |
| 1301 field->set_section(field->section() + "-cc"); | 1296 field->set_section(field->section() + "-cc"); |
| 1302 else | 1297 else |
| 1303 field->set_section(field->section() + "-default"); | 1298 field->set_section(field->section() + "-default"); |
| 1304 } | 1299 } |
| 1305 } | 1300 } |
| 1306 | 1301 |
| 1307 } // namespace autofill | 1302 } // namespace autofill |
| OLD | NEW |