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

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

Issue 1012853002: [Password Manager] Use successful XHR submission as a signal for password saving (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 5 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
« no previous file with comments | « components/autofill/content/renderer/password_autofill_agent.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 78679f3637b2e55e4d190878b87937ca3e6eccb6..d7b291a15f11e026398cc7d282d9d597b9c486cb 100644
--- a/components/autofill/content/renderer/password_autofill_agent.cc
+++ b/components/autofill/content/renderer/password_autofill_agent.cc
@@ -859,6 +859,36 @@ void PasswordAutofillAgent::OnDynamicFormsSeen() {
SendPasswordForms(false /* only_visible */);
}
+void PasswordAutofillAgent::XHRSucceeded() {
+ if (!ProvisionallySavedPasswordIsValid())
+ return;
+
+ // Prompt to save only if the form is now gone, either invisible or
+ // removed from the DOM.
+ blink::WebFrame* frame = render_frame()->GetWebFrame();
+ blink::WebVector<blink::WebFormElement> forms;
+ frame->document().forms(forms);
+
+ for (size_t i = 0; i < forms.size(); ++i) {
+ const blink::WebFormElement& form = forms[i];
+ if (!IsWebNodeVisible(form)) {
+ continue;
+ }
+
+ scoped_ptr<PasswordForm> password_form(
+ CreatePasswordForm(form, &nonscript_modified_values_));
+ if (password_form.get()) {
+ if (provisionally_saved_form_->action == password_form->action) {
+ // Form still exists, no save required.
+ return;
+ }
+ }
+ }
+ Send(new AutofillHostMsg_InPageNavigation(routing_id(),
+ *provisionally_saved_form_));
+ provisionally_saved_form_.reset();
+}
+
void PasswordAutofillAgent::FirstUserGestureObserved() {
gatekeeper_.OnUserGesture();
}
@@ -1365,6 +1395,13 @@ void PasswordAutofillAgent::ProvisionallySavePassword(
provisionally_saved_form_ = password_form.Pass();
}
+bool PasswordAutofillAgent::ProvisionallySavedPasswordIsValid() {
+ return provisionally_saved_form_ &&
+ !provisionally_saved_form_->username_value.empty() &&
+ !(provisionally_saved_form_->password_value.empty() &&
+ provisionally_saved_form_->new_password_value.empty());
+}
+
// LegacyPasswordAutofillAgent -------------------------------------------------
PasswordAutofillAgent::LegacyPasswordAutofillAgent::LegacyPasswordAutofillAgent(
« no previous file with comments | « components/autofill/content/renderer/password_autofill_agent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698