| 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 | 13 |
| 14 namespace remoting { | 14 namespace remoting { |
| 15 | 15 |
| 16 ClientSession::ClientSession( | 16 ClientSession::ClientSession( |
| 17 EventHandler* event_handler, | 17 EventHandler* event_handler, |
| 18 scoped_ptr<protocol::ConnectionToClient> connection, | 18 scoped_ptr<protocol::ConnectionToClient> connection, |
| 19 protocol::HostEventStub* host_event_stub, | 19 protocol::HostEventStub* host_event_stub, |
| 20 Capturer* capturer) | 20 Capturer* capturer) |
| 21 : event_handler_(event_handler), | 21 : event_handler_(event_handler), |
| 22 connection_(connection.Pass()), | 22 connection_(connection.Pass()), |
| 23 client_jid_(connection_->session()->jid()), | 23 client_jid_(connection_->session()->jid()), |
| 24 is_authenticated_(false), |
| 24 host_event_stub_(host_event_stub), | 25 host_event_stub_(host_event_stub), |
| 25 input_tracker_(host_event_stub_), | 26 input_tracker_(host_event_stub_), |
| 26 remote_input_filter_(&input_tracker_), | 27 remote_input_filter_(&input_tracker_), |
| 27 mouse_input_filter_(&remote_input_filter_), | 28 mouse_input_filter_(&remote_input_filter_), |
| 28 capturer_(capturer) { | 29 capturer_(capturer) { |
| 29 connection_->SetEventHandler(this); | 30 connection_->SetEventHandler(this); |
| 30 | 31 |
| 31 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be | 32 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be |
| 32 // set before channels are connected. Make it possible to set stubs | 33 // set before channels are connected. Make it possible to set stubs |
| 33 // later and set them only when connection is authenticated. | 34 // later and set them only when connection is authenticated. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (video_control.has_enable()) { | 84 if (video_control.has_enable()) { |
| 84 VLOG(1) << "Received VideoControl (enable=" | 85 VLOG(1) << "Received VideoControl (enable=" |
| 85 << video_control.enable() << ")"; | 86 << video_control.enable() << ")"; |
| 86 } | 87 } |
| 87 } | 88 } |
| 88 | 89 |
| 89 void ClientSession::OnConnectionAuthenticated( | 90 void ClientSession::OnConnectionAuthenticated( |
| 90 protocol::ConnectionToClient* connection) { | 91 protocol::ConnectionToClient* connection) { |
| 91 DCHECK(CalledOnValidThread()); | 92 DCHECK(CalledOnValidThread()); |
| 92 DCHECK_EQ(connection_.get(), connection); | 93 DCHECK_EQ(connection_.get(), connection); |
| 94 is_authenticated_ = true; |
| 93 auth_input_filter_.set_input_stub(&disable_input_filter_); | 95 auth_input_filter_.set_input_stub(&disable_input_filter_); |
| 94 event_handler_->OnSessionAuthenticated(this); | 96 event_handler_->OnSessionAuthenticated(this); |
| 95 } | 97 } |
| 96 | 98 |
| 97 void ClientSession::OnConnectionChannelsConnected( | 99 void ClientSession::OnConnectionChannelsConnected( |
| 98 protocol::ConnectionToClient* connection) { | 100 protocol::ConnectionToClient* connection) { |
| 99 DCHECK(CalledOnValidThread()); | 101 DCHECK(CalledOnValidThread()); |
| 100 DCHECK_EQ(connection_.get(), connection); | 102 DCHECK_EQ(connection_.get(), connection); |
| 101 SetDisableInputs(false); | 103 SetDisableInputs(false); |
| 102 event_handler_->OnSessionChannelsConnected(this); | 104 event_handler_->OnSessionChannelsConnected(this); |
| 103 } | 105 } |
| 104 | 106 |
| 105 void ClientSession::OnConnectionClosed( | 107 void ClientSession::OnConnectionClosed( |
| 106 protocol::ConnectionToClient* connection, | 108 protocol::ConnectionToClient* connection, |
| 107 protocol::ErrorCode error) { | 109 protocol::ErrorCode error) { |
| 108 DCHECK(CalledOnValidThread()); | 110 DCHECK(CalledOnValidThread()); |
| 109 DCHECK_EQ(connection_.get(), connection); | 111 DCHECK_EQ(connection_.get(), connection); |
| 110 if (!auth_input_filter_.input_stub()) | 112 if (!is_authenticated_) |
| 111 event_handler_->OnSessionAuthenticationFailed(this); | 113 event_handler_->OnSessionAuthenticationFailed(this); |
| 112 auth_input_filter_.set_input_stub(NULL); | 114 auth_input_filter_.set_input_stub(NULL); |
| 113 | 115 |
| 114 // Ensure that any pressed keys or buttons are released. | 116 // Ensure that any pressed keys or buttons are released. |
| 115 input_tracker_.ReleaseAll(); | 117 input_tracker_.ReleaseAll(); |
| 116 | 118 |
| 117 // TODO(sergeyu): Log failure reason? | 119 // TODO(sergeyu): Log failure reason? |
| 118 event_handler_->OnSessionClosed(this); | 120 event_handler_->OnSessionClosed(this); |
| 119 } | 121 } |
| 120 | 122 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 155 |
| 154 if (disable_inputs) { | 156 if (disable_inputs) { |
| 155 disable_input_filter_.set_input_stub(NULL); | 157 disable_input_filter_.set_input_stub(NULL); |
| 156 input_tracker_.ReleaseAll(); | 158 input_tracker_.ReleaseAll(); |
| 157 } else { | 159 } else { |
| 158 disable_input_filter_.set_input_stub(&mouse_input_filter_); | 160 disable_input_filter_.set_input_stub(&mouse_input_filter_); |
| 159 } | 161 } |
| 160 } | 162 } |
| 161 | 163 |
| 162 } // namespace remoting | 164 } // namespace remoting |
| OLD | NEW |