| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/sha1.h" | 9 #include "base/sha1.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/autofill/autofill_xml_parser.h" | 12 #include "chrome/browser/autofill/autofill_xml_parser.h" |
| 13 #include "chrome/browser/autofill/field_types.h" | 13 #include "chrome/browser/autofill/field_types.h" |
| 14 #include "chrome/browser/autofill/form_field.h" | 14 #include "chrome/browser/autofill/form_field.h" |
| 15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
| 16 #include "webkit/glue/form_field.h" | 16 #include "webkit/glue/form_field.h" |
| 17 | 17 |
| 18 using webkit_glue::FormData; | 18 using webkit_glue::FormData; |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // to match the form signature of the AutoFill servers. | 75 // to match the form signature of the AutoFill servers. |
| 76 if (LowerCaseEqualsASCII(field->form_control_type(), kControlTypeText) || | 76 if (LowerCaseEqualsASCII(field->form_control_type(), kControlTypeText) || |
| 77 LowerCaseEqualsASCII(field->form_control_type(), kControlTypeSelect)) { | 77 LowerCaseEqualsASCII(field->form_control_type(), kControlTypeSelect)) { |
| 78 // Add all supported form fields (including with empty names) to | 78 // Add all supported form fields (including with empty names) to |
| 79 // signature. This is a requirement for AutoFill servers. | 79 // signature. This is a requirement for AutoFill servers. |
| 80 form_signature_field_names_.append("&"); | 80 form_signature_field_names_.append("&"); |
| 81 form_signature_field_names_.append(UTF16ToUTF8(field->name())); | 81 form_signature_field_names_.append(UTF16ToUTF8(field->name())); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Generate a unique name for this field by appending a counter to the name. | 84 // Generate a unique name for this field by appending a counter to the name. |
| 85 string16 unique_name = field->name() + IntToString16(fields_.size() + 1); | 85 string16 unique_name = field->name() + |
| 86 base::IntToString16(fields_.size() + 1); |
| 86 fields_.push_back(new AutoFillField(*field, unique_name)); | 87 fields_.push_back(new AutoFillField(*field, unique_name)); |
| 87 } | 88 } |
| 88 | 89 |
| 89 // Terminate the vector with a NULL item. | 90 // Terminate the vector with a NULL item. |
| 90 fields_.push_back(NULL); | 91 fields_.push_back(NULL); |
| 91 GetHeuristicAutoFillTypes(); | 92 GetHeuristicAutoFillTypes(); |
| 92 | 93 |
| 93 std::string method = UTF16ToUTF8(form.method); | 94 std::string method = UTF16ToUTF8(form.method); |
| 94 if (StringToLowerASCII(method) == kFormMethodPost) { | 95 if (StringToLowerASCII(method) == kFormMethodPost) { |
| 95 method_ = POST; | 96 method_ = POST; |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 } else { | 435 } else { |
| 435 buzz::XmlElement *field_element = new buzz::XmlElement( | 436 buzz::XmlElement *field_element = new buzz::XmlElement( |
| 436 buzz::QName(kXMLElementField)); | 437 buzz::QName(kXMLElementField)); |
| 437 field_element->SetAttr(buzz::QName(kAttributeSignature), | 438 field_element->SetAttr(buzz::QName(kAttributeSignature), |
| 438 field->FieldSignature()); | 439 field->FieldSignature()); |
| 439 encompassing_xml_element->AddElement(field_element); | 440 encompassing_xml_element->AddElement(field_element); |
| 440 } | 441 } |
| 441 } | 442 } |
| 442 return true; | 443 return true; |
| 443 } | 444 } |
| OLD | NEW |