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

Unified Diff: ui/views/controls/menu/menu_message_loop_aura.cc

Issue 1138523006: Enable keyboard accelerators while a menu is open (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 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: 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..f1e2c9dc5ffdffa9d1537bed93c842fcedbb0a2d 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,29 +158,32 @@ 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<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();
}
-#endif
+
+ scoped_ptr<MenuEventFilter> menu_event_filter;
+ if (!nested_menu) {
+ // No need to recreate the MenuEventFilter for every nested menu.
+ menu_event_filter.reset(new MenuEventFilter);
+ aura::Env::GetInstanceDontCreate()->PrependPreTargetHandler(
+ menu_event_filter.get());
oshima 2015/09/08 21:43:08 You can add/remove the filter in MenuEventFilter's
afakhry 2015/09/08 23:34:38 Done.
+ }
+
+ base::MessageLoopForUI* loop = base::MessageLoopForUI::current();
+ base::MessageLoop::ScopedNestableTaskAllower allow(loop);
+ base::RunLoop run_loop;
+ message_loop_quit_ = run_loop.QuitClosure();
+
+ run_loop.Run();
+
+ if (menu_event_filter.get()) {
+ aura::Env::GetInstanceDontCreate()->RemovePreTargetHandler(
+ menu_event_filter.get());
+ }
+#endif // defined(OS_WIN)
}
void MenuMessageLoopAura::QuitNow() {

Powered by Google App Engine
This is Rietveld 408576698