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

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

Issue 214823011: Autofill/rAc: dispatch "input"/"change" on <input>, <textarea>, and <select> (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: squash a lil' bug Created 6 years, 9 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 df8056242e3eed16495550ae170eeafec6200860..a73ba4ffb1abe8545c0f4880896769cafae64233 100644
--- a/components/autofill/content/renderer/password_autofill_agent.cc
+++ b/components/autofill/content/renderer/password_autofill_agent.cc
@@ -166,14 +166,6 @@ bool IsElementEditable(const blink::WebInputElement& element) {
return element.isEnabled() && !element.isReadOnly();
}
-void SetElementAutofilled(blink::WebInputElement* element, bool autofilled) {
- if (element->isAutofilled() == autofilled)
- return;
- element->setAutofilled(autofilled);
- // Notify any changeEvent listeners.
- element->dispatchFormControlChangeEvent();
-}
-
bool DoUsernamesMatch(const base::string16& username1,
const base::string16& username2,
bool exact_match) {
@@ -297,11 +289,12 @@ bool PasswordAutofillAgent::TextDidChangeInTextField(
// The input text is being changed, so any autofilled password is now
// outdated.
blink::WebInputElement username = element; // We need a non-const.
+ username.setAutofilled(false);
+
blink::WebInputElement password = iter->second.password_field;
- SetElementAutofilled(&username, false);
if (password.isAutofilled()) {
- password.setValue(base::string16());
- SetElementAutofilled(&password, false);
+ password.setValue(base::string16(), true);
+ password.setAutofilled(false);
}
// If wait_for_username is true we will fill when the username loses focus.
@@ -812,7 +805,7 @@ bool PasswordAutofillAgent::FillUserNameAndPassword(
// Input matches the username, fill in required values.
if (IsElementAutocompletable(*username_element)) {
username_element->setValue(username, true);
- SetElementAutofilled(username_element, true);
+ username_element->setAutofilled(true);
if (set_selection) {
username_element->setSelectionRange(current_username.length(),
@@ -836,9 +829,6 @@ bool PasswordAutofillAgent::FillUserNameAndPassword(
password_element->setValue(password);
#endif
- // Note: Don't call SetElementAutofilled() here, as that dispatches an
- // onChange event in JavaScript, which is not appropriate for the password
- // element if a user gesture has not yet occured.
password_element->setAutofilled(true);
return true;
}

Powered by Google App Engine
This is Rietveld 408576698