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

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

Issue 786823002: PasswordFormManager takes WeakPtr<PasswordManagerDriver> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test compilation 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.cc
diff --git a/components/password_manager/core/browser/password_form_manager.cc b/components/password_manager/core/browser/password_form_manager.cc
index a0e0be91a406ce592b869ed182207ffc7d065719..6cad9ad94419f3152b27b7a52ccbe183b00a6a17 100644
--- a/components/password_manager/core/browser/password_form_manager.cc
+++ b/components/password_manager/core/browser/password_form_manager.cc
@@ -70,11 +70,12 @@ PasswordForm CopyAndModifySSLValidity(const PasswordForm& orig,
} // namespace
-PasswordFormManager::PasswordFormManager(PasswordManager* password_manager,
- PasswordManagerClient* client,
- PasswordManagerDriver* driver,
- const PasswordForm& observed_form,
- bool ssl_valid)
+PasswordFormManager::PasswordFormManager(
+ PasswordManager* password_manager,
+ PasswordManagerClient* client,
+ const base::WeakPtr<PasswordManagerDriver>& driver,
+ const PasswordForm& observed_form,
+ bool ssl_valid)
: best_matches_deleter_(&best_matches_),
observed_form_(CopyAndModifySSLValidity(observed_form, ssl_valid)),
is_new_login_(true),
@@ -472,7 +473,8 @@ void PasswordFormManager::OnRequestDone(
if (best_score <= 0) {
// If no saved forms can be used, then it isn't blacklisted and generation
// should be allowed.
- driver_->AllowPasswordGenerationForForm(observed_form_);
+ if (driver_)
+ driver_->AllowPasswordGenerationForForm(observed_form_);
if (logger)
logger->LogNumber(Logger::STRING_BEST_SCORE, best_score);
return;
@@ -508,7 +510,8 @@ void PasswordFormManager::OnRequestDone(
// If not blacklisted, inform the driver that password generation is allowed
// for |observed_form_|.
- driver_->AllowPasswordGenerationForForm(observed_form_);
+ if (driver_)
+ driver_->AllowPasswordGenerationForForm(observed_form_);
MaybeTriggerAutofill();
}
@@ -530,8 +533,10 @@ void PasswordFormManager::MaybeTriggerAutofill() {
manager_action_ = kManagerActionNone;
else
manager_action_ = kManagerActionAutofilled;
- password_manager_->Autofill(driver_, observed_form_, best_matches_,
- *preferred_match_, wait_for_username);
+ if (driver_) {
Evan Stade 2014/12/08 20:02:50 move this up to ~L521 for earlier abort?
vabr (Chromium) 2014/12/09 12:55:46 Done. Skipping setting |manager_action_| is actual
+ password_manager_->Autofill(driver_.get(), observed_form_, best_matches_,
+ *preferred_match_, wait_for_username);
+ }
}
void PasswordFormManager::OnGetPasswordStoreResults(
@@ -550,7 +555,8 @@ void PasswordFormManager::OnGetPasswordStoreResults(
// No result means that we visit this site the first time so we don't need
// to check whether this site is blacklisted or not. Just send a message
// to allow password generation.
- driver_->AllowPasswordGenerationForForm(observed_form_);
+ if (driver_)
+ driver_->AllowPasswordGenerationForForm(observed_form_);
return;
}
OnRequestDone(results);

Powered by Google App Engine
This is Rietveld 408576698