OLD | NEW |
1 // Copyright (c) 2012 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 "remoting/host/event_executor.h" | 5 #include "remoting/host/event_executor.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "remoting/host/capturer.h" | 12 #include "remoting/host/capturer.h" |
13 #include "remoting/proto/event.pb.h" | 13 #include "remoting/proto/event.pb.h" |
14 #include "ui/base/keycodes/keyboard_codes.h" | 14 #include "ui/base/keycodes/keyboard_codes.h" |
15 | 15 |
16 namespace remoting { | 16 namespace remoting { |
17 | 17 |
| 18 using protocol::KeyEvent; |
18 using protocol::MouseEvent; | 19 using protocol::MouseEvent; |
19 using protocol::KeyEvent; | |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 // A class to generate events on Windows. | 23 // A class to generate events on Windows. |
24 class EventExecutorWin : public EventExecutor { | 24 class EventExecutorWin : public EventExecutor { |
25 public: | 25 public: |
26 EventExecutorWin(MessageLoop* message_loop, Capturer* capturer); | 26 EventExecutorWin(MessageLoop* message_loop, Capturer* capturer); |
27 virtual ~EventExecutorWin() {} | 27 virtual ~EventExecutorWin() {} |
28 | 28 |
| 29 // ClipboardStub interface. |
| 30 virtual void InjectClipboardEvent(const protocol::ClipboardEvent& event) |
| 31 OVERRIDE; |
| 32 |
| 33 // InputStub interface. |
29 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; | 34 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; |
30 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; | 35 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; |
31 | 36 |
32 private: | 37 private: |
33 void HandleKey(const KeyEvent& event); | 38 void HandleKey(const KeyEvent& event); |
34 void HandleMouse(const MouseEvent& event); | 39 void HandleMouse(const MouseEvent& event); |
35 | 40 |
36 MessageLoop* message_loop_; | 41 MessageLoop* message_loop_; |
37 Capturer* capturer_; | 42 Capturer* capturer_; |
38 | 43 |
39 DISALLOW_COPY_AND_ASSIGN(EventExecutorWin); | 44 DISALLOW_COPY_AND_ASSIGN(EventExecutorWin); |
40 }; | 45 }; |
41 | 46 |
42 EventExecutorWin::EventExecutorWin(MessageLoop* message_loop, | 47 EventExecutorWin::EventExecutorWin(MessageLoop* message_loop, |
43 Capturer* capturer) | 48 Capturer* capturer) |
44 : message_loop_(message_loop), | 49 : message_loop_(message_loop), |
45 capturer_(capturer) { | 50 capturer_(capturer) { |
46 } | 51 } |
47 | 52 |
| 53 void EventExecutorWin::InjectClipboardEvent( |
| 54 const protocol::ClipboardEvent& event) { |
| 55 // TODO(simonmorris): Implement clipboard injection. |
| 56 } |
| 57 |
48 void EventExecutorWin::InjectKeyEvent(const KeyEvent& event) { | 58 void EventExecutorWin::InjectKeyEvent(const KeyEvent& event) { |
49 if (MessageLoop::current() != message_loop_) { | 59 if (MessageLoop::current() != message_loop_) { |
50 message_loop_->PostTask( | 60 message_loop_->PostTask( |
51 FROM_HERE, | 61 FROM_HERE, |
52 base::Bind(&EventExecutorWin::InjectKeyEvent, base::Unretained(this), | 62 base::Bind(&EventExecutorWin::InjectKeyEvent, base::Unretained(this), |
53 event)); | 63 event)); |
54 return; | 64 return; |
55 } | 65 } |
56 | 66 |
57 HandleKey(event); | 67 HandleKey(event); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 177 |
168 } // namespace | 178 } // namespace |
169 | 179 |
170 scoped_ptr<protocol::InputStub> EventExecutor::Create(MessageLoop* message_loop, | 180 scoped_ptr<protocol::InputStub> EventExecutor::Create(MessageLoop* message_loop, |
171 Capturer* capturer) { | 181 Capturer* capturer) { |
172 return scoped_ptr<protocol::InputStub>( | 182 return scoped_ptr<protocol::InputStub>( |
173 new EventExecutorWin(message_loop, capturer)); | 183 new EventExecutorWin(message_loop, capturer)); |
174 } | 184 } |
175 | 185 |
176 } // namespace remoting | 186 } // namespace remoting |
OLD | NEW |