diff options
author | jww@chromium.org <jww@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-16 22:52:07 +0000 |
---|---|---|
committer | jww@chromium.org <jww@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-16 22:52:07 +0000 |
commit | 58bc1c32387ae3628915d2cc7361823dcacb1d79 (patch) | |
tree | 369373ce753c2be1b3c22cad61c53d8abebbd330 /components | |
parent | fc339fc27b9e68851be8b69994c10929b8b98133 (diff) | |
download | chromium_src-58bc1c32387ae3628915d2cc7361823dcacb1d79.zip chromium_src-58bc1c32387ae3628915d2cc7361823dcacb1d79.tar.gz chromium_src-58bc1c32387ae3628915d2cc7361823dcacb1d79.tar.bz2 |
Put ignore autocomplete='off' behind a flag. Restores the basic
autocomplete='off' semantics, but creates a flag to ignore autocomplete='off' so
we can choose which way to go for release.
BUG=177288
Review URL: https://codereview.chromium.org/109343002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241053 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
10 files changed, 71 insertions, 4 deletions
diff --git a/components/autofill.gypi b/components/autofill.gypi index 2bf7d45..a4937a8 100644 --- a/components/autofill.gypi +++ b/components/autofill.gypi @@ -65,6 +65,8 @@ 'autofill/core/common/form_field_data.h', 'autofill/core/common/form_field_data_predictions.cc', 'autofill/core/common/form_field_data_predictions.h', + 'autofill/core/common/password_autofill_util.cc', + 'autofill/core/common/password_autofill_util.h', 'autofill/core/common/password_form.cc', 'autofill/core/common/password_form.h', 'autofill/core/common/password_form_fill_data.cc', diff --git a/components/autofill/content/common/autofill_param_traits_macros.h b/components/autofill/content/common/autofill_param_traits_macros.h index 67aad7d..d900664 100644 --- a/components/autofill/content/common/autofill_param_traits_macros.h +++ b/components/autofill/content/common/autofill_param_traits_macros.h @@ -32,6 +32,7 @@ IPC_STRUCT_TRAITS_BEGIN(autofill::PasswordForm) IPC_STRUCT_TRAITS_MEMBER(other_possible_usernames) IPC_STRUCT_TRAITS_MEMBER(password_element) IPC_STRUCT_TRAITS_MEMBER(password_value) + IPC_STRUCT_TRAITS_MEMBER(password_autocomplete_set) IPC_STRUCT_TRAITS_MEMBER(old_password_element) IPC_STRUCT_TRAITS_MEMBER(old_password_value) IPC_STRUCT_TRAITS_MEMBER(ssl_valid) diff --git a/components/autofill/content/renderer/password_autofill_agent.cc b/components/autofill/content/renderer/password_autofill_agent.cc index 072c1cf..0a5c23e 100644 --- a/components/autofill/content/renderer/password_autofill_agent.cc +++ b/components/autofill/content/renderer/password_autofill_agent.cc @@ -13,6 +13,7 @@ #include "components/autofill/content/renderer/form_autofill_util.h" #include "components/autofill/content/renderer/password_form_conversion_utils.h" #include "components/autofill/core/common/form_field_data.h" +#include "components/autofill/core/common/password_autofill_util.h" #include "components/autofill/core/common/password_form.h" #include "components/autofill/core/common/password_form_fill_data.h" #include "content/public/renderer/render_view.h" @@ -249,7 +250,9 @@ bool PasswordAutofillAgent::TextDidChangeInTextField( if (iter->second.fill_data.wait_for_username) return false; - if (!IsElementEditable(element) || !element.isText()) { + if (!IsElementEditable(element) || !element.isText() || + (!ShouldIgnoreAutocompleteOffForPasswordFields() && + !element.autoComplete())) { return false; } @@ -637,13 +640,21 @@ void PasswordAutofillAgent::FillFormOnPasswordRecieved( if (password_element.document().frame()->parent()) return; + if (!ShouldIgnoreAutocompleteOffForPasswordFields() && + !username_element.form().autoComplete()) + return; + // If we can't modify the password, don't try to set the username - if (!IsElementEditable(password_element)) + if (!IsElementEditable(password_element) || + (!ShouldIgnoreAutocompleteOffForPasswordFields() && + !password_element.autoComplete())) return; // Try to set the username to the preferred name, but only if the field // can be set and isn't prefilled. if (IsElementEditable(username_element) && + (ShouldIgnoreAutocompleteOffForPasswordFields() || + username_element.autoComplete()) && username_element.value().isEmpty()) { // TODO(tkent): Check maxlength and pattern. username_element.setValue(fill_data.basic_data.fields[0].value); @@ -711,11 +722,16 @@ bool PasswordAutofillAgent::FillUserNameAndPassword( // fields. // Don't fill username if password can't be set. - if (!IsElementEditable(*password_element)) + if (!IsElementEditable(*password_element) || + (!ShouldIgnoreAutocompleteOffForPasswordFields() && + !password_element->autoComplete())) { return false; + } // Input matches the username, fill in required values. - if (IsElementEditable(*username_element)) { + if (IsElementEditable(*username_element) && + (ShouldIgnoreAutocompleteOffForPasswordFields() || + username_element->autoComplete())) { username_element->setValue(username); SetElementAutofilled(username_element, true); diff --git a/components/autofill/content/renderer/password_form_conversion_utils.cc b/components/autofill/content/renderer/password_form_conversion_utils.cc index 8b6c601..c54b84f 100644 --- a/components/autofill/content/renderer/password_form_conversion_utils.cc +++ b/components/autofill/content/renderer/password_form_conversion_utils.cc @@ -32,6 +32,8 @@ scoped_ptr<PasswordForm> InitPasswordFormFromWebPasswordForm( web_password_form.possibleUserNames.size()); password_form->password_element = web_password_form.passwordElement; password_form->password_value = web_password_form.passwordValue; + password_form->password_autocomplete_set = + web_password_form.passwordShouldAutocomplete; password_form->old_password_element = web_password_form.oldPasswordElement; password_form->old_password_value = web_password_form.oldPasswordValue; password_form->scheme = PasswordForm::SCHEME_HTML; diff --git a/components/autofill/core/common/autofill_switches.cc b/components/autofill/core/common/autofill_switches.cc index 094e819..8174c03 100644 --- a/components/autofill/core/common/autofill_switches.cc +++ b/components/autofill/core/common/autofill_switches.cc @@ -19,6 +19,9 @@ const char kDisableInteractiveAutocomplete[] = // account creation. const char kDisablePasswordGeneration[] = "disable-password-generation"; +// Forces the password manager to ignore autocomplete='off' for password forms. +const char kEnableIgnoreAutocompleteOff[] = "enable-ignore-autocomplete-off"; + // Enables an interactive autocomplete UI and a way to invoke this UI from // WebKit by enabling HTMLFormElement#requestAutocomplete (and associated // autocomplete* events and logic). diff --git a/components/autofill/core/common/autofill_switches.h b/components/autofill/core/common/autofill_switches.h index f2bb0ac..21c3f6d 100644 --- a/components/autofill/core/common/autofill_switches.h +++ b/components/autofill/core/common/autofill_switches.h @@ -13,6 +13,7 @@ namespace switches { extern const char kAutofillServiceUrl[]; extern const char kDisableInteractiveAutocomplete[]; extern const char kDisablePasswordGeneration[]; +extern const char kEnableIgnoreAutocompleteOff[]; extern const char kEnableInteractiveAutocomplete[]; extern const char kEnablePasswordGeneration[]; extern const char kNoAutofillNecessaryForPasswordGeneration[]; diff --git a/components/autofill/core/common/password_autofill_util.cc b/components/autofill/core/common/password_autofill_util.cc new file mode 100644 index 0000000..b1f5dbf --- /dev/null +++ b/components/autofill/core/common/password_autofill_util.cc @@ -0,0 +1,19 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/autofill/core/common/password_autofill_util.h" + +#include "base/command_line.h" +#include "components/autofill/core/common/autofill_switches.h" + +namespace autofill { + +// We ignore autocomplete='off' if the user has specified the command line +// feature to enable it. +bool ShouldIgnoreAutocompleteOffForPasswordFields() { + return CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableIgnoreAutocompleteOff); +} + +} // namespace autofill diff --git a/components/autofill/core/common/password_autofill_util.h b/components/autofill/core/common/password_autofill_util.h new file mode 100644 index 0000000..8fc5be2 --- /dev/null +++ b/components/autofill/core/common/password_autofill_util.h @@ -0,0 +1,16 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_AUTOFILL_UTIL_H_ +#define COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_AUTOFILL_UTIL_H_ + +namespace autofill { + +// Returns true if the user has specified the flag to ignore autocomplete='off' +// for password fields in the password manager. +bool ShouldIgnoreAutocompleteOffForPasswordFields(); + +} // namespace autofill + +#endif // COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_AUTOFILL_UTIL_H_ diff --git a/components/autofill/core/common/password_form.cc b/components/autofill/core/common/password_form.cc index edfb2cbe..dcbc874 100644 --- a/components/autofill/core/common/password_form.cc +++ b/components/autofill/core/common/password_form.cc @@ -12,6 +12,7 @@ namespace autofill { PasswordForm::PasswordForm() : scheme(SCHEME_HTML), + password_autocomplete_set(true), ssl_valid(false), preferred(false), blacklisted_by_user(false), @@ -36,6 +37,7 @@ bool PasswordForm::operator==(const PasswordForm& form) const { other_possible_usernames == form.other_possible_usernames && password_element == form.password_element && password_value == form.password_value && + password_autocomplete_set == form.password_autocomplete_set && old_password_element == form.old_password_element && old_password_value == form.old_password_value && ssl_valid == form.ssl_valid && @@ -64,6 +66,7 @@ std::ostream& operator<<(std::ostream& os, const PasswordForm& form) { << " old_password_element: " << UTF16ToUTF8(form.old_password_element) << " old_password_value: " << UTF16ToUTF8(form.old_password_value) + << " autocomplete_set:" << form.password_autocomplete_set << " blacklisted: " << form.blacklisted_by_user << " preferred: " << form.preferred << " ssl_valid: " << form.ssl_valid diff --git a/components/autofill/core/common/password_form.h b/components/autofill/core/common/password_form.h index 0a3d801..1ab6905 100644 --- a/components/autofill/core/common/password_form.h +++ b/components/autofill/core/common/password_form.h @@ -125,6 +125,10 @@ struct PasswordForm { // When parsing an HTML form, this is typically empty. base::string16 password_value; + // False if autocomplete is set to "off" for the password input element; + // True otherwise. + bool password_autocomplete_set; + // If the form was a change password form, the name of the // 'old password' input element. Optional. base::string16 old_password_element; |