OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "Document.h" | 7 #include "Document.h" |
8 #include "Frame.h" | 8 #include "Frame.h" |
9 #include "HTMLFormElement.h" | 9 #include "HTMLFormElement.h" |
10 #include "HTMLInputElement.h" | 10 #include "HTMLInputElement.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 return NULL; | 35 return NULL; |
36 | 36 |
37 WebCore::FrameLoader* loader = frame->loader(); | 37 WebCore::FrameLoader* loader = frame->loader(); |
38 if (!loader) | 38 if (!loader) |
39 return NULL; | 39 return NULL; |
40 | 40 |
41 // Construct a new FormFieldValues. | 41 // Construct a new FormFieldValues. |
42 FormFieldValues* result = new FormFieldValues(); | 42 FormFieldValues* result = new FormFieldValues(); |
43 | 43 |
44 result->form_name = StringToString16(form->name()); | 44 result->form_name = StringToString16(form->name()); |
| 45 result->method = StringToString16(form->method()); |
45 result->source_url = KURLToGURL(document->url()); | 46 result->source_url = KURLToGURL(document->url()); |
46 result->target_url = KURLToGURL(document->completeURL(form->action())); | 47 result->target_url = KURLToGURL(document->completeURL(form->action())); |
47 result->ExtractFormFieldValues(webform); | 48 result->ExtractFormFieldValues(webform); |
48 | 49 |
49 return result; | 50 return result; |
50 } | 51 } |
51 | 52 |
52 void FormFieldValues::ExtractFormFieldValues(const WebKit::WebForm& webform) { | 53 void FormFieldValues::ExtractFormFieldValues(const WebKit::WebForm& webform) { |
53 RefPtr<WebCore::HTMLFormElement> form = WebFormToHTMLFormElement(webform); | 54 RefPtr<WebCore::HTMLFormElement> form = WebFormToHTMLFormElement(webform); |
54 | 55 |
(...skipping 12 matching lines...) Expand all Loading... |
67 if (!input_element->isEnabledFormControl()) | 68 if (!input_element->isEnabledFormControl()) |
68 continue; | 69 continue; |
69 | 70 |
70 // Ignore all input types except TEXT. | 71 // Ignore all input types except TEXT. |
71 if (input_element->inputType() != WebCore::HTMLInputElement::TEXT) | 72 if (input_element->inputType() != WebCore::HTMLInputElement::TEXT) |
72 continue; | 73 continue; |
73 | 74 |
74 // For each TEXT input field, store the name and value | 75 // For each TEXT input field, store the name and value |
75 string16 value = StringToString16(input_element->value()); | 76 string16 value = StringToString16(input_element->value()); |
76 TrimWhitespace(value, TRIM_LEADING, &value); | 77 TrimWhitespace(value, TRIM_LEADING, &value); |
77 if (value.length() == 0) | 78 if (value.empty()) |
78 continue; | 79 continue; |
79 | 80 |
80 string16 name = StringToString16(WebKit::nameOfInputElement(input_element)); | 81 string16 name = StringToString16(WebKit::nameOfInputElement(input_element)); |
81 if (name.length() == 0) | 82 if (name.empty()) |
82 continue; // If we have no name, there is nothing to store. | 83 continue; // If we have no name, there is nothing to store. |
83 | 84 |
84 elements.push_back(FormField(name, value)); | 85 string16 type = StringToString16(input_element->formControlType()); |
| 86 if (type.empty()) |
| 87 continue; |
| 88 |
| 89 elements.push_back(FormField(name, type, value)); |
85 } | 90 } |
86 } | 91 } |
87 | 92 |
88 } // namespace webkit_glue | 93 } // namespace webkit_glue |
OLD | NEW |