summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-12 22:02:02 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-12 22:02:02 +0000
commit492db2c2a256a33a3ca66a76054711755eae014e (patch)
tree72b9f86acab57db152e6c725a11469372b977383 /chrome/renderer
parent9dc700d1f0e45530ae1055c38721bad2504e53b7 (diff)
downloadchromium_src-492db2c2a256a33a3ca66a76054711755eae014e.zip
chromium_src-492db2c2a256a33a3ca66a76054711755eae014e.tar.gz
chromium_src-492db2c2a256a33a3ca66a76054711755eae014e.tar.bz2
Autofill should distinguish forms based on id as well as name.
BUG=79122 TEST=interactive_ui_tests --gtest_filter=AutofillTest.AutofillFormsDistinguishedById Review URL: http://codereview.chromium.org/6824066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81317 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/autofill/form_manager.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/chrome/renderer/autofill/form_manager.cc b/chrome/renderer/autofill/form_manager.cc
index 8f95f01..e83f51b 100644
--- a/chrome/renderer/autofill/form_manager.cc
+++ b/chrome/renderer/autofill/form_manager.cc
@@ -310,6 +310,16 @@ void GetOptionStringsFromElement(const WebSelectElement& select_element,
}
}
+// Returns the form's |name| attribute if non-empty; otherwise the form's |id|
+// attribute.
+const string16 GetFormIdentifier(const WebFormElement& form) {
+ string16 identifier = form.name();
+ if (identifier.empty())
+ identifier = form.getAttribute(WebString("id"));
+
+ return identifier;
+}
+
} // namespace
namespace autofill {
@@ -426,7 +436,7 @@ bool FormManager::WebFormElementToFormData(const WebFormElement& element,
if (requirements & REQUIRE_AUTOCOMPLETE && !element.autoComplete())
return false;
- form->name = element.name();
+ form->name = GetFormIdentifier(element);
form->method = element.method();
form->origin = frame->url();
form->action = frame->document().completeURL(element.action());
@@ -814,7 +824,7 @@ bool FormManager::FindCachedFormElement(const FormData& form,
// |true| -- WebKit distinguishes between a "null" string (lhs) and an
// "empty" string (rhs). We don't want that distinction, so forcing to
// string16.
- string16 element_name((*form_iter)->form_element.name());
+ string16 element_name = GetFormIdentifier((*form_iter)->form_element);
GURL action(
(*form_iter)->form_element.document().completeURL(
(*form_iter)->form_element.action()));