| 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 "remoting/host/input_injector_chromeos.h" | 5 #include "remoting/host/input_injector_chromeos.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 Core(); | 53 Core(); |
| 54 | 54 |
| 55 // Mirrors the public InputInjectorChromeos interface. | 55 // Mirrors the public InputInjectorChromeos interface. |
| 56 void InjectClipboardEvent(const ClipboardEvent& event); | 56 void InjectClipboardEvent(const ClipboardEvent& event); |
| 57 void InjectKeyEvent(const KeyEvent& event); | 57 void InjectKeyEvent(const KeyEvent& event); |
| 58 void InjectTextEvent(const TextEvent& event); | 58 void InjectTextEvent(const TextEvent& event); |
| 59 void InjectMouseEvent(const MouseEvent& event); | 59 void InjectMouseEvent(const MouseEvent& event); |
| 60 void Start(std::unique_ptr<protocol::ClipboardStub> client_clipboard); | 60 void Start(std::unique_ptr<protocol::ClipboardStub> client_clipboard); |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 // Sets the caps lock state to match states |
| 64 void SetLockStates(uint32_t states); |
| 65 |
| 63 std::unique_ptr<ui::SystemInputInjector> delegate_; | 66 std::unique_ptr<ui::SystemInputInjector> delegate_; |
| 64 std::unique_ptr<Clipboard> clipboard_; | 67 std::unique_ptr<Clipboard> clipboard_; |
| 65 | 68 |
| 66 // Used to rotate the input coordinates appropriately based on the current | 69 // Used to rotate the input coordinates appropriately based on the current |
| 67 // display rotation settings. | 70 // display rotation settings. |
| 68 std::unique_ptr<PointTransformer> point_transformer_; | 71 std::unique_ptr<PointTransformer> point_transformer_; |
| 69 | 72 |
| 70 DISALLOW_COPY_AND_ASSIGN(Core); | 73 DISALLOW_COPY_AND_ASSIGN(Core); |
| 71 }; | 74 }; |
| 72 | 75 |
| 73 InputInjectorChromeos::Core::Core() { | 76 InputInjectorChromeos::Core::Core() { |
| 74 } | 77 } |
| 75 | 78 |
| 76 void InputInjectorChromeos::Core::InjectClipboardEvent( | 79 void InputInjectorChromeos::Core::InjectClipboardEvent( |
| 77 const ClipboardEvent& event) { | 80 const ClipboardEvent& event) { |
| 78 clipboard_->InjectClipboardEvent(event); | 81 clipboard_->InjectClipboardEvent(event); |
| 79 } | 82 } |
| 80 | 83 |
| 81 void InputInjectorChromeos::Core::InjectKeyEvent(const KeyEvent& event) { | 84 void InputInjectorChromeos::Core::InjectKeyEvent(const KeyEvent& event) { |
| 82 DCHECK(event.has_pressed()); | 85 DCHECK(event.has_pressed()); |
| 83 DCHECK(event.has_usb_keycode()); | 86 DCHECK(event.has_usb_keycode()); |
| 84 | 87 |
| 88 if (event.has_lock_states()) { |
| 89 SetLockStates(event.lock_states()); |
| 90 } |
| 91 |
| 85 ui::DomCode dom_code = | 92 ui::DomCode dom_code = |
| 86 ui::KeycodeConverter::UsbKeycodeToDomCode(event.usb_keycode()); | 93 ui::KeycodeConverter::UsbKeycodeToDomCode(event.usb_keycode()); |
| 87 | 94 |
| 88 // Ignore events which can't be mapped. | 95 // Ignore events which can't be mapped. |
| 89 if (dom_code != ui::DomCode::NONE) { | 96 if (dom_code != ui::DomCode::NONE) { |
| 90 delegate_->InjectKeyEvent(dom_code, event.pressed(), | 97 delegate_->InjectKeyEvent(dom_code, event.pressed(), |
| 91 true /* suppress_auto_repeat */); | 98 true /* suppress_auto_repeat */); |
| 92 } | 99 } |
| 93 } | 100 } |
| 94 | 101 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 116 ui::OzonePlatform* ozone_platform = ui::OzonePlatform::GetInstance(); | 123 ui::OzonePlatform* ozone_platform = ui::OzonePlatform::GetInstance(); |
| 117 delegate_ = ozone_platform->CreateSystemInputInjector(); | 124 delegate_ = ozone_platform->CreateSystemInputInjector(); |
| 118 DCHECK(delegate_); | 125 DCHECK(delegate_); |
| 119 | 126 |
| 120 // Implemented by remoting::ClipboardAura. | 127 // Implemented by remoting::ClipboardAura. |
| 121 clipboard_ = Clipboard::Create(); | 128 clipboard_ = Clipboard::Create(); |
| 122 clipboard_->Start(std::move(client_clipboard)); | 129 clipboard_->Start(std::move(client_clipboard)); |
| 123 point_transformer_.reset(new PointTransformer()); | 130 point_transformer_.reset(new PointTransformer()); |
| 124 } | 131 } |
| 125 | 132 |
| 133 void InputInjectorChromeos::Core::SetLockStates(uint32_t states) { |
| 134 ui::InputController* input_controller = |
| 135 ui::OzonePlatform::GetInstance()->GetInputController(); |
| 136 input_controller->SetCapsLockEnabled( |
| 137 states & protocol::KeyEvent::LOCK_STATES_CAPSLOCK); |
| 138 } |
| 139 |
| 126 InputInjectorChromeos::InputInjectorChromeos( | 140 InputInjectorChromeos::InputInjectorChromeos( |
| 127 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 141 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
| 128 : input_task_runner_(task_runner) { | 142 : input_task_runner_(task_runner) { |
| 129 core_.reset(new Core()); | 143 core_.reset(new Core()); |
| 130 } | 144 } |
| 131 | 145 |
| 132 InputInjectorChromeos::~InputInjectorChromeos() { | 146 InputInjectorChromeos::~InputInjectorChromeos() { |
| 133 input_task_runner_->DeleteSoon(FROM_HERE, core_.release()); | 147 input_task_runner_->DeleteSoon(FROM_HERE, core_.release()); |
| 134 } | 148 } |
| 135 | 149 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // browser process. | 190 // browser process. |
| 177 return base::WrapUnique(new InputInjectorChromeos(ui_task_runner)); | 191 return base::WrapUnique(new InputInjectorChromeos(ui_task_runner)); |
| 178 } | 192 } |
| 179 | 193 |
| 180 // static | 194 // static |
| 181 bool InputInjector::SupportsTouchEvents() { | 195 bool InputInjector::SupportsTouchEvents() { |
| 182 return false; | 196 return false; |
| 183 } | 197 } |
| 184 | 198 |
| 185 } // namespace remoting | 199 } // namespace remoting |
| OLD | NEW |