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

Unified Diff: chrome/browser/ui/passwords/manage_passwords_ui_controller.cc

Issue 2202373002: Ignore OnBubbleHidden() event when the password bubble is reopened. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: delete proxy Created 4 years, 4 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
Index: chrome/browser/ui/passwords/manage_passwords_ui_controller.cc
diff --git a/chrome/browser/ui/passwords/manage_passwords_ui_controller.cc b/chrome/browser/ui/passwords/manage_passwords_ui_controller.cc
index 81f5748e73c9f56100a989751bfed9a257b9f44f..3ea412b73d8461a4c9d2aaa81906f12d4bdee2c7 100644
--- a/chrome/browser/ui/passwords/manage_passwords_ui_controller.cc
+++ b/chrome/browser/ui/passwords/manage_passwords_ui_controller.cc
@@ -59,7 +59,8 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagePasswordsUIController);
ManagePasswordsUIController::ManagePasswordsUIController(
content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
- bubble_status_(NOT_SHOWN) {
+ bubble_status_(NOT_SHOWN),
+ weak_ptr_factory_(this) {
passwords_data_.set_client(
ChromePasswordManagerClient::FromWebContents(web_contents));
password_manager::PasswordStore* password_store =
@@ -174,6 +175,8 @@ void ManagePasswordsUIController::UpdateIconAndBubbleState(
ManagePasswordsIconView* icon) {
if (bubble_status_ == SHOULD_POP_UP) {
DCHECK(!dialog_controller_);
+ // This will detach any existing bubble so OnBubbleHidden() isn't called.
+ weak_ptr_factory_.InvalidateWeakPtrs();
// We must display the icon before showing the bubble, as the bubble would
// be otherwise unanchored.
icon->SetState(GetState());
@@ -191,6 +194,15 @@ void ManagePasswordsUIController::UpdateIconAndBubbleState(
}
}
+base::WeakPtr<PasswordsModelDelegate>
+ManagePasswordsUIController::GetModelDelegateProxy() {
+ return weak_ptr_factory_.GetWeakPtr();
+}
+
+content::WebContents* ManagePasswordsUIController::GetWebContents() const {
+ return web_contents();
+}
+
const GURL& ManagePasswordsUIController::GetOrigin() const {
return passwords_data_.origin();
}
@@ -298,13 +310,16 @@ void ManagePasswordsUIController::UpdatePassword(
}
void ManagePasswordsUIController::ChooseCredential(
- autofill::PasswordForm form,
+ const autofill::PasswordForm& form,
password_manager::CredentialType credential_type) {
DCHECK(dialog_controller_);
DCHECK_EQ(password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD,
credential_type);
+ // Copy the argument before destroying the controller. |form| is a member of
+ // |dialog_controller_|.
+ autofill::PasswordForm copy_form = form;
dialog_controller_.reset();
- passwords_data_.ChooseCredential(&form);
+ passwords_data_.ChooseCredential(&copy_form);
passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE);
UpdateBubbleAndIconVisibility();
}

Powered by Google App Engine
This is Rietveld 408576698