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/win/session_input_injector.h" | 5 #include "remoting/host/win/session_input_injector.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
19 #include "base/win/windows_version.h" | |
20 #include "remoting/host/sas_injector.h" | 19 #include "remoting/host/sas_injector.h" |
21 #include "remoting/proto/event.pb.h" | 20 #include "remoting/proto/event.pb.h" |
22 #include "third_party/webrtc/modules/desktop_capture/win/desktop.h" | 21 #include "third_party/webrtc/modules/desktop_capture/win/desktop.h" |
23 #include "third_party/webrtc/modules/desktop_capture/win/scoped_thread_desktop.h
" | 22 #include "third_party/webrtc/modules/desktop_capture/win/scoped_thread_desktop.h
" |
24 #include "ui/events/keycodes/dom/dom_code.h" | 23 #include "ui/events/keycodes/dom/dom_code.h" |
25 | 24 |
26 namespace { | 25 namespace { |
27 | 26 |
28 bool CheckCtrlAndAltArePressed(const std::set<ui::DomCode>& pressed_keys) { | 27 bool CheckCtrlAndAltArePressed(const std::set<ui::DomCode>& pressed_keys) { |
29 size_t ctrl_keys = pressed_keys.count(ui::DomCode::CONTROL_LEFT) + | 28 size_t ctrl_keys = pressed_keys.count(ui::DomCode::CONTROL_LEFT) + |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 81 |
83 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; | 82 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; |
84 | 83 |
85 // Pointer to the next event executor. | 84 // Pointer to the next event executor. |
86 std::unique_ptr<InputInjector> nested_executor_; | 85 std::unique_ptr<InputInjector> nested_executor_; |
87 | 86 |
88 scoped_refptr<base::SingleThreadTaskRunner> execute_action_task_runner_; | 87 scoped_refptr<base::SingleThreadTaskRunner> execute_action_task_runner_; |
89 | 88 |
90 webrtc::ScopedThreadDesktop desktop_; | 89 webrtc::ScopedThreadDesktop desktop_; |
91 | 90 |
92 // Used to inject Secure Attention Sequence on Vista+. | 91 // Used to inject Secure Attention Sequence. |
93 base::Closure inject_sas_; | 92 base::Closure inject_sas_; |
94 | 93 |
95 // Used to lock the current session on non-home SKUs of Windows. | 94 // Used to lock the current session on non-home SKUs of Windows. |
96 base::Closure lock_workstation_; | 95 base::Closure lock_workstation_; |
97 | 96 |
98 // Used to inject Secure Attention Sequence on XP. | 97 // Used to inject Secure Attention Sequence on XP. |
99 std::unique_ptr<SasInjector> sas_injector_; | 98 std::unique_ptr<SasInjector> sas_injector_; |
100 | 99 |
101 // Keys currently pressed by the client, used to detect key sequences. | 100 // Keys currently pressed by the client, used to detect key sequences. |
102 std::set<ui::DomCode> pressed_keys_; | 101 std::set<ui::DomCode> pressed_keys_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // HostEventDispatcher should drop events lacking the pressed field. | 148 // HostEventDispatcher should drop events lacking the pressed field. |
150 DCHECK(event.has_pressed()); | 149 DCHECK(event.has_pressed()); |
151 | 150 |
152 if (event.has_usb_keycode()) { | 151 if (event.has_usb_keycode()) { |
153 ui::DomCode dom_code = static_cast<ui::DomCode>(event.usb_keycode()); | 152 ui::DomCode dom_code = static_cast<ui::DomCode>(event.usb_keycode()); |
154 if (event.pressed()) { | 153 if (event.pressed()) { |
155 // Simulate secure attention sequence if Ctrl-Alt-Del was just pressed. | 154 // Simulate secure attention sequence if Ctrl-Alt-Del was just pressed. |
156 if (dom_code == ui::DomCode::DEL && | 155 if (dom_code == ui::DomCode::DEL && |
157 CheckCtrlAndAltArePressed(pressed_keys_)) { | 156 CheckCtrlAndAltArePressed(pressed_keys_)) { |
158 VLOG(3) << "Sending Secure Attention Sequence to the session"; | 157 VLOG(3) << "Sending Secure Attention Sequence to the session"; |
159 | 158 execute_action_task_runner_->PostTask(FROM_HERE, inject_sas_); |
160 if (base::win::GetVersion() < base::win::VERSION_VISTA) { | |
161 if (!sas_injector_) | |
162 sas_injector_ = SasInjector::Create(); | |
163 if (!sas_injector_->InjectSas()) | |
164 LOG(ERROR) << "Failed to inject Secure Attention Sequence."; | |
165 } else { | |
166 execute_action_task_runner_->PostTask(FROM_HERE, inject_sas_); | |
167 } | |
168 } else if (dom_code == ui::DomCode::US_L && | 159 } else if (dom_code == ui::DomCode::US_L && |
169 IsWinKeyPressed(pressed_keys_)) { | 160 IsWinKeyPressed(pressed_keys_)) { |
170 execute_action_task_runner_->PostTask(FROM_HERE, lock_workstation_); | 161 execute_action_task_runner_->PostTask(FROM_HERE, lock_workstation_); |
171 } | 162 } |
172 | 163 |
173 pressed_keys_.insert(dom_code); | 164 pressed_keys_.insert(dom_code); |
174 } else { | 165 } else { |
175 pressed_keys_.erase(dom_code); | 166 pressed_keys_.erase(dom_code); |
176 } | 167 } |
177 } | 168 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 const protocol::MouseEvent& event) { | 255 const protocol::MouseEvent& event) { |
265 core_->InjectMouseEvent(event); | 256 core_->InjectMouseEvent(event); |
266 } | 257 } |
267 | 258 |
268 void SessionInputInjectorWin::InjectTouchEvent( | 259 void SessionInputInjectorWin::InjectTouchEvent( |
269 const protocol::TouchEvent& event) { | 260 const protocol::TouchEvent& event) { |
270 core_->InjectTouchEvent(event); | 261 core_->InjectTouchEvent(event); |
271 } | 262 } |
272 | 263 |
273 } // namespace remoting | 264 } // namespace remoting |
OLD | NEW |