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

Side by Side Diff: remoting/client/plugin/chromoting_instance.cc

Issue 799233004: Add touch events to the protocol, the stub layer, and to the client plugin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mac builds Created 5 years, 11 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
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/client/plugin/chromoting_instance.h" 5 #include "remoting/client/plugin/chromoting_instance.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #if defined(OS_NACL) 10 #if defined(OS_NACL)
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 const char ChromotingInstance::kRequestedCapabilities[] = ""; 181 const char ChromotingInstance::kRequestedCapabilities[] = "";
182 const char ChromotingInstance::kSupportedCapabilities[] = "desktopShape"; 182 const char ChromotingInstance::kSupportedCapabilities[] = "desktopShape";
183 183
184 ChromotingInstance::ChromotingInstance(PP_Instance pp_instance) 184 ChromotingInstance::ChromotingInstance(PP_Instance pp_instance)
185 : pp::Instance(pp_instance), 185 : pp::Instance(pp_instance),
186 initialized_(false), 186 initialized_(false),
187 plugin_task_runner_(new PluginThreadTaskRunner(&plugin_thread_delegate_)), 187 plugin_task_runner_(new PluginThreadTaskRunner(&plugin_thread_delegate_)),
188 context_(plugin_task_runner_.get()), 188 context_(plugin_task_runner_.get()),
189 input_tracker_(&mouse_input_filter_), 189 input_tracker_(&mouse_input_filter_),
190 key_mapper_(&input_tracker_), 190 touch_input_filter_(&input_tracker_),
191 key_mapper_(&touch_input_filter_),
191 cursor_setter_(this), 192 cursor_setter_(this),
192 empty_cursor_filter_(&cursor_setter_), 193 empty_cursor_filter_(&cursor_setter_),
193 text_input_controller_(this), 194 text_input_controller_(this),
194 use_async_pin_dialog_(false), 195 use_async_pin_dialog_(false),
195 weak_factory_(this) { 196 weak_factory_(this) {
196 #if defined(OS_NACL) 197 #if defined(OS_NACL)
197 // In NaCl global resources need to be initialized differently because they 198 // In NaCl global resources need to be initialized differently because they
198 // are not shared with Chrome. 199 // are not shared with Chrome.
199 thread_task_runner_handle_.reset( 200 thread_task_runner_handle_.reset(
200 new base::ThreadTaskRunnerHandle(plugin_task_runner_)); 201 new base::ThreadTaskRunnerHandle(plugin_task_runner_));
201 thread_wrapper_.reset( 202 thread_wrapper_.reset(
202 new jingle_glue::JingleThreadWrapper(plugin_task_runner_)); 203 new jingle_glue::JingleThreadWrapper(plugin_task_runner_));
203 media::InitializeCPUSpecificYUVConversions(); 204 media::InitializeCPUSpecificYUVConversions();
204 205
205 // Register a global log handler. 206 // Register a global log handler.
206 ChromotingInstance::RegisterLogMessageHandler(); 207 ChromotingInstance::RegisterLogMessageHandler();
207 #else 208 #else
208 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); 209 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
209 #endif 210 #endif
210 211
211 #if defined(OS_NACL) 212 #if defined(OS_NACL)
212 nacl_io_init_ppapi(pp_instance, pp::Module::Get()->get_browser_interface()); 213 nacl_io_init_ppapi(pp_instance, pp::Module::Get()->get_browser_interface());
213 mount("", "/etc", "memfs", 0, ""); 214 mount("", "/etc", "memfs", 0, "");
214 mount("", "/usr", "memfs", 0, ""); 215 mount("", "/usr", "memfs", 0, "");
215 #endif 216 #endif
216 217
217 // Register for mouse, wheel and keyboard events. 218 // Register for mouse, wheel and keyboard events.
219 // TODO(rkuroiwa): Add PP_INPUTEVENT_CLASS_TOUCH when ready.
Wez 2015/01/21 03:08:37 Shouldn't you be doing the registration in the Han
Rintaro Kuroiwa 2015/01/28 01:12:29 Moved. But it *should* check for capabilities as w
Wez 2015/02/05 02:09:06 Check what for capabilities? The client? Or the ho
Rintaro Kuroiwa 2015/02/06 23:35:00 The capabilities. IIUC, the javascript layer check
218 RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_WHEEL); 220 RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_WHEEL);
219 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); 221 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD);
220 222
221 // Disable the client-side IME in Chrome. 223 // Disable the client-side IME in Chrome.
222 text_input_controller_.SetTextInputType(PP_TEXTINPUT_TYPE_NONE); 224 text_input_controller_.SetTextInputType(PP_TEXTINPUT_TYPE_NONE);
223 225
224 // Resister this instance to handle debug log messsages. 226 // Resister this instance to handle debug log messsages.
225 RegisterLoggingInstance(); 227 RegisterLoggingInstance();
226 228
227 #if defined(USE_OPENSSL) 229 #if defined(USE_OPENSSL)
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } else if (method == "requestPairing") { 345 } else if (method == "requestPairing") {
344 HandleRequestPairing(*data); 346 HandleRequestPairing(*data);
345 } else if (method == "extensionMessage") { 347 } else if (method == "extensionMessage") {
346 HandleExtensionMessage(*data); 348 HandleExtensionMessage(*data);
347 } else if (method == "allowMouseLock") { 349 } else if (method == "allowMouseLock") {
348 HandleAllowMouseLockMessage(); 350 HandleAllowMouseLockMessage();
349 } else if (method == "sendMouseInputWhenUnfocused") { 351 } else if (method == "sendMouseInputWhenUnfocused") {
350 HandleSendMouseInputWhenUnfocused(); 352 HandleSendMouseInputWhenUnfocused();
351 } else if (method == "delegateLargeCursors") { 353 } else if (method == "delegateLargeCursors") {
352 HandleDelegateLargeCursors(); 354 HandleDelegateLargeCursors();
355 } else if (method == "sendTouchEvents") {
356 HandleSendTouchEvents();
353 } 357 }
354 } 358 }
355 359
356 void ChromotingInstance::DidChangeFocus(bool has_focus) { 360 void ChromotingInstance::DidChangeFocus(bool has_focus) {
357 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 361 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
358 362
359 if (!IsConnected()) 363 if (!IsConnected())
360 return; 364 return;
361 365
362 input_handler_.DidChangeFocus(has_focus); 366 input_handler_.DidChangeFocus(has_focus);
363 if (mouse_locker_) 367 if (mouse_locker_)
364 mouse_locker_->DidChangeFocus(has_focus); 368 mouse_locker_->DidChangeFocus(has_focus);
365 } 369 }
366 370
367 void ChromotingInstance::DidChangeView(const pp::View& view) { 371 void ChromotingInstance::DidChangeView(const pp::View& view) {
368 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 372 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
369 373
370 plugin_view_ = view; 374 plugin_view_ = view;
371 mouse_input_filter_.set_input_size( 375 webrtc::DesktopSize size(
372 webrtc::DesktopSize(view.GetRect().width(), view.GetRect().height())); 376 webrtc::DesktopSize(view.GetRect().width(), view.GetRect().height()));
377 mouse_input_filter_.set_input_size(size);
378 touch_input_filter_.set_input_size(size);
373 379
374 if (video_renderer_) 380 if (video_renderer_)
375 video_renderer_->OnViewChanged(view); 381 video_renderer_->OnViewChanged(view);
376 } 382 }
377 383
378 bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { 384 bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) {
379 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 385 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
380 386
381 if (!IsConnected()) 387 if (!IsConnected())
382 return false; 388 return false;
(...skipping 11 matching lines...) Expand all
394 OnConnectionState(protocol::ConnectionToHost::FAILED, 400 OnConnectionState(protocol::ConnectionToHost::FAILED,
395 protocol::INCOMPATIBLE_PROTOCOL); 401 protocol::INCOMPATIBLE_PROTOCOL);
396 } 402 }
397 403
398 void ChromotingInstance::OnVideoFirstFrameReceived() { 404 void ChromotingInstance::OnVideoFirstFrameReceived() {
399 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 405 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
400 PostLegacyJsonMessage("onFirstFrameReceived", data.Pass()); 406 PostLegacyJsonMessage("onFirstFrameReceived", data.Pass());
401 } 407 }
402 408
403 void ChromotingInstance::OnVideoSize(const webrtc::DesktopSize& size, 409 void ChromotingInstance::OnVideoSize(const webrtc::DesktopSize& size,
404 const webrtc::DesktopVector& dpi) { 410 const webrtc::DesktopVector& dpi) {
405 mouse_input_filter_.set_output_size(size); 411 mouse_input_filter_.set_output_size(size);
412 touch_input_filter_.set_output_size(size);
406 413
407 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 414 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
408 data->SetInteger("width", size.width()); 415 data->SetInteger("width", size.width());
409 data->SetInteger("height", size.height()); 416 data->SetInteger("height", size.height());
410 if (dpi.x()) 417 if (dpi.x())
411 data->SetInteger("x_dpi", dpi.x()); 418 data->SetInteger("x_dpi", dpi.x());
412 if (dpi.y()) 419 if (dpi.y())
413 data->SetInteger("y_dpi", dpi.y()); 420 data->SetInteger("y_dpi", dpi.y());
414 PostLegacyJsonMessage("onDesktopSize", data.Pass()); 421 PostLegacyJsonMessage("onDesktopSize", data.Pass());
415 } 422 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 664
658 if (!plugin_view_.is_null()) 665 if (!plugin_view_.is_null())
659 video_renderer_->OnViewChanged(plugin_view_); 666 video_renderer_->OnViewChanged(plugin_view_);
660 667
661 scoped_ptr<AudioPlayer> audio_player(new PepperAudioPlayer(this)); 668 scoped_ptr<AudioPlayer> audio_player(new PepperAudioPlayer(this));
662 client_.reset(new ChromotingClient(&context_, this, video_renderer_.get(), 669 client_.reset(new ChromotingClient(&context_, this, video_renderer_.get(),
663 audio_player.Pass())); 670 audio_player.Pass()));
664 671
665 // Connect the input pipeline to the protocol stub & initialize components. 672 // Connect the input pipeline to the protocol stub & initialize components.
666 mouse_input_filter_.set_input_stub(client_->input_stub()); 673 mouse_input_filter_.set_input_stub(client_->input_stub());
674 touch_input_filter_.set_input_stub(client_->input_stub());
667 if (!plugin_view_.is_null()) { 675 if (!plugin_view_.is_null()) {
668 mouse_input_filter_.set_input_size(webrtc::DesktopSize( 676 webrtc::DesktopSize size(plugin_view_.GetRect().width(),
669 plugin_view_.GetRect().width(), plugin_view_.GetRect().height())); 677 plugin_view_.GetRect().height());
678 mouse_input_filter_.set_input_size(size);
679 touch_input_filter_.set_input_size(size);
670 } 680 }
671 681
672 // Setup the signal strategy. 682 // Setup the signal strategy.
673 signal_strategy_.reset(new DelegatingSignalStrategy( 683 signal_strategy_.reset(new DelegatingSignalStrategy(
674 local_jid, base::Bind(&ChromotingInstance::SendOutgoingIq, 684 local_jid, base::Bind(&ChromotingInstance::SendOutgoingIq,
675 weak_factory_.GetWeakPtr()))); 685 weak_factory_.GetWeakPtr())));
676 686
677 // Create TransportFactory. 687 // Create TransportFactory.
678 scoped_ptr<protocol::TransportFactory> transport_factory( 688 scoped_ptr<protocol::TransportFactory> transport_factory(
679 new protocol::LibjingleTransportFactory( 689 new protocol::LibjingleTransportFactory(
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 } 947 }
938 948
939 void ChromotingInstance::HandleSendMouseInputWhenUnfocused() { 949 void ChromotingInstance::HandleSendMouseInputWhenUnfocused() {
940 input_handler_.set_send_mouse_input_when_unfocused(true); 950 input_handler_.set_send_mouse_input_when_unfocused(true);
941 } 951 }
942 952
943 void ChromotingInstance::HandleDelegateLargeCursors() { 953 void ChromotingInstance::HandleDelegateLargeCursors() {
944 cursor_setter_.set_delegate_stub(this); 954 cursor_setter_.set_delegate_stub(this);
945 } 955 }
946 956
957 void ChromotingInstance::HandleSendTouchEvents() {
958 input_handler_.set_send_touch_events(true);
Wez 2015/01/21 03:08:37 Rather than setting a flag on the PepperInputHandl
Rintaro Kuroiwa 2015/01/28 01:12:29 Done.
959 }
960
947 void ChromotingInstance::Disconnect() { 961 void ChromotingInstance::Disconnect() {
948 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 962 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
949 963
950 VLOG(0) << "Disconnecting from host."; 964 VLOG(0) << "Disconnecting from host.";
951 965
952 // Disconnect the input pipeline and teardown the connection. 966 // Disconnect the input pipeline and teardown the connection.
953 mouse_input_filter_.set_input_stub(nullptr); 967 mouse_input_filter_.set_input_stub(nullptr);
954 client_.reset(); 968 client_.reset();
955 video_renderer_.reset(); 969 video_renderer_.reset();
956 } 970 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 url_components.scheme.len); 1141 url_components.scheme.len);
1128 return url_scheme == kChromeExtensionUrlScheme; 1142 return url_scheme == kChromeExtensionUrlScheme;
1129 } 1143 }
1130 1144
1131 bool ChromotingInstance::IsConnected() { 1145 bool ChromotingInstance::IsConnected() {
1132 return client_ && 1146 return client_ &&
1133 (client_->connection_state() == protocol::ConnectionToHost::CONNECTED); 1147 (client_->connection_state() == protocol::ConnectionToHost::CONNECTED);
1134 } 1148 }
1135 1149
1136 } // namespace remoting 1150 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698