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

Unified Diff: components/autofill/content/renderer/password_autofill_agent.cc

Issue 1161023008: Suggest to fill password change forms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renaming and showing password field suggestions rarely Created 5 years, 6 months 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: 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(

Powered by Google App Engine
This is Rietveld 408576698