OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "ui/wm/core/nested_accelerator_dispatcher.h" | 5 #include "ui/wm/core/nested_accelerator_dispatcher.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_pump_dispatcher.h" | 8 #include "base/message_loop/message_pump_dispatcher.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "ui/base/accelerators/accelerator.h" | 10 #include "ui/base/accelerators/accelerator.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 private: | 36 private: |
37 // NestedAcceleratorDispatcher: | 37 // NestedAcceleratorDispatcher: |
38 virtual scoped_ptr<base::RunLoop> CreateRunLoop() OVERRIDE { | 38 virtual scoped_ptr<base::RunLoop> CreateRunLoop() OVERRIDE { |
39 return scoped_ptr<base::RunLoop>(new base::RunLoop(this)); | 39 return scoped_ptr<base::RunLoop>(new base::RunLoop(this)); |
40 } | 40 } |
41 | 41 |
42 // MessagePumpDispatcher: | 42 // MessagePumpDispatcher: |
43 virtual uint32_t Dispatch(const MSG& event) OVERRIDE { | 43 virtual uint32_t Dispatch(const MSG& event) OVERRIDE { |
44 if (IsKeyEvent(event)) { | 44 if (IsKeyEvent(event)) { |
45 ui::KeyEvent key_event(event, false); | 45 ui::KeyEvent key_event(event); |
46 ui::Accelerator accelerator = CreateAcceleratorFromKeyEvent(key_event); | 46 ui::Accelerator accelerator = CreateAcceleratorFromKeyEvent(key_event); |
47 | 47 |
48 switch (delegate_->ProcessAccelerator(accelerator)) { | 48 switch (delegate_->ProcessAccelerator(accelerator)) { |
49 case NestedAcceleratorDelegate::RESULT_PROCESS_LATER: | 49 case NestedAcceleratorDelegate::RESULT_PROCESS_LATER: |
50 return POST_DISPATCH_QUIT_LOOP; | 50 return POST_DISPATCH_QUIT_LOOP; |
51 case NestedAcceleratorDelegate::RESULT_PROCESSED: | 51 case NestedAcceleratorDelegate::RESULT_PROCESSED: |
52 return POST_DISPATCH_NONE; | 52 return POST_DISPATCH_NONE; |
53 case NestedAcceleratorDelegate::RESULT_NOT_PROCESSED: | 53 case NestedAcceleratorDelegate::RESULT_NOT_PROCESSED: |
54 break; | 54 break; |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 return nested_dispatcher_ ? nested_dispatcher_->Dispatch(event) | 58 return nested_dispatcher_ ? nested_dispatcher_->Dispatch(event) |
59 : POST_DISPATCH_PERFORM_DEFAULT; | 59 : POST_DISPATCH_PERFORM_DEFAULT; |
60 } | 60 } |
61 | 61 |
62 MessagePumpDispatcher* nested_dispatcher_; | 62 MessagePumpDispatcher* nested_dispatcher_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(NestedAcceleratorDispatcherWin); | 64 DISALLOW_COPY_AND_ASSIGN(NestedAcceleratorDispatcherWin); |
65 }; | 65 }; |
66 | 66 |
67 scoped_ptr<NestedAcceleratorDispatcher> NestedAcceleratorDispatcher::Create( | 67 scoped_ptr<NestedAcceleratorDispatcher> NestedAcceleratorDispatcher::Create( |
68 NestedAcceleratorDelegate* delegate, | 68 NestedAcceleratorDelegate* delegate, |
69 MessagePumpDispatcher* nested_dispatcher) { | 69 MessagePumpDispatcher* nested_dispatcher) { |
70 return scoped_ptr<NestedAcceleratorDispatcher>( | 70 return scoped_ptr<NestedAcceleratorDispatcher>( |
71 new NestedAcceleratorDispatcherWin(delegate, nested_dispatcher)); | 71 new NestedAcceleratorDispatcherWin(delegate, nested_dispatcher)); |
72 } | 72 } |
73 | 73 |
74 } // namespace wm | 74 } // namespace wm |
OLD | NEW |