Chromium Code Reviews| 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. |