OLD | NEW |
(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_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 SessionEventExecutorWin::SessionEventExecutorWin( |
| 33 MessageLoop* message_loop, |
| 34 base::MessageLoopProxy* io_message_loop, |
| 35 scoped_ptr<protocol::InputStub> 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 Chromoting IPC channel if the name was passed in the command |
| 43 // line. |
| 44 if (!channel_name.empty()) { |
| 45 chromoting_channel_.reset(new IPC::ChannelProxy( |
| 46 channel_name, |
| 47 IPC::Channel::MODE_CLIENT, |
| 48 this, |
| 49 io_message_loop)); |
| 50 } |
| 51 } |
| 52 |
| 53 SessionEventExecutorWin::~SessionEventExecutorWin() { |
| 54 } |
| 55 |
| 56 void SessionEventExecutorWin::InjectKeyEvent(const KeyEvent& event) { |
| 57 if (MessageLoop::current() != message_loop_) { |
| 58 message_loop_->PostTask( |
| 59 FROM_HERE, |
| 60 base::Bind(&SessionEventExecutorWin::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 Secure Attention Sequence. |
| 67 // TODO(alexeypa): replace this with proper SAS handling. |
| 68 if (chromoting_channel_.get() != NULL && event.keycode() == VK_SCROLL) { |
| 69 if (event.pressed()) { |
| 70 if (scroll_pressed_) { |
| 71 chromoting_channel_->Send(new ChromotingHostMsg_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 SessionEventExecutorWin::InjectMouseEvent(const MouseEvent& event) { |
| 85 if (MessageLoop::current() != message_loop_) { |
| 86 message_loop_->PostTask( |
| 87 FROM_HERE, |
| 88 base::Bind(&SessionEventExecutorWin::InjectMouseEvent, |
| 89 base::Unretained(this), event)); |
| 90 return; |
| 91 } |
| 92 |
| 93 nested_executor_->InjectMouseEvent(event); |
| 94 } |
| 95 |
| 96 bool SessionEventExecutorWin::OnMessageReceived(const IPC::Message& message) { |
| 97 return false; |
| 98 } |
| 99 |
| 100 } // namespace remoting |
OLD | NEW |