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

Unified Diff: components/password_manager/core/browser/password_form_manager.h

Issue 786823002: PasswordFormManager takes WeakPtr<PasswordManagerDriver> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SupportsWeakPtr Created 6 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/password_manager/core/browser/password_form_manager.h
diff --git a/components/password_manager/core/browser/password_form_manager.h b/components/password_manager/core/browser/password_form_manager.h
index e400630657e534e7de9052b8d53af8ed28c24fbc..ee745792122c6e956cd1d3295cf64d0914bcb166 100644
--- a/components/password_manager/core/browser/password_form_manager.h
+++ b/components/password_manager/core/browser/password_form_manager.h
@@ -10,6 +10,7 @@
#include "build/build_config.h"
+#include "base/memory/weak_ptr.h"
#include "base/stl_util.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/common/password_form.h"
@@ -32,7 +33,7 @@ class PasswordFormManager : public PasswordStoreConsumer {
// used to filter login results from database.
PasswordFormManager(PasswordManager* password_manager,
PasswordManagerClient* client,
- PasswordManagerDriver* driver,
+ const base::WeakPtr<PasswordManagerDriver>& driver,
const autofill::PasswordForm& observed_form,
bool ssl_valid);
~PasswordFormManager() override;
@@ -327,9 +328,17 @@ class PasswordFormManager : public PasswordStoreConsumer {
// The client which implements embedder-specific PasswordManager operations.
PasswordManagerClient* client_;
- // The driver which implements platform-specific PasswordManager operations.
- // TODO(vabr): remove this due to lifetime issues. http://crbug.com/439387
- PasswordManagerDriver* driver_;
+ // The driver for frame-specific operations. Note that while |driver_| lives
+ // only as long as its associated frame, |this| is kept alive at least until
+ // main frame navigation or even past that (if it carries a provisionally
+ // saved password). Normally, |this| requests stored credentials from
+ // PasswordStore, and only needs |driver_| to update the frame with those as
+ // soon as the store calls back with the results. But because the store
+ // retrieval involves UI->DB->UI thread communication, the frame (and
+ // |driver_|) might get deleted sooner than the store calls back. In that
+ // case, the updates of the frame are no longer needed, and calls to |driver_|
+ // should silently be omitted.
+ const base::WeakPtr<PasswordManagerDriver> driver_;
// These three fields record the "ActionsTaken" by the browser and
// the user with this form, and the result. They are combined and

Powered by Google App Engine
This is Rietveld 408576698