diff options
author | jamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-20 19:32:45 +0000 |
---|---|---|
committer | jamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-20 19:32:45 +0000 |
commit | 35c14eeb34ca5f21b70a388e868ff3968545812f (patch) | |
tree | 70d4fb062c1d406ac4f22bb0bd577fd5d503a04b /remoting/host/client_session.cc | |
parent | 0b711e4718b64621ee2cdf5c5de597a53d1b2b07 (diff) | |
download | chromium_src-35c14eeb34ca5f21b70a388e868ff3968545812f.zip chromium_src-35c14eeb34ca5f21b70a388e868ff3968545812f.tar.gz chromium_src-35c14eeb34ca5f21b70a388e868ff3968545812f.tar.bz2 |
Completed basic implementation.
BUG=None
TEST=Manual
Review URL: http://codereview.chromium.org/7200009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89714 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/client_session.cc')
-rw-r--r-- | remoting/host/client_session.cc | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc index 0ebd0c5..8718429 100644 --- a/remoting/host/client_session.cc +++ b/remoting/host/client_session.cc @@ -31,6 +31,7 @@ ClientSession::ClientSession( connection_(connection), input_stub_(input_stub), authenticated_(false), + awaiting_continue_approval_(false), remote_mouse_button_state_(0) { } @@ -82,7 +83,12 @@ void ClientSession::OnAuthorizationComplete(bool success) { void ClientSession::InjectKeyEvent(const protocol::KeyEvent* event, Task* done) { base::ScopedTaskRunner done_runner(done); - if (authenticated_) { + if (authenticated_ && !ShouldIgnoreRemoteKeyboardInput(event)) { + if (event->pressed()) { + pressed_keys_.insert(event->keycode()); + } else { + pressed_keys_.erase(event->keycode()); + } input_stub_->InjectKeyEvent(event, done_runner.Release()); } } @@ -90,7 +96,7 @@ void ClientSession::InjectKeyEvent(const protocol::KeyEvent* event, void ClientSession::InjectMouseEvent(const protocol::MouseEvent* event, Task* done) { base::ScopedTaskRunner done_runner(done); - if (authenticated_ && !ShouldIgnoreRemoteInput()) { + if (authenticated_ && !ShouldIgnoreRemoteMouseInput(event)) { if (event->has_button() && event->has_button_down()) { if (event->button() >= 1 && event->button() < 32) { uint32 button_change = 1 << (event->button() - 1); @@ -129,12 +135,18 @@ void ClientSession::LocalMouseMoved(const gfx::Point& mouse_pos) { } } -bool ClientSession::ShouldIgnoreRemoteInput() const { +bool ClientSession::ShouldIgnoreRemoteMouseInput( + const protocol::MouseEvent* event) const { // If the last remote input event was a click or a drag, then it's not safe - // to block remote input. For example, it might result in the host missing - // the mouse-up event and being stuck with the button pressed. + // to block remote mouse events. For example, it might result in the host + // missing the mouse-up event and being stuck with the button pressed. if (remote_mouse_button_state_ != 0) return false; + // Otherwise, if the host user has not yet approved the continuation of the + // connection, then ignore remote mouse events. + if (awaiting_continue_approval_) + return true; + // Otherwise, ignore remote mouse events if the local mouse moved recently. int64 millis = (base::Time::Now() - latest_local_input_time_) .InMilliseconds(); if (millis < kRemoteBlockTimeoutMillis) @@ -142,4 +154,16 @@ bool ClientSession::ShouldIgnoreRemoteInput() const { return false; } +bool ClientSession::ShouldIgnoreRemoteKeyboardInput( + const protocol::KeyEvent* event) const { + // If the host user has not yet approved the continuation of the connection, + // then all remote keyboard input is ignored, except to release keys that + // were already pressed. + if (awaiting_continue_approval_) { + return event->pressed() || + (pressed_keys_.find(event->keycode()) == pressed_keys_.end()); + } + return false; +} + } // namespace remoting |