| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "Frame.h" | 7 #include "Frame.h" |
| 8 #include "HTMLFormElement.h" | 8 #include "HTMLFormElement.h" |
| 9 #include "HTMLInputElement.h" | 9 #include "HTMLInputElement.h" |
| 10 #include "HTMLNames.h" | 10 #include "HTMLNames.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 WebCore::HTMLInputElement* input_element = | 50 WebCore::HTMLInputElement* input_element = |
| 51 static_cast<WebCore::HTMLInputElement*>(form_element); | 51 static_cast<WebCore::HTMLInputElement*>(form_element); |
| 52 if (!input_element->isEnabledFormControl()) | 52 if (!input_element->isEnabledFormControl()) |
| 53 continue; | 53 continue; |
| 54 | 54 |
| 55 // Ignore all input types except TEXT. | 55 // Ignore all input types except TEXT. |
| 56 if (input_element->inputType() != WebCore::HTMLInputElement::TEXT) | 56 if (input_element->inputType() != WebCore::HTMLInputElement::TEXT) |
| 57 continue; | 57 continue; |
| 58 | 58 |
| 59 // For each TEXT input field, store the name and value | 59 // For each TEXT input field, store the name and value |
| 60 std::wstring value = StringToStdWString(input_element->value()); | 60 string16 value = StringToString16(input_element->value()); |
| 61 TrimWhitespace(value, TRIM_LEADING, &value); | 61 TrimWhitespace(value, TRIM_LEADING, &value); |
| 62 if (value.length() == 0) | 62 if (value.length() == 0) |
| 63 continue; | 63 continue; |
| 64 | 64 |
| 65 std::wstring name = GetNameForInputElement(input_element); | 65 string16 name = GetNameForInputElement(input_element); |
| 66 if (name.length() == 0) | 66 if (name.length() == 0) |
| 67 continue; // If we have no name, there is nothing to store. | 67 continue; // If we have no name, there is nothing to store. |
| 68 | 68 |
| 69 result->elements.push_back(AutofillForm::Element(name, value)); | 69 result->elements.push_back(AutofillForm::Element(name, value)); |
| 70 } | 70 } |
| 71 | 71 |
| 72 return result; | 72 return result; |
| 73 } | 73 } |
| 74 | 74 |
| 75 // static | 75 // static |
| 76 std::wstring AutofillForm::GetNameForInputElement(WebCore::HTMLInputElement* | 76 string16 AutofillForm::GetNameForInputElement(WebCore::HTMLInputElement* |
| 77 element) { | 77 element) { |
| 78 std::wstring name = StringToStdWString(element->name()); | 78 string16 name = StringToString16(element->name()); |
| 79 std::wstring trimmed_name; | 79 string16 trimmed_name; |
| 80 TrimWhitespace(name, TRIM_LEADING, &trimmed_name); | 80 TrimWhitespace(name, TRIM_LEADING, &trimmed_name); |
| 81 if (trimmed_name.length() > 0) | 81 if (trimmed_name.length() > 0) |
| 82 return trimmed_name; | 82 return trimmed_name; |
| 83 | 83 |
| 84 name = StringToStdWString(element->getAttribute(WebCore::HTMLNames::idAttr)); | 84 name = StringToString16(element->getAttribute(WebCore::HTMLNames::idAttr)); |
| 85 TrimWhitespace(name, TRIM_LEADING, &trimmed_name); | 85 TrimWhitespace(name, TRIM_LEADING, &trimmed_name); |
| 86 if (trimmed_name.length() > 0) | 86 if (trimmed_name.length() > 0) |
| 87 return trimmed_name; | 87 return trimmed_name; |
| 88 | 88 |
| 89 return std::wstring(); | 89 return string16(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace webkit_glue | 92 } // namespace webkit_glue |
| OLD | NEW |