summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/form_manager.cc
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-10 22:00:17 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-10 22:00:17 +0000
commit2ad69c89162c0bb2cb9560d1d70ddbd928a37dc3 (patch)
treeca2d4dca5b51086d8d10083c223cdbb7432c1362 /chrome/renderer/form_manager.cc
parent436e86cec0586bc8ac632ebd86eed0519d47535c (diff)
downloadchromium_src-2ad69c89162c0bb2cb9560d1d70ddbd928a37dc3.zip
chromium_src-2ad69c89162c0bb2cb9560d1d70ddbd928a37dc3.tar.gz
chromium_src-2ad69c89162c0bb2cb9560d1d70ddbd928a37dc3.tar.bz2
AutoFill: Fix a bug that caused AutoFill to not fill the field the user is
typing in. This change also conveniently removes filling the default profile, since this feature has been removed from AutoFill. BUG=46219 TEST=FormManagerTest.FillFormNonEmptyField Review URL: http://codereview.chromium.org/2766005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49454 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/form_manager.cc')
-rw-r--r--chrome/renderer/form_manager.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/chrome/renderer/form_manager.cc b/chrome/renderer/form_manager.cc
index 6cc4e17..3868582 100644
--- a/chrome/renderer/form_manager.cc
+++ b/chrome/renderer/form_manager.cc
@@ -514,7 +514,7 @@ bool FormManager::FindFormWithFormControlElement(
return false;
}
-bool FormManager::FillForm(const FormData& form) {
+bool FormManager::FillForm(const FormData& form, const WebKit::WebNode& node) {
FormElement* form_element = NULL;
if (!FindCachedFormElement(form, &form_element))
return false;
@@ -522,6 +522,7 @@ bool FormManager::FillForm(const FormData& form) {
RequirementsMask requirements = static_cast<RequirementsMask>(
REQUIRE_AUTOCOMPLETE | REQUIRE_ENABLED | REQUIRE_EMPTY);
ForEachMatchingFormField(form_element,
+ node,
requirements,
form,
NewCallback(this, &FormManager::FillFormField));
@@ -537,6 +538,7 @@ bool FormManager::PreviewForm(const FormData& form) {
RequirementsMask requirements = static_cast<RequirementsMask>(
REQUIRE_AUTOCOMPLETE | REQUIRE_ENABLED | REQUIRE_EMPTY);
ForEachMatchingFormField(form_element,
+ WebNode(),
requirements,
form,
NewCallback(this, &FormManager::PreviewFormField));
@@ -567,13 +569,6 @@ void FormManager::ClearPreviewedForm(const FormData& form) {
}
}
-void FormManager::FillForms(const std::vector<FormData>& forms) {
- for (std::vector<FormData>::const_iterator iter = forms.begin();
- iter != forms.end(); ++iter) {
- FillForm(*iter);
- }
-}
-
void FormManager::Reset() {
for (WebFrameFormElementMap::iterator iter = form_elements_map_.begin();
iter != form_elements_map_.end(); ++iter) {
@@ -682,6 +677,7 @@ bool FormManager::FindCachedFormElement(const FormData& form,
}
void FormManager::ForEachMatchingFormField(FormElement* form,
+ const WebKit::WebNode& node,
RequirementsMask requirements,
const FormData& data,
Callback* callback) {
@@ -723,7 +719,12 @@ void FormManager::ForEachMatchingFormField(FormElement* form,
if (requirements & REQUIRE_AUTOCOMPLETE && !input_element.autoComplete())
continue;
- if (requirements & REQUIRE_EMPTY && !input_element.value().isEmpty())
+ // Don't require the node that initiated the auto-fill process to be
+ // empty. The user is typing in this field and we should complete the
+ // value when the user selects a value to fill out.
+ if (requirements & REQUIRE_EMPTY &&
+ input_element != node &&
+ !input_element.value().isEmpty())
continue;
}