Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(599)

Side by Side Diff: remoting/host/event_executor_win.cc

Issue 9617027: Chromoting: Implemented security attention sequence (SAS) emulation on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ipc/ipc_channel.h"
13 #include "ipc/ipc_channel_proxy.h"
12 #include "remoting/host/capturer.h" 14 #include "remoting/host/capturer.h"
13 #include "remoting/proto/event.pb.h" 15 #include "remoting/proto/event.pb.h"
14 #include "ui/base/keycodes/keyboard_codes.h" 16 #include "ui/base/keycodes/keyboard_codes.h"
15 17
18 #include "remoting/host/chromoting_service_messages.h"
19
16 namespace remoting { 20 namespace remoting {
17 21
18 using protocol::MouseEvent; 22 using protocol::MouseEvent;
19 using protocol::KeyEvent; 23 using protocol::KeyEvent;
20 24
21 namespace { 25 namespace {
22 26
27 // Name of the chromoting service IPC channel.
28 const char kChromotingServiceChannelName[] = "chromoting_service";
29
23 // A class to generate events on Windows. 30 // A class to generate events on Windows.
24 class EventExecutorWin : public EventExecutor { 31 class EventExecutorWin : public EventExecutor, public IPC::Channel::Listener {
25 public: 32 public:
26 EventExecutorWin(MessageLoop* message_loop, Capturer* capturer); 33 EventExecutorWin(MessageLoop* message_loop,
34 base::MessageLoopProxy* io_message_loop,
35 Capturer* capturer);
Wez 2012/03/07 01:56:13 EventExecutorWin is responsible just for injecting
alexeypa (please no reviews) 2012/03/07 19:59:08 There is DesktopEnvironment class that looks like
Wez 2012/03/08 00:01:33 DesktopEnvironment is a cross-platform interface f
alexeypa (please no reviews) 2012/03/08 01:52:54 OK, makes sense.
27 virtual ~EventExecutorWin() {} 36 virtual ~EventExecutorWin() {}
28 37
29 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; 38 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE;
30 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; 39 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE;
31 40
41 // IPC::Channel::Listener implementation.
42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
43
32 private: 44 private:
33 void HandleKey(const KeyEvent& event); 45 void HandleKey(const KeyEvent& event);
34 void HandleMouse(const MouseEvent& event); 46 void HandleMouse(const MouseEvent& event);
35 47
36 MessageLoop* message_loop_; 48 MessageLoop* message_loop_;
37 Capturer* capturer_; 49 Capturer* capturer_;
38 50
51 // IPC channel connecting the host with the chromoting service.
52 scoped_ptr<IPC::ChannelProxy> chromoting_service_;
53
54 bool scroll_pressed_;
55
39 DISALLOW_COPY_AND_ASSIGN(EventExecutorWin); 56 DISALLOW_COPY_AND_ASSIGN(EventExecutorWin);
40 }; 57 };
41 58
42 EventExecutorWin::EventExecutorWin(MessageLoop* message_loop, 59 EventExecutorWin::EventExecutorWin(MessageLoop* message_loop,
60 base::MessageLoopProxy* io_message_loop,
43 Capturer* capturer) 61 Capturer* capturer)
44 : message_loop_(message_loop), 62 : message_loop_(message_loop),
45 capturer_(capturer) { 63 capturer_(capturer),
64 scroll_pressed_(false) {
65 // Connect to the service.
66 if (io_message_loop) {
67 chromoting_service_.reset(new IPC::ChannelProxy(
68 kChromotingServiceChannelName,
69 IPC::Channel::MODE_CLIENT,
70 this,
71 io_message_loop));
72 }
46 } 73 }
47 74
48 void EventExecutorWin::InjectKeyEvent(const KeyEvent& event) { 75 void EventExecutorWin::InjectKeyEvent(const KeyEvent& event) {
49 if (MessageLoop::current() != message_loop_) { 76 if (MessageLoop::current() != message_loop_) {
50 message_loop_->PostTask( 77 message_loop_->PostTask(
51 FROM_HERE, 78 FROM_HERE,
52 base::Bind(&EventExecutorWin::InjectKeyEvent, base::Unretained(this), 79 base::Bind(&EventExecutorWin::InjectKeyEvent, base::Unretained(this),
53 event)); 80 event));
54 return; 81 return;
55 } 82 }
56 83
84 // Poor man's Ctrl+Alt+Delete emulation: a double Scroll Lock is converted to
85 // the security attention sequence.
86 // TODO(alexeypa): replace this with proper SAS handling.
87 if (chromoting_service_.get() != NULL && event.keycode() == VK_SCROLL) {
88 if (event.pressed()) {
89 if (scroll_pressed_) {
90 chromoting_service_->Send(new ChromotingServiceMsg_SendSas());
91 scroll_pressed_ = false;
92 } else {
93 scroll_pressed_ = true;
94 }
95 }
96 } else {
97 scroll_pressed_ = false;
98 }
99
57 HandleKey(event); 100 HandleKey(event);
58 } 101 }
59 102
60 void EventExecutorWin::InjectMouseEvent(const MouseEvent& event) { 103 void EventExecutorWin::InjectMouseEvent(const MouseEvent& event) {
61 if (MessageLoop::current() != message_loop_) { 104 if (MessageLoop::current() != message_loop_) {
62 message_loop_->PostTask( 105 message_loop_->PostTask(
63 FROM_HERE, 106 FROM_HERE,
64 base::Bind(&EventExecutorWin::InjectMouseEvent, base::Unretained(this), 107 base::Bind(&EventExecutorWin::InjectMouseEvent, base::Unretained(this),
65 event)); 108 event));
66 return; 109 return;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 down ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP; 201 down ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP;
159 } else { 202 } else {
160 button_event.mi.dwFlags = 203 button_event.mi.dwFlags =
161 down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP; 204 down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP;
162 } 205 }
163 206
164 SendInput(1, &button_event, sizeof(INPUT)); 207 SendInput(1, &button_event, sizeof(INPUT));
165 } 208 }
166 } 209 }
167 210
211 bool EventExecutorWin::OnMessageReceived(const IPC::Message& message) {
212 return false;
213 }
214
168 } // namespace 215 } // namespace
169 216
170 EventExecutor* EventExecutor::Create(MessageLoop* message_loop, 217 EventExecutor* EventExecutor::Create(MessageLoop* message_loop,
218 base::MessageLoopProxy* io_message_loop,
171 Capturer* capturer) { 219 Capturer* capturer) {
172 return new EventExecutorWin(message_loop, capturer); 220 return new EventExecutorWin(message_loop, io_message_loop, capturer);
173 } 221 }
174 222
175 } // namespace remoting 223 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698