| 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/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 Loading... |
| 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_scaler_(&input_tracker_), |
| 191 key_mapper_(&touch_input_scaler_), |
| 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_)); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 } else if (method == "extensionMessage") { | 346 } else if (method == "extensionMessage") { |
| 346 HandleExtensionMessage(*data); | 347 HandleExtensionMessage(*data); |
| 347 } else if (method == "allowMouseLock") { | 348 } else if (method == "allowMouseLock") { |
| 348 HandleAllowMouseLockMessage(); | 349 HandleAllowMouseLockMessage(); |
| 349 } else if (method == "sendMouseInputWhenUnfocused") { | 350 } else if (method == "sendMouseInputWhenUnfocused") { |
| 350 HandleSendMouseInputWhenUnfocused(); | 351 HandleSendMouseInputWhenUnfocused(); |
| 351 } else if (method == "delegateLargeCursors") { | 352 } else if (method == "delegateLargeCursors") { |
| 352 HandleDelegateLargeCursors(); | 353 HandleDelegateLargeCursors(); |
| 353 } else if (method == "enableDebugRegion") { | 354 } else if (method == "enableDebugRegion") { |
| 354 HandleEnableDebugRegion(*data); | 355 HandleEnableDebugRegion(*data); |
| 356 } else if (method == "enableTouchEvents") { |
| 357 HandleEnableTouchEvents(); |
| 355 } | 358 } |
| 356 } | 359 } |
| 357 | 360 |
| 358 void ChromotingInstance::DidChangeFocus(bool has_focus) { | 361 void ChromotingInstance::DidChangeFocus(bool has_focus) { |
| 359 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 362 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
| 360 | 363 |
| 361 if (!IsConnected()) | 364 if (!IsConnected()) |
| 362 return; | 365 return; |
| 363 | 366 |
| 364 input_handler_.DidChangeFocus(has_focus); | 367 input_handler_.DidChangeFocus(has_focus); |
| 365 if (mouse_locker_) | 368 if (mouse_locker_) |
| 366 mouse_locker_->DidChangeFocus(has_focus); | 369 mouse_locker_->DidChangeFocus(has_focus); |
| 367 } | 370 } |
| 368 | 371 |
| 369 void ChromotingInstance::DidChangeView(const pp::View& view) { | 372 void ChromotingInstance::DidChangeView(const pp::View& view) { |
| 370 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 373 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
| 371 | 374 |
| 372 plugin_view_ = view; | 375 plugin_view_ = view; |
| 373 mouse_input_filter_.set_input_size( | 376 webrtc::DesktopSize size( |
| 374 webrtc::DesktopSize(view.GetRect().width(), view.GetRect().height())); | 377 webrtc::DesktopSize(view.GetRect().width(), view.GetRect().height())); |
| 378 mouse_input_filter_.set_input_size(size); |
| 379 touch_input_scaler_.set_input_size(size); |
| 375 | 380 |
| 376 if (video_renderer_) | 381 if (video_renderer_) |
| 377 video_renderer_->OnViewChanged(view); | 382 video_renderer_->OnViewChanged(view); |
| 378 } | 383 } |
| 379 | 384 |
| 380 bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { | 385 bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { |
| 381 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 386 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
| 382 | 387 |
| 383 if (!IsConnected()) | 388 if (!IsConnected()) |
| 384 return false; | 389 return false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 396 OnConnectionState(protocol::ConnectionToHost::FAILED, | 401 OnConnectionState(protocol::ConnectionToHost::FAILED, |
| 397 protocol::INCOMPATIBLE_PROTOCOL); | 402 protocol::INCOMPATIBLE_PROTOCOL); |
| 398 } | 403 } |
| 399 | 404 |
| 400 void ChromotingInstance::OnVideoFirstFrameReceived() { | 405 void ChromotingInstance::OnVideoFirstFrameReceived() { |
| 401 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 406 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 402 PostLegacyJsonMessage("onFirstFrameReceived", data.Pass()); | 407 PostLegacyJsonMessage("onFirstFrameReceived", data.Pass()); |
| 403 } | 408 } |
| 404 | 409 |
| 405 void ChromotingInstance::OnVideoSize(const webrtc::DesktopSize& size, | 410 void ChromotingInstance::OnVideoSize(const webrtc::DesktopSize& size, |
| 406 const webrtc::DesktopVector& dpi) { | 411 const webrtc::DesktopVector& dpi) { |
| 407 mouse_input_filter_.set_output_size(size); | 412 mouse_input_filter_.set_output_size(size); |
| 413 touch_input_scaler_.set_output_size(size); |
| 408 | 414 |
| 409 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 415 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 410 data->SetInteger("width", size.width()); | 416 data->SetInteger("width", size.width()); |
| 411 data->SetInteger("height", size.height()); | 417 data->SetInteger("height", size.height()); |
| 412 if (dpi.x()) | 418 if (dpi.x()) |
| 413 data->SetInteger("x_dpi", dpi.x()); | 419 data->SetInteger("x_dpi", dpi.x()); |
| 414 if (dpi.y()) | 420 if (dpi.y()) |
| 415 data->SetInteger("y_dpi", dpi.y()); | 421 data->SetInteger("y_dpi", dpi.y()); |
| 416 PostLegacyJsonMessage("onDesktopSize", data.Pass()); | 422 PostLegacyJsonMessage("onDesktopSize", data.Pass()); |
| 417 } | 423 } |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 | 687 |
| 682 if (!plugin_view_.is_null()) | 688 if (!plugin_view_.is_null()) |
| 683 video_renderer_->OnViewChanged(plugin_view_); | 689 video_renderer_->OnViewChanged(plugin_view_); |
| 684 | 690 |
| 685 scoped_ptr<AudioPlayer> audio_player(new PepperAudioPlayer(this)); | 691 scoped_ptr<AudioPlayer> audio_player(new PepperAudioPlayer(this)); |
| 686 client_.reset(new ChromotingClient(&context_, this, video_renderer_.get(), | 692 client_.reset(new ChromotingClient(&context_, this, video_renderer_.get(), |
| 687 audio_player.Pass())); | 693 audio_player.Pass())); |
| 688 | 694 |
| 689 // Connect the input pipeline to the protocol stub & initialize components. | 695 // Connect the input pipeline to the protocol stub & initialize components. |
| 690 mouse_input_filter_.set_input_stub(client_->input_stub()); | 696 mouse_input_filter_.set_input_stub(client_->input_stub()); |
| 697 touch_input_scaler_.set_input_stub(client_->input_stub()); |
| 691 if (!plugin_view_.is_null()) { | 698 if (!plugin_view_.is_null()) { |
| 692 mouse_input_filter_.set_input_size(webrtc::DesktopSize( | 699 webrtc::DesktopSize size(plugin_view_.GetRect().width(), |
| 693 plugin_view_.GetRect().width(), plugin_view_.GetRect().height())); | 700 plugin_view_.GetRect().height()); |
| 701 mouse_input_filter_.set_input_size(size); |
| 702 touch_input_scaler_.set_input_size(size); |
| 694 } | 703 } |
| 695 | 704 |
| 696 // Setup the signal strategy. | 705 // Setup the signal strategy. |
| 697 signal_strategy_.reset(new DelegatingSignalStrategy( | 706 signal_strategy_.reset(new DelegatingSignalStrategy( |
| 698 local_jid, base::Bind(&ChromotingInstance::SendOutgoingIq, | 707 local_jid, base::Bind(&ChromotingInstance::SendOutgoingIq, |
| 699 weak_factory_.GetWeakPtr()))); | 708 weak_factory_.GetWeakPtr()))); |
| 700 | 709 |
| 701 // Create TransportFactory. | 710 // Create TransportFactory. |
| 702 scoped_ptr<protocol::TransportFactory> transport_factory( | 711 scoped_ptr<protocol::TransportFactory> transport_factory( |
| 703 new protocol::LibjingleTransportFactory( | 712 new protocol::LibjingleTransportFactory( |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 const base::DictionaryValue& data) { | 981 const base::DictionaryValue& data) { |
| 973 bool enable = false; | 982 bool enable = false; |
| 974 if (!data.GetBoolean("enable", &enable)) { | 983 if (!data.GetBoolean("enable", &enable)) { |
| 975 LOG(ERROR) << "Invalid enableDebugRegion."; | 984 LOG(ERROR) << "Invalid enableDebugRegion."; |
| 976 return; | 985 return; |
| 977 } | 986 } |
| 978 | 987 |
| 979 video_renderer_->EnableDebugDirtyRegion(enable); | 988 video_renderer_->EnableDebugDirtyRegion(enable); |
| 980 } | 989 } |
| 981 | 990 |
| 991 void ChromotingInstance::HandleEnableTouchEvents() { |
| 992 RequestInputEvents(PP_INPUTEVENT_CLASS_TOUCH); |
| 993 } |
| 994 |
| 982 void ChromotingInstance::Disconnect() { | 995 void ChromotingInstance::Disconnect() { |
| 983 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 996 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
| 984 | 997 |
| 985 VLOG(0) << "Disconnecting from host."; | 998 VLOG(0) << "Disconnecting from host."; |
| 986 | 999 |
| 987 // Disconnect the input pipeline and teardown the connection. | 1000 // Disconnect the input pipeline and teardown the connection. |
| 988 mouse_input_filter_.set_input_stub(nullptr); | 1001 mouse_input_filter_.set_input_stub(nullptr); |
| 989 client_.reset(); | 1002 client_.reset(); |
| 990 video_renderer_.reset(); | 1003 video_renderer_.reset(); |
| 991 } | 1004 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 | 1188 |
| 1176 #if !defined(OS_NACL) | 1189 #if !defined(OS_NACL) |
| 1177 // Log messages are forwarded to the webapp only in PNaCl version of the | 1190 // Log messages are forwarded to the webapp only in PNaCl version of the |
| 1178 // plugin, so ProcessLogToUI() needs to be called explicitly in the non-PNaCl | 1191 // plugin, so ProcessLogToUI() needs to be called explicitly in the non-PNaCl |
| 1179 // version. | 1192 // version. |
| 1180 ProcessLogToUI(message); | 1193 ProcessLogToUI(message); |
| 1181 #endif // !defined(OS_NACL) | 1194 #endif // !defined(OS_NACL) |
| 1182 } | 1195 } |
| 1183 | 1196 |
| 1184 } // namespace remoting | 1197 } // namespace remoting |
| OLD | NEW |