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

Unified Diff: chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc

Issue 2474783002: Fix memory leak for extension uninstall dialog. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 | « no previous file | chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc
diff --git a/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc b/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc
index 6aed9daa19761504bf3c996fc6fcc8ded121dbbf..252af5175f38d9b2946f700c595c811abaee3c25 100644
--- a/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc
+++ b/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc
@@ -44,8 +44,8 @@ class ExtensionUninstallDialogViews
~ExtensionUninstallDialogViews() override;
// Called when the ExtensionUninstallDialogDelegate has been destroyed to make
- // sure we invalidate pointers.
- void DialogDelegateDestroyed() { view_ = NULL; }
+ // sure we invalidate pointers. This object will also be freed.
+ void DialogDelegateDestroyed();
// Forwards the accept and cancels to the delegate.
void DialogAccepted(bool handle_report_abuse);
@@ -140,8 +140,17 @@ void ExtensionUninstallDialogViews::Show() {
constrained_window::CreateBrowserModalDialogViews(view_, parent_)->Show();
}
+void ExtensionUninstallDialogViews::DialogDelegateDestroyed() {
+ // Checks view_ to ensure OnDialogClosed() will not be called twice.
+ if (view_) {
+ view_ = nullptr;
+ OnDialogClosed(CLOSE_ACTION_CANCELED);
+ }
+}
+
void ExtensionUninstallDialogViews::DialogAccepted(bool report_abuse_checked) {
// The widget gets destroyed when the dialog is accepted.
+ DCHECK(view_);
view_->DialogDestroyed();
view_ = nullptr;
OnDialogClosed(report_abuse_checked ?
@@ -150,6 +159,7 @@ void ExtensionUninstallDialogViews::DialogAccepted(bool report_abuse_checked) {
void ExtensionUninstallDialogViews::DialogCanceled() {
// The widget gets destroyed when the dialog is canceled.
+ DCHECK(view_);
view_->DialogDestroyed();
view_ = nullptr;
OnDialogClosed(CLOSE_ACTION_CANCELED);
« no previous file with comments | « no previous file | chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698