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/input_injector.h" | 5 #include "remoting/host/input_injector.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" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 using protocol::KeyEvent; | 52 using protocol::KeyEvent; |
53 using protocol::TextEvent; | 53 using protocol::TextEvent; |
54 using protocol::MouseEvent; | 54 using protocol::MouseEvent; |
55 using protocol::TouchEvent; | 55 using protocol::TouchEvent; |
56 | 56 |
57 // A class to generate events on Windows. | 57 // A class to generate events on Windows. |
58 class InputInjectorWin : public InputInjector { | 58 class InputInjectorWin : public InputInjector { |
59 public: | 59 public: |
60 InputInjectorWin(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 60 InputInjectorWin(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
61 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | 61 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
62 virtual ~InputInjectorWin(); | 62 ~InputInjectorWin() override; |
63 | 63 |
64 // ClipboardStub interface. | 64 // ClipboardStub interface. |
65 virtual void InjectClipboardEvent(const ClipboardEvent& event) override; | 65 void InjectClipboardEvent(const ClipboardEvent& event) override; |
66 | 66 |
67 // InputStub interface. | 67 // InputStub interface. |
68 virtual void InjectKeyEvent(const KeyEvent& event) override; | 68 void InjectKeyEvent(const KeyEvent& event) override; |
69 virtual void InjectTextEvent(const TextEvent& event) override; | 69 void InjectTextEvent(const TextEvent& event) override; |
70 virtual void InjectMouseEvent(const MouseEvent& event) override; | 70 void InjectMouseEvent(const MouseEvent& event) override; |
71 virtual void InjectTouchEvent(const TouchEvent& event) override; | 71 void InjectTouchEvent(const TouchEvent& event) override; |
72 | 72 |
73 // InputInjector interface. | 73 // InputInjector interface. |
74 virtual void Start( | 74 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override; |
75 scoped_ptr<protocol::ClipboardStub> client_clipboard) override; | |
76 | 75 |
77 private: | 76 private: |
78 // The actual implementation resides in InputInjectorWin::Core class. | 77 // The actual implementation resides in InputInjectorWin::Core class. |
79 class Core : public base::RefCountedThreadSafe<Core> { | 78 class Core : public base::RefCountedThreadSafe<Core> { |
80 public: | 79 public: |
81 Core(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 80 Core(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
82 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | 81 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
83 | 82 |
84 // Mirrors the ClipboardStub interface. | 83 // Mirrors the ClipboardStub interface. |
85 void InjectClipboardEvent(const ClipboardEvent& event); | 84 void InjectClipboardEvent(const ClipboardEvent& event); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 PLOG(ERROR) << "Failed to inject a mouse event"; | 340 PLOG(ERROR) << "Failed to inject a mouse event"; |
342 } | 341 } |
343 } | 342 } |
344 | 343 |
345 void InputInjectorWin::Core::HandleTouch(const TouchEvent& event) { | 344 void InputInjectorWin::Core::HandleTouch(const TouchEvent& event) { |
346 touch_injector_.InjectTouchEvent(event); | 345 touch_injector_.InjectTouchEvent(event); |
347 } | 346 } |
348 | 347 |
349 } // namespace | 348 } // namespace |
350 | 349 |
| 350 // static |
351 scoped_ptr<InputInjector> InputInjector::Create( | 351 scoped_ptr<InputInjector> InputInjector::Create( |
352 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 352 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
353 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 353 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
354 return make_scoped_ptr( | 354 return make_scoped_ptr( |
355 new InputInjectorWin(main_task_runner, ui_task_runner)); | 355 new InputInjectorWin(main_task_runner, ui_task_runner)); |
356 } | 356 } |
357 | 357 |
| 358 // static |
| 359 bool InputInjector::SupportsTouchEvents() { |
| 360 return TouchInjectorWinDelegate::Create(); |
| 361 } |
| 362 |
358 } // namespace remoting | 363 } // namespace remoting |
OLD | NEW |