diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-10 03:59:11 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-10 03:59:11 +0000 |
commit | a151aa05cb2beecdb9f92a108ff78fa11ea9ce2e (patch) | |
tree | a58db79ec08d6fc45827106bc9aa2c5e2434ac52 /webkit | |
parent | 56aaac0fa20bf3033f12f71a920431db1c7f0cc5 (diff) | |
download | chromium_src-a151aa05cb2beecdb9f92a108ff78fa11ea9ce2e.zip chromium_src-a151aa05cb2beecdb9f92a108ff78fa11ea9ce2e.tar.gz chromium_src-a151aa05cb2beecdb9f92a108ff78fa11ea9ce2e.tar.bz2 |
Revert "Move conditions of FormFields creation to FormFieldHistoryManager;
AutoFill does not have the same conditions. This required manipulating
the FormField data structure to add necessary field data."
This reverts commit r38570.
TBR=jhawkins
Review URL: http://codereview.chromium.org/602014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38573 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/form_field.cc | 28 | ||||
-rw-r--r-- | webkit/glue/form_field.h | 13 | ||||
-rw-r--r-- | webkit/glue/form_field_values.cc | 37 |
3 files changed, 37 insertions, 41 deletions
diff --git a/webkit/glue/form_field.cc b/webkit/glue/form_field.cc index 4d95cb8..a87644f 100644 --- a/webkit/glue/form_field.cc +++ b/webkit/glue/form_field.cc @@ -4,39 +4,19 @@ #include "webkit/glue/form_field.h" -#include "base/string_util.h" - -using WebKit::WebInputElement; - namespace webkit_glue { FormField::FormField() { } -FormField::FormField(const WebInputElement& input_element) { - name_ = input_element.nameForAutofill(); - - // TODO(jhawkins): Extract the field label. For now we just use the field - // name. - label_ = name_; - - value_ = input_element.value(); - TrimWhitespace(value_, TRIM_LEADING, &value_); - - form_control_type_ = input_element.formControlType(); - input_type_ = input_element.inputType(); -} - FormField::FormField(const string16& label, const string16& name, - const string16& value, - const string16& form_control_type, - WebInputElement::InputType input_type) + const string16& html_input_type, + const string16& value) : label_(label), name_(name), - value_(value), - form_control_type_(form_control_type), - input_type_(input_type) { + html_input_type_(html_input_type), + value_(value) { } } // namespace webkit_glue diff --git a/webkit/glue/form_field.h b/webkit/glue/form_field.h index dfaf9ce..9711c38 100644 --- a/webkit/glue/form_field.h +++ b/webkit/glue/form_field.h @@ -6,7 +6,6 @@ #define WEBKIT_GLUE_FORM_FIELD_H_ #include "base/string16.h" -#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" namespace webkit_glue { @@ -14,27 +13,23 @@ namespace webkit_glue { class FormField { public: FormField(); - explicit FormField(const WebKit::WebInputElement& input_element); FormField(const string16& label, const string16& name, - const string16& value, - const string16& form_control_type, - WebKit::WebInputElement::InputType input_type); + const string16& html_input_type, + const string16& value); string16 label() const { return label_; } string16 name() const { return name_; } + string16 html_input_type() const { return html_input_type_; } string16 value() const { return value_; } - string16 form_control_type() const { return form_control_type_; } - WebKit::WebInputElement::InputType input_type() const { return input_type_; } void set_value(const string16& value) { value_ = value; } private: string16 label_; string16 name_; + string16 html_input_type_; string16 value_; - string16 form_control_type_; - WebKit::WebInputElement::InputType input_type_; }; } // namespace webkit_glue diff --git a/webkit/glue/form_field_values.cc b/webkit/glue/form_field_values.cc index 00f3984..6118889 100644 --- a/webkit/glue/form_field_values.cc +++ b/webkit/glue/form_field_values.cc @@ -5,16 +5,13 @@ #include "base/basictypes.h" #include "base/logging.h" #include "base/string16.h" +#include "base/string_util.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" #include "webkit/glue/form_field_values.h" -using WebKit::WebFormElement; -using WebKit::WebFrame; -using WebKit::WebInputElement; -using WebKit::WebVector; - +using namespace WebKit; namespace webkit_glue { FormFieldValues* FormFieldValues::Create(const WebFormElement& form) { @@ -36,14 +33,38 @@ FormFieldValues* FormFieldValues::Create(const WebFormElement& form) { return result; } -void FormFieldValues::ExtractFormFieldValues(const WebFormElement& form) { +void FormFieldValues::ExtractFormFieldValues( + const WebKit::WebFormElement& form) { + WebVector<WebInputElement> input_elements; form.getInputElements(input_elements); for (size_t i = 0; i < input_elements.size(); i++) { const WebInputElement& input_element = input_elements[i]; - if (input_element.isEnabledFormControl()) - elements.push_back(FormField(input_element)); + if (!input_element.isEnabledFormControl()) + continue; + + // Ignore all input types except TEXT. + if (input_element.inputType() != WebInputElement::Text) + continue; + + // For each TEXT input field, store the name and value + string16 value = input_element.value(); + TrimWhitespace(value, TRIM_LEADING, &value); + if (value.empty()) + continue; + + string16 name = input_element.nameForAutofill(); + if (name.empty()) + continue; // If we have no name, there is nothing to store. + + string16 type = input_element.formControlType(); + if (type.empty()) + continue; + + // TODO(jhawkins): Extract the field label. For now we just use the field + // name. + elements.push_back(FormField(name, name, type, value)); } } |