OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/views/controls/menu/menu_message_loop_mac.h" |
| 6 |
| 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" |
| 9 |
| 10 namespace views { |
| 11 |
| 12 // static |
| 13 MenuMessageLoop* MenuMessageLoop::Create() { |
| 14 return new MenuMessageLoopMac; |
| 15 } |
| 16 |
| 17 MenuMessageLoopMac::MenuMessageLoopMac() |
| 18 : message_loop_depth_(0) { |
| 19 } |
| 20 |
| 21 MenuMessageLoopMac::~MenuMessageLoopMac() {} |
| 22 |
| 23 void MenuMessageLoopMac::RepostEventToWindow(const ui::LocatedEvent& event, |
| 24 gfx::NativeWindow window, |
| 25 gfx::Point screen_loc) OVERRIDE; |
| 26 NOTIMPLEMENTED(); |
| 27 } |
| 28 |
| 29 void MenuMessageLoopMac::Run(MenuController* controller, |
| 30 Widget* owner, |
| 31 bool nested_menu) { |
| 32 message_loop_depth_++; |
| 33 DCHECK_LE(mesage_loop_depth_, 2); |
| 34 |
| 35 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
| 36 base::MessageLoop::ScopedNestableTaskAllower allow(loop); |
| 37 base::RunLoop run_loop; |
| 38 run_loop.Run(); |
| 39 |
| 40 message_loop_depth_--; |
| 41 } |
| 42 |
| 43 bool MenuMessageLoopMac::ShouldQuitNow() const { |
| 44 return true; |
| 45 } |
| 46 |
| 47 void MenuMessageLoopMac::QuitNow() { |
| 48 base::MessageLoop::current()->QuitNow(); |
| 49 } |
| 50 |
| 51 int MenuMessageLoopMac::message_loop_depth() const { |
| 52 return message_loop_depth_; |
| 53 } |
| 54 |
| 55 } // namespace views |
OLD | NEW |