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

Unified Diff: chrome/browser/ui/gtk/extensions/extension_uninstall_dialog_gtk.cc

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/gtk/extensions/extension_uninstall_dialog_gtk.cc
diff --git a/chrome/browser/ui/gtk/extensions/extension_uninstall_dialog_gtk.cc b/chrome/browser/ui/gtk/extensions/extension_uninstall_dialog_gtk.cc
index 2c3e94c5f1b993fcf9a09e8fe8ded7786e48d74a..1f45a6991e05baf30c6f4f2c422767af084bd926 100644
--- a/chrome/browser/ui/gtk/extensions/extension_uninstall_dialog_gtk.cc
+++ b/chrome/browser/ui/gtk/extensions/extension_uninstall_dialog_gtk.cc
@@ -26,41 +26,59 @@ namespace {
// Left or right margin.
const int kPanelHorizMargin = 13;
-void OnResponse(GtkWidget* dialog, int response_id,
- ExtensionUninstallDialog::Delegate* delegate) {
- if (response_id == GTK_RESPONSE_ACCEPT)
- delegate->ExtensionDialogAccepted();
- else
- delegate->ExtensionDialogCanceled();
-
- gtk_widget_destroy(dialog);
-}
+// GTK implementation of the uninstall dialog.
+class ExtensionUninstallDialogGtk : public ExtensionUninstallDialog {
+ public:
+ ExtensionUninstallDialogGtk(Profile* profile, Delegate* delegate);
+ virtual ~ExtensionUninstallDialogGtk() OVERRIDE;
+
+ private:
+ virtual void Show() OVERRIDE;
+
+ CHROMEGTK_CALLBACK_1(ExtensionUninstallDialogGtk, void, OnResponse, int);
+
+ GtkWidget* dialog_;
+};
+
+ExtensionUninstallDialogGtk::ExtensionUninstallDialogGtk(
+ Profile* profile, ExtensionUninstallDialog::Delegate* delegate)
+ : ExtensionUninstallDialog(profile, delegate),
+ dialog_(NULL) {}
+
+void ExtensionUninstallDialogGtk::Show() {
+ Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
+ if (!browser) {
+ delegate_->ExtensionUninstallCanceled();
+ return;
+ }
+
+ BrowserWindow* browser_window = browser->window();
+ if (!browser_window) {
+ delegate_->ExtensionUninstallCanceled();
+ return;
+ }
-void ShowUninstallDialogGtk(GtkWindow* parent,
- SkBitmap* skia_icon,
- const Extension* extension,
- ExtensionUninstallDialog::Delegate *delegate) {
// Build the dialog.
- GtkWidget* dialog = gtk_dialog_new_with_buttons(
+ dialog_ = gtk_dialog_new_with_buttons(
l10n_util::GetStringUTF8(IDS_EXTENSION_UNINSTALL_PROMPT_TITLE).c_str(),
- parent,
+ browser_window->GetNativeHandle(),
GTK_DIALOG_MODAL,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CLOSE,
l10n_util::GetStringUTF8(IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON).c_str(),
GTK_RESPONSE_ACCEPT,
NULL);
- gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
+ gtk_dialog_set_has_separator(GTK_DIALOG(dialog_), FALSE);
// Create a two column layout.
- GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+ GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog_));
gtk_box_set_spacing(GTK_BOX(content_area), ui::kContentAreaSpacing);
GtkWidget* icon_hbox = gtk_hbox_new(FALSE, ui::kContentAreaSpacing);
gtk_box_pack_start(GTK_BOX(content_area), icon_hbox, TRUE, TRUE, 0);
// Put Icon in the left column.
- GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(skia_icon);
+ GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon_);
GtkWidget* icon = gtk_image_new_from_pixbuf(pixbuf);
g_object_unref(pixbuf);
gtk_box_pack_start(GTK_BOX(icon_hbox), icon, TRUE, TRUE, 0);
@@ -70,36 +88,44 @@ void ShowUninstallDialogGtk(GtkWindow* parent,
gtk_box_pack_start(GTK_BOX(icon_hbox), right_column_area, TRUE, TRUE, 0);
std::string heading_text = l10n_util::GetStringFUTF8(
- IDS_EXTENSION_UNINSTALL_PROMPT_HEADING, UTF8ToUTF16(extension->name()));
+ IDS_EXTENSION_UNINSTALL_PROMPT_HEADING, UTF8ToUTF16(extension_->name()));
GtkWidget* heading_label = gtk_label_new(heading_text.c_str());
gtk_misc_set_alignment(GTK_MISC(heading_label), 0.0, 0.5);
gtk_box_pack_start(GTK_BOX(right_column_area), heading_label, TRUE, TRUE, 0);
- g_signal_connect(dialog, "response", G_CALLBACK(OnResponse), delegate);
- gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
- gtk_widget_show_all(dialog);
+ g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this);
+ gtk_window_set_resizable(GTK_WINDOW(dialog_), FALSE);
+ gtk_widget_show_all(dialog_);
}
-} // namespace
-
-// static
-void ExtensionUninstallDialog::Show(
- Profile* profile,
- ExtensionUninstallDialog::Delegate* delegate,
- const Extension* extension,
- SkBitmap* icon) {
- Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
- if (!browser) {
- delegate->ExtensionDialogCanceled();
- return;
+ExtensionUninstallDialogGtk::~ExtensionUninstallDialogGtk() {
+ delegate_ = NULL;
+ if (dialog_) {
+ gtk_widget_destroy(dialog_);
+ dialog_ = NULL;
}
+}
- BrowserWindow* browser_window = browser->window();
- if (!browser_window) {
- delegate->ExtensionDialogCanceled();
- return;
+void ExtensionUninstallDialogGtk::OnResponse(
+ GtkWidget* dialog, int response_id) {
+ CHECK_EQ(dialog_, dialog);
+
+ gtk_widget_destroy(dialog_);
+ dialog_ = NULL;
+
+ if (delegate_) {
+ if (response_id == GTK_RESPONSE_ACCEPT)
+ delegate_->ExtensionUninstallAccepted();
+ else
+ delegate_->ExtensionUninstallCanceled();
}
+}
- ShowUninstallDialogGtk(browser_window->GetNativeHandle(),
- icon, extension, delegate);
+} // namespace
+
+// static
+// Platform specific implementation of the uninstall dialog show method.
+ExtensionUninstallDialog* ExtensionUninstallDialog::Create(
+ Profile* profile, Delegate* delegate) {
+ return new ExtensionUninstallDialogGtk(profile, delegate);
}

Powered by Google App Engine
This is Rietveld 408576698