| 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/capturer.h" | 10 #include "remoting/host/capturer.h" |
| 11 #include "remoting/proto/control.pb.h" | 11 #include "remoting/proto/control.pb.h" |
| 12 #include "remoting/proto/event.pb.h" | 12 #include "remoting/proto/event.pb.h" |
| 13 #include "remoting/protocol/client_stub.h" |
| 13 | 14 |
| 14 namespace remoting { | 15 namespace remoting { |
| 15 | 16 |
| 16 ClientSession::ClientSession( | 17 ClientSession::ClientSession( |
| 17 EventHandler* event_handler, | 18 EventHandler* event_handler, |
| 18 scoped_ptr<protocol::ConnectionToClient> connection, | 19 scoped_ptr<protocol::ConnectionToClient> connection, |
| 19 protocol::HostEventStub* host_event_stub, | 20 protocol::HostEventStub* host_event_stub, |
| 20 Capturer* capturer) | 21 Capturer* capturer) |
| 21 : event_handler_(event_handler), | 22 : event_handler_(event_handler), |
| 22 connection_(connection.Pass()), | 23 connection_(connection.Pass()), |
| 23 client_jid_(connection_->session()->jid()), | 24 client_jid_(connection_->session()->jid()), |
| 24 is_authenticated_(false), | 25 is_authenticated_(false), |
| 25 host_event_stub_(host_event_stub), | 26 host_event_stub_(host_event_stub), |
| 26 input_tracker_(host_event_stub_), | 27 input_tracker_(host_event_stub_), |
| 27 remote_input_filter_(&input_tracker_), | 28 remote_input_filter_(&input_tracker_), |
| 28 mouse_input_filter_(&remote_input_filter_), | 29 mouse_input_filter_(&remote_input_filter_), |
| 29 capturer_(capturer) { | 30 capturer_(capturer) { |
| 30 connection_->SetEventHandler(this); | 31 connection_->SetEventHandler(this); |
| 31 | 32 |
| 32 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be | 33 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be |
| 33 // set before channels are connected. Make it possible to set stubs | 34 // set before channels are connected. Make it possible to set stubs |
| 34 // later and set them only when connection is authenticated. | 35 // later and set them only when connection is authenticated. |
| 35 connection_->set_clipboard_stub(this); | 36 connection_->set_clipboard_stub(this); |
| 36 connection_->set_host_stub(this); | 37 connection_->set_host_stub(this); |
| 37 connection_->set_input_stub(this); | 38 connection_->set_input_stub(this); |
| 39 clipboard_echo_filter_.set_host_stub(host_event_stub_); |
| 38 } | 40 } |
| 39 | 41 |
| 40 ClientSession::~ClientSession() { | 42 ClientSession::~ClientSession() { |
| 41 } | 43 } |
| 42 | 44 |
| 43 void ClientSession::InjectClipboardEvent( | 45 void ClientSession::InjectClipboardEvent( |
| 44 const protocol::ClipboardEvent& event) { | 46 const protocol::ClipboardEvent& event) { |
| 45 DCHECK(CalledOnValidThread()); | 47 DCHECK(CalledOnValidThread()); |
| 46 | 48 |
| 47 // TODO(wez): Disable clipboard in both directions on local activity, and | 49 // TODO(wez): Disable clipboard in both directions on local activity, and |
| 48 // replace these tests with a HostInputFilter (or ClipboardFilter). | 50 // replace these tests with a HostInputFilter (or ClipboardFilter). |
| 49 if (auth_input_filter_.input_stub() == NULL) | 51 if (auth_input_filter_.input_stub() == NULL) |
| 50 return; | 52 return; |
| 51 if (disable_input_filter_.input_stub() == NULL) | 53 if (disable_input_filter_.input_stub() == NULL) |
| 52 return; | 54 return; |
| 53 | 55 |
| 54 host_event_stub_->InjectClipboardEvent(event); | 56 clipboard_echo_filter_.host_filter()->InjectClipboardEvent(event); |
| 55 } | 57 } |
| 56 | 58 |
| 57 void ClientSession::InjectKeyEvent(const protocol::KeyEvent& event) { | 59 void ClientSession::InjectKeyEvent(const protocol::KeyEvent& event) { |
| 58 DCHECK(CalledOnValidThread()); | 60 DCHECK(CalledOnValidThread()); |
| 59 auth_input_filter_.InjectKeyEvent(event); | 61 auth_input_filter_.InjectKeyEvent(event); |
| 60 } | 62 } |
| 61 | 63 |
| 62 void ClientSession::InjectMouseEvent(const protocol::MouseEvent& event) { | 64 void ClientSession::InjectMouseEvent(const protocol::MouseEvent& event) { |
| 63 DCHECK(CalledOnValidThread()); | 65 DCHECK(CalledOnValidThread()); |
| 64 | 66 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 86 << video_control.enable() << ")"; | 88 << video_control.enable() << ")"; |
| 87 } | 89 } |
| 88 } | 90 } |
| 89 | 91 |
| 90 void ClientSession::OnConnectionAuthenticated( | 92 void ClientSession::OnConnectionAuthenticated( |
| 91 protocol::ConnectionToClient* connection) { | 93 protocol::ConnectionToClient* connection) { |
| 92 DCHECK(CalledOnValidThread()); | 94 DCHECK(CalledOnValidThread()); |
| 93 DCHECK_EQ(connection_.get(), connection); | 95 DCHECK_EQ(connection_.get(), connection); |
| 94 is_authenticated_ = true; | 96 is_authenticated_ = true; |
| 95 auth_input_filter_.set_input_stub(&disable_input_filter_); | 97 auth_input_filter_.set_input_stub(&disable_input_filter_); |
| 98 clipboard_echo_filter_.set_client_stub(connection_->client_stub()); |
| 96 event_handler_->OnSessionAuthenticated(this); | 99 event_handler_->OnSessionAuthenticated(this); |
| 97 } | 100 } |
| 98 | 101 |
| 99 void ClientSession::OnConnectionChannelsConnected( | 102 void ClientSession::OnConnectionChannelsConnected( |
| 100 protocol::ConnectionToClient* connection) { | 103 protocol::ConnectionToClient* connection) { |
| 101 DCHECK(CalledOnValidThread()); | 104 DCHECK(CalledOnValidThread()); |
| 102 DCHECK_EQ(connection_.get(), connection); | 105 DCHECK_EQ(connection_.get(), connection); |
| 103 SetDisableInputs(false); | 106 SetDisableInputs(false); |
| 104 event_handler_->OnSessionChannelsConnected(this); | 107 event_handler_->OnSessionChannelsConnected(this); |
| 105 } | 108 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 158 |
| 156 if (disable_inputs) { | 159 if (disable_inputs) { |
| 157 disable_input_filter_.set_input_stub(NULL); | 160 disable_input_filter_.set_input_stub(NULL); |
| 158 input_tracker_.ReleaseAll(); | 161 input_tracker_.ReleaseAll(); |
| 159 } else { | 162 } else { |
| 160 disable_input_filter_.set_input_stub(&mouse_input_filter_); | 163 disable_input_filter_.set_input_stub(&mouse_input_filter_); |
| 161 } | 164 } |
| 162 } | 165 } |
| 163 | 166 |
| 164 } // namespace remoting | 167 } // namespace remoting |
| OLD | NEW |