Reviewers: Dan Beam,
Description:
[Autofill] Show a warning if the form disables Autofill.
BUG=159291
TEST=(see bug)
Please review this at
https://chromiumcodereview.appspot.com/11364066/
SVN Base: svn://
svn.chromium.org/chrome/trunk/src
Affected files:
M chrome/renderer/autofill/autofill_agent.cc
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..6df42395213d670ed1d457c22cca8acb905d570e
100644
--- a/chrome/renderer/autofill/autofill_agent.cc
+++ b/chrome/renderer/autofill/autofill_agent.cc
@@ -605,8 +605,7 @@ void AutofillAgent::ShowSuggestions(const
WebInputElement& element,
// 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 (element.getAttribute("autocomplete") == ASCIIToUTF16("off") ||
element.nameForAutofill().isEmpty()) {
CombineDataListEntriesAndShow(element, std::vector<string16>(),
std::vector<string16>(),
@@ -624,10 +623,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);