| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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/wm/core/nested_accelerator_controller.h" | |
| 6 | |
| 7 #include "base/auto_reset.h" | |
| 8 #include "base/run_loop.h" | |
| 9 #include "ui/wm/core/nested_accelerator_delegate.h" | |
| 10 #include "ui/wm/core/nested_accelerator_dispatcher.h" | |
| 11 | |
| 12 namespace wm { | |
| 13 | |
| 14 NestedAcceleratorController::NestedAcceleratorController( | |
| 15 NestedAcceleratorDelegate* delegate) | |
| 16 : dispatcher_delegate_(delegate) { | |
| 17 DCHECK(delegate); | |
| 18 } | |
| 19 | |
| 20 NestedAcceleratorController::~NestedAcceleratorController() { | |
| 21 } | |
| 22 | |
| 23 void NestedAcceleratorController::RunWithDispatcher( | |
| 24 base::MessagePumpDispatcher* nested_dispatcher) { | |
| 25 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); | |
| 26 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); | |
| 27 | |
| 28 scoped_ptr<NestedAcceleratorDispatcher> old_accelerator_dispatcher = | |
| 29 accelerator_dispatcher_.Pass(); | |
| 30 accelerator_dispatcher_ = NestedAcceleratorDispatcher::Create( | |
| 31 dispatcher_delegate_.get(), nested_dispatcher); | |
| 32 | |
| 33 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | |
| 34 // use run_loop.QuitClosure(). | |
| 35 scoped_ptr<base::RunLoop> run_loop = accelerator_dispatcher_->CreateRunLoop(); | |
| 36 base::AutoReset<base::Closure> reset_closure(&quit_closure_, | |
| 37 run_loop->QuitClosure()); | |
| 38 run_loop->Run(); | |
| 39 accelerator_dispatcher_ = old_accelerator_dispatcher.Pass(); | |
| 40 } | |
| 41 | |
| 42 void NestedAcceleratorController::QuitNestedMessageLoop() { | |
| 43 CHECK(!quit_closure_.is_null()); | |
| 44 quit_closure_.Run(); | |
| 45 accelerator_dispatcher_.reset(); | |
| 46 } | |
| 47 | |
| 48 } // namespace wm | |
| OLD | NEW |