| 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 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 | 7 |
| 8 MSVC_PUSH_WARNING_LEVEL(0); | 8 MSVC_PUSH_WARNING_LEVEL(0); |
| 9 #include "Frame.h" | 9 #include "Frame.h" |
| 10 #include "HTMLInputElement.h" | 10 #include "HTMLInputElement.h" |
| 11 #include "HTMLNames.h" | 11 #include "HTMLNames.h" |
| 12 MSVC_POP_WARNING(); | 12 MSVC_POP_WARNING(); |
| 13 | 13 |
| 14 #undef LOG | 14 #undef LOG |
| 15 | 15 |
| 16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/string_util.h" |
| 18 #include "webkit/glue/autofill_form.h" | 19 #include "webkit/glue/autofill_form.h" |
| 19 #include "webkit/glue/glue_util.h" | 20 #include "webkit/glue/glue_util.h" |
| 20 | 21 |
| 21 AutofillForm* AutofillForm::CreateAutofillForm( | 22 AutofillForm* AutofillForm::CreateAutofillForm( |
| 22 WebCore::HTMLFormElement* form) { | 23 WebCore::HTMLFormElement* form) { |
| 23 | 24 |
| 24 DCHECK(form); | 25 DCHECK(form); |
| 25 | 26 |
| 26 WebCore::Frame* frame = form->document()->frame(); | 27 WebCore::Frame* frame = form->document()->frame(); |
| 27 | 28 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 50 WebCore::HTMLInputElement* input_element = | 51 WebCore::HTMLInputElement* input_element = |
| 51 static_cast<WebCore::HTMLInputElement*>(form_element); | 52 static_cast<WebCore::HTMLInputElement*>(form_element); |
| 52 if (!input_element->isEnabled()) | 53 if (!input_element->isEnabled()) |
| 53 continue; | 54 continue; |
| 54 | 55 |
| 55 // Ignore all input types except TEXT. | 56 // Ignore all input types except TEXT. |
| 56 if (input_element->inputType() != WebCore::HTMLInputElement::TEXT) | 57 if (input_element->inputType() != WebCore::HTMLInputElement::TEXT) |
| 57 continue; | 58 continue; |
| 58 | 59 |
| 59 // For each TEXT input field, store the name and value | 60 // For each TEXT input field, store the name and value |
| 60 std::wstring name = webkit_glue::StringToStdWString(input_element->name()); | |
| 61 std::wstring value = webkit_glue::StringToStdWString( | 61 std::wstring value = webkit_glue::StringToStdWString( |
| 62 input_element->value()); | 62 input_element->value()); |
| 63 TrimWhitespace(value, TRIM_LEADING, &value); |
| 64 if (value.length() == 0) |
| 65 continue; |
| 66 |
| 67 std::wstring name = webkit_glue::StringToStdWString(input_element->name()); |
| 68 // Test that the name is not blank. |
| 69 std::wstring trimmed_name; |
| 70 TrimWhitespace(name, TRIM_LEADING, &trimmed_name); |
| 71 if (trimmed_name.length() == 0) |
| 72 continue; |
| 63 | 73 |
| 64 result->elements.push_back(AutofillForm::Element(name, value)); | 74 result->elements.push_back(AutofillForm::Element(name, value)); |
| 65 } | 75 } |
| 66 | 76 |
| 67 return result; | 77 return result; |
| 68 } | 78 } |
| OLD | NEW |