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

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

Issue 22477006: Added JsonMessage to the control channel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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/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 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 base::LazyInstance<base::Lock>::Leaky 137 base::LazyInstance<base::Lock>::Leaky
138 g_logging_lock = LAZY_INSTANCE_INITIALIZER; 138 g_logging_lock = LAZY_INSTANCE_INITIALIZER;
139 logging::LogMessageHandlerFunction g_logging_old_handler = NULL; 139 logging::LogMessageHandlerFunction g_logging_old_handler = NULL;
140 140
141 } // namespace 141 } // namespace
142 142
143 // String sent in the "hello" message to the webapp to describe features. 143 // String sent in the "hello" message to the webapp to describe features.
144 const char ChromotingInstance::kApiFeatures[] = 144 const char ChromotingInstance::kApiFeatures[] =
145 "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey " 145 "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey "
146 "notifyClientDimensions notifyClientResolution pauseVideo pauseAudio " 146 "notifyClientDimensions notifyClientResolution pauseVideo pauseAudio "
147 "asyncPin thirdPartyAuth pinlessAuth"; 147 "asyncPin thirdPartyAuth pinlessAuth jsonMessage";
148 148
149 const char ChromotingInstance::kRequestedCapabilities[] = ""; 149 const char ChromotingInstance::kRequestedCapabilities[] = "";
150 const char ChromotingInstance::kSupportedCapabilities[] = "desktopShape"; 150 const char ChromotingInstance::kSupportedCapabilities[] = "desktopShape";
151 151
152 bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, 152 bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str,
153 ClientConfig* config) { 153 ClientConfig* config) {
154 std::vector<std::string> auth_methods; 154 std::vector<std::string> auth_methods;
155 base::SplitString(auth_methods_str, ',', &auth_methods); 155 base::SplitString(auth_methods_str, ',', &auth_methods);
156 for (std::vector<std::string>::iterator it = auth_methods.begin(); 156 for (std::vector<std::string>::iterator it = auth_methods.begin();
157 it != auth_methods.end(); ++it) { 157 it != auth_methods.end(); ++it) {
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 return; 426 return;
427 } 427 }
428 OnThirdPartyTokenFetched(token, shared_secret); 428 OnThirdPartyTokenFetched(token, shared_secret);
429 } else if (method == "requestPairing") { 429 } else if (method == "requestPairing") {
430 std::string client_name; 430 std::string client_name;
431 if (!data->GetString("clientName", &client_name)) { 431 if (!data->GetString("clientName", &client_name)) {
432 LOG(ERROR) << "Invalid requestPairing"; 432 LOG(ERROR) << "Invalid requestPairing";
433 return; 433 return;
434 } 434 }
435 RequestPairing(client_name); 435 RequestPairing(client_name);
436 } else if (method == "jsonMessage") {
437 std::string type, json;
438 if (!data->GetString("type", &type) || !data->GetString("json", &json)) {
439 LOG(ERROR) << "Invalid jsonMessage.";
440 return;
441 }
442 SendClientJson(type, json);
Wez 2013/08/09 21:25:48 Why not leave it up to the caller to choose the fo
Jamie 2013/08/09 21:39:06 In case we want to have more than one supported me
436 } 443 }
437 } 444 }
438 445
439 void ChromotingInstance::DidChangeView(const pp::View& view) { 446 void ChromotingInstance::DidChangeView(const pp::View& view) {
440 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 447 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
441 448
442 plugin_view_ = view; 449 plugin_view_ = view;
443 if (view_) { 450 if (view_) {
444 view_->SetView(view); 451 view_->SetView(view);
445 mouse_input_filter_.set_input_size(view_->get_view_size_dips()); 452 mouse_input_filter_.set_input_size(view_->get_view_size_dips());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 537 }
531 538
532 void ChromotingInstance::SetPairingResponse( 539 void ChromotingInstance::SetPairingResponse(
533 const protocol::PairingResponse& pairing_response) { 540 const protocol::PairingResponse& pairing_response) {
534 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 541 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
535 data->SetString("clientId", pairing_response.client_id()); 542 data->SetString("clientId", pairing_response.client_id());
536 data->SetString("sharedSecret", pairing_response.shared_secret()); 543 data->SetString("sharedSecret", pairing_response.shared_secret());
537 PostChromotingMessage("pairingResponse", data.Pass()); 544 PostChromotingMessage("pairingResponse", data.Pass());
538 } 545 }
539 546
547 void ChromotingInstance::ProcessHostJson(const protocol::JsonMessage& message) {
548 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
549 data->SetString("type", message.type());
550 data->SetString("json", message.json());
551 PostChromotingMessage("jsonMessage", data.Pass());
552 }
553
540 void ChromotingInstance::FetchSecretFromDialog( 554 void ChromotingInstance::FetchSecretFromDialog(
541 bool pairing_supported, 555 bool pairing_supported,
542 const protocol::SecretFetchedCallback& secret_fetched_callback) { 556 const protocol::SecretFetchedCallback& secret_fetched_callback) {
543 // Once the Session object calls this function, it won't continue the 557 // Once the Session object calls this function, it won't continue the
544 // authentication until the callback is called (or connection is canceled). 558 // authentication until the callback is called (or connection is canceled).
545 // So, it's impossible to reach this with a callback already registered. 559 // So, it's impossible to reach this with a callback already registered.
546 DCHECK(secret_fetched_callback_.is_null()); 560 DCHECK(secret_fetched_callback_.is_null());
547 secret_fetched_callback_ = secret_fetched_callback; 561 secret_fetched_callback_ = secret_fetched_callback;
548 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 562 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
549 data->SetBoolean("pairingSupported", pairing_supported); 563 data->SetBoolean("pairingSupported", pairing_supported);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 846
833 void ChromotingInstance::RequestPairing(const std::string& client_name) { 847 void ChromotingInstance::RequestPairing(const std::string& client_name) {
834 if (!IsConnected()) { 848 if (!IsConnected()) {
835 return; 849 return;
836 } 850 }
837 protocol::PairingRequest pairing_request; 851 protocol::PairingRequest pairing_request;
838 pairing_request.set_client_name(client_name); 852 pairing_request.set_client_name(client_name);
839 host_connection_->host_stub()->RequestPairing(pairing_request); 853 host_connection_->host_stub()->RequestPairing(pairing_request);
840 } 854 }
841 855
856 void ChromotingInstance::SendClientJson(const std::string& type,
857 const std::string& json) {
858 if (!IsConnected()) {
859 return;
860 }
861 protocol::JsonMessage message;
862 message.set_type(type);
863 message.set_json(json);
864 host_connection_->host_stub()->ProcessClientJson(message);
865 }
866
842 ChromotingStats* ChromotingInstance::GetStats() { 867 ChromotingStats* ChromotingInstance::GetStats() {
843 if (!client_.get()) 868 if (!client_.get())
844 return NULL; 869 return NULL;
845 return client_->GetStats(); 870 return client_->GetStats();
846 } 871 }
847 872
848 void ChromotingInstance::PostChromotingMessage( 873 void ChromotingInstance::PostChromotingMessage(
849 const std::string& method, 874 const std::string& method,
850 scoped_ptr<base::DictionaryValue> data) { 875 scoped_ptr<base::DictionaryValue> data) {
851 scoped_ptr<base::DictionaryValue> message(new base::DictionaryValue()); 876 scoped_ptr<base::DictionaryValue> message(new base::DictionaryValue());
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 url_components.scheme.len); 1034 url_components.scheme.len);
1010 return url_scheme == kChromeExtensionUrlScheme; 1035 return url_scheme == kChromeExtensionUrlScheme;
1011 } 1036 }
1012 1037
1013 bool ChromotingInstance::IsConnected() { 1038 bool ChromotingInstance::IsConnected() {
1014 return host_connection_.get() && 1039 return host_connection_.get() &&
1015 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); 1040 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED);
1016 } 1041 }
1017 1042
1018 } // namespace remoting 1043 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698