diff options
author | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-05 01:29:14 +0000 |
---|---|---|
committer | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-05 01:29:14 +0000 |
commit | 1ecbe866c38fb6c781d337393b7ff62d0c662f4e (patch) | |
tree | 37ddf68241e68df9035f2c612388369f1539fe4d /chrome/renderer | |
parent | 456cface8888f0e39742243f25295d55c8922744 (diff) | |
download | chromium_src-1ecbe866c38fb6c781d337393b7ff62d0c662f4e.zip chromium_src-1ecbe866c38fb6c781d337393b7ff62d0c662f4e.tar.gz chromium_src-1ecbe866c38fb6c781d337393b7ff62d0c662f4e.tar.bz2 |
Move forms/ out of webkit/.
The motivation for this CL is to move PasswordForm and friends (which are totally unrelated to WebKit) out of webkit/ and into a target that platforms that do not use WebKit (such as iOS) can logically depend on.
As such, this CL does three things:
1. Separates the WebKit-related code in webkit/forms from the
non-WebKit-related code. Concretely, this means having the WebKit::WebFormElement->PasswordForm conversion function in its own file.
2. Moves the core, non-WebKit-related forms code to chrome/common and content/public/common depending on where its usage points are.
3. Moves the above-mentioned conversion function to content/public/renderer. It cannot stay in webkit/ as it (now) has a dependency on content/, and as it is used only in chrome/renderer and content/renderer, this is a good place for it.
The rest of this CL is churn due to namespace, file location, and GYP target changes.
BUG=
Review URL: https://chromiumcodereview.appspot.com/11000016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160280 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/DEPS | 1 | ||||
-rw-r--r-- | chrome/renderer/autofill/autofill_agent.cc | 26 | ||||
-rw-r--r-- | chrome/renderer/autofill/autofill_agent.h | 16 | ||||
-rw-r--r-- | chrome/renderer/autofill/autofill_renderer_browsertest.cc | 22 | ||||
-rw-r--r-- | chrome/renderer/autofill/form_autocomplete_browsertest.cc | 7 | ||||
-rw-r--r-- | chrome/renderer/autofill/form_autofill_browsertest.cc | 385 | ||||
-rw-r--r-- | chrome/renderer/autofill/form_autofill_util.cc | 39 | ||||
-rw-r--r-- | chrome/renderer/autofill/form_autofill_util.h | 20 | ||||
-rw-r--r-- | chrome/renderer/autofill/form_cache.cc | 10 | ||||
-rw-r--r-- | chrome/renderer/autofill/form_cache.h | 8 | ||||
-rw-r--r-- | chrome/renderer/autofill/password_autofill_manager.cc | 43 | ||||
-rw-r--r-- | chrome/renderer/autofill/password_autofill_manager.h | 14 | ||||
-rw-r--r-- | chrome/renderer/autofill/password_autofill_manager_browsertest.cc | 13 | ||||
-rw-r--r-- | chrome/renderer/autofill/password_generation_manager.cc | 12 | ||||
-rw-r--r-- | chrome/renderer/autofill/password_generation_manager.h | 8 | ||||
-rw-r--r-- | chrome/renderer/autofill/password_generation_manager_browsertest.cc | 2 |
16 files changed, 298 insertions, 328 deletions
diff --git a/chrome/renderer/DEPS b/chrome/renderer/DEPS index d86e5de3..768d625 100644 --- a/chrome/renderer/DEPS +++ b/chrome/renderer/DEPS @@ -14,7 +14,6 @@ include_rules = [ "+webkit/extensions", "+webkit/fileapi", - "+webkit/forms", # Defines some types that are marshalled over IPC. "+webkit/glue", "+webkit/glue/plugins", "+webkit/gpu", diff --git a/chrome/renderer/autofill/autofill_agent.cc b/chrome/renderer/autofill/autofill_agent.cc index a86a213..bd574c0 100644 --- a/chrome/renderer/autofill/autofill_agent.cc +++ b/chrome/renderer/autofill/autofill_agent.cc @@ -12,8 +12,12 @@ #include "base/utf_string_conversions.h" #include "chrome/common/autofill_messages.h" #include "chrome/common/chrome_constants.h" +#include "chrome/common/form_data.h" +#include "chrome/common/form_data_predictions.h" +#include "chrome/common/form_field_data.h" #include "chrome/renderer/autofill/form_autofill_util.h" #include "chrome/renderer/autofill/password_autofill_manager.h" +#include "content/public/common/password_form.h" #include "content/public/renderer/render_view.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -28,10 +32,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/l10n/l10n_util.h" -#include "webkit/forms/form_data.h" -#include "webkit/forms/form_data_predictions.h" -#include "webkit/forms/form_field.h" -#include "webkit/forms/password_form.h" using WebKit::WebAutofillClient; using WebKit::WebFormControlElement; @@ -43,8 +43,6 @@ using WebKit::WebNode; using WebKit::WebNodeCollection; using WebKit::WebOptionElement; using WebKit::WebString; -using webkit::forms::FormData; -using webkit::forms::FormDataPredictions; namespace { @@ -169,7 +167,7 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { // The document has now been fully loaded. Scan for forms to be sent up to // the browser. - std::vector<webkit::forms::FormData> forms; + std::vector<FormData> forms; form_cache_.ExtractForms(*frame, &forms); if (!forms.empty()) { @@ -334,8 +332,8 @@ void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) { ShowSuggestions(element, false, true, false); - webkit::forms::FormData form; - webkit::forms::FormField field; + FormData form; + FormFieldData field; if (FindFormAndFieldForInputElement(element, &form, &field, REQUIRE_NONE)) { Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field, base::TimeTicks::Now())); @@ -507,7 +505,7 @@ void AutofillAgent::AcceptDataListSuggestion(const string16& suggested_value) { } void AutofillAgent::OnFormDataFilled(int query_id, - const webkit::forms::FormData& form) { + const FormData& form) { if (!render_view()->GetWebView() || query_id != autofill_query_id_) return; @@ -626,8 +624,8 @@ void AutofillAgent::QueryAutofillSuggestions(const WebInputElement& element, autofill_query_id_ = query_counter++; display_warning_if_disabled_ = display_warning_if_disabled; - webkit::forms::FormData form; - webkit::forms::FormField field; + FormData form; + FormFieldData field; if (!FindFormAndFieldForInputElement(element, &form, &field, REQUIRE_AUTOCOMPLETE)) { // If we didn't find the cached form, at least let autocomplete have a shot @@ -675,8 +673,8 @@ void AutofillAgent::FillAutofillFormData(const WebNode& node, static int query_counter = 0; autofill_query_id_ = query_counter++; - webkit::forms::FormData form; - webkit::forms::FormField field; + FormData form; + FormFieldData field; if (!FindFormAndFieldForInputElement(node.toConst<WebInputElement>(), &form, &field, REQUIRE_AUTOCOMPLETE)) { return; diff --git a/chrome/renderer/autofill/autofill_agent.h b/chrome/renderer/autofill/autofill_agent.h index b269300..89f0a31 100644 --- a/chrome/renderer/autofill/autofill_agent.h +++ b/chrome/renderer/autofill/autofill_agent.h @@ -17,13 +17,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" -namespace webkit { -namespace forms { -struct FormData; -struct FormDataPredictions; -struct FormField; -} -} +struct FormFieldData; namespace WebKit { class WebNode; @@ -100,9 +94,9 @@ class AutofillAgent : public content::RenderViewObserver, const std::vector<string16>& labels, const std::vector<string16>& icons, const std::vector<int>& unique_ids); - void OnFormDataFilled(int query_id, const webkit::forms::FormData& form); + void OnFormDataFilled(int query_id, const FormData& form); void OnFieldTypePredictionsAvailable( - const std::vector<webkit::forms::FormDataPredictions>& forms); + const std::vector<FormDataPredictions>& forms); // For external Autofill selection. void OnSelectAutofillSuggestionAtIndex(int listIndex); @@ -163,8 +157,8 @@ class AutofillAgent : public content::RenderViewObserver, // |node|. Returns true if the data was found; and false otherwise. bool FindFormAndFieldForNode( const WebKit::WebNode& node, - webkit::forms::FormData* form, - webkit::forms::FormField* field) WARN_UNUSED_RESULT; + FormData* form, + FormFieldData* field) WARN_UNUSED_RESULT; // Set |node| to display the given |value|. void SetNodeText(const string16& value, WebKit::WebInputElement* node); diff --git a/chrome/renderer/autofill/autofill_renderer_browsertest.cc b/chrome/renderer/autofill/autofill_renderer_browsertest.cc index 6f38ca9..dd6171b 100644 --- a/chrome/renderer/autofill/autofill_renderer_browsertest.cc +++ b/chrome/renderer/autofill/autofill_renderer_browsertest.cc @@ -4,20 +4,18 @@ #include "base/utf_string_conversions.h" #include "chrome/common/autofill_messages.h" +#include "chrome/common/form_data.h" +#include "chrome/common/form_field_data.h" #include "chrome/test/base/chrome_render_view_test.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" -#include "webkit/forms/form_data.h" -#include "webkit/forms/form_field.h" using WebKit::WebDocument; using WebKit::WebFrame; using WebKit::WebInputElement; using WebKit::WebString; -using webkit::forms::FormData; -using webkit::forms::FormField; namespace autofill { @@ -49,31 +47,31 @@ TEST_F(ChromeRenderViewTest, SendForms) { ASSERT_EQ(1UL, forms.size()); ASSERT_EQ(4UL, forms[0].fields.size()); - FormField expected; + FormFieldData expected; expected.name = ASCIIToUTF16("firstname"); expected.value = string16(); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, forms[0].fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[0]); expected.name = ASCIIToUTF16("middlename"); expected.value = string16(); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, forms[0].fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[1]); expected.name = ASCIIToUTF16("lastname"); expected.value = string16(); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, forms[0].fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[2]); expected.name = ASCIIToUTF16("state"); expected.value = ASCIIToUTF16("?"); expected.form_control_type = ASCIIToUTF16("select-one"); expected.max_length = 0; - EXPECT_FORM_FIELD_EQUALS(expected, forms[0].fields[3]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[3]); // Verify that |didAcceptAutofillSuggestion()| sends the expected number of // fields. @@ -110,19 +108,19 @@ TEST_F(ChromeRenderViewTest, SendForms) { expected.value = string16(); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, form2.fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[0]); expected.name = ASCIIToUTF16("middlename"); expected.value = string16(); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, form2.fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[1]); expected.name = ASCIIToUTF16("state"); expected.value = ASCIIToUTF16("?"); expected.form_control_type = ASCIIToUTF16("select-one"); expected.max_length = 0; - EXPECT_FORM_FIELD_EQUALS(expected, form2.fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[2]); } TEST_F(ChromeRenderViewTest, FillFormElement) { diff --git a/chrome/renderer/autofill/form_autocomplete_browsertest.cc b/chrome/renderer/autofill/form_autocomplete_browsertest.cc index 5285231..0249918 100644 --- a/chrome/renderer/autofill/form_autocomplete_browsertest.cc +++ b/chrome/renderer/autofill/form_autocomplete_browsertest.cc @@ -4,16 +4,15 @@ #include "base/time.h" #include "chrome/common/autofill_messages.h" +#include "chrome/common/form_data.h" #include "chrome/test/base/chrome_render_view_test.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError.h" -#include "webkit/forms/form_data.h" #include "webkit/glue/web_io_operators.h" -using webkit::forms::FormData; using WebKit::WebFrame; using WebKit::WebString; using WebKit::WebURLError; @@ -40,7 +39,7 @@ TEST_F(FormAutocompleteTest, NormalFormSubmit) { AutofillHostMsg_FormSubmitted::Read(message, &forms); ASSERT_EQ(2U, forms.a.fields.size()); - webkit::forms::FormField& form_field = forms.a.fields[0]; + FormFieldData& form_field = forms.a.fields[0]; EXPECT_EQ(WebString("fname"), form_field.name); EXPECT_EQ(WebString("Rick"), form_field.value); @@ -89,7 +88,7 @@ TEST_F(FormAutocompleteTest, AutoCompleteOffInputSubmit) { AutofillHostMsg_FormSubmitted::Read(message, &forms); ASSERT_EQ(1U, forms.a.fields.size()); - webkit::forms::FormField& form_field = forms.a.fields[0]; + FormFieldData& form_field = forms.a.fields[0]; EXPECT_EQ(WebString("fname"), form_field.name); EXPECT_EQ(WebString("Rick"), form_field.value); } diff --git a/chrome/renderer/autofill/form_autofill_browsertest.cc b/chrome/renderer/autofill/form_autofill_browsertest.cc index ae91235..15ab038e 100644 --- a/chrome/renderer/autofill/form_autofill_browsertest.cc +++ b/chrome/renderer/autofill/form_autofill_browsertest.cc @@ -9,6 +9,7 @@ #include "base/string_util.h" #include "base/stringprintf.h" #include "base/utf_string_conversions.h" +#include "chrome/common/form_data.h" #include "chrome/renderer/autofill/form_autofill_util.h" #include "chrome/renderer/autofill/form_cache.h" #include "chrome/test/base/chrome_render_view_test.h" @@ -22,7 +23,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebSelectElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" -#include "webkit/forms/form_data.h" #include "webkit/glue/web_io_operators.h" using WebKit::WebDocument; @@ -44,9 +44,6 @@ using autofill::FormCache; using autofill::PreviewForm; using autofill::WebFormControlElementToFormField; -using webkit::forms::FormData; -using webkit::forms::FormField; - class FormAutofillTest : public ChromeRenderViewTest { public: FormAutofillTest() : ChromeRenderViewTest() {} @@ -84,19 +81,19 @@ class FormAutofillTest : public ChromeRenderViewTest { EXPECT_EQ(GURL(web_frame->document().url()), form.origin); EXPECT_EQ(GURL("http://cnn.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(labels.size(), fields.size()); for (size_t i = 0; i < labels.size(); ++i) { int max_length = control_types[i] == ASCIIToUTF16("text") ? WebInputElement::defaultMaxLength() : 0; - FormField expected; + FormFieldData expected; expected.label = labels[i]; expected.name = names[i]; expected.value = values[i]; expected.form_control_type = control_types[i]; expected.max_length = max_length; SCOPED_TRACE(StringPrintf("i: %" PRIuS, i)); - EXPECT_FORM_FIELD_EQUALS(expected, fields[i]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[i]); } } @@ -131,23 +128,23 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormField) { WebElement web_element = frame->document().getElementById("element"); WebFormControlElement element = web_element.to<WebFormControlElement>(); - FormField result1; + FormFieldData result1; WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result1); - FormField expected; + FormFieldData expected; expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); expected.name = ASCIIToUTF16("element"); expected.value = string16(); - EXPECT_FORM_FIELD_EQUALS(expected, result1); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result1); - FormField result2; + FormFieldData result2; WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result2); expected.name = ASCIIToUTF16("element"); expected.value = ASCIIToUTF16("value"); - EXPECT_FORM_FIELD_EQUALS(expected, result2); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result2); } // We should be able to extract a text field with autocomplete="off". @@ -160,15 +157,15 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutocompleteOff) { WebElement web_element = frame->document().getElementById("element"); WebFormControlElement element = web_element.to<WebFormControlElement>(); - FormField result; + FormFieldData result; WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); - FormField expected; + FormFieldData expected; expected.name = ASCIIToUTF16("element"); expected.value = ASCIIToUTF16("value"); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, result); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); } // We should be able to extract a text field with maxlength specified. @@ -181,15 +178,15 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldMaxLength) { WebElement web_element = frame->document().getElementById("element"); WebFormControlElement element = web_element.to<WebFormControlElement>(); - FormField result; + FormFieldData result; WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); - FormField expected; + FormFieldData expected; expected.name = ASCIIToUTF16("element"); expected.value = ASCIIToUTF16("value"); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = 5; - EXPECT_FORM_FIELD_EQUALS(expected, result); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); } // We should be able to extract a text field that has been autofilled. @@ -202,16 +199,16 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutofilled) { WebElement web_element = frame->document().getElementById("element"); WebInputElement element = web_element.to<WebInputElement>(); element.setAutofilled(true); - FormField result; + FormFieldData result; WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); - FormField expected; + FormFieldData expected; expected.name = ASCIIToUTF16("element"); expected.value = ASCIIToUTF16("value"); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); expected.is_autofilled = true; - EXPECT_FORM_FIELD_EQUALS(expected, result); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); } // We should be able to extract a <select> field. @@ -226,31 +223,31 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldSelect) { WebElement web_element = frame->document().getElementById("element"); WebFormControlElement element = web_element.to<WebFormControlElement>(); - FormField result1; + FormFieldData result1; WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result1); - FormField expected; + FormFieldData expected; expected.name = ASCIIToUTF16("element"); expected.max_length = 0; expected.form_control_type = ASCIIToUTF16("select-one"); expected.value = ASCIIToUTF16("CA"); - EXPECT_FORM_FIELD_EQUALS(expected, result1); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result1); - FormField result2; + FormFieldData result2; WebFormControlElementToFormField( element, static_cast<autofill::ExtractMask>(autofill::EXTRACT_VALUE | autofill::EXTRACT_OPTION_TEXT), &result2); expected.value = ASCIIToUTF16("California"); - EXPECT_FORM_FIELD_EQUALS(expected, result2); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result2); - FormField result3; + FormFieldData result3; WebFormControlElementToFormField(element, autofill::EXTRACT_OPTIONS, &result3); expected.value = string16(); - EXPECT_FORM_FIELD_EQUALS(expected, result3); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result3); ASSERT_EQ(2U, result3.option_values.size()); ASSERT_EQ(2U, result3.option_contents.size()); @@ -275,36 +272,36 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldInvalidType) { WebElement web_element = frame->document().getElementById("hidden"); WebFormControlElement element = web_element.to<WebFormControlElement>(); - FormField result; + FormFieldData result; WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); - FormField expected; + FormFieldData expected; expected.max_length = 0; expected.name = ASCIIToUTF16("hidden"); expected.form_control_type = ASCIIToUTF16("hidden"); - EXPECT_FORM_FIELD_EQUALS(expected, result); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); web_element = frame->document().getElementById("password"); element = web_element.to<WebFormControlElement>(); WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); expected.name = ASCIIToUTF16("password"); expected.form_control_type = ASCIIToUTF16("password"); - EXPECT_FORM_FIELD_EQUALS(expected, result); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); web_element = frame->document().getElementById("checkbox"); element = web_element.to<WebFormControlElement>(); WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); expected.name = ASCIIToUTF16("checkbox"); expected.form_control_type = ASCIIToUTF16("checkbox"); - EXPECT_FORM_FIELD_EQUALS(expected, result); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); web_element = frame->document().getElementById("radio"); element = web_element.to<WebFormControlElement>(); WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); expected.name = ASCIIToUTF16("radio"); expected.form_control_type = ASCIIToUTF16("radio"); - EXPECT_FORM_FIELD_EQUALS(expected, result); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); web_element = frame->document().getElementById("submit"); @@ -312,7 +309,7 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldInvalidType) { WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); expected.name = ASCIIToUTF16("submit"); expected.form_control_type = ASCIIToUTF16("submit"); - EXPECT_FORM_FIELD_EQUALS(expected, result); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); } // We should be able to extract the autocompletetype attribute. @@ -340,93 +337,93 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutocompletetype) { // An absent attribute is equivalent to an empty one. WebElement web_element = frame->document().getElementById("absent"); WebFormControlElement element = web_element.to<WebFormControlElement>(); - FormField result1; + FormFieldData result1; WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result1); - FormField expected; + FormFieldData expected; expected.name = ASCIIToUTF16("absent"); expected.form_control_type = ASCIIToUTF16("text"); expected.autocomplete_type = string16(); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, result1); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result1); web_element = frame->document().getElementById("empty"); element = web_element.to<WebFormControlElement>(); - FormField result2; + FormFieldData result2; WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result2); expected.name = ASCIIToUTF16("empty"); expected.form_control_type = ASCIIToUTF16("text"); expected.autocomplete_type = string16(); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, result2); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result2); // The renderer should trim whitespace. web_element = frame->document().getElementById("whitespace"); element = web_element.to<WebFormControlElement>(); - FormField result3; + FormFieldData result3; WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result3); expected.name = ASCIIToUTF16("whitespace"); expected.form_control_type = ASCIIToUTF16("text"); expected.autocomplete_type = string16(); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, result3); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result3); // Common case: exactly one type specified. web_element = frame->document().getElementById("regular"); element = web_element.to<WebFormControlElement>(); - FormField result4; + FormFieldData result4; WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result4); expected.name = ASCIIToUTF16("regular"); expected.form_control_type = ASCIIToUTF16("text"); expected.autocomplete_type = ASCIIToUTF16("email"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, result4); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result4); // Verify that we correctly extract fallback types as well. web_element = frame->document().getElementById("multi-valued"); element = web_element.to<WebFormControlElement>(); - FormField result5; + FormFieldData result5; WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result5); expected.name = ASCIIToUTF16("multi-valued"); expected.form_control_type = ASCIIToUTF16("text"); expected.autocomplete_type = ASCIIToUTF16("x-confirm-email email"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, result5); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result5); // The attribute is not yet part of the HTML standard, so we only recognize // the prefixed version -- 'x-autocompletetype' -- and not the unprefixed one. web_element = frame->document().getElementById("unprefixed"); element = web_element.to<WebFormControlElement>(); - FormField result6; + FormFieldData result6; WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result6); expected.name = ASCIIToUTF16("unprefixed"); expected.form_control_type = ASCIIToUTF16("text"); expected.autocomplete_type = string16(); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, result6); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result6); // <select> elements should behave no differently from text fields here. web_element = frame->document().getElementById("select"); element = web_element.to<WebFormControlElement>(); - FormField result7; + FormFieldData result7; WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result7); expected.name = ASCIIToUTF16("select"); expected.form_control_type = ASCIIToUTF16("select-one"); expected.autocomplete_type = ASCIIToUTF16("state"); expected.max_length = 0; - EXPECT_FORM_FIELD_EQUALS(expected, result7); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result7); // Very long attribute values should be replaced by a default string, to // prevent malicious websites from DOSing the browser process. web_element = frame->document().getElementById("malicious"); element = web_element.to<WebFormControlElement>(); - FormField result8; + FormFieldData result8; WebFormControlElementToFormField(element, autofill::EXTRACT_NONE, &result8); expected.name = ASCIIToUTF16("malicious"); expected.form_control_type = ASCIIToUTF16("text"); expected.autocomplete_type = ASCIIToUTF16("x-max-data-length-exceeded"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, result8); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, result8); } TEST_F(FormAutofillTest, WebFormElementToFormData) { @@ -459,7 +456,7 @@ TEST_F(FormAutofillTest, WebFormElementToFormData) { WebInputElement input_element = element.to<WebInputElement>(); FormData form; - FormField field; + FormFieldData field; EXPECT_TRUE(WebFormElementToFormData(forms[0], input_element, autofill::REQUIRE_NONE, @@ -470,30 +467,30 @@ TEST_F(FormAutofillTest, WebFormElementToFormData) { EXPECT_EQ(GURL(frame->document().url()), form.origin); EXPECT_EQ(GURL("http://cnn.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(3U, fields.size()); - FormField expected; + FormFieldData expected; expected.name = ASCIIToUTF16("firstname"); expected.value = ASCIIToUTF16("John"); expected.label = ASCIIToUTF16("First name:"); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = ASCIIToUTF16("Smith"); expected.label = ASCIIToUTF16("Last name:"); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("state"); expected.value = ASCIIToUTF16("CA"); expected.label = ASCIIToUTF16("State:"); expected.form_control_type = ASCIIToUTF16("select-one"); expected.max_length = 0; - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); } // We should not be able to serialize a form with too many fillable fields. @@ -517,7 +514,7 @@ TEST_F(FormAutofillTest, WebFormElementToFormDataTooManyFields) { WebInputElement input_element = element.to<WebInputElement>(); FormData form; - FormField field; + FormFieldData field; EXPECT_FALSE(WebFormElementToFormData(forms[0], input_element, autofill::REQUIRE_NONE, @@ -564,24 +561,24 @@ TEST_F(FormAutofillTest, ExtractMultipleForms) { EXPECT_EQ(GURL(web_frame->document().url()), form.origin); EXPECT_EQ(GURL("http://cnn.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(3U, fields.size()); - FormField expected; + FormFieldData expected; expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); expected.name = ASCIIToUTF16("firstname"); expected.value = ASCIIToUTF16("John"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = ASCIIToUTF16("Smith"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("email"); expected.value = ASCIIToUTF16("john@example.com"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); // Second form. const FormData& form2 = forms[1]; @@ -589,20 +586,20 @@ TEST_F(FormAutofillTest, ExtractMultipleForms) { EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); EXPECT_EQ(GURL("http://zoo.com"), form2.action); - const std::vector<FormField>& fields2 = form2.fields; + const std::vector<FormFieldData>& fields2 = form2.fields; ASSERT_EQ(3U, fields2.size()); expected.name = ASCIIToUTF16("firstname"); expected.value = ASCIIToUTF16("Jack"); - EXPECT_FORM_FIELD_EQUALS(expected, fields2[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = ASCIIToUTF16("Adams"); - EXPECT_FORM_FIELD_EQUALS(expected, fields2[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); expected.name = ASCIIToUTF16("email"); expected.value = ASCIIToUTF16("jack@example.com"); - EXPECT_FORM_FIELD_EQUALS(expected, fields2[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); } // We should not extract a form if it has too few fillable fields. @@ -679,24 +676,24 @@ TEST_F(FormAutofillTest, WebFormElementToFormDataAutocomplete) { EXPECT_EQ(GURL(web_frame->document().url()), form.origin); EXPECT_EQ(GURL("http://abc.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(3U, fields.size()); - FormField expected; + FormFieldData expected; expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); expected.name = ASCIIToUTF16("middlename"); expected.value = ASCIIToUTF16("Jack"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = ASCIIToUTF16("Smith"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("email"); expected.value = ASCIIToUTF16("john@example.com"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); } } @@ -724,47 +721,47 @@ TEST_F(FormAutofillTest, FindForm) { // Find the form and verify it's the correct form. FormData form; - FormField field; + FormFieldData field; EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, autofill::REQUIRE_NONE)); EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); EXPECT_EQ(GURL(web_frame->document().url()), form.origin); EXPECT_EQ(GURL("http://buh.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(4U, fields.size()); - FormField expected; + FormFieldData expected; expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); expected.name = ASCIIToUTF16("firstname"); expected.value = ASCIIToUTF16("John"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); - EXPECT_FORM_FIELD_EQUALS(expected, field); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, field); expected.name = ASCIIToUTF16("lastname"); expected.value = ASCIIToUTF16("Smith"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("email"); expected.value = ASCIIToUTF16("john@example.com"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); expected.name = ASCIIToUTF16("phone"); expected.value = ASCIIToUTF16("1.800.555.1234"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[3]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); // Try again, but require autocomplete. FormData form2; - FormField field2; + FormFieldData field2; EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, autofill::REQUIRE_AUTOCOMPLETE)); EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); EXPECT_EQ(GURL("http://buh.com"), form2.action); - const std::vector<FormField>& fields2 = form2.fields; + const std::vector<FormFieldData>& fields2 = form2.fields; ASSERT_EQ(3U, fields2.size()); expected.form_control_type = ASCIIToUTF16("text"); @@ -772,16 +769,16 @@ TEST_F(FormAutofillTest, FindForm) { expected.name = ASCIIToUTF16("firstname"); expected.value = ASCIIToUTF16("John"); - EXPECT_FORM_FIELD_EQUALS(expected, fields2[0]); - EXPECT_FORM_FIELD_EQUALS(expected, field); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, field); expected.name = ASCIIToUTF16("lastname"); expected.value = ASCIIToUTF16("Smith"); - EXPECT_FORM_FIELD_EQUALS(expected, fields2[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); expected.name = ASCIIToUTF16("phone"); expected.value = ASCIIToUTF16("1.800.555.1234"); - EXPECT_FORM_FIELD_EQUALS(expected, fields2[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); } TEST_F(FormAutofillTest, FillForm) { @@ -813,47 +810,47 @@ TEST_F(FormAutofillTest, FillForm) { // Find the form that contains the input element. FormData form; - FormField field; + FormFieldData field; EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, autofill::REQUIRE_AUTOCOMPLETE)); EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); EXPECT_EQ(GURL(web_frame->document().url()), form.origin); EXPECT_EQ(GURL("http://buh.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(7U, fields.size()); - FormField expected; + FormFieldData expected; expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); expected.name = ASCIIToUTF16("firstname"); expected.value = string16(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = string16(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("notempty"); expected.value = ASCIIToUTF16("Hi"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); expected.name = ASCIIToUTF16("notenabled"); expected.value = string16(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[3]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); expected.name = ASCIIToUTF16("readonly"); expected.value = string16(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[4]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[4]); expected.name = ASCIIToUTF16("invisible"); expected.value = string16(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[5]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[5]); expected.name = ASCIIToUTF16("displaynone"); expected.value = string16(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[6]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[6]); // Fill the form. form.fields[0].value = ASCIIToUTF16("Wyatt"); @@ -940,35 +937,35 @@ TEST_F(FormAutofillTest, PreviewForm) { // Find the form that contains the input element. FormData form; - FormField field; + FormFieldData field; EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, autofill::REQUIRE_AUTOCOMPLETE)); EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); EXPECT_EQ(GURL(web_frame->document().url()), form.origin); EXPECT_EQ(GURL("http://buh.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(4U, fields.size()); - FormField expected; + FormFieldData expected; expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); expected.name = ASCIIToUTF16("firstname"); expected.value = string16(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = string16(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("notempty"); expected.value = ASCIIToUTF16("Hi"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); expected.name = ASCIIToUTF16("notenabled"); expected.value = string16(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[3]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); // Preview the form. form.fields[0].value = ASCIIToUTF16("Wyatt"); @@ -1891,33 +1888,33 @@ TEST_F(FormAutofillTest, FillFormMaxLength) { // Find the form that contains the input element. FormData form; - FormField field; + FormFieldData field; EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, autofill::REQUIRE_NONE)); EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); EXPECT_EQ(GURL(web_frame->document().url()), form.origin); EXPECT_EQ(GURL("http://buh.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(3U, fields.size()); - FormField expected; + FormFieldData expected; expected.form_control_type = ASCIIToUTF16("text"); expected.name = ASCIIToUTF16("firstname"); expected.max_length = 5; expected.is_autofilled = false; - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.name = ASCIIToUTF16("lastname"); expected.max_length = 7; expected.is_autofilled = false; - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("email"); expected.max_length = 9; expected.is_autofilled = false; - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); // Fill the form. form.fields[0].value = ASCIIToUTF16("Brother"); @@ -1927,7 +1924,7 @@ TEST_F(FormAutofillTest, FillFormMaxLength) { // Find the newly-filled form that contains the input element. FormData form2; - FormField field2; + FormFieldData field2; EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, autofill::REQUIRE_NONE)); @@ -1935,7 +1932,7 @@ TEST_F(FormAutofillTest, FillFormMaxLength) { EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); EXPECT_EQ(GURL("http://buh.com"), form2.action); - const std::vector<FormField>& fields2 = form2.fields; + const std::vector<FormFieldData>& fields2 = form2.fields; ASSERT_EQ(3U, fields2.size()); expected.form_control_type = ASCIIToUTF16("text"); @@ -1944,19 +1941,19 @@ TEST_F(FormAutofillTest, FillFormMaxLength) { expected.value = ASCIIToUTF16("Broth"); expected.max_length = 5; expected.is_autofilled = true; - EXPECT_FORM_FIELD_EQUALS(expected, fields2[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = ASCIIToUTF16("Jonatha"); expected.max_length = 7; expected.is_autofilled = true; - EXPECT_FORM_FIELD_EQUALS(expected, fields2[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); expected.name = ASCIIToUTF16("email"); expected.value = ASCIIToUTF16("brotherj@"); expected.max_length = 9; expected.is_autofilled = true; - EXPECT_FORM_FIELD_EQUALS(expected, fields2[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); } // This test uses negative values of the maxlength attribute for input elements. @@ -1984,28 +1981,28 @@ TEST_F(FormAutofillTest, FillFormNegativeMaxLength) { // Find the form that contains the input element. FormData form; - FormField field; + FormFieldData field; EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, autofill::REQUIRE_NONE)); EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); EXPECT_EQ(GURL(web_frame->document().url()), form.origin); EXPECT_EQ(GURL("http://buh.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(3U, fields.size()); - FormField expected; + FormFieldData expected; expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); expected.name = ASCIIToUTF16("firstname"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.name = ASCIIToUTF16("lastname"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("email"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); // Fill the form. form.fields[0].value = ASCIIToUTF16("Brother"); @@ -2015,7 +2012,7 @@ TEST_F(FormAutofillTest, FillFormNegativeMaxLength) { // Find the newly-filled form that contains the input element. FormData form2; - FormField field2; + FormFieldData field2; EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, autofill::REQUIRE_NONE)); @@ -2023,20 +2020,20 @@ TEST_F(FormAutofillTest, FillFormNegativeMaxLength) { EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); EXPECT_EQ(GURL("http://buh.com"), form2.action); - const std::vector<FormField>& fields2 = form2.fields; + const std::vector<FormFieldData>& fields2 = form2.fields; ASSERT_EQ(3U, fields2.size()); expected.name = ASCIIToUTF16("firstname"); expected.value = ASCIIToUTF16("Brother"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = ASCIIToUTF16("Jonathan"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("email"); expected.value = ASCIIToUTF16("brotherj@example.com"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); } TEST_F(FormAutofillTest, FillFormEmptyName) { @@ -2061,28 +2058,28 @@ TEST_F(FormAutofillTest, FillFormEmptyName) { // Find the form that contains the input element. FormData form; - FormField field; + FormFieldData field; EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, autofill::REQUIRE_NONE)); EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); EXPECT_EQ(GURL(web_frame->document().url()), form.origin); EXPECT_EQ(GURL("http://buh.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(3U, fields.size()); - FormField expected; + FormFieldData expected; expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); expected.name = ASCIIToUTF16("firstname"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.name = ASCIIToUTF16("lastname"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("email"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); // Fill the form. form.fields[0].value = ASCIIToUTF16("Wyatt"); @@ -2092,7 +2089,7 @@ TEST_F(FormAutofillTest, FillFormEmptyName) { // Find the newly-filled form that contains the input element. FormData form2; - FormField field2; + FormFieldData field2; EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, autofill::REQUIRE_NONE)); @@ -2100,7 +2097,7 @@ TEST_F(FormAutofillTest, FillFormEmptyName) { EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); EXPECT_EQ(GURL("http://buh.com"), form2.action); - const std::vector<FormField>& fields2 = form2.fields; + const std::vector<FormFieldData>& fields2 = form2.fields; ASSERT_EQ(3U, fields2.size()); expected.form_control_type = ASCIIToUTF16("text"); @@ -2108,15 +2105,15 @@ TEST_F(FormAutofillTest, FillFormEmptyName) { expected.name = ASCIIToUTF16("firstname"); expected.value = ASCIIToUTF16("Wyatt"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = ASCIIToUTF16("Earp"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("email"); expected.value = ASCIIToUTF16("wyatt@example.com"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); } TEST_F(FormAutofillTest, FillFormEmptyFormNames) { @@ -2147,31 +2144,31 @@ TEST_F(FormAutofillTest, FillFormEmptyFormNames) { // Find the form that contains the input element. FormData form; - FormField field; + FormFieldData field; EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, autofill::REQUIRE_NONE)); EXPECT_EQ(string16(), form.name); EXPECT_EQ(GURL(web_frame->document().url()), form.origin); EXPECT_EQ(GURL("http://abc.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(3U, fields.size()); - FormField expected; + FormFieldData expected; expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); expected.name = ASCIIToUTF16("apple"); expected.is_autofilled = false; - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.name = ASCIIToUTF16("banana"); expected.is_autofilled = false; - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("cantelope"); expected.is_autofilled = false; - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); // Fill the form. form.fields[0].value = ASCIIToUTF16("Red"); @@ -2181,7 +2178,7 @@ TEST_F(FormAutofillTest, FillFormEmptyFormNames) { // Find the newly-filled form that contains the input element. FormData form2; - FormField field2; + FormFieldData field2; EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, autofill::REQUIRE_NONE)); @@ -2189,23 +2186,23 @@ TEST_F(FormAutofillTest, FillFormEmptyFormNames) { EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); EXPECT_EQ(GURL("http://abc.com"), form2.action); - const std::vector<FormField>& fields2 = form2.fields; + const std::vector<FormFieldData>& fields2 = form2.fields; ASSERT_EQ(3U, fields2.size()); expected.name = ASCIIToUTF16("apple"); expected.value = ASCIIToUTF16("Red"); expected.is_autofilled = true; - EXPECT_FORM_FIELD_EQUALS(expected, fields2[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); expected.name = ASCIIToUTF16("banana"); expected.value = ASCIIToUTF16("Yellow"); expected.is_autofilled = true; - EXPECT_FORM_FIELD_EQUALS(expected, fields2[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); expected.name = ASCIIToUTF16("cantelope"); expected.value = ASCIIToUTF16("Also Yellow"); expected.is_autofilled = true; - EXPECT_FORM_FIELD_EQUALS(expected, fields2[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); } TEST_F(FormAutofillTest, ThreePartPhone) { @@ -2240,28 +2237,28 @@ TEST_F(FormAutofillTest, ThreePartPhone) { EXPECT_EQ(GURL(frame->document().url()), form.origin); EXPECT_EQ(GURL("http://cnn.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(4U, fields.size()); - FormField expected; + FormFieldData expected; expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); expected.label = ASCIIToUTF16("Phone:"); expected.name = ASCIIToUTF16("dayphone1"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.label = ASCIIToUTF16("-"); expected.name = ASCIIToUTF16("dayphone2"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.label = ASCIIToUTF16("-"); expected.name = ASCIIToUTF16("dayphone3"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); expected.label = ASCIIToUTF16("ext.:"); expected.name = ASCIIToUTF16("dayphone4"); - EXPECT_FORM_FIELD_EQUALS(expected, fields[3]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); } @@ -2299,43 +2296,43 @@ TEST_F(FormAutofillTest, MaxLengthFields) { EXPECT_EQ(GURL(frame->document().url()), form.origin); EXPECT_EQ(GURL("http://cnn.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(6U, fields.size()); - FormField expected; + FormFieldData expected; expected.form_control_type = ASCIIToUTF16("text"); expected.label = ASCIIToUTF16("Phone:"); expected.name = ASCIIToUTF16("dayphone1"); expected.max_length = 3; - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.label = ASCIIToUTF16("-"); expected.name = ASCIIToUTF16("dayphone2"); expected.max_length = 3; - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.label = ASCIIToUTF16("-"); expected.name = ASCIIToUTF16("dayphone3"); expected.max_length = 4; - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); expected.label = ASCIIToUTF16("ext.:"); expected.name = ASCIIToUTF16("dayphone4"); expected.max_length = 5; - EXPECT_FORM_FIELD_EQUALS(expected, fields[3]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); // When unspecified |size|, default is returned. expected.label = string16(); expected.name = ASCIIToUTF16("default1"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[4]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[4]); // When invalid |size|, default is returned. expected.label = string16(); expected.name = ASCIIToUTF16("invalid1"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[5]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[5]); } // This test re-creates the experience of typing in a field then selecting a @@ -2366,34 +2363,34 @@ TEST_F(FormAutofillTest, FillFormNonEmptyField) { // Find the form that contains the input element. FormData form; - FormField field; + FormFieldData field; EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, autofill::REQUIRE_NONE)); EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); EXPECT_EQ(GURL(web_frame->document().url()), form.origin); EXPECT_EQ(GURL("http://buh.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(3U, fields.size()); - FormField expected; + FormFieldData expected; expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); expected.name = ASCIIToUTF16("firstname"); expected.value = ASCIIToUTF16("Wy"); expected.is_autofilled = false; - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = string16(); expected.is_autofilled = false; - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("email"); expected.value = string16(); expected.is_autofilled = false; - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); // Preview the form and verify that the cursor position has been updated. form.fields[0].value = ASCIIToUTF16("Wyatt"); @@ -2408,7 +2405,7 @@ TEST_F(FormAutofillTest, FillFormNonEmptyField) { // Find the newly-filled form that contains the input element. FormData form2; - FormField field2; + FormFieldData field2; EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, autofill::REQUIRE_NONE)); @@ -2416,23 +2413,23 @@ TEST_F(FormAutofillTest, FillFormNonEmptyField) { EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); EXPECT_EQ(GURL("http://buh.com"), form2.action); - const std::vector<FormField>& fields2 = form2.fields; + const std::vector<FormFieldData>& fields2 = form2.fields; ASSERT_EQ(3U, fields2.size()); expected.name = ASCIIToUTF16("firstname"); expected.value = ASCIIToUTF16("Wyatt"); expected.is_autofilled = true; - EXPECT_FORM_FIELD_EQUALS(expected, fields2[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = ASCIIToUTF16("Earp"); expected.is_autofilled = true; - EXPECT_FORM_FIELD_EQUALS(expected, fields2[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); expected.name = ASCIIToUTF16("email"); expected.value = ASCIIToUTF16("wyatt@example.com"); expected.is_autofilled = true; - EXPECT_FORM_FIELD_EQUALS(expected, fields2[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); // Verify that the cursor position has been updated. EXPECT_EQ(5, input_element.selectionStart()); @@ -2475,35 +2472,35 @@ TEST_F(FormAutofillTest, ClearFormWithNode) { // Verify the form is cleared. FormData form2; - FormField field2; + FormFieldData field2; EXPECT_TRUE(FindFormAndFieldForInputElement(firstname, &form2, &field2, autofill::REQUIRE_NONE)); EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); EXPECT_EQ(GURL("http://buh.com"), form2.action); - const std::vector<FormField>& fields2 = form2.fields; + const std::vector<FormFieldData>& fields2 = form2.fields; ASSERT_EQ(4U, fields2.size()); - FormField expected; + FormFieldData expected; expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); expected.name = ASCIIToUTF16("firstname"); expected.value = string16(); - EXPECT_FORM_FIELD_EQUALS(expected, fields2[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = string16(); - EXPECT_FORM_FIELD_EQUALS(expected, fields2[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); expected.name = ASCIIToUTF16("noAC"); expected.value = string16(); - EXPECT_FORM_FIELD_EQUALS(expected, fields2[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); expected.name = ASCIIToUTF16("notenabled"); expected.value = ASCIIToUTF16("no clear"); - EXPECT_FORM_FIELD_EQUALS(expected, fields2[3]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[3]); // Verify that the cursor position has been updated. EXPECT_EQ(0, firstname.selectionStart()); @@ -2550,35 +2547,35 @@ TEST_F(FormAutofillTest, ClearFormWithNodeContainingSelectOne) { // Verify the form is cleared. FormData form2; - FormField field2; + FormFieldData field2; EXPECT_TRUE(FindFormAndFieldForInputElement(firstname, &form2, &field2, autofill::REQUIRE_NONE)); EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); EXPECT_EQ(GURL("http://buh.com"), form2.action); - const std::vector<FormField>& fields2 = form2.fields; + const std::vector<FormFieldData>& fields2 = form2.fields; ASSERT_EQ(3U, fields2.size()); - FormField expected; + FormFieldData expected; expected.name = ASCIIToUTF16("firstname"); expected.value = string16(); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, fields2[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = string16(); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, fields2[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); expected.name = ASCIIToUTF16("state"); expected.value = ASCIIToUTF16("?"); expected.form_control_type = ASCIIToUTF16("select-one"); expected.max_length = 0; - EXPECT_FORM_FIELD_EQUALS(expected, fields2[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); // Verify that the cursor position has been updated. EXPECT_EQ(0, firstname.selectionStart()); @@ -2886,28 +2883,28 @@ TEST_F(FormAutofillTest, SelectOneAsText) { EXPECT_EQ(GURL(frame->document().url()), form.origin); EXPECT_EQ(GURL("http://cnn.com"), form.action); - const std::vector<FormField>& fields = form.fields; + const std::vector<FormFieldData>& fields = form.fields; ASSERT_EQ(3U, fields.size()); - FormField expected; + FormFieldData expected; expected.name = ASCIIToUTF16("firstname"); expected.value = ASCIIToUTF16("John"); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = ASCIIToUTF16("Smith"); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("country"); expected.value = ASCIIToUTF16("Albania"); expected.form_control_type = ASCIIToUTF16("select-one"); expected.max_length = 0; - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); form.fields.clear(); // Extract the country select-one value as value. @@ -2927,17 +2924,17 @@ TEST_F(FormAutofillTest, SelectOneAsText) { expected.value = ASCIIToUTF16("John"); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[0]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); expected.name = ASCIIToUTF16("lastname"); expected.value = ASCIIToUTF16("Smith"); expected.form_control_type = ASCIIToUTF16("text"); expected.max_length = WebInputElement::defaultMaxLength(); - EXPECT_FORM_FIELD_EQUALS(expected, fields[1]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); expected.name = ASCIIToUTF16("country"); expected.value = ASCIIToUTF16("AL"); expected.form_control_type = ASCIIToUTF16("select-one"); expected.max_length = 0; - EXPECT_FORM_FIELD_EQUALS(expected, fields[2]); + EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); } diff --git a/chrome/renderer/autofill/form_autofill_util.cc b/chrome/renderer/autofill/form_autofill_util.cc index 105c89d..42d6ffa 100644 --- a/chrome/renderer/autofill/form_autofill_util.cc +++ b/chrome/renderer/autofill/form_autofill_util.cc @@ -10,6 +10,8 @@ #include "base/memory/scoped_vector.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" +#include "chrome/common/form_data.h" +#include "chrome/common/form_field_data.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement.h" @@ -23,8 +25,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebSelectElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" -#include "webkit/forms/form_data.h" -#include "webkit/forms/form_field.h" using WebKit::WebElement; using WebKit::WebFormControlElement; @@ -38,8 +38,6 @@ using WebKit::WebOptionElement; using WebKit::WebSelectElement; using WebKit::WebString; using WebKit::WebVector; -using webkit::forms::FormData; -using webkit::forms::FormField; namespace { @@ -416,7 +414,7 @@ void GetOptionStringsFromElement(const WebSelectElement& select_element, // The callback type used by |ForEachMatchingFormField()|. typedef void (*Callback)(WebKit::WebFormControlElement*, - const webkit::forms::FormField*, + const FormFieldData*, bool); // For each autofillable field in |data| that matches a field in the |form|, @@ -478,7 +476,7 @@ void ForEachMatchingFormField(const WebFormElement& form_element, // Sets the |field|'s value to the value in |data|. // Also sets the "autofilled" attribute, causing the background to be yellow. void FillFormField(WebKit::WebFormControlElement* field, - const webkit::forms::FormField* data, + const FormFieldData* data, bool is_initiating_node) { // Nothing to fill. if (data->value.empty()) @@ -508,7 +506,7 @@ void FillFormField(WebKit::WebFormControlElement* field, // Sets the |field|'s "suggested" (non JS visible) value to the value in |data|. // Also sets the "autofilled" attribute, causing the background to be yellow. void PreviewFormField(WebKit::WebFormControlElement* field, - const webkit::forms::FormField* data, + const FormFieldData* data, bool is_initiating_node) { // Nothing to preview. if (data->value.empty()) @@ -587,7 +585,7 @@ void ExtractAutofillableElements( void WebFormControlElementToFormField(const WebFormControlElement& element, ExtractMask extract_mask, - FormField* field) { + FormFieldData* field) { DCHECK(field); DCHECK(!element.isNull()); @@ -663,8 +661,8 @@ bool WebFormElementToFormData( const WebKit::WebFormControlElement& form_control_element, RequirementsMask requirements, ExtractMask extract_mask, - webkit::forms::FormData* form, - webkit::forms::FormField* field) { + FormData* form, + FormFieldData* field) { const WebFrame* frame = form_element.document().frame(); if (!frame) return false; @@ -683,12 +681,12 @@ bool WebFormElementToFormData( if (!form->action.is_valid()) form->action = GURL(form_element.action()); - // A map from a FormField's name to the FormField itself. - std::map<string16, FormField*> name_map; + // A map from a FormFieldData's name to the FormFieldData itself. + std::map<string16, FormFieldData*> name_map; // The extracted FormFields. We use pointers so we can store them in // |name_map|. - ScopedVector<FormField> form_fields; + ScopedVector<FormFieldData> form_fields; WebVector<WebFormControlElement> control_elements; form_element.getFormControlElements(control_elements); @@ -708,8 +706,8 @@ bool WebFormElementToFormData( !input_element->autoComplete()) continue; - // Create a new FormField, fill it out and map it to the field's name. - FormField* form_field = new FormField; + // Create a new FormFieldData, fill it out and map it to the field's name. + FormFieldData* form_field = new FormFieldData; WebFormControlElementToFormField(control_element, extract_mask, form_field); form_fields.push_back(form_field); // TODO(jhawkins): A label element is mapped to a form control element's id. @@ -726,8 +724,8 @@ bool WebFormElementToFormData( // Loop through the label elements inside the form element. For each label // element, get the corresponding form control element, use the form control - // element's name as a key into the <name, FormField> map to find the - // previously created FormField and set the FormField's label to the + // element's name as a key into the <name, FormFieldData> map to find the + // previously created FormFieldData and set the FormFieldData's label to the // label.firstChild().nodeValue() of the label element. WebNodeList labels = form_element.getElementsByTagName("label"); for (unsigned i = 0; i < labels.length(); ++i) { @@ -748,7 +746,8 @@ bool WebFormElementToFormData( element_name = field_element.nameForAutofill(); } - std::map<string16, FormField*>::iterator iter = name_map.find(element_name); + std::map<string16, FormFieldData*>::iterator iter = + name_map.find(element_name); if (iter != name_map.end()) { string16 label_text = FindChildText(label); @@ -782,7 +781,7 @@ bool WebFormElementToFormData( } // Copy the created FormFields into the resulting FormData object. - for (ScopedVector<FormField>::const_iterator iter = form_fields.begin(); + for (ScopedVector<FormFieldData>::const_iterator iter = form_fields.begin(); iter != form_fields.end(); ++iter) { form->fields.push_back(**iter); } @@ -792,7 +791,7 @@ bool WebFormElementToFormData( bool FindFormAndFieldForInputElement(const WebInputElement& element, FormData* form, - webkit::forms::FormField* field, + FormFieldData* field, RequirementsMask requirements) { if (!IsAutofillableElement(element)) return false; diff --git a/chrome/renderer/autofill/form_autofill_util.h b/chrome/renderer/autofill/form_autofill_util.h index 99253b8..b63424f 100644 --- a/chrome/renderer/autofill/form_autofill_util.h +++ b/chrome/renderer/autofill/form_autofill_util.h @@ -9,12 +9,8 @@ #include "base/string16.h" -namespace webkit { -namespace forms { struct FormData; -struct FormField; -} -} +struct FormFieldData; namespace WebKit { class WebFormElement; @@ -72,7 +68,7 @@ void ExtractAutofillableElements( void WebFormControlElementToFormField( const WebKit::WebFormControlElement& element, ExtractMask extract_mask, - webkit::forms::FormField* field); + FormFieldData* field); // Fills |form| with the FormData object corresponding to the |form_element|. // If |field| is non-NULL, also fills |field| with the FormField object @@ -86,25 +82,25 @@ bool WebFormElementToFormData( const WebKit::WebFormControlElement& form_control_element, RequirementsMask requirements, ExtractMask extract_mask, - webkit::forms::FormData* form, - webkit::forms::FormField* field); + FormData* form, + FormFieldData* field); // Finds the form that contains |element| and returns it in |form|. Fills // |field| with the |FormField| representation for element. // Returns false if the form is not found or cannot be serialized. bool FindFormAndFieldForInputElement(const WebKit::WebInputElement& element, - webkit::forms::FormData* form, - webkit::forms::FormField* field, + FormData* form, + FormFieldData* field, RequirementsMask requirements); // Fills the form represented by |form|. |element| is the input element that // initiated the auto-fill process. -void FillForm(const webkit::forms::FormData& form, +void FillForm(const FormData& form, const WebKit::WebInputElement& element); // Previews the form represented by |form|. |element| is the input element that // initiated the preview process. -void PreviewForm(const webkit::forms::FormData& form, +void PreviewForm(const FormData& form, const WebKit::WebInputElement& element); // Clears the placeholder values and the auto-filled background for any fields diff --git a/chrome/renderer/autofill/form_cache.cc b/chrome/renderer/autofill/form_cache.cc index c5ff6d6..f7bec03 100644 --- a/chrome/renderer/autofill/form_cache.cc +++ b/chrome/renderer/autofill/form_cache.cc @@ -6,6 +6,10 @@ #include "base/logging.h" #include "base/utf_string_conversions.h" +#include "chrome/common/form_data.h" +#include "chrome/common/form_data_predictions.h" +#include "chrome/common/form_field_data.h" +#include "chrome/common/form_field_data_predictions.h" #include "chrome/renderer/autofill/form_autofill_util.h" #include "grit/generated_resources.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" @@ -17,10 +21,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" #include "ui/base/l10n/l10n_util.h" -#include "webkit/forms/form_data.h" -#include "webkit/forms/form_data_predictions.h" -#include "webkit/forms/form_field.h" -#include "webkit/forms/form_field_predictions.h" using WebKit::WebDocument; using WebKit::WebFormControlElement; @@ -30,8 +30,6 @@ using WebKit::WebInputElement; using WebKit::WebSelectElement; using WebKit::WebString; using WebKit::WebVector; -using webkit::forms::FormData; -using webkit::forms::FormDataPredictions; namespace { diff --git a/chrome/renderer/autofill/form_cache.h b/chrome/renderer/autofill/form_cache.h index 7acdec5..43bd651 100644 --- a/chrome/renderer/autofill/form_cache.h +++ b/chrome/renderer/autofill/form_cache.h @@ -11,12 +11,8 @@ #include "base/string16.h" -namespace webkit { -namespace forms { struct FormData; struct FormDataPredictions; -} -} namespace WebKit { class WebDocument; @@ -36,7 +32,7 @@ class FormCache { // Scans the DOM in |frame| extracting and storing forms. // Returns a vector of the extracted forms. void ExtractForms(const WebKit::WebFrame& frame, - std::vector<webkit::forms::FormData>* forms); + std::vector<FormData>* forms); // Resets the forms for the specified |frame|. void ResetFrame(const WebKit::WebFrame& frame); @@ -49,7 +45,7 @@ class FormCache { // field's overall predicted type. Also sets the title to include the field's // heuristic type, server type, and signature; as well as the form's signature // and the experiment id for the server predictions. - bool ShowPredictions(const webkit::forms::FormDataPredictions& form); + bool ShowPredictions(const FormDataPredictions& form); private: // The cached web frames. diff --git a/chrome/renderer/autofill/password_autofill_manager.cc b/chrome/renderer/autofill/password_autofill_manager.cc index 2d86597..413411f 100644 --- a/chrome/renderer/autofill/password_autofill_manager.cc +++ b/chrome/renderer/autofill/password_autofill_manager.cc @@ -8,7 +8,11 @@ #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" #include "chrome/common/autofill_messages.h" +#include "chrome/common/form_field_data.h" +#include "chrome/common/password_form_fill_data.h" #include "chrome/renderer/autofill/form_autofill_util.h" +#include "content/public/common/password_form.h" +#include "content/public/renderer/password_form_conversion_utils.h" #include "content/public/renderer/render_view.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" @@ -20,9 +24,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" #include "ui/base/keycodes/keyboard_codes.h" -#include "webkit/forms/form_field.h" -#include "webkit/forms/password_form.h" -#include "webkit/forms/password_form_dom_manager.h" namespace { @@ -48,7 +49,7 @@ typedef std::vector<FormElements*> FormElementsList; // Helper to search the given form element for the specified input elements // in |data|, and add results to |result|. static bool FindFormInputElements(WebKit::WebFormElement* fe, - const webkit::forms::FormData& data, + const FormData& data, FormElements* result) { // Loop through the list of elements we need to find on the form in order to // autofill it. If we don't find any one of them, abort processing this @@ -96,7 +97,7 @@ static bool FindFormInputElements(WebKit::WebFormElement* fe, // Helper to locate form elements identified by |data|. void FindFormElements(WebKit::WebView* view, - const webkit::forms::FormData& data, + const FormData& data, FormElementsList* results) { DCHECK(view); DCHECK(results); @@ -150,7 +151,7 @@ bool IsElementEditable(const WebKit::WebInputElement& element) { return element.isEnabled() && !element.isReadOnly(); } -void FillForm(FormElements* fe, const webkit::forms::FormData& data) { +void FillForm(FormElements* fe, const FormData& data) { if (!fe->form_element.autoComplete()) return; @@ -220,7 +221,7 @@ bool PasswordAutofillManager::TextFieldDidEndEditing( if (iter == login_to_password_info_.end()) return false; - const webkit::forms::PasswordFormFillData& fill_data = + const PasswordFormFillData& fill_data = iter->second.fill_data; // If wait_for_username is false, we should have filled when the text changed. @@ -343,7 +344,7 @@ void PasswordAutofillManager::SendPasswordForms(WebKit::WebFrame* frame, WebKit::WebVector<WebKit::WebFormElement> forms; frame->document().forms(forms); - std::vector<webkit::forms::PasswordForm> password_forms; + std::vector<content::PasswordForm> password_forms; for (size_t i = 0; i < forms.size(); ++i) { const WebKit::WebFormElement& form = forms[i]; @@ -356,8 +357,8 @@ void PasswordAutofillManager::SendPasswordForms(WebKit::WebFrame* frame, if (only_visible && !form.hasNonEmptyBoundingBox()) continue; - scoped_ptr<webkit::forms::PasswordForm> password_form( - webkit::forms::PasswordFormDomManager::CreatePasswordForm(form)); + scoped_ptr<content::PasswordForm> password_form( + content::CreatePasswordForm(form)); if (password_form.get()) password_forms.push_back(*password_form); } @@ -426,7 +427,7 @@ bool PasswordAutofillManager::InputElementLostFocus() { } void PasswordAutofillManager::OnFillPasswordForm( - const webkit::forms::PasswordFormFillData& form_data, + const PasswordFormFillData& form_data, bool disable_popup) { disable_popup_ = disable_popup; @@ -463,8 +464,8 @@ void PasswordAutofillManager::OnFillPasswordForm( password_info.password_field = password_element; login_to_password_info_[username_element] = password_info; - webkit::forms::FormData form; - webkit::forms::FormField field; + FormData form; + FormFieldData field; FindFormAndFieldForInputElement( username_element, &form, &field, REQUIRE_NONE); Send(new AutofillHostMsg_AddPasswordFormMapping( @@ -478,13 +479,13 @@ void PasswordAutofillManager::OnFillPasswordForm( // PasswordAutofillManager, private: void PasswordAutofillManager::GetSuggestions( - const webkit::forms::PasswordFormFillData& fill_data, + const PasswordFormFillData& fill_data, const string16& input, std::vector<string16>* suggestions) { if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) suggestions->push_back(fill_data.basic_data.fields[0].value); - webkit::forms::PasswordFormFillData::LoginCollection::const_iterator iter; + PasswordFormFillData::LoginCollection::const_iterator iter; for (iter = fill_data.additional_logins.begin(); iter != fill_data.additional_logins.end(); ++iter) { if (StartsWith(iter->first, input, false)) @@ -493,7 +494,7 @@ void PasswordAutofillManager::GetSuggestions( } bool PasswordAutofillManager::ShowSuggestionPopup( - const webkit::forms::PasswordFormFillData& fill_data, + const PasswordFormFillData& fill_data, const WebKit::WebInputElement& user_input) { WebKit::WebFrame* frame = user_input.document().frame(); if (!frame) @@ -507,8 +508,8 @@ bool PasswordAutofillManager::ShowSuggestionPopup( GetSuggestions(fill_data, user_input.value(), &suggestions); if (disable_popup_) { - webkit::forms::FormData form; - webkit::forms::FormField field; + FormData form; + FormFieldData field; FindFormAndFieldForInputElement( user_input, &form, &field, REQUIRE_NONE); @@ -539,7 +540,7 @@ bool PasswordAutofillManager::ShowSuggestionPopup( bool PasswordAutofillManager::FillUserNameAndPassword( WebKit::WebInputElement* username_element, WebKit::WebInputElement* password_element, - const webkit::forms::PasswordFormFillData& fill_data, + const PasswordFormFillData& fill_data, bool exact_username_match, bool set_selection) { string16 current_username = username_element->value(); @@ -554,7 +555,7 @@ bool PasswordAutofillManager::FillUserNameAndPassword( password = fill_data.basic_data.fields[1].value; } else { // Scan additional logins for a match. - webkit::forms::PasswordFormFillData::LoginCollection::const_iterator iter; + PasswordFormFillData::LoginCollection::const_iterator iter; for (iter = fill_data.additional_logins.begin(); iter != fill_data.additional_logins.end(); ++iter) { if (DoUsernamesMatch(iter->first, current_username, @@ -586,7 +587,7 @@ bool PasswordAutofillManager::FillUserNameAndPassword( void PasswordAutofillManager::PerformInlineAutocomplete( const WebKit::WebInputElement& username_input, const WebKit::WebInputElement& password_input, - const webkit::forms::PasswordFormFillData& fill_data) { + const PasswordFormFillData& fill_data) { DCHECK(!fill_data.wait_for_username); // We need non-const versions of the username and password inputs. diff --git a/chrome/renderer/autofill/password_autofill_manager.h b/chrome/renderer/autofill/password_autofill_manager.h index 6d35416..8b407f3 100644 --- a/chrome/renderer/autofill/password_autofill_manager.h +++ b/chrome/renderer/autofill/password_autofill_manager.h @@ -9,10 +9,10 @@ #include <vector> #include "base/memory/weak_ptr.h" +#include "chrome/common/password_form_fill_data.h" #include "chrome/renderer/page_click_listener.h" #include "content/public/renderer/render_view_observer.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" -#include "webkit/forms/password_form_dom_manager.h" namespace WebKit { class WebInputElement; @@ -54,7 +54,7 @@ class PasswordAutofillManager : public content::RenderViewObserver, struct PasswordInfo { WebKit::WebInputElement password_field; - webkit::forms::PasswordFormFillData fill_data; + PasswordFormFillData fill_data; bool backspace_pressed_last; PasswordInfo() : backspace_pressed_last(false) {} }; @@ -74,24 +74,24 @@ class PasswordAutofillManager : public content::RenderViewObserver, virtual bool InputElementLostFocus() OVERRIDE; // RenderView IPC handlers: - void OnFillPasswordForm(const webkit::forms::PasswordFormFillData& form_data, + void OnFillPasswordForm(const PasswordFormFillData& form_data, bool disable_popup); // Scans the given frame for password forms and sends them up to the browser. // If |only_visible| is true, only forms visible in the layout are sent. void SendPasswordForms(WebKit::WebFrame* frame, bool only_visible); - void GetSuggestions(const webkit::forms::PasswordFormFillData& fill_data, + void GetSuggestions(const PasswordFormFillData& fill_data, const string16& input, std::vector<string16>* suggestions); - bool ShowSuggestionPopup(const webkit::forms::PasswordFormFillData& fill_data, + bool ShowSuggestionPopup(const PasswordFormFillData& fill_data, const WebKit::WebInputElement& user_input); bool FillUserNameAndPassword( WebKit::WebInputElement* username_element, WebKit::WebInputElement* password_element, - const webkit::forms::PasswordFormFillData& fill_data, + const PasswordFormFillData& fill_data, bool exact_username_match, bool set_selection); @@ -100,7 +100,7 @@ class PasswordAutofillManager : public content::RenderViewObserver, void PerformInlineAutocomplete( const WebKit::WebInputElement& username, const WebKit::WebInputElement& password, - const webkit::forms::PasswordFormFillData& fill_data); + const PasswordFormFillData& fill_data); // Invoked when the passed frame is closing. Gives us a chance to clear any // reference we may have to elements in that frame. diff --git a/chrome/renderer/autofill/password_autofill_manager_browsertest.cc b/chrome/renderer/autofill/password_autofill_manager_browsertest.cc index d242e6d..529cdd8 100644 --- a/chrome/renderer/autofill/password_autofill_manager_browsertest.cc +++ b/chrome/renderer/autofill/password_autofill_manager_browsertest.cc @@ -5,6 +5,8 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/common/autofill_messages.h" +#include "chrome/common/form_data.h" +#include "chrome/common/form_field_data.h" #include "chrome/renderer/autofill/autofill_agent.h" #include "chrome/renderer/autofill/password_autofill_manager.h" #include "chrome/test/base/chrome_render_view_test.h" @@ -17,13 +19,8 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" #include "ui/base/keycodes/keyboard_codes.h" -#include "webkit/forms/form_data.h" -#include "webkit/forms/form_field.h" -using webkit::forms::FormField; -using webkit::forms::PasswordFormFillData; -using webkit::forms::PasswordForm; -using webkit::forms::PasswordFormDomManager; +using content::PasswordForm; using WebKit::WebDocument; using WebKit::WebElement; using WebKit::WebFrame; @@ -80,12 +77,12 @@ class PasswordAutofillManagerTest : public ChromeRenderViewTest { username3_ = ASCIIToUTF16(kCarolUsername); password3_ = ASCIIToUTF16(kCarolPassword); - FormField username_field; + FormFieldData username_field; username_field.name = ASCIIToUTF16(kUsernameName); username_field.value = username1_; fill_data_.basic_data.fields.push_back(username_field); - FormField password_field; + FormFieldData password_field; password_field.name = ASCIIToUTF16(kPasswordName); password_field.value = password1_; fill_data_.basic_data.fields.push_back(password_field); diff --git a/chrome/renderer/autofill/password_generation_manager.cc b/chrome/renderer/autofill/password_generation_manager.cc index 2ac682e..ac6202e 100644 --- a/chrome/renderer/autofill/password_generation_manager.cc +++ b/chrome/renderer/autofill/password_generation_manager.cc @@ -7,6 +7,7 @@ #include "base/logging.h" #include "chrome/common/autofill_messages.h" #include "chrome/common/password_generation_util.h" +#include "content/public/renderer/password_form_conversion_utils.h" #include "content/public/renderer/render_view.h" #include "google_apis/gaia/gaia_urls.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h" @@ -110,8 +111,8 @@ void PasswordGenerationManager::DidFinishLoad(WebKit::WebFrame* frame) { // If we can't get a valid PasswordForm, we skip this form because the // the password won't get saved even if we generate it. - scoped_ptr<webkit::forms::PasswordForm> password_form( - webkit::forms::PasswordFormDomManager::CreatePasswordForm(forms[i])); + scoped_ptr<content::PasswordForm> password_form( + content::CreatePasswordForm(forms[i])); if (!password_form.get()) { DVLOG(2) << "Skipping form as it would not be saved"; continue; @@ -175,9 +176,8 @@ WebKit::WebCString PasswordGenerationManager::imageNameForReadOnlyState() { void PasswordGenerationManager::handleClick(WebKit::WebInputElement& element) { gfx::Rect rect(element.decorationElementFor(this).boundsInViewportSpace()); - scoped_ptr<webkit::forms::PasswordForm> password_form( - webkit::forms::PasswordFormDomManager::CreatePasswordForm( - element.form())); + scoped_ptr<content::PasswordForm> password_form( + content::CreatePasswordForm(element.form())); // We should not have shown the icon we can't create a valid PasswordForm. DCHECK(password_form.get()); @@ -209,7 +209,7 @@ bool PasswordGenerationManager::OnMessageReceived(const IPC::Message& message) { } void PasswordGenerationManager::OnFormNotBlacklisted( - const webkit::forms::PasswordForm& form) { + const content::PasswordForm& form) { not_blacklisted_password_form_origins_.push_back(form.origin); MaybeShowIcon(); } diff --git a/chrome/renderer/autofill/password_generation_manager.h b/chrome/renderer/autofill/password_generation_manager.h index 0e72a71..cd930d9 100644 --- a/chrome/renderer/autofill/password_generation_manager.h +++ b/chrome/renderer/autofill/password_generation_manager.h @@ -19,11 +19,9 @@ class WebCString; class WebDocument; } -namespace webkit { -namespace forms { +namespace content { struct PasswordForm; -} // namespace forms -} // namespace webkit +} namespace autofill { @@ -60,7 +58,7 @@ class PasswordGenerationManager : public content::RenderViewObserver, virtual void willDetach(const WebKit::WebInputElement& element) OVERRIDE; // Message handlers. - void OnFormNotBlacklisted(const webkit::forms::PasswordForm& form); + void OnFormNotBlacklisted(const content::PasswordForm& form); void OnPasswordAccepted(const string16& password); void OnPasswordGenerationEnabled(bool enabled); diff --git a/chrome/renderer/autofill/password_generation_manager_browsertest.cc b/chrome/renderer/autofill/password_generation_manager_browsertest.cc index 6b434e8..2dddb9c 100644 --- a/chrome/renderer/autofill/password_generation_manager_browsertest.cc +++ b/chrome/renderer/autofill/password_generation_manager_browsertest.cc @@ -80,7 +80,7 @@ class PasswordGenerationManagerTest : public ChromeRenderViewTest { } void SetNotBlacklistedMessage(const char* form_str) { - webkit::forms::PasswordForm form; + content::PasswordForm form; form.origin = GURL(StringPrintf("data:text/html;charset=utf-8,%s",form_str)); AutofillMsg_FormNotBlacklisted msg(0, form); |