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 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. |
34 connection_->set_clipboard_stub(this); | 35 connection_->set_clipboard_stub(this); |
35 connection_->set_host_stub(this); | 36 connection_->set_host_stub(this); |
36 connection_->set_input_stub(this); | 37 connection_->set_input_stub(this); |
| 38 clipboard_echo_filter_.set_host_stub(host_event_stub_); |
37 } | 39 } |
38 | 40 |
39 ClientSession::~ClientSession() { | 41 ClientSession::~ClientSession() { |
40 } | 42 } |
41 | 43 |
42 void ClientSession::InjectClipboardEvent( | 44 void ClientSession::InjectClipboardEvent( |
43 const protocol::ClipboardEvent& event) { | 45 const protocol::ClipboardEvent& event) { |
44 DCHECK(CalledOnValidThread()); | 46 DCHECK(CalledOnValidThread()); |
45 | 47 |
46 // TODO(wez): Disable clipboard in both directions on local activity, and | 48 // TODO(wez): Disable clipboard in both directions on local activity, and |
47 // replace these tests with a HostInputFilter (or ClipboardFilter). | 49 // replace these tests with a HostInputFilter (or ClipboardFilter). |
48 if (auth_input_filter_.input_stub() == NULL) | 50 if (auth_input_filter_.input_stub() == NULL) |
49 return; | 51 return; |
50 if (disable_input_filter_.input_stub() == NULL) | 52 if (disable_input_filter_.input_stub() == NULL) |
51 return; | 53 return; |
52 | 54 |
53 host_event_stub_->InjectClipboardEvent(event); | 55 clipboard_echo_filter_.get_host_filter()->InjectClipboardEvent(event); |
54 } | 56 } |
55 | 57 |
56 void ClientSession::InjectKeyEvent(const protocol::KeyEvent& event) { | 58 void ClientSession::InjectKeyEvent(const protocol::KeyEvent& event) { |
57 DCHECK(CalledOnValidThread()); | 59 DCHECK(CalledOnValidThread()); |
58 auth_input_filter_.InjectKeyEvent(event); | 60 auth_input_filter_.InjectKeyEvent(event); |
59 } | 61 } |
60 | 62 |
61 void ClientSession::InjectMouseEvent(const protocol::MouseEvent& event) { | 63 void ClientSession::InjectMouseEvent(const protocol::MouseEvent& event) { |
62 DCHECK(CalledOnValidThread()); | 64 DCHECK(CalledOnValidThread()); |
63 | 65 |
(...skipping 20 matching lines...) Expand all Loading... |
84 VLOG(1) << "Received VideoControl (enable=" | 86 VLOG(1) << "Received VideoControl (enable=" |
85 << video_control.enable() << ")"; | 87 << video_control.enable() << ")"; |
86 } | 88 } |
87 } | 89 } |
88 | 90 |
89 void ClientSession::OnConnectionAuthenticated( | 91 void ClientSession::OnConnectionAuthenticated( |
90 protocol::ConnectionToClient* connection) { | 92 protocol::ConnectionToClient* connection) { |
91 DCHECK(CalledOnValidThread()); | 93 DCHECK(CalledOnValidThread()); |
92 DCHECK_EQ(connection_.get(), connection); | 94 DCHECK_EQ(connection_.get(), connection); |
93 auth_input_filter_.set_input_stub(&disable_input_filter_); | 95 auth_input_filter_.set_input_stub(&disable_input_filter_); |
| 96 clipboard_echo_filter_.set_client_stub(connection_->client_stub()); |
94 event_handler_->OnSessionAuthenticated(this); | 97 event_handler_->OnSessionAuthenticated(this); |
95 } | 98 } |
96 | 99 |
97 void ClientSession::OnConnectionChannelsConnected( | 100 void ClientSession::OnConnectionChannelsConnected( |
98 protocol::ConnectionToClient* connection) { | 101 protocol::ConnectionToClient* connection) { |
99 DCHECK(CalledOnValidThread()); | 102 DCHECK(CalledOnValidThread()); |
100 DCHECK_EQ(connection_.get(), connection); | 103 DCHECK_EQ(connection_.get(), connection); |
101 SetDisableInputs(false); | 104 SetDisableInputs(false); |
102 event_handler_->OnSessionChannelsConnected(this); | 105 event_handler_->OnSessionChannelsConnected(this); |
103 } | 106 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 156 |
154 if (disable_inputs) { | 157 if (disable_inputs) { |
155 disable_input_filter_.set_input_stub(NULL); | 158 disable_input_filter_.set_input_stub(NULL); |
156 input_tracker_.ReleaseAll(); | 159 input_tracker_.ReleaseAll(); |
157 } else { | 160 } else { |
158 disable_input_filter_.set_input_stub(&mouse_input_filter_); | 161 disable_input_filter_.set_input_stub(&mouse_input_filter_); |
159 } | 162 } |
160 } | 163 } |
161 | 164 |
162 } // namespace remoting | 165 } // namespace remoting |
OLD | NEW |