1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/host/session_event_executor_win.h"
#include <string>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_proxy.h"
#include "remoting/proto/event.pb.h"
#include "ui/base/keycodes/keyboard_codes.h"
#include "remoting/host/chromoting_messages.h"
namespace {
// The command line switch specifying the name of the session IPC channel.
const char kProcessChannelId[] = "channel";
} // namespace
namespace remoting {
using protocol::MouseEvent;
using protocol::KeyEvent;
SessionEventExecutorWin::SessionEventExecutorWin(
MessageLoop* message_loop,
base::MessageLoopProxy* io_message_loop,
scoped_ptr<protocol::InputStub> nested_executor)
: nested_executor_(nested_executor.Pass()),
message_loop_(message_loop),
scroll_pressed_(false) {
std::string channel_name =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(kProcessChannelId);
// Connect to the Chromoting IPC channel if the name was passed in the command
// line.
if (!channel_name.empty()) {
chromoting_channel_.reset(new IPC::ChannelProxy(
channel_name,
IPC::Channel::MODE_CLIENT,
this,
io_message_loop));
}
}
SessionEventExecutorWin::~SessionEventExecutorWin() {
}
void SessionEventExecutorWin::InjectKeyEvent(const KeyEvent& event) {
if (MessageLoop::current() != message_loop_) {
message_loop_->PostTask(
FROM_HERE,
base::Bind(&SessionEventExecutorWin::InjectKeyEvent,
base::Unretained(this), event));
return;
}
// Poor man's Ctrl+Alt+Delete emulation: a double Scroll Lock is converted to
// the Secure Attention Sequence.
// TODO(alexeypa): replace this with proper SAS handling.
if (chromoting_channel_.get() != NULL && event.keycode() == VK_SCROLL) {
if (event.pressed()) {
if (scroll_pressed_) {
chromoting_channel_->Send(new ChromotingHostMsg_SendSasToConsole());
scroll_pressed_ = false;
} else {
scroll_pressed_ = true;
}
}
} else {
scroll_pressed_ = false;
}
nested_executor_->InjectKeyEvent(event);
}
void SessionEventExecutorWin::InjectMouseEvent(const MouseEvent& event) {
if (MessageLoop::current() != message_loop_) {
message_loop_->PostTask(
FROM_HERE,
base::Bind(&SessionEventExecutorWin::InjectMouseEvent,
base::Unretained(this), event));
return;
}
nested_executor_->InjectMouseEvent(event);
}
bool SessionEventExecutorWin::OnMessageReceived(const IPC::Message& message) {
return false;
}
} // namespace remoting
|