Chromium Code Reviews| Index: chrome/renderer/autofill/autofill_agent.cc |
| diff --git a/chrome/renderer/autofill/autofill_agent.cc b/chrome/renderer/autofill/autofill_agent.cc |
| index 8af890ab029926c37efce9cfb7d83c3699cd94ca..d3f470214d1ff71c11408742e064eade22f32d86 100644 |
| --- a/chrome/renderer/autofill/autofill_agent.cc |
| +++ b/chrome/renderer/autofill/autofill_agent.cc |
| @@ -600,13 +600,15 @@ void AutofillAgent::ShowSuggestions(const WebInputElement& element, |
| element_ = element; |
| - // If autocomplete is disabled at the form level, then we might want to show |
| - // a warning in place of suggestions. However, if autocomplete is disabled |
| - // specifically for this field, we never want to show a warning. Otherwise, |
| - // we might interfere with custom popups (e.g. search suggestions) used by |
| - // the website. Also, if the field has no name, then we won't have values. |
| - const WebFormElement form = element.form(); |
| - if ((!element.autoComplete() && (form.isNull() || form.autoComplete())) || |
| + // If autocomplete is disabled at the form level, then we might want to show a |
| + // warning in place of suggestions. However, if autocomplete is disabled |
| + // specifically for this field, we never want to show a warning. Otherwise, |
| + // we might interfere with custom popups (e.g. search suggestions) used by the |
| + // website. Note that we cannot use the WebKit method element.autoComplete() |
| + // as it does not allow us to distinguish the case where autocomplete is |
| + // disabled for *both* the element and for the form. |
| + // Also, if the field has no name, then we won't have values. |
| + if (element.getAttribute("autocomplete") == ASCIIToUTF16("off") || |
|
Dan Beam
2012/11/03 03:56:21
does this need to be lowercased?
Ilya Sherman
2012/11/06 02:14:43
Good call -- done.
|
| element.nameForAutofill().isEmpty()) { |
| CombineDataListEntriesAndShow(element, std::vector<string16>(), |
| std::vector<string16>(), |
| @@ -624,10 +626,19 @@ void AutofillAgent::QueryAutofillSuggestions(const WebInputElement& element, |
| autofill_query_id_ = query_counter++; |
| display_warning_if_disabled_ = display_warning_if_disabled; |
| + // If autocomplete is disabled at the form level, we want to see if there |
| + // would have been any suggestions were it enabled, so that we can show a |
| + // warning. Otherwise, we want to ignore fields that disable autocomplete, so |
| + // that the suggestions list does not include suggestions for these form |
| + // fields -- see comment 1 on http://crbug.com/69914 |
| + RequirementsMask requirements = REQUIRE_AUTOCOMPLETE; |
| + const WebFormElement form_element = element.form(); |
| + if (!form_element.isNull() && !form_element.autoComplete()) |
| + requirements = REQUIRE_NONE; |
| + |
| FormData form; |
| FormFieldData field; |
| - if (!FindFormAndFieldForInputElement(element, &form, &field, |
| - REQUIRE_AUTOCOMPLETE)) { |
| + if (!FindFormAndFieldForInputElement(element, &form, &field, requirements)) { |
| // If we didn't find the cached form, at least let autocomplete have a shot |
| // at providing suggestions. |
| WebFormControlElementToFormField(element, EXTRACT_VALUE, &field); |