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

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

Issue 119493004: [Password Autofill] Trigger onChange events in JavaScript when autofilling passwords. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 0a5c23e191398576b618ed1168ea47ff4319871c..5b173f90377bd8f1b51d8c25e1e6f459b8739b05 100644
--- a/components/autofill/content/renderer/password_autofill_agent.cc
+++ b/components/autofill/content/renderer/password_autofill_agent.cc
@@ -657,7 +657,7 @@ void PasswordAutofillAgent::FillFormOnPasswordRecieved(
username_element.autoComplete()) &&
username_element.value().isEmpty()) {
// TODO(tkent): Check maxlength and pattern.
- username_element.setValue(fill_data.basic_data.fields[0].value);
+ username_element.setValue(fill_data.basic_data.fields[0].value, true);
}
// Fill if we have an exact match for the username. Note that this sets
@@ -732,7 +732,7 @@ bool PasswordAutofillAgent::FillUserNameAndPassword(
if (IsElementEditable(*username_element) &&
(ShouldIgnoreAutocompleteOffForPasswordFields() ||
username_element->autoComplete())) {
- username_element->setValue(username);
+ username_element->setValue(username, true);
SetElementAutofilled(username_element, true);
if (set_selection) {
@@ -753,9 +753,12 @@ bool PasswordAutofillAgent::FillUserNameAndPassword(
gesture_handler_->addElement(*password_element);
password_element->setSuggestedValue(password);
} else {
- password_element->setValue(password);
+ password_element->setValue(password, true);
}
- SetElementAutofilled(password_element, true);
+ // 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;
}
@@ -833,7 +836,7 @@ void PasswordAutofillAgent::AutofillWebUserGestureHandler::onGesture() {
std::vector<blink::WebInputElement>::iterator iter;
for (iter = elements_.begin(); iter != elements_.end(); ++iter) {
if (!iter->isNull() && !iter->suggestedValue().isNull())
- iter->setValue(iter->suggestedValue());
+ iter->setValue(iter->suggestedValue(), true);
}
elements_.clear();

Powered by Google App Engine
This is Rietveld 408576698