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 ea8944a26a098cfda0842c0c72e8096fd047d984..27b3f759e8d3056b69bdc88431a61cdd640d4343 100644 |
--- a/components/autofill/content/renderer/password_autofill_agent.cc |
+++ b/components/autofill/content/renderer/password_autofill_agent.cc |
@@ -858,7 +858,11 @@ bool PasswordAutofillAgent::ShowSuggestions( |
// is no username or the corresponding username element is not editable since |
// it is only in that case that the username element does not have a |
// suggestions popup. |
- if (element.isPasswordField() && username_is_available) |
+ if (element.isPasswordField() && username_is_available && |
+ (!password_info->fill_data.is_change_password_form || |
Garrett Casto
2015/06/12 00:09:09
Instead of keeping an additional structure, how ab
dvadym
2015/06/12 17:22:37
I agree, that it's better to be simpler, so I've r
|
+ (password_info->fill_data.is_change_password_form && |
+ had_focus_username_fields_.find(*username_element) != |
+ had_focus_username_fields_.end()))) |
return true; |
// Chrome should never show more than one account for a password element since |
@@ -1396,6 +1400,7 @@ void PasswordAutofillAgent::FrameClosing() { |
login_to_password_info_.clear(); |
provisionally_saved_form_.reset(); |
nonscript_modified_values_.clear(); |
+ had_focus_username_fields_.clear(); |
} |
bool PasswordAutofillAgent::FindLoginInfo(const blink::WebNode& node, |
@@ -1449,6 +1454,21 @@ bool PasswordAutofillAgent::ProvisionallySavedPasswordIsValid() { |
provisionally_saved_form_->new_password_value.empty()); |
} |
+void PasswordAutofillAgent::FocusedNodeChanged(const blink::WebNode& node) { |
+ if (node.isNull() || !node.isElementNode()) |
+ return; |
+ |
+ blink::WebElement web_element = node.toConst<blink::WebElement>(); |
+ const blink::WebInputElement* element = toWebInputElement(&web_element); |
+ |
+ // If |element| is a username element then add it to username elements that |
+ // had focus. |
+ if (element && element->isTextField() && |
+ login_to_password_info_.find(*element) != login_to_password_info_.end()) { |
+ had_focus_username_fields_.insert(*element); |
+ } |
+} |
+ |
// LegacyPasswordAutofillAgent ------------------------------------------------- |
PasswordAutofillAgent::LegacyPasswordAutofillAgent::LegacyPasswordAutofillAgent( |