| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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::ClipboardEvent; |
| 19 using protocol::KeyEvent; |
| 18 using protocol::MouseEvent; | 20 using protocol::MouseEvent; |
| 19 using protocol::KeyEvent; | |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // A class to generate events on Windows. | 24 // A class to generate events on Windows. |
| 24 class EventExecutorWin : public EventExecutor { | 25 class EventExecutorWin : public EventExecutor { |
| 25 public: | 26 public: |
| 26 EventExecutorWin(MessageLoop* message_loop, Capturer* capturer); | 27 EventExecutorWin(MessageLoop* message_loop, Capturer* capturer); |
| 27 virtual ~EventExecutorWin() {} | 28 virtual ~EventExecutorWin() {} |
| 28 | 29 |
| 30 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; |
| 29 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; | 31 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; |
| 30 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; | 32 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; |
| 31 | 33 |
| 32 private: | 34 private: |
| 33 void HandleKey(const KeyEvent& event); | 35 void HandleKey(const KeyEvent& event); |
| 34 void HandleMouse(const MouseEvent& event); | 36 void HandleMouse(const MouseEvent& event); |
| 35 | 37 |
| 36 MessageLoop* message_loop_; | 38 MessageLoop* message_loop_; |
| 37 Capturer* capturer_; | 39 Capturer* capturer_; |
| 38 | 40 |
| 39 DISALLOW_COPY_AND_ASSIGN(EventExecutorWin); | 41 DISALLOW_COPY_AND_ASSIGN(EventExecutorWin); |
| 40 }; | 42 }; |
| 41 | 43 |
| 42 EventExecutorWin::EventExecutorWin(MessageLoop* message_loop, | 44 EventExecutorWin::EventExecutorWin(MessageLoop* message_loop, |
| 43 Capturer* capturer) | 45 Capturer* capturer) |
| 44 : message_loop_(message_loop), | 46 : message_loop_(message_loop), |
| 45 capturer_(capturer) { | 47 capturer_(capturer) { |
| 46 } | 48 } |
| 47 | 49 |
| 50 void EventExecutorWin::InjectClipboardEvent(const ClipboardEvent& event) { |
| 51 // TODO(simonmorris): Implement clipboard injection. |
| 52 } |
| 53 |
| 48 void EventExecutorWin::InjectKeyEvent(const KeyEvent& event) { | 54 void EventExecutorWin::InjectKeyEvent(const KeyEvent& event) { |
| 49 if (MessageLoop::current() != message_loop_) { | 55 if (MessageLoop::current() != message_loop_) { |
| 50 message_loop_->PostTask( | 56 message_loop_->PostTask( |
| 51 FROM_HERE, | 57 FROM_HERE, |
| 52 base::Bind(&EventExecutorWin::InjectKeyEvent, base::Unretained(this), | 58 base::Bind(&EventExecutorWin::InjectKeyEvent, base::Unretained(this), |
| 53 event)); | 59 event)); |
| 54 return; | 60 return; |
| 55 } | 61 } |
| 56 | 62 |
| 57 HandleKey(event); | 63 HandleKey(event); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 } | 172 } |
| 167 | 173 |
| 168 } // namespace | 174 } // namespace |
| 169 | 175 |
| 170 EventExecutor* EventExecutor::Create(MessageLoop* message_loop, | 176 EventExecutor* EventExecutor::Create(MessageLoop* message_loop, |
| 171 Capturer* capturer) { | 177 Capturer* capturer) { |
| 172 return new EventExecutorWin(message_loop, capturer); | 178 return new EventExecutorWin(message_loop, capturer); |
| 173 } | 179 } |
| 174 | 180 |
| 175 } // namespace remoting | 181 } // namespace remoting |
| OLD | NEW |