Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: components/autofill/content/renderer/form_autofill_util.cc

Issue 1699993002: [Autofill] Fill fields if they contain a default value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed from buh.com Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/autofill/form_autofill_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/content/renderer/form_autofill_util.cc
diff --git a/components/autofill/content/renderer/form_autofill_util.cc b/components/autofill/content/renderer/form_autofill_util.cc
index 9db4b76cceb7bf3b55db5cebce8288691189b2b5..b7c4533c80bdba2da857342a4fe2ae68603e0cba 100644
--- a/components/autofill/content/renderer/form_autofill_util.cc
+++ b/components/autofill/content/renderer/form_autofill_util.cc
@@ -805,13 +805,19 @@ void ForEachMatchingFormFieldCommon(
bool is_initiating_element = (*element == initiating_element);
- // Only autofill empty fields and the field that initiated the filling,
- // i.e. the field the user is currently editing and interacting with.
+ // Only autofill empty fields (or those with the field's default value
+ // attribute) and the field that initiated the filling, i.e. the field the
+ // user is currently editing and interacting with.
const WebInputElement* input_element = toWebInputElement(element);
+ CR_DEFINE_STATIC_LOCAL(WebString, kValue, ("value"));
if (!force_override && !is_initiating_element &&
- ((IsAutofillableInputElement(input_element) ||
- IsTextAreaElement(*element)) &&
- !element->value().isEmpty()))
+ // A text field, with a non-empty value that is NOT the value of the
+ // input field's "value" attribute, is skipped.
+ (IsAutofillableInputElement(input_element) ||
+ IsTextAreaElement(*element)) &&
+ !element->value().isEmpty() &&
+ (!element->hasAttribute(kValue) ||
+ element->getAttribute(kValue) != element->value()))
continue;
if (((filters & FILTER_DISABLED_ELEMENTS) && !element->isEnabled()) ||
« no previous file with comments | « chrome/renderer/autofill/form_autofill_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698