OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/accelerators/nested_dispatcher_controller.h" | 5 #include "ui/wm/core/nested_accelerator_controller.h" |
6 | 6 |
7 #include "ash/accelerators/accelerator_dispatcher.h" | |
8 #include "ash/shell.h" | |
9 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
10 #include "base/run_loop.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 | 11 |
12 namespace ash { | 12 namespace wm { |
13 | 13 |
14 NestedDispatcherController::NestedDispatcherController() { | 14 NestedAcceleratorController::NestedAcceleratorController( |
| 15 NestedAcceleratorDelegate* delegate) |
| 16 : dispatcher_delegate_(delegate) { |
| 17 DCHECK(delegate); |
15 } | 18 } |
16 | 19 |
17 NestedDispatcherController::~NestedDispatcherController() { | 20 NestedAcceleratorController::~NestedAcceleratorController() { |
18 } | 21 } |
19 | 22 |
20 void NestedDispatcherController::RunWithDispatcher( | 23 void NestedAcceleratorController::RunWithDispatcher( |
21 base::MessagePumpDispatcher* nested_dispatcher) { | 24 base::MessagePumpDispatcher* nested_dispatcher) { |
22 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); | 25 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
23 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); | 26 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); |
24 | 27 |
25 scoped_ptr<AcceleratorDispatcher> old_accelerator_dispatcher = | 28 scoped_ptr<NestedAcceleratorDispatcher> old_accelerator_dispatcher = |
26 accelerator_dispatcher_.Pass(); | 29 accelerator_dispatcher_.Pass(); |
27 accelerator_dispatcher_ = AcceleratorDispatcher::Create(nested_dispatcher); | 30 accelerator_dispatcher_ = NestedAcceleratorDispatcher::Create( |
| 31 dispatcher_delegate_.get(), nested_dispatcher); |
28 | 32 |
29 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 33 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them |
30 // use run_loop.QuitClosure(). | 34 // use run_loop.QuitClosure(). |
31 scoped_ptr<base::RunLoop> run_loop = accelerator_dispatcher_->CreateRunLoop(); | 35 scoped_ptr<base::RunLoop> run_loop = accelerator_dispatcher_->CreateRunLoop(); |
32 base::AutoReset<base::Closure> reset_closure(&quit_closure_, | 36 base::AutoReset<base::Closure> reset_closure(&quit_closure_, |
33 run_loop->QuitClosure()); | 37 run_loop->QuitClosure()); |
34 run_loop->Run(); | 38 run_loop->Run(); |
35 accelerator_dispatcher_ = old_accelerator_dispatcher.Pass(); | 39 accelerator_dispatcher_ = old_accelerator_dispatcher.Pass(); |
36 } | 40 } |
37 | 41 |
38 void NestedDispatcherController::QuitNestedMessageLoop() { | 42 void NestedAcceleratorController::QuitNestedMessageLoop() { |
39 CHECK(!quit_closure_.is_null()); | 43 CHECK(!quit_closure_.is_null()); |
40 quit_closure_.Run(); | 44 quit_closure_.Run(); |
41 accelerator_dispatcher_.reset(); | 45 accelerator_dispatcher_.reset(); |
42 } | 46 } |
43 | 47 |
44 } // namespace ash | 48 } // namespace wm |
OLD | NEW |