Chromium Code Reviews| Index: ui/views/controls/menu/menu_controller.cc |
| diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc |
| index a63448d679b1d8715e1550f65095e324cc1624cc..fa6af11fe1c919a2a518e082c8786d86397cbe81 100644 |
| --- a/ui/views/controls/menu/menu_controller.cc |
| +++ b/ui/views/controls/menu/menu_controller.cc |
| @@ -107,6 +107,7 @@ bool TitleMatchesMnemonic(MenuItemView* menu, base::char16 key) { |
| return !lower_title.empty() && lower_title[0] == key; |
| } |
| +#if defined(USE_AURA) |
|
tapted
2014/05/02 00:22:57
I think there will be resistance to this many #ifd
|
| aura::Window* GetOwnerRootWindow(views::Widget* owner) { |
| return owner ? owner->GetNativeWindow()->GetRootWindow() : NULL; |
| } |
| @@ -167,6 +168,7 @@ class ActivationChangeObserverImpl |
| DISALLOW_COPY_AND_ASSIGN(ActivationChangeObserverImpl); |
| }; |
| +#endif // USE_AURA |
| } // namespace |
| @@ -1191,6 +1193,13 @@ void MenuController::RunMessageLoop(bool nested_menu) { |
| run_loop.Run(); |
| } |
| } |
| +#elif defined(OS_MACOSX) |
| +void MenuController::RunMessageLoop(bool nested_menu) { |
| + base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
| + base::MessageLoop::ScopedNestableTaskAllower allow(loop); |
| + base::RunLoop run_loop; |
| + run_loop.Run(); |
| +} |
| #else |
| void MenuController::RunMessageLoop(bool nested_menu) { |
| internal::MenuEventDispatcher event_dispatcher(this); |
| @@ -2229,6 +2238,7 @@ void MenuController::RepostEvent(SubmenuView* source, |
| if (!window) |
| return; |
| +#if defined(USE_AURA) |
| aura::Window* root = window->GetRootWindow(); |
| ScreenPositionClient* spc = aura::client::GetScreenPositionClient(root); |
| if (!spc) |
| @@ -2241,6 +2251,7 @@ void MenuController::RepostEvent(SubmenuView* source, |
| clone.set_location(root_loc); |
| clone.set_root_location(root_loc); |
| root->GetHost()->dispatcher()->RepostEvent(clone); |
| +#endif |
| } |
| void MenuController::SetDropMenuItem( |
| @@ -2379,21 +2390,29 @@ void MenuController::SetExitType(ExitType type) { |
| message_loop_depth_; |
| if (quit_now) { |
| +#if defined(USE_AURA) |
| if (owner_) { |
| aura::Window* root = owner_->GetNativeWindow()->GetRootWindow(); |
| aura::client::GetDispatcherClient(root)->QuitNestedMessageLoop(); |
| } else { |
| base::MessageLoop::current()->QuitNow(); |
| } |
| +#else |
| + base::MessageLoop::current()->QuitNow(); |
| +#endif |
| // Restore the previous dispatcher. |
| nested_dispatcher_.reset(); |
| } |
| } |
| bool MenuController::ShouldQuitNow() const { |
| +#if defined(USE_AURA) |
| aura::Window* root = GetOwnerRootWindow(owner_); |
| return !aura::client::GetDragDropClient(root) || |
| !aura::client::GetDragDropClient(root)->IsDragDropInProgress(); |
| +#else |
| + return true; |
| +#endif |
| } |
| void MenuController::HandleMouseLocation(SubmenuView* source, |
| @@ -2429,8 +2448,8 @@ void MenuController::HandleMouseLocation(SubmenuView* source, |
| } |
| gfx::Screen* MenuController::GetScreen() { |
| - aura::Window* root = GetOwnerRootWindow(owner_); |
| - return root ? gfx::Screen::GetScreenFor(root) |
| + Widget* root = owner_->GetTopLevelWidget(); |
| + return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) |
|
Andre
2014/05/01 22:38:43
I'm not sure about this change (limited experience
tapted
2014/05/02 00:22:57
This looks good! (I think :)
|
| : gfx::Screen::GetNativeScreen(); |
| } |