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); |
} |
} |