| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/host/client_session.h" | 5 #include "remoting/host/client_session.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "remoting/host/video_frame_capturer.h" | 10 #include "remoting/host/video_frame_capturer.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 protocol::InputStub* host_input_stub, | 22 protocol::InputStub* host_input_stub, |
| 23 VideoFrameCapturer* capturer, | 23 VideoFrameCapturer* capturer, |
| 24 const base::TimeDelta& max_duration) | 24 const base::TimeDelta& max_duration) |
| 25 : event_handler_(event_handler), | 25 : event_handler_(event_handler), |
| 26 connection_(connection.Pass()), | 26 connection_(connection.Pass()), |
| 27 client_jid_(connection_->session()->jid()), | 27 client_jid_(connection_->session()->jid()), |
| 28 host_clipboard_stub_(host_clipboard_stub), | 28 host_clipboard_stub_(host_clipboard_stub), |
| 29 host_input_stub_(host_input_stub), | 29 host_input_stub_(host_input_stub), |
| 30 input_tracker_(host_input_stub_), | 30 input_tracker_(host_input_stub_), |
| 31 remote_input_filter_(&input_tracker_), | 31 remote_input_filter_(&input_tracker_), |
| 32 mouse_input_filter_(&remote_input_filter_), | 32 mouse_clamping_filter_(capturer, &remote_input_filter_), |
| 33 disable_input_filter_(&mouse_input_filter_), | 33 disable_input_filter_(&mouse_clamping_filter_), |
| 34 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()), | 34 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()), |
| 35 auth_input_filter_(&disable_input_filter_), | 35 auth_input_filter_(&disable_input_filter_), |
| 36 auth_clipboard_filter_(&disable_clipboard_filter_), | 36 auth_clipboard_filter_(&disable_clipboard_filter_), |
| 37 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), | 37 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), |
| 38 capturer_(capturer), | 38 capturer_(capturer), |
| 39 max_duration_(max_duration) { | 39 max_duration_(max_duration) { |
| 40 connection_->SetEventHandler(this); | 40 connection_->SetEventHandler(this); |
| 41 | 41 |
| 42 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be | 42 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be |
| 43 // set before channels are connected. Make it possible to set stubs | 43 // set before channels are connected. Make it possible to set stubs |
| 44 // later and set them only when connection is authenticated. | 44 // later and set them only when connection is authenticated. |
| 45 connection_->set_clipboard_stub(&auth_clipboard_filter_); | 45 connection_->set_clipboard_stub(&auth_clipboard_filter_); |
| 46 connection_->set_host_stub(this); | 46 connection_->set_host_stub(this); |
| 47 connection_->set_input_stub(this); | 47 connection_->set_input_stub(&auth_input_filter_); |
| 48 clipboard_echo_filter_.set_host_stub(host_clipboard_stub_); | 48 clipboard_echo_filter_.set_host_stub(host_clipboard_stub_); |
| 49 | 49 |
| 50 // |auth_*_filter_|'s states reflect whether the session is authenticated. | 50 // |auth_*_filter_|'s states reflect whether the session is authenticated. |
| 51 auth_input_filter_.set_enabled(false); | 51 auth_input_filter_.set_enabled(false); |
| 52 auth_clipboard_filter_.set_enabled(false); | 52 auth_clipboard_filter_.set_enabled(false); |
| 53 } | 53 } |
| 54 | 54 |
| 55 ClientSession::~ClientSession() { | 55 ClientSession::~ClientSession() { |
| 56 } | 56 } |
| 57 | 57 |
| 58 void ClientSession::InjectKeyEvent(const protocol::KeyEvent& event) { | |
| 59 DCHECK(CalledOnValidThread()); | |
| 60 auth_input_filter_.InjectKeyEvent(event); | |
| 61 } | |
| 62 | |
| 63 void ClientSession::InjectMouseEvent(const protocol::MouseEvent& event) { | |
| 64 DCHECK(CalledOnValidThread()); | |
| 65 | |
| 66 // Ensure that the MouseInputFilter is clamping to the current dimensions. | |
| 67 mouse_input_filter_.set_output_size(capturer_->size_most_recent()); | |
| 68 mouse_input_filter_.set_input_size(capturer_->size_most_recent()); | |
| 69 | |
| 70 auth_input_filter_.InjectMouseEvent(event); | |
| 71 } | |
| 72 | |
| 73 void ClientSession::NotifyClientDimensions( | 58 void ClientSession::NotifyClientDimensions( |
| 74 const protocol::ClientDimensions& dimensions) { | 59 const protocol::ClientDimensions& dimensions) { |
| 75 // TODO(wez): Use the dimensions, e.g. to resize the host desktop to match. | 60 // TODO(wez): Use the dimensions, e.g. to resize the host desktop to match. |
| 76 if (dimensions.has_width() && dimensions.has_height()) { | 61 if (dimensions.has_width() && dimensions.has_height()) { |
| 77 VLOG(1) << "Received ClientDimensions (width=" | 62 VLOG(1) << "Received ClientDimensions (width=" |
| 78 << dimensions.width() << ", height=" << dimensions.height() << ")"; | 63 << dimensions.width() << ", height=" << dimensions.height() << ")"; |
| 79 } | 64 } |
| 80 } | 65 } |
| 81 | 66 |
| 82 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { | 67 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { | 167 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { |
| 183 DCHECK(CalledOnValidThread()); | 168 DCHECK(CalledOnValidThread()); |
| 184 | 169 |
| 185 return scoped_ptr<protocol::ClipboardStub>( | 170 return scoped_ptr<protocol::ClipboardStub>( |
| 186 new protocol::ClipboardThreadProxy( | 171 new protocol::ClipboardThreadProxy( |
| 187 client_clipboard_factory_.GetWeakPtr(), | 172 client_clipboard_factory_.GetWeakPtr(), |
| 188 base::MessageLoopProxy::current())); | 173 base::MessageLoopProxy::current())); |
| 189 } | 174 } |
| 190 | 175 |
| 191 } // namespace remoting | 176 } // namespace remoting |
| OLD | NEW |