Chromium Code Reviews| Index: ui/views/controls/menu/menu_message_loop_aura.cc |
| diff --git a/ui/views/controls/menu/menu_message_loop_aura.cc b/ui/views/controls/menu/menu_message_loop_aura.cc |
| index 3ed33281aa6f43e8b99a301acb33af9aef39515f..1447a362bb92345dcc0b25c427c147f7f661f808 100644 |
| --- a/ui/views/controls/menu/menu_message_loop_aura.cc |
| +++ b/ui/views/controls/menu/menu_message_loop_aura.cc |
| @@ -18,6 +18,7 @@ |
| #include "ui/events/platform/platform_event_source.h" |
| #include "ui/events/platform/scoped_event_dispatcher.h" |
| #include "ui/views/controls/menu/menu_controller.h" |
| +#include "ui/views/controls/menu/menu_event_filter.h" |
| #include "ui/views/widget/widget.h" |
| #include "ui/wm/public/activation_change_observer.h" |
| #include "ui/wm/public/activation_client.h" |
| @@ -103,7 +104,7 @@ MenuMessageLoop* MenuMessageLoop::Create() { |
| return new MenuMessageLoopAura; |
| } |
| -MenuMessageLoopAura::MenuMessageLoopAura() : owner_(NULL) { |
| +MenuMessageLoopAura::MenuMessageLoopAura() : owner_(nullptr) { |
| } |
| MenuMessageLoopAura::~MenuMessageLoopAura() { |
| @@ -157,33 +158,38 @@ void MenuMessageLoopAura::Run(MenuController* controller, |
| run_loop.Run(); |
| } |
| #else |
| - internal::MenuEventDispatcher event_dispatcher(controller); |
| - scoped_ptr<ui::ScopedEventDispatcher> dispatcher_override; |
| - if (ui::PlatformEventSource::GetInstance()) { |
| - dispatcher_override = |
| - ui::PlatformEventSource::GetInstance()->OverrideDispatcher( |
| - &event_dispatcher); |
| - } |
| + scoped_ptr<MenuEventFilter> menu_event_filter( |
| + new MenuEventFilter(controller)); |
| + |
| + scoped_ptr<ActivationChangeObserverImpl> observer; |
| + |
| if (root) { |
| - scoped_ptr<ActivationChangeObserverImpl> observer; |
| if (!nested_menu) |
| observer.reset(new ActivationChangeObserverImpl(controller, root)); |
| - aura::client::DispatcherRunLoop run_loop( |
| - aura::client::GetDispatcherClient(root), NULL); |
| - message_loop_quit_ = run_loop.QuitClosure(); |
| - run_loop.Run(); |
| - } else { |
| - base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
| - base::MessageLoop::ScopedNestableTaskAllower allow(loop); |
| - base::RunLoop run_loop; |
| - message_loop_quit_ = run_loop.QuitClosure(); |
| - run_loop.Run(); |
| + MenuEventFilter::Delegate* filter_delegate = |
| + MenuEventFilter::GetMenuEventFilterDelegate(root); |
| + if (filter_delegate) |
| + menu_event_filter->SetDelegate(filter_delegate); |
|
pkotwicz
2015/08/28 20:41:50
Can you pass in the MenuEventFilter::Delegate to t
afakhry
2015/08/28 21:42:20
Done.
|
| } |
| -#endif |
| + |
| + aura::Env::GetInstanceDontCreate()->PrependPreTargetHandler( |
| + menu_event_filter.get()); |
| + |
| + base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
| + base::MessageLoop::ScopedNestableTaskAllower allow(loop); |
| + base::RunLoop run_loop; |
| + message_loop_quit_ = run_loop.QuitClosure(); |
| + |
| + run_loop.Run(); |
| + |
| + aura::Env::GetInstanceDontCreate()->RemovePreTargetHandler( |
| + menu_event_filter.get()); |
| +#endif // defined(OS_WIN) |
| } |
| void MenuMessageLoopAura::QuitNow() { |
| CHECK(!message_loop_quit_.is_null()); |
| + |
|
pkotwicz
2015/08/28 22:10:10
Nit: Remove new new line
afakhry
2015/08/28 23:32:12
Done.
|
| message_loop_quit_.Run(); |
| #if !defined(OS_WIN) |