summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-09 04:11:09 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-09 04:11:09 +0000
commit3347bab3eed62551354d0d49c5f1f185244a9bb1 (patch)
tree5754965971d9c1fa84616af38ffe35f354ddaebe /chrome
parent70d38b09d6f504b6a47b4d0e8f0a9b2f5d615373 (diff)
downloadchromium_src-3347bab3eed62551354d0d49c5f1f185244a9bb1.zip
chromium_src-3347bab3eed62551354d0d49c5f1f185244a9bb1.tar.gz
chromium_src-3347bab3eed62551354d0d49c5f1f185244a9bb1.tar.bz2
AutoFill: Delay sending the form field values to the AutoFillManager until they're needed.
BUG=40306 TEST=none Review URL: http://codereview.chromium.org/1626009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44055 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/renderer/form_manager.cc14
-rw-r--r--chrome/renderer/form_manager.h8
-rw-r--r--chrome/renderer/form_manager_unittest.cc1
-rw-r--r--chrome/renderer/render_view.cc4
4 files changed, 19 insertions, 8 deletions
diff --git a/chrome/renderer/form_manager.cc b/chrome/renderer/form_manager.cc
index d688e6e..cd5af20 100644
--- a/chrome/renderer/form_manager.cc
+++ b/chrome/renderer/form_manager.cc
@@ -69,7 +69,7 @@ FormManager::~FormManager() {
// static
void FormManager::WebFormControlElementToFormField(
- const WebFormControlElement& element, FormField* field) {
+ const WebFormControlElement& element, bool get_value, FormField* field) {
DCHECK(field);
// The label is not officially part of a WebFormControlElement; however, the
@@ -78,6 +78,9 @@ void FormManager::WebFormControlElementToFormField(
field->set_name(element.nameForAutofill());
field->set_form_control_type(element.formControlType());
+ if (!get_value)
+ return;
+
// TODO(jhawkins): In WebKit, move value() and setValue() to
// WebFormControlElement.
string16 value;
@@ -98,6 +101,7 @@ void FormManager::WebFormControlElementToFormField(
// static
bool FormManager::WebFormElementToFormData(const WebFormElement& element,
RequirementsMask requirements,
+ bool get_values,
FormData* form) {
DCHECK(form);
@@ -148,7 +152,7 @@ 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, field);
+ WebFormControlElementToFormField(control_element, get_values, 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
@@ -224,6 +228,7 @@ void FormManager::GetForms(RequirementsMask requirements,
FormData form;
if (WebFormElementToFormData((*form_iter)->form_element,
requirements,
+ true,
&form))
forms->push_back(form);
}
@@ -311,7 +316,8 @@ bool FormManager::FindFormWithFormControlElement(
form_element->control_elements.begin();
iter != form_element->control_elements.end(); ++iter) {
if (iter->nameForAutofill() == element.nameForAutofill()) {
- WebFormElementToFormData(form_element->form_element, requirements, form);
+ WebFormElementToFormData(
+ form_element->form_element, requirements, true, form);
return true;
}
}
@@ -424,7 +430,7 @@ bool FormManager::FormElementToFormData(const WebFrame* frame,
continue;
FormField field;
- WebFormControlElementToFormField(control_element, &field);
+ WebFormControlElementToFormField(control_element, false, &field);
form->fields.push_back(field);
}
diff --git a/chrome/renderer/form_manager.h b/chrome/renderer/form_manager.h
index 3842450..e1176bc 100644
--- a/chrome/renderer/form_manager.h
+++ b/chrome/renderer/form_manager.h
@@ -35,18 +35,22 @@ class FormManager {
virtual ~FormManager();
// Fills out a FormField object from a given WebFormControlElement.
+ // If |get_value| is true, |field| will have the value set from |element|.
static void WebFormControlElementToFormField(
const WebKit::WebFormControlElement& element,
+ bool get_value,
webkit_glue::FormField* field);
- // Fills out a FormData object from a given WebFormElement. Returns true if
- // |form| is filled out; it's possible that |element| won't meet the
+ // 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|.
// 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,
webkit_glue::FormData* form);
// Scans the DOM in |frame| extracting and storing forms.
diff --git a/chrome/renderer/form_manager_unittest.cc b/chrome/renderer/form_manager_unittest.cc
index 281ff16..909d47b 100644
--- a/chrome/renderer/form_manager_unittest.cc
+++ b/chrome/renderer/form_manager_unittest.cc
@@ -44,6 +44,7 @@ TEST_F(FormManagerTest, WebFormElementToFormData) {
FormData form;
EXPECT_TRUE(FormManager::WebFormElementToFormData(forms[0],
FormManager::REQUIRE_NONE,
+ true,
&form));
EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
EXPECT_EQ(GURL(frame->url()), form.origin);
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index eb80dd6..a1353f7 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -2341,7 +2341,7 @@ void RenderView::willSubmitForm(WebFrame* frame, const WebFormElement& form) {
FormData form_data;
if (FormManager::WebFormElementToFormData(
- form, FormManager::REQUIRE_AUTOCOMPLETE, &form_data))
+ form, FormManager::REQUIRE_AUTOCOMPLETE, true, &form_data))
Send(new ViewHostMsg_FormSubmitted(routing_id_, form_data));
}
@@ -4656,7 +4656,7 @@ void RenderView::SendForms(WebFrame* frame) {
FormManager::REQUIRE_AUTOCOMPLETE |
FormManager::REQUIRE_ELEMENTS_ENABLED);
if (FormManager::WebFormElementToFormData(
- web_form, requirements, &form))
+ web_form, requirements, false, &form))
forms.push_back(form);
}