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

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

Issue 1842693003: [Autofill] Fill fields where the value equals the placeholder attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 years, 9 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
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 b7c4533c80bdba2da857342a4fe2ae68603e0cba..cb7947514250d5bbe3f689711c7590b9da959a29 100644
--- a/components/autofill/content/renderer/form_autofill_util.cc
+++ b/components/autofill/content/renderer/form_autofill_util.cc
@@ -810,14 +810,17 @@ void ForEachMatchingFormFieldCommon(
// user is currently editing and interacting with.
const WebInputElement* input_element = toWebInputElement(element);
CR_DEFINE_STATIC_LOCAL(WebString, kValue, ("value"));
+ CR_DEFINE_STATIC_LOCAL(WebString, kPlaceholder, ("placeholder"));
if (!force_override && !is_initiating_element &&
// A text field, with a non-empty value that is NOT the value of the
- // input field's "value" attribute, is skipped.
+ // input field's "value" or "placeholder" attribute, is skipped.
(IsAutofillableInputElement(input_element) ||
IsTextAreaElement(*element)) &&
!element->value().isEmpty() &&
(!element->hasAttribute(kValue) ||
- element->getAttribute(kValue) != element->value()))
+ element->getAttribute(kValue) != element->value()) &&
+ (!element->hasAttribute(kPlaceholder) ||
+ element->getAttribute(kPlaceholder) != element->value()))
continue;
if (((filters & FILTER_DISABLED_ELEMENTS) && !element->isEnabled()) ||
@@ -1340,6 +1343,7 @@ void WebFormControlElementToFormField(const WebFormControlElement& element,
DCHECK(!element.isNull());
CR_DEFINE_STATIC_LOCAL(WebString, kAutocomplete, ("autocomplete"));
CR_DEFINE_STATIC_LOCAL(WebString, kRole, ("role"));
+ CR_DEFINE_STATIC_LOCAL(WebString, kPlaceholder, ("placeholder"));
// The label is not officially part of a WebFormControlElement; however, the
// labels for all form control elements are scraped from the DOM and set in
@@ -1357,6 +1361,8 @@ void WebFormControlElementToFormField(const WebFormControlElement& element,
base::StringPiece16(element.getAttribute(kRole)), "presentation"))
field->role = FormFieldData::ROLE_ATTRIBUTE_PRESENTATION;
+ field->placeholder = element.getAttribute(kPlaceholder);
+
if (!IsAutofillableElement(element))
return;
« no previous file with comments | « components/autofill/content/common/autofill_messages.h ('k') | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698