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

Side by Side Diff: remoting/host/session_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: SessionEventExecutor + strong SD and random channel name 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "remoting/host/session_event_executor_win.h"
6
7 #include <string>
8
9 #include "base/bind.h"
10 #include "base/command_line.h"
11 #include "base/compiler_specific.h"
12 #include "base/message_loop.h"
13 #include "ipc/ipc_channel.h"
14 #include "ipc/ipc_channel_proxy.h"
15 #include "remoting/proto/event.pb.h"
16 #include "ui/base/keycodes/keyboard_codes.h"
17
18 #include "remoting/host/chromoting_session_messages.h"
19
20 namespace {
21
22 // The command line switch specifying the name of the session IPC channel.
23 const char kProcessChannelId[] = "channel";
24
25 } // namespace
26
27 namespace remoting {
28
29 using protocol::MouseEvent;
30 using protocol::KeyEvent;
31
32 SessionEventExecutor::SessionEventExecutor(
33 MessageLoop* message_loop,
34 base::MessageLoopProxy* io_message_loop,
35 scoped_ptr<EventExecutor> nested_executor)
36 : nested_executor_(nested_executor.Pass()),
37 message_loop_(message_loop),
38 scroll_pressed_(false) {
39 std::string channel_name =
40 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(kProcessChannelId);
41
42 // Connect to the session IPC channel if the name was passed in the command
43 // line.
44 if (!channel_name.empty()) {
45 chromoting_session_.reset(new IPC::ChannelProxy(
46 channel_name,
47 IPC::Channel::MODE_CLIENT,
48 this,
49 io_message_loop));
50 }
51 }
52
53 SessionEventExecutor::~SessionEventExecutor() {
54 }
55
56 void SessionEventExecutor::InjectKeyEvent(const KeyEvent& event) {
57 if (MessageLoop::current() != message_loop_) {
58 message_loop_->PostTask(
59 FROM_HERE,
60 base::Bind(&SessionEventExecutor::InjectKeyEvent,
61 base::Unretained(this), event));
62 return;
63 }
64
65 // Poor man's Ctrl+Alt+Delete emulation: a double Scroll Lock is converted to
66 // the security attention sequence.
67 // TODO(alexeypa): replace this with proper SAS handling.
68 if (chromoting_session_.get() != NULL && event.keycode() == VK_SCROLL) {
69 if (event.pressed()) {
70 if (scroll_pressed_) {
71 chromoting_session_->Send(new ChromotingSessionMsg_SendSasToConsole());
72 scroll_pressed_ = false;
73 } else {
74 scroll_pressed_ = true;
75 }
76 }
77 } else {
78 scroll_pressed_ = false;
79 }
80
81 nested_executor_->InjectKeyEvent(event);
82 }
83
84 void SessionEventExecutor::InjectMouseEvent(const MouseEvent& event) {
85 if (MessageLoop::current() != message_loop_) {
86 message_loop_->PostTask(
87 FROM_HERE,
88 base::Bind(&SessionEventExecutor::InjectMouseEvent,
89 base::Unretained(this), event));
90 return;
91 }
92
93 nested_executor_->InjectMouseEvent(event);
94 }
95
96 bool SessionEventExecutor::OnMessageReceived(const IPC::Message& message) {
97 return false;
98 }
99 /*
100 EventExecutor* EventExecutor::Create(MessageLoop* message_loop,
101 base::MessageLoopProxy* io_message_loop,
102 Capturer* capturer) {
103 return new EventExecutorWin(message_loop, io_message_loop, capturer);
104 }
105 */
106 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698