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

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

Issue 136793007: Add Autofill preview support for <select> input fields (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 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
« 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 7054a90b90a06815e0ab22835ea685d3cf196aa4..995bb06baf509bb79ca337cdb37d5a57230fc5e5 100644
--- a/components/autofill/content/renderer/form_autofill_util.cc
+++ b/components/autofill/content/renderer/form_autofill_util.cc
@@ -567,9 +567,9 @@ void PreviewFormField(const FormFieldData& data,
if (data.value.empty())
return;
- // Preview input and textarea fields. For input fields, excludes checkboxes
- // and radio buttons, as there is no provision for setSuggestedCheckedValue
- // in WebInputElement.
+ // Preview input, textarea and select fields. For input fields, excludes
+ // checkboxes and radio buttons, as there is no provision for
+ // setSuggestedCheckedValue in WebInputElement.
WebInputElement* input_element = toWebInputElement(field);
if (IsTextInput(input_element) || IsMonthInput(input_element)) {
// If the maxlength attribute contains a negative value, maxLength()
@@ -577,7 +577,7 @@ void PreviewFormField(const FormFieldData& data,
input_element->setSuggestedValue(
data.value.substr(0, input_element->maxLength()));
input_element->setAutofilled(true);
- } else if (IsTextAreaElement(*field)) {
+ } else if (IsTextAreaElement(*field) || IsSelectElement(*field)) {
field->setSuggestedValue(data.value);
field->setAutofilled(true);
}
@@ -1056,11 +1056,12 @@ bool ClearPreviewedFormWithElement(const WebFormControlElement& element,
// want to reset the auto-filled status for fields that were previewed.
WebFormControlElement control_element = control_elements[i];
- // Only text input and textarea elements can be previewed.
+ // Only text input, textarea and select elements can be previewed.
WebInputElement* input_element = toWebInputElement(&control_element);
if (!IsTextInput(input_element) &&
!IsMonthInput(input_element) &&
- !IsTextAreaElement(control_element))
+ !IsTextAreaElement(control_element) &&
+ !IsSelectElement(control_element))
continue;
// If the element is not auto-filled, we did not preview it,
@@ -1070,7 +1071,8 @@ bool ClearPreviewedFormWithElement(const WebFormControlElement& element,
if ((IsTextInput(input_element) ||
IsMonthInput(input_element) ||
- IsTextAreaElement(control_element)) &&
+ IsTextAreaElement(control_element) ||
+ IsSelectElement(control_element)) &&
control_element.suggestedValue().isEmpty())
continue;
@@ -1090,6 +1092,9 @@ bool ClearPreviewedFormWithElement(const WebFormControlElement& element,
} else {
control_element.setAutofilled(false);
}
+ } else if (IsSelectElement(control_element)) {
+ control_element.setSuggestedValue(WebString());
+ control_element.setAutofilled(false);
}
}
« 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