diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-06 07:41:21 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-06 07:41:21 +0000 |
commit | 3ac30fdc3f96debb29fe3a1741c5c00fbd3af3f1 (patch) | |
tree | ed8a044bdf75f566c8081933c1311423f86c51a9 /remoting | |
parent | b95bf500ea84813fc3f5d8498cd5bf71feeed291 (diff) | |
download | chromium_src-3ac30fdc3f96debb29fe3a1741c5c00fbd3af3f1.zip chromium_src-3ac30fdc3f96debb29fe3a1741c5c00fbd3af3f1.tar.gz chromium_src-3ac30fdc3f96debb29fe3a1741c5c00fbd3af3f1.tar.bz2 |
Trap Ctrl-Alt-Del to inject a Secure Attention Sequence into Windows.
BUG=120313
Review URL: http://codereview.chromium.org/9995006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131107 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/session_event_executor_win.cc | 44 | ||||
-rw-r--r-- | remoting/host/session_event_executor_win.h | 5 |
2 files changed, 34 insertions, 15 deletions
diff --git a/remoting/host/session_event_executor_win.cc b/remoting/host/session_event_executor_win.cc index 117ab37..75920f0 100644 --- a/remoting/host/session_event_executor_win.cc +++ b/remoting/host/session_event_executor_win.cc @@ -13,7 +13,6 @@ #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" #include "remoting/host/desktop_win.h" @@ -23,6 +22,21 @@ namespace { // The command line switch specifying the name of the Chromoting IPC channel. const char kProcessChannelId[] = "chromoting-ipc"; +const uint32 kUsbLeftControl = 0x0700e0; +const uint32 kUsbRightControl = 0x0700e4; +const uint32 kUsbLeftAlt = 0x0700e2; +const uint32 kUsbRightAlt = 0x0700e6; +const uint32 kUsbDelete = 0x07004c; + +bool areCtrlAndAltPressed(const std::set<uint32>& pressed_keys) { + size_t ctrl_keys = pressed_keys.count(kUsbLeftControl) + + pressed_keys.count(kUsbRightControl); + size_t alt_keys = pressed_keys.count(kUsbLeftAlt) + + pressed_keys.count(kUsbRightAlt); + return ctrl_keys != 0 && alt_keys != 0 && + (ctrl_keys + alt_keys == pressed_keys.size()); +} + } // namespace namespace remoting { @@ -36,8 +50,7 @@ SessionEventExecutorWin::SessionEventExecutorWin( base::MessageLoopProxy* io_message_loop, scoped_ptr<protocol::HostEventStub> nested_executor) : nested_executor_(nested_executor.Pass()), - message_loop_(message_loop), - scroll_pressed_(false) { + message_loop_(message_loop) { std::string channel_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(kProcessChannelId); @@ -78,20 +91,23 @@ void SessionEventExecutorWin::InjectKeyEvent(const KeyEvent& 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) { + // HostEventDispatcher should drop events lacking the pressed field. + DCHECK(event.has_pressed()); + + if (event.has_usb_keycode()) { if (event.pressed()) { - if (scroll_pressed_) { - chromoting_channel_->Send(new ChromotingHostMsg_SendSasToConsole()); - scroll_pressed_ = false; - } else { - scroll_pressed_ = true; + // Simulate secure attention sequence if Ctrl-Alt-Del was just pressed. + if (event.usb_keycode() == kUsbDelete && + areCtrlAndAltPressed(pressed_keys_)) { + VLOG(3) << "Sending Secure Attention Sequence to console"; + if (chromoting_channel_.get()) + chromoting_channel_->Send(new ChromotingHostMsg_SendSasToConsole()); } + + pressed_keys_.insert(event.usb_keycode()); + } else { + pressed_keys_.erase(event.usb_keycode()); } - } else { - scroll_pressed_ = false; } SwitchToInputDesktop(); diff --git a/remoting/host/session_event_executor_win.h b/remoting/host/session_event_executor_win.h index d465398..0d1f12f 100644 --- a/remoting/host/session_event_executor_win.h +++ b/remoting/host/session_event_executor_win.h @@ -5,6 +5,8 @@ #ifndef REMOTING_HOST_SESSION_EVENT_EXECUTOR_WIN_H_ #define REMOTING_HOST_SESSION_EVENT_EXECUTOR_WIN_H_ +#include <set> + #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "ipc/ipc_channel.h" @@ -59,7 +61,8 @@ class SessionEventExecutorWin : public protocol::HostEventStub, // The Chromoting IPC channel connecting the host with the service. scoped_ptr<IPC::ChannelProxy> chromoting_channel_; - bool scroll_pressed_; + // Keys currently pressed by the client, used to detect Ctrl-Alt-Del. + std::set<uint32> pressed_keys_; DISALLOW_COPY_AND_ASSIGN(SessionEventExecutorWin); }; |