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

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: ignore return value 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
« no previous file with comments | « chrome/browser/ui/views/infobars/infobar_view.h ('k') | chrome/browser/ui/views/infobars/link_infobar.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fe87ea73257892524171a4550d21aea7c2286e41 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,22 @@ const InfoBarContainer::Delegate* InfoBarView::container_delegate() const {
return infobar_container ? infobar_container->delegate() : NULL;
}
+void 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()));
+ // Ignore the result as we know we can only get here after the menu has
+ // closed.
Peter Kasting 2011/09/19 19:08:14 Nit: This comment is a bit confusing, partly becau
+ ignore_result(menu_runner_->RunMenuAt(
+ GetWidget(), button, gfx::Rect(screen_point, button->size()), anchor,
+ views::MenuRunner::HAS_MNEMONICS));
+ // TODO(pkasting): this may be deleted after rewrite. Update comment after
+ // rewrite as necessary.
+}
+
void InfoBarView::PlatformSpecificShow(bool animate) {
views::Widget* widget = GetWidget();
views::FocusManager* focus_manager = GetFocusManager();
@@ -310,6 +328,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.
+ 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.
« no previous file with comments | « chrome/browser/ui/views/infobars/infobar_view.h ('k') | chrome/browser/ui/views/infobars/link_infobar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698