Index: components/autofill/content/renderer/password_autofill_agent.cc |
diff --git a/components/autofill/content/renderer/password_autofill_agent.cc b/components/autofill/content/renderer/password_autofill_agent.cc |
index 9e3e0d87fef189c727540f73b52222a8dd24e80b..86ff3779dc76fb185f1e36c899ca5c95f9d6cf88 100644 |
--- a/components/autofill/content/renderer/password_autofill_agent.cc |
+++ b/components/autofill/content/renderer/password_autofill_agent.cc |
@@ -965,6 +965,10 @@ bool PasswordAutofillAgent::FillUserNameAndPassword( |
base::string16 username; |
base::string16 password; |
+ // Don't fill username if password can't be set. |
+ if (!IsElementAutocompletable(*password_element)) |
+ return false; |
+ |
// Look for any suitable matches to current field text. |
if (DoUsernamesMatch(fill_data.basic_data.fields[0].value, |
current_username, |
@@ -1011,11 +1015,6 @@ bool PasswordAutofillAgent::FillUserNameAndPassword( |
// TODO(tkent): Check maxlength and pattern for both username and password |
// fields. |
- // Don't fill username if password can't be set. |
- if (!IsElementAutocompletable(*password_element)) { |
- return false; |
- } |
- |
// Input matches the username, fill in required values. |
if (IsElementAutocompletable(*username_element)) { |
username_element->setValue(username, true); |