| 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 13 matching lines...) Expand all Loading... |
| 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 is_authenticated_(false), | 28 is_authenticated_(false), |
| 29 host_clipboard_stub_(host_clipboard_stub), | 29 host_clipboard_stub_(host_clipboard_stub), |
| 30 host_input_stub_(host_input_stub), | 30 host_input_stub_(host_input_stub), |
| 31 input_tracker_(host_input_stub_), | 31 input_tracker_(host_input_stub_), |
| 32 remote_input_filter_(&input_tracker_), | 32 remote_input_filter_(&input_tracker_), |
| 33 mouse_input_filter_(&remote_input_filter_), | 33 mouse_input_filter_(&remote_input_filter_), |
| 34 mouse_clamping_filter_(capturer, &mouse_input_filter_), |
| 34 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), | 35 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), |
| 35 capturer_(capturer), | 36 capturer_(capturer), |
| 36 max_duration_(max_duration) { | 37 max_duration_(max_duration) { |
| 37 connection_->SetEventHandler(this); | 38 connection_->SetEventHandler(this); |
| 38 | 39 |
| 39 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be | 40 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be |
| 40 // set before channels are connected. Make it possible to set stubs | 41 // set before channels are connected. Make it possible to set stubs |
| 41 // later and set them only when connection is authenticated. | 42 // later and set them only when connection is authenticated. |
| 42 connection_->set_clipboard_stub(&auth_clipboard_filter_); | 43 connection_->set_clipboard_stub(&auth_clipboard_filter_); |
| 43 connection_->set_host_stub(this); | 44 connection_->set_host_stub(this); |
| 44 connection_->set_input_stub(this); | 45 connection_->set_input_stub(&auth_input_filter_); |
| 45 clipboard_echo_filter_.set_host_stub(host_clipboard_stub_); | 46 clipboard_echo_filter_.set_host_stub(host_clipboard_stub_); |
| 46 } | 47 } |
| 47 | 48 |
| 48 ClientSession::~ClientSession() { | 49 ClientSession::~ClientSession() { |
| 49 } | 50 } |
| 50 | 51 |
| 51 void ClientSession::InjectKeyEvent(const protocol::KeyEvent& event) { | |
| 52 DCHECK(CalledOnValidThread()); | |
| 53 auth_input_filter_.InjectKeyEvent(event); | |
| 54 } | |
| 55 | |
| 56 void ClientSession::InjectMouseEvent(const protocol::MouseEvent& event) { | |
| 57 DCHECK(CalledOnValidThread()); | |
| 58 | |
| 59 // Ensure that the MouseInputFilter is clamping to the current dimensions. | |
| 60 mouse_input_filter_.set_output_size(capturer_->size_most_recent()); | |
| 61 mouse_input_filter_.set_input_size(capturer_->size_most_recent()); | |
| 62 | |
| 63 auth_input_filter_.InjectMouseEvent(event); | |
| 64 } | |
| 65 | |
| 66 void ClientSession::NotifyClientDimensions( | 52 void ClientSession::NotifyClientDimensions( |
| 67 const protocol::ClientDimensions& dimensions) { | 53 const protocol::ClientDimensions& dimensions) { |
| 68 // TODO(wez): Use the dimensions, e.g. to resize the host desktop to match. | 54 // TODO(wez): Use the dimensions, e.g. to resize the host desktop to match. |
| 69 if (dimensions.has_width() && dimensions.has_height()) { | 55 if (dimensions.has_width() && dimensions.has_height()) { |
| 70 VLOG(1) << "Received ClientDimensions (width=" | 56 VLOG(1) << "Received ClientDimensions (width=" |
| 71 << dimensions.width() << ", height=" << dimensions.height() << ")"; | 57 << dimensions.width() << ", height=" << dimensions.height() << ")"; |
| 72 } | 58 } |
| 73 } | 59 } |
| 74 | 60 |
| 75 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { | 61 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 145 } |
| 160 | 146 |
| 161 void ClientSession::SetDisableInputs(bool disable_inputs) { | 147 void ClientSession::SetDisableInputs(bool disable_inputs) { |
| 162 DCHECK(CalledOnValidThread()); | 148 DCHECK(CalledOnValidThread()); |
| 163 | 149 |
| 164 if (disable_inputs) { | 150 if (disable_inputs) { |
| 165 disable_input_filter_.set_input_stub(NULL); | 151 disable_input_filter_.set_input_stub(NULL); |
| 166 disable_clipboard_filter_.set_clipboard_stub(NULL); | 152 disable_clipboard_filter_.set_clipboard_stub(NULL); |
| 167 input_tracker_.ReleaseAll(); | 153 input_tracker_.ReleaseAll(); |
| 168 } else { | 154 } else { |
| 169 disable_input_filter_.set_input_stub(&mouse_input_filter_); | 155 disable_input_filter_.set_input_stub(&mouse_clamping_filter_); |
| 170 disable_clipboard_filter_.set_clipboard_stub( | 156 disable_clipboard_filter_.set_clipboard_stub( |
| 171 clipboard_echo_filter_.host_filter()); | 157 clipboard_echo_filter_.host_filter()); |
| 172 } | 158 } |
| 173 } | 159 } |
| 174 | 160 |
| 175 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { | 161 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { |
| 176 DCHECK(CalledOnValidThread()); | 162 DCHECK(CalledOnValidThread()); |
| 177 | 163 |
| 178 return scoped_ptr<protocol::ClipboardStub>( | 164 return scoped_ptr<protocol::ClipboardStub>( |
| 179 new protocol::ClipboardThreadProxy( | 165 new protocol::ClipboardThreadProxy( |
| 180 client_clipboard_factory_.GetWeakPtr(), | 166 client_clipboard_factory_.GetWeakPtr(), |
| 181 base::MessageLoopProxy::current())); | 167 base::MessageLoopProxy::current())); |
| 182 } | 168 } |
| 183 | 169 |
| 184 } // namespace remoting | 170 } // namespace remoting |
| OLD | NEW |