summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 20:27:17 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 20:27:17 +0000
commitd51eb48985356adc40a55d678b14f0c0a5870ffb (patch)
treee0152ac8fad198468719fc3921087421a4ffdee0
parentc6e72c6f1ba7ea524176074b758d1f91a05516a8 (diff)
downloadchromium_src-d51eb48985356adc40a55d678b14f0c0a5870ffb.zip
chromium_src-d51eb48985356adc40a55d678b14f0c0a5870ffb.tar.gz
chromium_src-d51eb48985356adc40a55d678b14f0c0a5870ffb.tar.bz2
Re-apply r42703 which was reverted because of a conflict with another patch that was being reverted:
TBR=ananta Views: fix a crash where in the browser actions container. This crash didn't actually affect linux/views (for some reason the RunContextMenu() call seems to never return). BUG=38964 TEST=crash an extension while the context menu for it is showing. original review: http://codereview.chromium.org/1237004/show Review URL: http://codereview.chromium.org/1449001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42813 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/views/browser_actions_container.cc18
-rw-r--r--chrome/browser/views/browser_actions_container.h14
-rw-r--r--views/controls/menu/native_menu_gtk.cc9
-rw-r--r--views/controls/menu/native_menu_gtk.h9
4 files changed, 37 insertions, 13 deletions
diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc
index b23cb76..7ccaee8 100644
--- a/chrome/browser/views/browser_actions_container.cc
+++ b/chrome/browser/views/browser_actions_container.cc
@@ -125,7 +125,13 @@ BrowserActionButton::BrowserActionButton(Extension* extension,
Extension::kBrowserActionIconMaxSize));
}
-BrowserActionButton::~BrowserActionButton() {
+void BrowserActionButton::Destroy() {
+ if (showing_context_menu_) {
+ context_menu_menu_->CancelMenu();
+ MessageLoop::current()->DeleteSoon(FROM_HERE, this);
+ } else {
+ delete this;
+ }
}
gfx::Insets BrowserActionButton::GetInsets() const {
@@ -235,6 +241,8 @@ bool BrowserActionButton::OnMousePressed(const views::MouseEvent& e) {
context_menu_menu_->RunContextMenuAt(point);
SetButtonNotPushed();
+ showing_context_menu_ = false;
+
return false;
} else if (IsPopup()) {
return MenuButton::OnMousePressed(e);
@@ -276,6 +284,9 @@ void BrowserActionButton::SetButtonNotPushed() {
menu_visible_ = false;
}
+BrowserActionButton::~BrowserActionButton() {
+}
+
////////////////////////////////////////////////////////////////////////////////
// BrowserActionView
@@ -289,6 +300,11 @@ BrowserActionView::BrowserActionView(Extension* extension,
button_->UpdateState();
}
+BrowserActionView::~BrowserActionView() {
+ RemoveChildView(button_);
+ button_->Destroy();
+}
+
gfx::Canvas* BrowserActionView::GetIconWithBadge() {
int tab_id = panel_->GetCurrentTabId();
diff --git a/chrome/browser/views/browser_actions_container.h b/chrome/browser/views/browser_actions_container.h
index 45cfaf9..de6048c 100644
--- a/chrome/browser/views/browser_actions_container.h
+++ b/chrome/browser/views/browser_actions_container.h
@@ -50,7 +50,9 @@ class BrowserActionButton : public views::MenuButton,
public NotificationObserver {
public:
BrowserActionButton(Extension* extension, BrowserActionsContainer* panel);
- ~BrowserActionButton();
+
+ // Call this instead of delete.
+ void Destroy();
ExtensionAction* browser_action() const { return browser_action_; }
Extension* extension() { return extension_; }
@@ -94,10 +96,12 @@ class BrowserActionButton : public views::MenuButton,
// Notifications when to set button state to pushed/not pushed (for when the
// popup/context menu is hidden or shown by the container).
- virtual void SetButtonPushed();
- virtual void SetButtonNotPushed();
+ void SetButtonPushed();
+ void SetButtonNotPushed();
private:
+ virtual ~BrowserActionButton();
+
// The browser action this view represents. The ExtensionAction is not owned
// by this class.
ExtensionAction* browser_action_;
@@ -124,6 +128,8 @@ class BrowserActionButton : public views::MenuButton,
NotificationRegistrar registrar_;
+ friend class DeleteTask<BrowserActionButton>;
+
DISALLOW_COPY_AND_ASSIGN(BrowserActionButton);
};
@@ -136,6 +142,8 @@ class BrowserActionButton : public views::MenuButton,
class BrowserActionView : public views::View {
public:
BrowserActionView(Extension* extension, BrowserActionsContainer* panel);
+ virtual ~BrowserActionView();
+
BrowserActionButton* button() { return button_; }
// Allocates a canvas object on the heap and draws into it the icon for the
diff --git a/views/controls/menu/native_menu_gtk.cc b/views/controls/menu/native_menu_gtk.cc
index a910a76..71af5c8 100644
--- a/views/controls/menu/native_menu_gtk.cc
+++ b/views/controls/menu/native_menu_gtk.cc
@@ -105,7 +105,7 @@ void NativeMenuGtk::RunMenuAt(const gfx::Point& point, int alignment) {
// Listen for "hide" signal so that we know when to return from the blocking
// RunMenuAt call.
gint handle_id =
- g_signal_connect(menu_, "hide", G_CALLBACK(OnMenuHidden), this);
+ g_signal_connect(menu_, "hide", G_CALLBACK(OnMenuHiddenThunk), this);
// Block until menu is no longer shown by running a nested message loop.
MessageLoopForUI::current()->Run(NULL);
@@ -121,7 +121,7 @@ void NativeMenuGtk::RunMenuAt(const gfx::Point& point, int alignment) {
}
void NativeMenuGtk::CancelMenu() {
- NOTIMPLEMENTED();
+ gtk_widget_hide(menu_);
}
void NativeMenuGtk::Rebuild() {
@@ -177,9 +177,8 @@ gfx::NativeMenu NativeMenuGtk::GetNativeMenu() const {
////////////////////////////////////////////////////////////////////////////////
// NativeMenuGtk, private:
-// static
-void NativeMenuGtk::OnMenuHidden(GtkWidget* widget, NativeMenuGtk* menu) {
- if (!menu->menu_shown_) {
+void NativeMenuGtk::OnMenuHidden(GtkWidget* widget) {
+ if (!menu_shown_) {
// This indicates we don't have a menu open, and should never happen.
NOTREACHED();
return;
diff --git a/views/controls/menu/native_menu_gtk.h b/views/controls/menu/native_menu_gtk.h
index 2c69ba3..78d03ec 100644
--- a/views/controls/menu/native_menu_gtk.h
+++ b/views/controls/menu/native_menu_gtk.h
@@ -1,12 +1,13 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#ifndef VIEWS_CONTROLS_MENU_NATIVE_MENU_GTK_H_
#define VIEWS_CONTROLS_MENU_NATIVE_MENU_GTK_H_
#include <gtk/gtk.h>
+#include "app/gtk_signal.h"
#include "base/task.h"
#include "views/controls/menu/menu_wrapper.h"
@@ -38,7 +39,7 @@ class NativeMenuGtk : public MenuWrapper {
virtual gfx::NativeMenu GetNativeMenu() const;
private:
- static void OnMenuHidden(GtkWidget* widget, NativeMenuGtk* menu);
+ CHROMEGTK_CALLBACK_0(NativeMenuGtk, void, OnMenuHidden);
void AddSeparatorAt(int index);
GtkWidget* AddMenuItemAt(int index, GtkRadioMenuItem* radio_group,