Chromium Code Reviews| Index: remoting/host/client_session.cc |
| diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc |
| index 6e7e3d74b4b91e2beae37410d44f4d8b46463c2e..bb620c1d1344bc9e5e31fa730dfa717882ba62a4 100644 |
| --- a/remoting/host/client_session.cc |
| +++ b/remoting/host/client_session.cc |
| @@ -25,12 +25,13 @@ ClientSession::ClientSession( |
| : event_handler_(event_handler), |
| connection_(connection.Pass()), |
| client_jid_(connection_->session()->jid()), |
| - is_authenticated_(false), |
| host_clipboard_stub_(host_clipboard_stub), |
| host_input_stub_(host_input_stub), |
| input_tracker_(host_input_stub_), |
| remote_input_filter_(&input_tracker_), |
| mouse_input_filter_(&remote_input_filter_), |
| + disable_input_filter_(&mouse_input_filter_), |
| + auth_input_filter_(&disable_input_filter_), |
| client_clipboard_factory_(clipboard_echo_filter_.client_filter()), |
| capturer_(capturer), |
| max_duration_(max_duration) { |
| @@ -43,6 +44,9 @@ ClientSession::ClientSession( |
| connection_->set_host_stub(this); |
| connection_->set_input_stub(this); |
| clipboard_echo_filter_.set_host_stub(host_clipboard_stub_); |
| + |
| + // |auth_input_filter|'s state reflects whether the session is authenticated. |
|
simonmorris
2012/08/20 16:37:18
_ after "auth_input_filter".
Wez
2012/08/20 19:58:21
Done.
|
| + auth_input_filter_.set_enabled(false); |
| } |
| ClientSession::~ClientSession() { |
| @@ -54,9 +58,9 @@ void ClientSession::InjectClipboardEvent( |
| // TODO(wez): Disable clipboard in both directions on local activity, and |
| // replace these tests with a HostInputFilter (or ClipboardFilter). |
| - if (auth_input_filter_.input_stub() == NULL) |
| + if (!auth_input_filter_.enabled()) |
| return; |
| - if (disable_input_filter_.input_stub() == NULL) |
| + if (!disable_input_filter_.enabled()) |
| return; |
| clipboard_echo_filter_.host_filter()->InjectClipboardEvent(event); |
| @@ -99,15 +103,18 @@ void ClientSession::OnConnectionAuthenticated( |
| protocol::ConnectionToClient* connection) { |
| DCHECK(CalledOnValidThread()); |
| DCHECK_EQ(connection_.get(), connection); |
| - is_authenticated_ = true; |
| - auth_input_filter_.set_input_stub(&disable_input_filter_); |
| + |
| + auth_input_filter_.set_enabled(true); |
| + |
| clipboard_echo_filter_.set_client_stub(connection_->client_stub()); |
| + |
| if (max_duration_ > base::TimeDelta()) { |
| // TODO(simonmorris): Let Disconnect() tell the client that the |
| // disconnection was caused by the session exceeding its maximum duration. |
| max_duration_timer_.Start(FROM_HERE, max_duration_, |
| this, &ClientSession::Disconnect); |
| } |
| + |
| event_handler_->OnSessionAuthenticated(this); |
| } |
| @@ -124,9 +131,14 @@ void ClientSession::OnConnectionClosed( |
| protocol::ErrorCode error) { |
| DCHECK(CalledOnValidThread()); |
| DCHECK_EQ(connection_.get(), connection); |
| - if (!is_authenticated_) |
| + |
| + if (!auth_input_filter_.enabled()) |
| event_handler_->OnSessionAuthenticationFailed(this); |
| - auth_input_filter_.set_input_stub(NULL); |
| + |
| + // Block any further input events from the client. |
| + // TODO(wez): Fix ChromotingHost::OnSessionClosed not to check our |
| + // is_authenticated(), so that we can disable |auth_input_filter_| here. |
| + disable_input_filter_.set_enabled(false); |
| // Ensure that any pressed keys or buttons are released. |
| input_tracker_.ReleaseAll(); |
| @@ -169,12 +181,10 @@ void ClientSession::LocalMouseMoved(const SkIPoint& mouse_pos) { |
| void ClientSession::SetDisableInputs(bool disable_inputs) { |
| DCHECK(CalledOnValidThread()); |
| - if (disable_inputs) { |
| - disable_input_filter_.set_input_stub(NULL); |
| + if (disable_inputs) |
| input_tracker_.ReleaseAll(); |
| - } else { |
| - disable_input_filter_.set_input_stub(&mouse_input_filter_); |
| - } |
| + |
| + disable_input_filter_.set_enabled(!disable_inputs); |
| } |
| scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { |