Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: remoting/host/client_session.cc

Issue 10831223: Use ClipboardFilter in ClientSession auth & disable-input blocking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ClientSession unit tests to build. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 21 matching lines...) Expand all
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 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), 34 client_clipboard_factory_(clipboard_echo_filter_.client_filter()),
35 capturer_(capturer), 35 capturer_(capturer),
36 max_duration_(max_duration) { 36 max_duration_(max_duration) {
37 connection_->SetEventHandler(this); 37 connection_->SetEventHandler(this);
38 38
39 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be 39 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be
40 // set before channels are connected. Make it possible to set stubs 40 // set before channels are connected. Make it possible to set stubs
41 // later and set them only when connection is authenticated. 41 // later and set them only when connection is authenticated.
42 connection_->set_clipboard_stub(this); 42 connection_->set_clipboard_stub(&auth_clipboard_filter_);
43 connection_->set_host_stub(this); 43 connection_->set_host_stub(this);
44 connection_->set_input_stub(this); 44 connection_->set_input_stub(this);
45 clipboard_echo_filter_.set_host_stub(host_clipboard_stub_); 45 clipboard_echo_filter_.set_host_stub(host_clipboard_stub_);
46 } 46 }
47 47
48 ClientSession::~ClientSession() { 48 ClientSession::~ClientSession() {
49 } 49 }
50 50
51 void ClientSession::InjectClipboardEvent(
52 const protocol::ClipboardEvent& event) {
53 DCHECK(CalledOnValidThread());
54
55 // TODO(wez): Disable clipboard in both directions on local activity, and
56 // replace these tests with a HostInputFilter (or ClipboardFilter).
57 if (auth_input_filter_.input_stub() == NULL)
58 return;
59 if (disable_input_filter_.input_stub() == NULL)
60 return;
61
62 clipboard_echo_filter_.host_filter()->InjectClipboardEvent(event);
63 }
64
65 void ClientSession::InjectKeyEvent(const protocol::KeyEvent& event) { 51 void ClientSession::InjectKeyEvent(const protocol::KeyEvent& event) {
66 DCHECK(CalledOnValidThread()); 52 DCHECK(CalledOnValidThread());
67 auth_input_filter_.InjectKeyEvent(event); 53 auth_input_filter_.InjectKeyEvent(event);
68 } 54 }
69 55
70 void ClientSession::InjectMouseEvent(const protocol::MouseEvent& event) { 56 void ClientSession::InjectMouseEvent(const protocol::MouseEvent& event) {
71 DCHECK(CalledOnValidThread()); 57 DCHECK(CalledOnValidThread());
72 58
73 // Ensure that the MouseInputFilter is clamping to the current dimensions. 59 // Ensure that the MouseInputFilter is clamping to the current dimensions.
74 mouse_input_filter_.set_output_size(capturer_->size_most_recent()); 60 mouse_input_filter_.set_output_size(capturer_->size_most_recent());
(...skipping 17 matching lines...) Expand all
92 if (video_control.has_enable()) { 78 if (video_control.has_enable()) {
93 VLOG(1) << "Received VideoControl (enable=" 79 VLOG(1) << "Received VideoControl (enable="
94 << video_control.enable() << ")"; 80 << video_control.enable() << ")";
95 } 81 }
96 } 82 }
97 83
98 void ClientSession::OnConnectionAuthenticated( 84 void ClientSession::OnConnectionAuthenticated(
99 protocol::ConnectionToClient* connection) { 85 protocol::ConnectionToClient* connection) {
100 DCHECK(CalledOnValidThread()); 86 DCHECK(CalledOnValidThread());
101 DCHECK_EQ(connection_.get(), connection); 87 DCHECK_EQ(connection_.get(), connection);
88
102 is_authenticated_ = true; 89 is_authenticated_ = true;
103 auth_input_filter_.set_input_stub(&disable_input_filter_); 90 auth_input_filter_.set_input_stub(&disable_input_filter_);
91 auth_clipboard_filter_.set_clipboard_stub(&disable_clipboard_filter_);
92
104 clipboard_echo_filter_.set_client_stub(connection_->client_stub()); 93 clipboard_echo_filter_.set_client_stub(connection_->client_stub());
94
105 if (max_duration_ > base::TimeDelta()) { 95 if (max_duration_ > base::TimeDelta()) {
106 // TODO(simonmorris): Let Disconnect() tell the client that the 96 // TODO(simonmorris): Let Disconnect() tell the client that the
107 // disconnection was caused by the session exceeding its maximum duration. 97 // disconnection was caused by the session exceeding its maximum duration.
108 max_duration_timer_.Start(FROM_HERE, max_duration_, 98 max_duration_timer_.Start(FROM_HERE, max_duration_,
109 this, &ClientSession::Disconnect); 99 this, &ClientSession::Disconnect);
110 } 100 }
101
111 event_handler_->OnSessionAuthenticated(this); 102 event_handler_->OnSessionAuthenticated(this);
112 } 103 }
113 104
114 void ClientSession::OnConnectionChannelsConnected( 105 void ClientSession::OnConnectionChannelsConnected(
115 protocol::ConnectionToClient* connection) { 106 protocol::ConnectionToClient* connection) {
116 DCHECK(CalledOnValidThread()); 107 DCHECK(CalledOnValidThread());
117 DCHECK_EQ(connection_.get(), connection); 108 DCHECK_EQ(connection_.get(), connection);
118 SetDisableInputs(false); 109 SetDisableInputs(false);
119 event_handler_->OnSessionChannelsConnected(this); 110 event_handler_->OnSessionChannelsConnected(this);
120 } 111 }
121 112
122 void ClientSession::OnConnectionClosed( 113 void ClientSession::OnConnectionClosed(
123 protocol::ConnectionToClient* connection, 114 protocol::ConnectionToClient* connection,
124 protocol::ErrorCode error) { 115 protocol::ErrorCode error) {
125 DCHECK(CalledOnValidThread()); 116 DCHECK(CalledOnValidThread());
126 DCHECK_EQ(connection_.get(), connection); 117 DCHECK_EQ(connection_.get(), connection);
127 if (!is_authenticated_) 118 if (!is_authenticated_)
128 event_handler_->OnSessionAuthenticationFailed(this); 119 event_handler_->OnSessionAuthenticationFailed(this);
129 auth_input_filter_.set_input_stub(NULL); 120 auth_input_filter_.set_input_stub(NULL);
121 auth_clipboard_filter_.set_clipboard_stub(NULL);
130 122
131 // Ensure that any pressed keys or buttons are released. 123 // Ensure that any pressed keys or buttons are released.
132 input_tracker_.ReleaseAll(); 124 input_tracker_.ReleaseAll();
133 125
134 // TODO(sergeyu): Log failure reason? 126 // TODO(sergeyu): Log failure reason?
135 event_handler_->OnSessionClosed(this); 127 event_handler_->OnSessionClosed(this);
136 } 128 }
137 129
138 void ClientSession::OnSequenceNumberUpdated( 130 void ClientSession::OnSequenceNumberUpdated(
139 protocol::ConnectionToClient* connection, int64 sequence_number) { 131 protocol::ConnectionToClient* connection, int64 sequence_number) {
(...skipping 24 matching lines...) Expand all
164 void ClientSession::LocalMouseMoved(const SkIPoint& mouse_pos) { 156 void ClientSession::LocalMouseMoved(const SkIPoint& mouse_pos) {
165 DCHECK(CalledOnValidThread()); 157 DCHECK(CalledOnValidThread());
166 remote_input_filter_.LocalMouseMoved(mouse_pos); 158 remote_input_filter_.LocalMouseMoved(mouse_pos);
167 } 159 }
168 160
169 void ClientSession::SetDisableInputs(bool disable_inputs) { 161 void ClientSession::SetDisableInputs(bool disable_inputs) {
170 DCHECK(CalledOnValidThread()); 162 DCHECK(CalledOnValidThread());
171 163
172 if (disable_inputs) { 164 if (disable_inputs) {
173 disable_input_filter_.set_input_stub(NULL); 165 disable_input_filter_.set_input_stub(NULL);
166 disable_clipboard_filter_.set_clipboard_stub(NULL);
174 input_tracker_.ReleaseAll(); 167 input_tracker_.ReleaseAll();
175 } else { 168 } else {
176 disable_input_filter_.set_input_stub(&mouse_input_filter_); 169 disable_input_filter_.set_input_stub(&mouse_input_filter_);
170 disable_clipboard_filter_.set_clipboard_stub(
171 clipboard_echo_filter_.host_filter());
177 } 172 }
178 } 173 }
179 174
180 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { 175 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() {
181 DCHECK(CalledOnValidThread()); 176 DCHECK(CalledOnValidThread());
182 177
183 return scoped_ptr<protocol::ClipboardStub>( 178 return scoped_ptr<protocol::ClipboardStub>(
184 new protocol::ClipboardThreadProxy( 179 new protocol::ClipboardThreadProxy(
185 client_clipboard_factory_.GetWeakPtr(), 180 client_clipboard_factory_.GetWeakPtr(),
186 base::MessageLoopProxy::current())); 181 base::MessageLoopProxy::current()));
187 } 182 }
188 183
189 } // namespace remoting 184 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698