summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-01 18:28:58 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-01 18:28:58 +0000
commit1fa7b48bbeb65db6a8865ccb0f432c6cb44fd39c (patch)
tree200ce5aba779cd617ca610645775901afbaf70ed /chrome
parent2cc800b06bfbdc34b49e25c059ac1da34d63eb61 (diff)
downloadchromium_src-1fa7b48bbeb65db6a8865ccb0f432c6cb44fd39c.zip
chromium_src-1fa7b48bbeb65db6a8865ccb0f432c6cb44fd39c.tar.gz
chromium_src-1fa7b48bbeb65db6a8865ccb0f432c6cb44fd39c.tar.bz2
AutoFill: Don't send select option values to the browser on page load. Only
send the values when the browser instructs the renderer to send form data for a specific form to be auto-filled. BUG=49992 TEST=FormManagerTest.* Review URL: http://codereview.chromium.org/3588004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61202 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autofill/autofill_manager.cc25
-rw-r--r--chrome/browser/autofill/autofill_manager.h7
-rw-r--r--chrome/renderer/autofill_helper.cc4
-rw-r--r--chrome/renderer/form_manager.cc107
-rw-r--r--chrome/renderer/form_manager.h34
-rw-r--r--chrome/renderer/form_manager_browsertest.cc134
-rw-r--r--chrome/renderer/render_view.cc2
7 files changed, 115 insertions, 198 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index 6df9593..3bc138d 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -731,31 +731,6 @@ void AutoFillManager::FillFormField(const AutoFillProfile* profile,
}
}
-void AutoFillManager::FillSelectOneField(const AutoFillProfile* profile,
- AutoFillType type,
- webkit_glue::FormField* field) {
- DCHECK(profile);
- DCHECK(field);
- DCHECK(field->form_control_type() == ASCIIToUTF16("select-one"));
- string16 selected_string = profile->GetFieldText(type);
- std::string ascii_value = UTF16ToASCII(selected_string);
- for (size_t i = 0; i < field->option_strings().size(); ++i) {
- if (profile->GetFieldText(type) == field->option_strings()[i]) {
- // An exact match - use it.
- selected_string = profile->GetFieldText(type);
- break;
- }
- if (!base::strcasecmp(UTF16ToASCII(field->option_strings()[i]).c_str(),
- ascii_value.c_str())) {
- // A match, but not in the same case - save it for the case we won't
- // find an exact match.
- selected_string = field->option_strings()[i];
- }
- }
- field->set_value(selected_string);
-}
-
-
void AutoFillManager::FillPhoneNumberField(const AutoFillProfile* profile,
webkit_glue::FormField* field) {
// If we are filling a phone number, check to see if the size field
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index 0faf475..d46e19e 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -155,13 +155,6 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
AutoFillType type,
webkit_glue::FormField* field);
- // Select matching data in the |field|. For now only fixes the cases of the
- // wrong case, in the future should do extended matching (for example,
- // Hawaii -> HI).
- void FillSelectOneField(const AutoFillProfile* profile,
- AutoFillType type,
- webkit_glue::FormField* field);
-
// Set |field| argument's value for phone number based on contents of the
// |profile|.
void FillPhoneNumberField(const AutoFillProfile* profile,
diff --git a/chrome/renderer/autofill_helper.cc b/chrome/renderer/autofill_helper.cc
index bc4c330..5ea469b 100644
--- a/chrome/renderer/autofill_helper.cc
+++ b/chrome/renderer/autofill_helper.cc
@@ -47,7 +47,7 @@ void AutoFillHelper::QueryAutoFillSuggestions(const WebNode& node) {
const WebFormControlElement& element = node.toConst<WebFormControlElement>();
webkit_glue::FormField field;
- FormManager::WebFormControlElementToFormField(element, true, &field);
+ FormManager::WebFormControlElementToFormField(element, true, false, &field);
// WebFormControlElementToFormField does not scrape the DOM for the field
// label, so find the label here.
@@ -285,7 +285,7 @@ void AutoFillHelper::SendForms(WebFrame* frame) {
webkit_glue::FormData form;
if (FormManager::WebFormElementToFormData(
- web_form, FormManager::REQUIRE_NONE, false, &form)) {
+ web_form, FormManager::REQUIRE_NONE, false, false, &form)) {
forms.push_back(form);
}
}
diff --git a/chrome/renderer/form_manager.cc b/chrome/renderer/form_manager.cc
index 059aa8c..820a086 100644
--- a/chrome/renderer/form_manager.cc
+++ b/chrome/renderer/form_manager.cc
@@ -245,7 +245,10 @@ FormManager::~FormManager() {
// static
void FormManager::WebFormControlElementToFormField(
- const WebFormControlElement& element, bool get_value, FormField* field) {
+ const WebFormControlElement& element,
+ bool get_value,
+ bool get_options,
+ FormField* field) {
DCHECK(field);
// The label is not officially part of a WebFormControlElement; however, the
@@ -254,10 +257,12 @@ void FormManager::WebFormControlElementToFormField(
field->set_name(element.nameForAutofill());
field->set_form_control_type(element.formControlType());
- // Set option strings on the field if available.
- std::vector<string16> option_strings;
- GetOptionStringsFromElement(element, &option_strings);
- field->set_option_strings(option_strings);
+ if (get_options) {
+ // Set option strings on the field if available.
+ std::vector<string16> option_strings;
+ GetOptionStringsFromElement(element, &option_strings);
+ field->set_option_strings(option_strings);
+ }
if (element.formControlType() == WebString::fromUTF8("text")) {
const WebInputElement& input_element = element.toConst<WebInputElement>();
@@ -317,6 +322,7 @@ string16 FormManager::LabelForElement(const WebFormControlElement& element) {
bool FormManager::WebFormElementToFormData(const WebFormElement& element,
RequirementsMask requirements,
bool get_values,
+ bool get_options,
FormData* form) {
DCHECK(form);
@@ -368,7 +374,8 @@ bool FormManager::WebFormElementToFormData(const WebFormElement& element,
// Create a new FormField, fill it out and map it to the field's name.
FormField* field = new FormField;
- WebFormControlElementToFormField(control_element, get_values, field);
+ WebFormControlElementToFormField(
+ control_element, get_values, get_options, field);
form_fields.push_back(field);
// TODO(jhawkins): A label element is mapped to a form control element's id.
// field->name() will contain the id only if the name does not exist. Add
@@ -454,28 +461,12 @@ void FormManager::ExtractForms(const WebFrame* frame) {
}
}
-void FormManager::GetForms(RequirementsMask requirements,
- std::vector<FormData>* forms) {
- DCHECK(forms);
-
- for (FormElementList::iterator form_iter = form_elements_.begin();
- form_iter != form_elements_.end(); ++form_iter) {
- FormData form;
- if (WebFormElementToFormData((*form_iter)->form_element,
- requirements,
- true,
- &form))
- forms->push_back(form);
- }
-}
-
void FormManager::GetFormsInFrame(const WebFrame* frame,
RequirementsMask requirements,
std::vector<FormData>* forms) {
DCHECK(frame);
DCHECK(forms);
- // TODO(jhawkins): Factor this out and use it here and in GetForms.
for (FormElementList::const_iterator form_iter =
form_elements_.begin();
form_iter != form_elements_.end(); ++form_iter) {
@@ -494,35 +485,13 @@ void FormManager::GetFormsInFrame(const WebFrame* frame,
continue;
FormData form;
- FormElementToFormData(frame, form_element, requirements, &form);
+ WebFormElementToFormData(
+ form_element->form_element, requirements, true, false, &form);
if (form.fields.size() >= kRequiredAutoFillFields)
forms->push_back(form);
}
}
-bool FormManager::FindForm(const WebFormElement& element,
- RequirementsMask requirements,
- FormData* form) {
- DCHECK(form);
-
- const WebFrame* frame = element.document().frame();
- if (!frame)
- return false;
-
- for (FormElementList::const_iterator iter = form_elements_.begin();
- iter != form_elements_.end(); ++iter) {
- if ((*iter)->form_element.document().frame() != frame)
- continue;
-
- if ((*iter)->form_element.name() != element.name())
- continue;
-
- return FormElementToFormData(frame, *iter, requirements, form);
- }
-
- return false;
-}
-
bool FormManager::FindFormWithFormControlElement(
const WebFormControlElement& element,
RequirementsMask requirements,
@@ -545,7 +514,7 @@ bool FormManager::FindFormWithFormControlElement(
iter != form_element->control_elements.end(); ++iter) {
if (iter->nameForAutofill() == element.nameForAutofill()) {
WebFormElementToFormData(
- form_element->form_element, requirements, true, form);
+ form_element->form_element, requirements, true, true, form);
return true;
}
}
@@ -674,50 +643,6 @@ bool FormManager::FormWithNodeIsAutoFilled(const WebNode& node) {
}
// static
-bool FormManager::FormElementToFormData(const WebFrame* frame,
- const FormElement* form_element,
- RequirementsMask requirements,
- FormData* form) {
- if (requirements & REQUIRE_AUTOCOMPLETE &&
- !form_element->form_element.autoComplete())
- return false;
-
- form->name = form_element->form_element.name();
- form->method = form_element->form_element.method();
- form->origin = frame->url();
- form->action =
- frame->document().completeURL(form_element->form_element.action());
-
- // If the completed URL is not valid, just use the action we get from
- // WebKit.
- if (!form->action.is_valid())
- form->action = GURL(form_element->form_element.action());
-
- for (std::vector<WebFormControlElement>::const_iterator element_iter =
- form_element->control_elements.begin();
- element_iter != form_element->control_elements.end(); ++element_iter) {
- const WebFormControlElement& control_element = *element_iter;
-
- if (requirements & REQUIRE_AUTOCOMPLETE &&
- control_element.formControlType() == WebString::fromUTF8("text")) {
- const WebInputElement& input_element =
- control_element.toConst<WebInputElement>();
- if (!input_element.autoComplete())
- continue;
- }
-
- if (requirements & REQUIRE_ENABLED && !control_element.isEnabled())
- continue;
-
- FormField field;
- WebFormControlElementToFormField(control_element, false, &field);
- form->fields.push_back(field);
- }
-
- return true;
-}
-
-// static
string16 FormManager::InferLabelForElement(
const WebFormControlElement& element) {
// Don't scrape labels for hidden elements.
diff --git a/chrome/renderer/form_manager.h b/chrome/renderer/form_manager.h
index dbb71d3..7d09d02 100644
--- a/chrome/renderer/form_manager.h
+++ b/chrome/renderer/form_manager.h
@@ -39,9 +39,13 @@ class FormManager {
// Fills out a FormField object from a given WebFormControlElement.
// If |get_value| is true, |field| will have the value set from |element|.
+ // If |get_options| is true, |field| will have the select options set from
+ // |element|.
+ // TODO(jhawkins): Use a bit-field instead of two parameters.
static void WebFormControlElementToFormField(
const WebKit::WebFormControlElement& element,
bool get_value,
+ bool get_options,
webkit_glue::FormField* field);
// Returns the corresponding label for |element|. WARNING: This method can
@@ -49,36 +53,28 @@ class FormManager {
// is loading.
static string16 LabelForElement(const WebKit::WebFormControlElement& element);
- // Fills out a FormData object from a given WebFormElement. If |get_values|
- // is true, the fields in |form| will have the values filled out. Returns
- // true if |form| is filled out; it's possible that |element| won't meet the
- // requirements in |requirements|. This also returns false if there are no
- // fields in |form|.
+ // Fills out a FormData object from a given WebFormElement. If |get_values|
+ // is true, the fields in |form| will have the values filled out. If
+ // |get_options| is true, the fields in |form will have select options filled
+ // out. Returns true if |form| is filled out; it's possible that |element|
+ // won't meet the requirements in |requirements|. This also returns false if
+ // there are no fields in |form|.
// TODO(jhawkins): Remove the user of this in RenderView and move this to
// private.
static bool WebFormElementToFormData(const WebKit::WebFormElement& element,
RequirementsMask requirements,
bool get_values,
+ bool get_options,
webkit_glue::FormData* form);
// Scans the DOM in |frame| extracting and storing forms.
void ExtractForms(const WebKit::WebFrame* frame);
- // Returns a vector of forms that match |requirements|.
- void GetForms(RequirementsMask requirements,
- std::vector<webkit_glue::FormData>* forms);
-
// Returns a vector of forms in |frame| that match |requirements|.
void GetFormsInFrame(const WebKit::WebFrame* frame,
RequirementsMask requirements,
std::vector<webkit_glue::FormData>* forms);
- // Returns the cached FormData for |element|. Returns true if the form was
- // found in the cache.
- bool FindForm(const WebKit::WebFormElement& element,
- RequirementsMask requirements,
- webkit_glue::FormData* form);
-
// Finds the form that contains |element| and returns it in |form|. Returns
// false if the form is not found.
bool FindFormWithFormControlElement(
@@ -129,14 +125,6 @@ class FormManager {
typedef Callback2<WebKit::WebFormControlElement*,
const webkit_glue::FormField*>::Type Callback;
- // Converts a FormElement to FormData storage. Returns false if the form does
- // not meet all the requirements in the requirements mask.
- // TODO(jhawkins): Modify FormElement so we don't need |frame|.
- static bool FormElementToFormData(const WebKit::WebFrame* frame,
- const FormElement* form_element,
- RequirementsMask requirements,
- webkit_glue::FormData* form);
-
// Infers corresponding label for |element| from surrounding context in the
// DOM. Contents of preceding <p> tag or preceding text element found in
// the form.
diff --git a/chrome/renderer/form_manager_browsertest.cc b/chrome/renderer/form_manager_browsertest.cc
index a72b601..0b89e1d 100644
--- a/chrome/renderer/form_manager_browsertest.cc
+++ b/chrome/renderer/form_manager_browsertest.cc
@@ -53,6 +53,7 @@ TEST_F(FormManagerTest, WebFormElementToFormData) {
EXPECT_TRUE(FormManager::WebFormElementToFormData(forms[0],
FormManager::REQUIRE_NONE,
true,
+ false,
&form));
EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
EXPECT_EQ(GURL(frame->url()), form.origin);
@@ -100,7 +101,7 @@ TEST_F(FormManagerTest, ExtractForms) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
@@ -133,11 +134,13 @@ TEST_F(FormManagerTest, ExtractForms) {
TEST_F(FormManagerTest, ExtractMultipleForms) {
LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">"
" <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>"
+ " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>"
" <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>"
"</FORM>"
"<FORM name=\"TestForm2\" action=\"http://zoo.com\" method=\"post\">"
+ " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>"
" <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>"
- " <INPUT type=\"submit\" name=\"second\" value=\"Submit\"/>"
+ " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>"
"</FORM>");
WebFrame* web_frame = GetMainFrame();
@@ -147,7 +150,7 @@ TEST_F(FormManagerTest, ExtractMultipleForms) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(2U, forms.size());
// First form.
@@ -157,7 +160,7 @@ TEST_F(FormManagerTest, ExtractMultipleForms) {
EXPECT_EQ(GURL("http://cnn.com"), form.action);
const std::vector<FormField>& fields = form.fields;
- ASSERT_EQ(2U, fields.size());
+ ASSERT_EQ(3U, fields.size());
EXPECT_EQ(FormField(string16(),
ASCIIToUTF16("firstname"),
ASCIIToUTF16("John"),
@@ -165,11 +168,17 @@ TEST_F(FormManagerTest, ExtractMultipleForms) {
20),
fields[0]);
EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("lastname"),
+ ASCIIToUTF16("Smith"),
+ ASCIIToUTF16("text"),
+ 20),
+ fields[1]);
+ EXPECT_EQ(FormField(string16(),
ASCIIToUTF16("reply-send"),
ASCIIToUTF16("Send"),
ASCIIToUTF16("submit"),
0),
- fields[1]);
+ fields[2]);
// Second form.
const FormData& form2 = forms[1];
@@ -178,19 +187,25 @@ TEST_F(FormManagerTest, ExtractMultipleForms) {
EXPECT_EQ(GURL("http://zoo.com"), form2.action);
const std::vector<FormField>& fields2 = form2.fields;
- ASSERT_EQ(2U, fields2.size());
+ ASSERT_EQ(3U, fields2.size());
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("firstname"),
+ ASCIIToUTF16("John"),
+ ASCIIToUTF16("text"),
+ 20),
+ fields2[0]);
EXPECT_EQ(FormField(string16(),
ASCIIToUTF16("lastname"),
ASCIIToUTF16("Smith"),
ASCIIToUTF16("text"),
20),
- fields2[0]);
+ fields2[1]);
EXPECT_EQ(FormField(string16(),
- ASCIIToUTF16("second"),
- ASCIIToUTF16("Submit"),
+ ASCIIToUTF16("reply-send"),
+ ASCIIToUTF16("Send"),
ASCIIToUTF16("submit"),
0),
- fields2[1]);
+ fields2[2]);
}
TEST_F(FormManagerTest, GetFormsAutocomplete) {
@@ -198,6 +213,7 @@ TEST_F(FormManagerTest, GetFormsAutocomplete) {
LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\""
" autocomplete=off>"
" <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>"
+ " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>"
" <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>"
"</FORM>");
@@ -209,18 +225,20 @@ TEST_F(FormManagerTest, GetFormsAutocomplete) {
// Verify that we did load the forms.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// autocomplete=off and we're requiring autocomplete, so no forms returned.
forms.clear();
- form_manager.GetForms(FormManager::REQUIRE_AUTOCOMPLETE, &forms);
+ form_manager.GetFormsInFrame(
+ web_frame, FormManager::REQUIRE_AUTOCOMPLETE, &forms);
ASSERT_EQ(0U, forms.size());
// The firstname element is not auto-completable due to autocomplete=off.
LoadHTML("<FORM name=\"TestForm\" action=\"http://abc.com\" method=\"post\">"
" <INPUT type=\"text\" id=\"firstname\" value=\"John\""
" autocomplete=off>"
+ " <INPUT type=\"text\" id=\"middlename\" value=\"Jack\"/>"
" <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>"
" <INPUT type=\"submit\" name=\"reply\" value=\"Send\"/>"
"</FORM>");
@@ -232,7 +250,8 @@ TEST_F(FormManagerTest, GetFormsAutocomplete) {
form_manager.ExtractForms(web_frame);
forms.clear();
- form_manager.GetForms(FormManager::REQUIRE_AUTOCOMPLETE, &forms);
+ form_manager.GetFormsInFrame(
+ web_frame, FormManager::REQUIRE_AUTOCOMPLETE, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
@@ -241,25 +260,32 @@ TEST_F(FormManagerTest, GetFormsAutocomplete) {
EXPECT_EQ(GURL("http://abc.com"), form.action);
const std::vector<FormField>& fields = form.fields;
- ASSERT_EQ(2U, fields.size());
+ ASSERT_EQ(3U, fields.size());
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("middlename"),
+ ASCIIToUTF16("Jack"),
+ ASCIIToUTF16("text"),
+ 20),
+ fields[0]);
EXPECT_EQ(FormField(string16(),
ASCIIToUTF16("lastname"),
ASCIIToUTF16("Smith"),
ASCIIToUTF16("text"),
20),
- fields[0]);
+ fields[1]);
EXPECT_EQ(FormField(string16(),
ASCIIToUTF16("reply"),
ASCIIToUTF16("Send"),
ASCIIToUTF16("submit"),
0),
- fields[1]);
+ fields[2]);
}
TEST_F(FormManagerTest, GetFormsElementsEnabled) {
// The firstname element is not enabled due to disabled being set.
LoadHTML("<FORM name=\"TestForm\" action=\"http://xyz.com\" method=\"post\">"
" <INPUT disabled type=\"text\" id=\"firstname\" value=\"John\"/>"
+ " <INPUT type=\"text\" id=\"middlename\" value=\"Jack\"/>"
" <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>"
" <INPUT type=\"submit\" name=\"submit\" value=\"Send\"/>"
"</FORM>");
@@ -271,7 +297,7 @@ TEST_F(FormManagerTest, GetFormsElementsEnabled) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_ENABLED, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_ENABLED, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
@@ -280,19 +306,25 @@ TEST_F(FormManagerTest, GetFormsElementsEnabled) {
EXPECT_EQ(GURL("http://xyz.com"), form.action);
const std::vector<FormField>& fields = form.fields;
- ASSERT_EQ(2U, fields.size());
+ ASSERT_EQ(3U, fields.size());
+ EXPECT_EQ(FormField(string16(),
+ ASCIIToUTF16("middlename"),
+ ASCIIToUTF16("Jack"),
+ ASCIIToUTF16("text"),
+ 20),
+ fields[0]);
EXPECT_EQ(FormField(string16(),
ASCIIToUTF16("lastname"),
ASCIIToUTF16("Smith"),
ASCIIToUTF16("text"),
20),
- fields[0]);
+ fields[1]);
EXPECT_EQ(FormField(string16(),
ASCIIToUTF16("submit"),
ASCIIToUTF16("Send"),
ASCIIToUTF16("submit"),
0),
- fields[1]);
+ fields[2]);
}
TEST_F(FormManagerTest, FindForm) {
@@ -310,7 +342,7 @@ TEST_F(FormManagerTest, FindForm) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// Get the input element we want to find.
@@ -366,7 +398,7 @@ TEST_F(FormManagerTest, FillForm) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// Get the input element we want to find.
@@ -491,7 +523,7 @@ TEST_F(FormManagerTest, PreviewForm) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// Get the input element we want to find.
@@ -611,14 +643,14 @@ TEST_F(FormManagerTest, Reset) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// There should be no forms after the call to Reset.
form_manager.Reset();
forms.clear();
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(0U, forms.size());
}
@@ -638,7 +670,7 @@ TEST_F(FormManagerTest, Labels) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
@@ -684,7 +716,7 @@ TEST_F(FormManagerTest, LabelsWithSpans) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
@@ -734,7 +766,7 @@ TEST_F(FormManagerTest, InvalidLabels) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
@@ -782,7 +814,8 @@ TEST_F(FormManagerTest, OneLabelElementFirstControlElementDisabled) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_AUTOCOMPLETE, &forms);
+ form_manager.GetFormsInFrame(
+ web_frame, FormManager::REQUIRE_AUTOCOMPLETE, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
@@ -828,7 +861,7 @@ TEST_F(FormManagerTest, LabelsInferredFromText) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
@@ -874,7 +907,7 @@ TEST_F(FormManagerTest, LabelsInferredFromTextHidden) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
@@ -917,7 +950,7 @@ TEST_F(FormManagerTest, LabelsInferredFromParagraph) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
@@ -974,7 +1007,7 @@ TEST_F(FormManagerTest, LabelsInferredFromTableCell) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
@@ -1050,7 +1083,7 @@ TEST_F(FormManagerTest, LabelsInferredFromTableCellNested) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
@@ -1123,7 +1156,7 @@ TEST_F(FormManagerTest, LabelsInferredFromDefinitionList) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
@@ -1169,7 +1202,7 @@ TEST_F(FormManagerTest, LabelsInferredWithSameName) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
@@ -1228,6 +1261,7 @@ TEST_F(FormManagerTest, LabelsInferredWithImageTags) {
EXPECT_TRUE(FormManager::WebFormElementToFormData(forms[0],
FormManager::REQUIRE_NONE,
true,
+ false,
&form));
EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
EXPECT_EQ(GURL(frame->url()), form.origin);
@@ -1288,7 +1322,7 @@ TEST_F(FormManagerTest, FillFormMaxLength) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// Get the input element we want to find.
@@ -1376,7 +1410,7 @@ TEST_F(FormManagerTest, FillFormNegativeMaxLength) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// Get the input element we want to find.
@@ -1466,7 +1500,7 @@ TEST_F(FormManagerTest, FillFormMoreFormDataFields) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// After the field modification, the fields in |form| will look like:
@@ -1576,7 +1610,7 @@ TEST_F(FormManagerTest, FillFormFewerFormDataFields) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// After the field modification, the fields in |form| will look like:
@@ -1670,7 +1704,7 @@ TEST_F(FormManagerTest, FillFormChangedFormDataFields) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// After the field modification, the fields in |form| will look like:
@@ -1746,7 +1780,7 @@ TEST_F(FormManagerTest, FillFormExtraFieldInCache) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// After the field modification, the fields in |form| will look like:
@@ -1818,7 +1852,7 @@ TEST_F(FormManagerTest, FillFormEmptyName) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// Get the input element we want to find.
@@ -1910,7 +1944,7 @@ TEST_F(FormManagerTest, FillFormEmptyFormNames) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(2U, forms.size());
// Get the input element we want to find.
@@ -2006,6 +2040,7 @@ TEST_F(FormManagerTest, ThreePartPhone) {
EXPECT_TRUE(FormManager::WebFormElementToFormData(forms[0],
FormManager::REQUIRE_NONE,
true,
+ false,
&form));
EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
EXPECT_EQ(GURL(frame->url()), form.origin);
@@ -2073,6 +2108,7 @@ TEST_F(FormManagerTest, SizeFields) {
EXPECT_TRUE(FormManager::WebFormElementToFormData(forms[0],
FormManager::REQUIRE_NONE,
true,
+ false,
&form));
EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
EXPECT_EQ(GURL(frame->url()), form.origin);
@@ -2144,7 +2180,7 @@ TEST_F(FormManagerTest, FillFormNonEmptyField) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// Get the input element we want to find.
@@ -2237,7 +2273,7 @@ TEST_F(FormManagerTest, ClearFormWithNode) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// Set the auto-filled attribute on the firstname element.
@@ -2320,7 +2356,7 @@ TEST_F(FormManagerTest, ClearPreviewedFormWithNode) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
// Set the auto-filled attribute.
@@ -2371,7 +2407,7 @@ TEST_F(FormManagerTest, FormWithNodeIsAutoFilled) {
// Verify that we have the form.
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
WebInputElement firstname =
@@ -2402,7 +2438,7 @@ TEST_F(FormManagerTest, LabelsHiddenFields) {
form_manager.ExtractForms(web_frame);
std::vector<FormData> forms;
- form_manager.GetForms(FormManager::REQUIRE_NONE, &forms);
+ form_manager.GetFormsInFrame(web_frame, FormManager::REQUIRE_NONE, &forms);
ASSERT_EQ(1U, forms.size());
const FormData& form = forms[0];
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 5c00e11..8076c06 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -2798,7 +2798,7 @@ void RenderView::willSubmitForm(WebFrame* frame, const WebFormElement& form) {
FormData form_data;
if (FormManager::WebFormElementToFormData(
- form, FormManager::REQUIRE_AUTOCOMPLETE, true, &form_data))
+ form, FormManager::REQUIRE_AUTOCOMPLETE, true, false, &form_data))
Send(new ViewHostMsg_FormSubmitted(routing_id_, form_data));
}