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

Unified Diff: chrome/browser/ui/views/infobars/infobar_view.cc

Issue 7796010: Attempt at fixing crash in menus shown from infobars. Here's what the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change comment and remove change to views 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/views/infobars/infobar_view.cc
diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc
index 8faa905a9dfc4a60100ab33d6db12678f2ab148e..3881486559ebb73bd2029bd1bab473723aceab97 100644
--- a/chrome/browser/ui/views/infobars/infobar_view.cc
+++ b/chrome/browser/ui/views/infobars/infobar_view.cc
@@ -26,6 +26,8 @@
#include "views/controls/image_view.h"
#include "views/controls/label.h"
#include "views/controls/link.h"
+#include "views/controls/menu/menu_model_adapter.h"
+#include "views/controls/menu/menu_runner.h"
#include "views/focus/external_focus_tracker.h"
#include "views/widget/widget.h"
#include "views/window/non_client_view.h"
@@ -289,6 +291,19 @@ const InfoBarContainer::Delegate* InfoBarView::container_delegate() const {
return infobar_container ? infobar_container->delegate() : NULL;
}
+views::MenuRunner::RunResult InfoBarView::RunMenuAt(
+ ui::MenuModel* menu_model,
+ views::MenuButton* button,
+ views::MenuItemView::AnchorPosition anchor) {
+ views::MenuModelAdapter adapter(menu_model);
+ gfx::Point screen_point;
+ views::View::ConvertPointToScreen(button, &screen_point);
+ menu_runner_.reset(new views::MenuRunner(adapter.CreateMenu()));
+ return menu_runner_->RunMenuAt(
+ GetWidget(), button, gfx::Rect(screen_point, button->size()), anchor,
+ views::MenuRunner::HAS_MNEMONICS);
+}
+
void InfoBarView::PlatformSpecificShow(bool animate) {
views::Widget* widget = GetWidget();
views::FocusManager* focus_manager = GetFocusManager();
@@ -310,6 +325,12 @@ void InfoBarView::PlatformSpecificShow(bool animate) {
}
void InfoBarView::PlatformSpecificHide(bool animate) {
+ // We're being removed. Cancel any menus we may have open. Because we are
+ // deleted after a delay and after our delegate is deleted we have to
+ // explicitly cancel the menu rather than relying on the destructor to cancel
+ // the menu.
Peter Kasting 2011/09/15 21:43:12 Nit: Please add: // TODO(pkasting): Remove this w
+ menu_runner_.reset();
+
// It's possible to be called twice (once with |animate| true and once with it
// false); in this case the second RemoveFocusChangeListener() call will
// silently no-op.

Powered by Google App Engine
This is Rietveld 408576698