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

Unified Diff: chrome/browser/ui/cocoa/extensions/extension_uninstall_dialog_cocoa.mm

Issue 7920023: Fix crashes related to the extension uninstall dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make Show() pure virtual Created 9 years, 3 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/cocoa/extensions/extension_uninstall_dialog_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/extensions/extension_uninstall_dialog_cocoa.mm b/chrome/browser/ui/cocoa/extensions/extension_uninstall_dialog_cocoa.mm
index 825fc9dccb0a1d1e1bbc5fe106a672bd22ee54c8..eb894419be95f8ea8f167d71fd0fde58920819b2 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_uninstall_dialog_cocoa.mm
+++ b/chrome/browser/ui/cocoa/extensions/extension_uninstall_dialog_cocoa.mm
@@ -17,12 +17,28 @@
#include "ui/base/l10n/l10n_util_mac.h"
#include "ui/base/resource/resource_bundle.h"
-// static
-void ExtensionUninstallDialog::Show(
- Profile* profile,
- ExtensionUninstallDialog::Delegate* delegate,
- const Extension* extension,
- SkBitmap* icon) {
+namespace {
+
+// The Cocoa implementation of ExtensionUninstallDialog. This has a less
+// complex life cycle than the Views and GTK implementations because the
+// dialog blocks the page from navigating away and destroying the dialog,
+// so there's no way for the dialog to outlive its delegate.
+class ExtensionUninstallDialogCocoa : public ExtensionUninstallDialog {
+ public:
+ ExtensionUninstallDialogCocoa(Profile* profile, Delegate* delegate);
+ virtual ~ExtensionUninstallDialogCocoa() OVERRIDE;
+
+ private:
+ virtual void Show() OVERRIDE;
+};
+
+ExtensionUninstallDialogCocoa::ExtensionUninstallDialogCocoa(
+ Profile* profile, ExtensionUninstallDialog::Delegate* delegate)
+ : ExtensionUninstallDialog(profile, delegate) {}
+
+ExtensionUninstallDialogCocoa::~ExtensionUninstallDialogCocoa() {}
+
+void ExtensionUninstallDialogCocoa::Show() {
NSAlert* alert = [[[NSAlert alloc] init] autorelease];
NSButton* continueButton = [alert addButtonWithTitle:l10n_util::GetNSString(
@@ -37,12 +53,20 @@ void ExtensionUninstallDialog::Show(
[alert setMessageText:l10n_util::GetNSStringF(
IDS_EXTENSION_UNINSTALL_PROMPT_HEADING,
- UTF8ToUTF16(extension->name()))];
+ UTF8ToUTF16(extension_->name()))];
[alert setAlertStyle:NSWarningAlertStyle];
- [alert setIcon:gfx::SkBitmapToNSImage(*icon)];
+ [alert setIcon:gfx::SkBitmapToNSImage(icon_)];
if ([alert runModal] == NSAlertFirstButtonReturn)
- delegate->ExtensionDialogAccepted();
+ delegate_->ExtensionUninstallAccepted();
else
- delegate->ExtensionDialogCanceled();
+ delegate_->ExtensionUninstallCanceled();
+}
+
+} // namespace
+
+// static
+ExtensionUninstallDialog* ExtensionUninstallDialog::Create(
+ Profile* profile, Delegate* delegate) {
+ return new ExtensionUninstallDialogCocoa(profile, delegate);
}

Powered by Google App Engine
This is Rietveld 408576698