Chromium Code Reviews| 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 6a3c2b45d2dbe3f0a50a837fe6e669c4e8a4a0df..91fc888f970f1f9595201e92cb0a40d0b24a11a8 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(); |
| -} |
|
Ilya Sherman
2014/03/29 00:07:07
Why is this function safe to remove? Does setAuto
Dan Beam
2014/03/29 00:51:14
no, passing true to setValue() dispatches a change
|
| - |
| 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. |
|
Dan Beam
2014/03/29 00:51:14
^ there should already be a change dispatched in t
|
| 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); |
|
Dan Beam
2014/03/29 00:51:14
sends change ^ (when appropriate)
|
| + 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); |
|
Dan Beam
2014/03/29 00:51:14
^ this previously could've attempted to send 2 cha
|
| + 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. |
|
Ilya Sherman
2014/03/29 00:07:07
How is this case handled now? We shouldn't trigge
Dan Beam
2014/03/29 00:51:14
setAutofilled() doesn't dispatch a change
|
| password_element->setAutofilled(true); |
| return true; |
| } |