| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } else if (method == "requestPairing") { | 344 } else if (method == "requestPairing") { |
| 344 HandleRequestPairing(*data); | 345 HandleRequestPairing(*data); |
| 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(); |
| 354 } else if (method == "enableTouchEvents") { |
| 355 HandleEnableTouchEvents(); |
| 353 } | 356 } |
| 354 } | 357 } |
| 355 | 358 |
| 356 void ChromotingInstance::DidChangeFocus(bool has_focus) { | 359 void ChromotingInstance::DidChangeFocus(bool has_focus) { |
| 357 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 360 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
| 358 | 361 |
| 359 if (!IsConnected()) | 362 if (!IsConnected()) |
| 360 return; | 363 return; |
| 361 | 364 |
| 362 input_handler_.DidChangeFocus(has_focus); | 365 input_handler_.DidChangeFocus(has_focus); |
| 363 if (mouse_locker_) | 366 if (mouse_locker_) |
| 364 mouse_locker_->DidChangeFocus(has_focus); | 367 mouse_locker_->DidChangeFocus(has_focus); |
| 365 } | 368 } |
| 366 | 369 |
| 367 void ChromotingInstance::DidChangeView(const pp::View& view) { | 370 void ChromotingInstance::DidChangeView(const pp::View& view) { |
| 368 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 371 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
| 369 | 372 |
| 370 plugin_view_ = view; | 373 plugin_view_ = view; |
| 371 mouse_input_filter_.set_input_size( | 374 webrtc::DesktopSize size( |
| 372 webrtc::DesktopSize(view.GetRect().width(), view.GetRect().height())); | 375 webrtc::DesktopSize(view.GetRect().width(), view.GetRect().height())); |
| 376 mouse_input_filter_.set_input_size(size); |
| 377 touch_input_scaler_.set_input_size(size); |
| 373 | 378 |
| 374 if (video_renderer_) | 379 if (video_renderer_) |
| 375 video_renderer_->OnViewChanged(view); | 380 video_renderer_->OnViewChanged(view); |
| 376 } | 381 } |
| 377 | 382 |
| 378 bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { | 383 bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { |
| 379 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 384 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
| 380 | 385 |
| 381 if (!IsConnected()) | 386 if (!IsConnected()) |
| 382 return false; | 387 return false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 394 OnConnectionState(protocol::ConnectionToHost::FAILED, | 399 OnConnectionState(protocol::ConnectionToHost::FAILED, |
| 395 protocol::INCOMPATIBLE_PROTOCOL); | 400 protocol::INCOMPATIBLE_PROTOCOL); |
| 396 } | 401 } |
| 397 | 402 |
| 398 void ChromotingInstance::OnVideoFirstFrameReceived() { | 403 void ChromotingInstance::OnVideoFirstFrameReceived() { |
| 399 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 404 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 400 PostLegacyJsonMessage("onFirstFrameReceived", data.Pass()); | 405 PostLegacyJsonMessage("onFirstFrameReceived", data.Pass()); |
| 401 } | 406 } |
| 402 | 407 |
| 403 void ChromotingInstance::OnVideoSize(const webrtc::DesktopSize& size, | 408 void ChromotingInstance::OnVideoSize(const webrtc::DesktopSize& size, |
| 404 const webrtc::DesktopVector& dpi) { | 409 const webrtc::DesktopVector& dpi) { |
| 405 mouse_input_filter_.set_output_size(size); | 410 mouse_input_filter_.set_output_size(size); |
| 411 touch_input_scaler_.set_output_size(size); |
| 406 | 412 |
| 407 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 413 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 408 data->SetInteger("width", size.width()); | 414 data->SetInteger("width", size.width()); |
| 409 data->SetInteger("height", size.height()); | 415 data->SetInteger("height", size.height()); |
| 410 if (dpi.x()) | 416 if (dpi.x()) |
| 411 data->SetInteger("x_dpi", dpi.x()); | 417 data->SetInteger("x_dpi", dpi.x()); |
| 412 if (dpi.y()) | 418 if (dpi.y()) |
| 413 data->SetInteger("y_dpi", dpi.y()); | 419 data->SetInteger("y_dpi", dpi.y()); |
| 414 PostLegacyJsonMessage("onDesktopSize", data.Pass()); | 420 PostLegacyJsonMessage("onDesktopSize", data.Pass()); |
| 415 } | 421 } |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 | 663 |
| 658 if (!plugin_view_.is_null()) | 664 if (!plugin_view_.is_null()) |
| 659 video_renderer_->OnViewChanged(plugin_view_); | 665 video_renderer_->OnViewChanged(plugin_view_); |
| 660 | 666 |
| 661 scoped_ptr<AudioPlayer> audio_player(new PepperAudioPlayer(this)); | 667 scoped_ptr<AudioPlayer> audio_player(new PepperAudioPlayer(this)); |
| 662 client_.reset(new ChromotingClient(&context_, this, video_renderer_.get(), | 668 client_.reset(new ChromotingClient(&context_, this, video_renderer_.get(), |
| 663 audio_player.Pass())); | 669 audio_player.Pass())); |
| 664 | 670 |
| 665 // Connect the input pipeline to the protocol stub & initialize components. | 671 // Connect the input pipeline to the protocol stub & initialize components. |
| 666 mouse_input_filter_.set_input_stub(client_->input_stub()); | 672 mouse_input_filter_.set_input_stub(client_->input_stub()); |
| 673 touch_input_scaler_.set_input_stub(client_->input_stub()); |
| 667 if (!plugin_view_.is_null()) { | 674 if (!plugin_view_.is_null()) { |
| 668 mouse_input_filter_.set_input_size(webrtc::DesktopSize( | 675 webrtc::DesktopSize size(plugin_view_.GetRect().width(), |
| 669 plugin_view_.GetRect().width(), plugin_view_.GetRect().height())); | 676 plugin_view_.GetRect().height()); |
| 677 mouse_input_filter_.set_input_size(size); |
| 678 touch_input_scaler_.set_input_size(size); |
| 670 } | 679 } |
| 671 | 680 |
| 672 // Setup the signal strategy. | 681 // Setup the signal strategy. |
| 673 signal_strategy_.reset(new DelegatingSignalStrategy( | 682 signal_strategy_.reset(new DelegatingSignalStrategy( |
| 674 local_jid, base::Bind(&ChromotingInstance::SendOutgoingIq, | 683 local_jid, base::Bind(&ChromotingInstance::SendOutgoingIq, |
| 675 weak_factory_.GetWeakPtr()))); | 684 weak_factory_.GetWeakPtr()))); |
| 676 | 685 |
| 677 // Create TransportFactory. | 686 // Create TransportFactory. |
| 678 scoped_ptr<protocol::TransportFactory> transport_factory( | 687 scoped_ptr<protocol::TransportFactory> transport_factory( |
| 679 new protocol::LibjingleTransportFactory( | 688 new protocol::LibjingleTransportFactory( |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 } | 946 } |
| 938 | 947 |
| 939 void ChromotingInstance::HandleSendMouseInputWhenUnfocused() { | 948 void ChromotingInstance::HandleSendMouseInputWhenUnfocused() { |
| 940 input_handler_.set_send_mouse_input_when_unfocused(true); | 949 input_handler_.set_send_mouse_input_when_unfocused(true); |
| 941 } | 950 } |
| 942 | 951 |
| 943 void ChromotingInstance::HandleDelegateLargeCursors() { | 952 void ChromotingInstance::HandleDelegateLargeCursors() { |
| 944 cursor_setter_.set_delegate_stub(this); | 953 cursor_setter_.set_delegate_stub(this); |
| 945 } | 954 } |
| 946 | 955 |
| 956 void ChromotingInstance::HandleEnableTouchEvents() { |
| 957 RequestInputEvents(PP_INPUTEVENT_CLASS_TOUCH); |
| 958 } |
| 959 |
| 947 void ChromotingInstance::Disconnect() { | 960 void ChromotingInstance::Disconnect() { |
| 948 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 961 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
| 949 | 962 |
| 950 VLOG(0) << "Disconnecting from host."; | 963 VLOG(0) << "Disconnecting from host."; |
| 951 | 964 |
| 952 // Disconnect the input pipeline and teardown the connection. | 965 // Disconnect the input pipeline and teardown the connection. |
| 953 mouse_input_filter_.set_input_stub(nullptr); | 966 mouse_input_filter_.set_input_stub(nullptr); |
| 954 client_.reset(); | 967 client_.reset(); |
| 955 video_renderer_.reset(); | 968 video_renderer_.reset(); |
| 956 } | 969 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 url_components.scheme.len); | 1140 url_components.scheme.len); |
| 1128 return url_scheme == kChromeExtensionUrlScheme; | 1141 return url_scheme == kChromeExtensionUrlScheme; |
| 1129 } | 1142 } |
| 1130 | 1143 |
| 1131 bool ChromotingInstance::IsConnected() { | 1144 bool ChromotingInstance::IsConnected() { |
| 1132 return client_ && | 1145 return client_ && |
| 1133 (client_->connection_state() == protocol::ConnectionToHost::CONNECTED); | 1146 (client_->connection_state() == protocol::ConnectionToHost::CONNECTED); |
| 1134 } | 1147 } |
| 1135 | 1148 |
| 1136 } // namespace remoting | 1149 } // namespace remoting |
| OLD | NEW |