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

Unified Diff: chrome/renderer/autofill/autofill_agent.cc

Issue 11364066: [Autofill] Show a warning if the form disables Autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Case-insensitivity + test Created 8 years, 1 month 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: chrome/renderer/autofill/autofill_agent.cc
diff --git a/chrome/renderer/autofill/autofill_agent.cc b/chrome/renderer/autofill/autofill_agent.cc
index 8af890ab029926c37efce9cfb7d83c3699cd94ca..040647a9b8cca518ee2c3e8f39bc7d085a2ed134 100644
--- a/chrome/renderer/autofill/autofill_agent.cc
+++ b/chrome/renderer/autofill/autofill_agent.cc
@@ -600,13 +600,17 @@ 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.
+ const string16 autocomplete_attribute =
+ StringToLowerASCII(string16(element.getAttribute("autocomplete")));
Dan Beam 2012/11/06 02:22:17 I'm confused by these conversions - are you doing
Ilya Sherman 2012/11/06 03:45:08 The WebKit data is utf-16 encoded, but uses a WebK
Evan Stade 2012/11/06 04:16:27 LowerCaseEqualsASCII?
Ilya Sherman 2012/11/06 04:28:42 Ah, good call. Done.
+ if (autocomplete_attribute == ASCIIToUTF16("off") ||
element.nameForAutofill().isEmpty()) {
CombineDataListEntriesAndShow(element, std::vector<string16>(),
std::vector<string16>(),
@@ -624,10 +628,20 @@ 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
+ // Rather than testing the form's autocomplete enabled state, we test the
+ // element's state. The DCHECK below ensures that this is equivalent.
+ DCHECK(element.autoComplete() || !element.form().autoComplete());
+ const RequirementsMask requirements =
+ element.autoComplete() ? REQUIRE_AUTOCOMPLETE : 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);

Powered by Google App Engine
This is Rietveld 408576698