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 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 logging::LogMessageHandlerFunction g_logging_old_handler = NULL; | 132 logging::LogMessageHandlerFunction g_logging_old_handler = NULL; |
133 | 133 |
134 } // namespace | 134 } // namespace |
135 | 135 |
136 // String sent in the "hello" message to the plugin to describe features. | 136 // String sent in the "hello" message to the plugin to describe features. |
137 const char ChromotingInstance::kApiFeatures[] = | 137 const char ChromotingInstance::kApiFeatures[] = |
138 "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey " | 138 "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey " |
139 "notifyClientDimensions notifyClientResolution pauseVideo pauseAudio " | 139 "notifyClientDimensions notifyClientResolution pauseVideo pauseAudio " |
140 "asyncPin thirdPartyAuth"; | 140 "asyncPin thirdPartyAuth"; |
141 | 141 |
142 const char ChromotingInstance::kRequestedCapabilities[] = ""; | |
143 const char ChromotingInstance::kSupportedCapabilities[] = ""; | |
144 | |
142 bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, | 145 bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, |
143 ClientConfig* config) { | 146 ClientConfig* config) { |
144 std::vector<std::string> auth_methods; | 147 std::vector<std::string> auth_methods; |
145 base::SplitString(auth_methods_str, ',', &auth_methods); | 148 base::SplitString(auth_methods_str, ',', &auth_methods); |
146 for (std::vector<std::string>::iterator it = auth_methods.begin(); | 149 for (std::vector<std::string>::iterator it = auth_methods.begin(); |
147 it != auth_methods.end(); ++it) { | 150 it != auth_methods.end(); ++it) { |
148 protocol::AuthenticationMethod authentication_method = | 151 protocol::AuthenticationMethod authentication_method = |
149 protocol::AuthenticationMethod::FromString(*it); | 152 protocol::AuthenticationMethod::FromString(*it); |
150 if (authentication_method.is_valid()) | 153 if (authentication_method.is_valid()) |
151 config->authentication_methods.push_back(authentication_method); | 154 config->authentication_methods.push_back(authentication_method); |
(...skipping 28 matching lines...) Expand all Loading... | |
180 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); | 183 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); |
181 | 184 |
182 // Resister this instance to handle debug log messsages. | 185 // Resister this instance to handle debug log messsages. |
183 RegisterLoggingInstance(); | 186 RegisterLoggingInstance(); |
184 | 187 |
185 // Send hello message. | 188 // Send hello message. |
186 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 189 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
187 data->SetInteger("apiVersion", kApiVersion); | 190 data->SetInteger("apiVersion", kApiVersion); |
188 data->SetString("apiFeatures", kApiFeatures); | 191 data->SetString("apiFeatures", kApiFeatures); |
189 data->SetInteger("apiMinVersion", kApiMinMessagingVersion); | 192 data->SetInteger("apiMinVersion", kApiMinMessagingVersion); |
193 data->SetString("requestedCapabilities", kRequestedCapabilities); | |
Sergey Ulanov
2013/04/16 08:38:53
It's not clear to me what's the difference between
alexeypa (please no reviews)
2013/04/16 22:06:11
"requested" capabilities are the ones that need to
| |
194 data->SetString("supportedCapabilities", kSupportedCapabilities); | |
195 | |
190 PostChromotingMessage("hello", data.Pass()); | 196 PostChromotingMessage("hello", data.Pass()); |
191 } | 197 } |
192 | 198 |
193 ChromotingInstance::~ChromotingInstance() { | 199 ChromotingInstance::~ChromotingInstance() { |
194 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 200 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
195 | 201 |
196 // Unregister this instance so that debug log messages will no longer be sent | 202 // Unregister this instance so that debug log messages will no longer be sent |
197 // to it. This will stop all logging in all Chromoting instances. | 203 // to it. This will stop all logging in all Chromoting instances. |
198 UnregisterLoggingInstance(); | 204 UnregisterLoggingInstance(); |
199 | 205 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 this->AsWeakPtr()); | 292 this->AsWeakPtr()); |
287 } else { | 293 } else { |
288 std::string shared_secret; | 294 std::string shared_secret; |
289 if (!data->GetString("sharedSecret", &shared_secret)) { | 295 if (!data->GetString("sharedSecret", &shared_secret)) { |
290 LOG(ERROR) << "sharedSecret not specified in connect()."; | 296 LOG(ERROR) << "sharedSecret not specified in connect()."; |
291 return; | 297 return; |
292 } | 298 } |
293 config.fetch_secret_callback = | 299 config.fetch_secret_callback = |
294 base::Bind(&ChromotingInstance::FetchSecretFromString, shared_secret); | 300 base::Bind(&ChromotingInstance::FetchSecretFromString, shared_secret); |
295 } | 301 } |
302 | |
303 // Read the list of capabilities, if any. | |
304 base::ListValue* capabilities = NULL; | |
305 if (data->GetList("capabilities", &capabilities)) { | |
Sergey Ulanov
2013/04/16 08:38:53
Here capablities are represented as list, while re
alexeypa (please no reviews)
2013/04/16 22:06:11
Done.
| |
306 if (!config.capabilities.FromListValue(*capabilities)) { | |
307 LOG(ERROR) << "capabilities are invalid in connect()."; | |
308 return; | |
309 } | |
310 } | |
311 | |
296 Connect(config); | 312 Connect(config); |
297 } else if (method == "disconnect") { | 313 } else if (method == "disconnect") { |
298 Disconnect(); | 314 Disconnect(); |
299 } else if (method == "incomingIq") { | 315 } else if (method == "incomingIq") { |
300 std::string iq; | 316 std::string iq; |
301 if (!data->GetString("iq", &iq)) { | 317 if (!data->GetString("iq", &iq)) { |
302 LOG(ERROR) << "Invalid onIq() data."; | 318 LOG(ERROR) << "Invalid onIq() data."; |
303 return; | 319 return; |
304 } | 320 } |
305 OnIncomingIq(iq); | 321 OnIncomingIq(iq); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 data->SetString("scope", scope); | 483 data->SetString("scope", scope); |
468 PostChromotingMessage("fetchThirdPartyToken", data.Pass()); | 484 PostChromotingMessage("fetchThirdPartyToken", data.Pass()); |
469 } | 485 } |
470 | 486 |
471 void ChromotingInstance::OnConnectionReady(bool ready) { | 487 void ChromotingInstance::OnConnectionReady(bool ready) { |
472 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 488 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
473 data->SetBoolean("ready", ready); | 489 data->SetBoolean("ready", ready); |
474 PostChromotingMessage("onConnectionReady", data.Pass()); | 490 PostChromotingMessage("onConnectionReady", data.Pass()); |
475 } | 491 } |
476 | 492 |
493 void ChromotingInstance::SetCapabilities(const std::string& capabilities) { | |
494 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | |
495 data->SetString("capabilities", capabilities); | |
496 PostChromotingMessage("setCapabilities", data.Pass()); | |
497 } | |
498 | |
477 void ChromotingInstance::FetchSecretFromDialog( | 499 void ChromotingInstance::FetchSecretFromDialog( |
478 const protocol::SecretFetchedCallback& secret_fetched_callback) { | 500 const protocol::SecretFetchedCallback& secret_fetched_callback) { |
479 // Once the Session object calls this function, it won't continue the | 501 // Once the Session object calls this function, it won't continue the |
480 // authentication until the callback is called (or connection is canceled). | 502 // authentication until the callback is called (or connection is canceled). |
481 // So, it's impossible to reach this with a callback already registered. | 503 // So, it's impossible to reach this with a callback already registered. |
482 DCHECK(secret_fetched_callback_.is_null()); | 504 DCHECK(secret_fetched_callback_.is_null()); |
483 secret_fetched_callback_ = secret_fetched_callback; | 505 secret_fetched_callback_ = secret_fetched_callback; |
484 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 506 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
485 PostChromotingMessage("fetchPin", data.Pass()); | 507 PostChromotingMessage("fetchPin", data.Pass()); |
486 } | 508 } |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
914 url_components.scheme.len); | 936 url_components.scheme.len); |
915 return url_scheme == kChromeExtensionUrlScheme; | 937 return url_scheme == kChromeExtensionUrlScheme; |
916 } | 938 } |
917 | 939 |
918 bool ChromotingInstance::IsConnected() { | 940 bool ChromotingInstance::IsConnected() { |
919 return host_connection_.get() && | 941 return host_connection_.get() && |
920 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); | 942 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); |
921 } | 943 } |
922 | 944 |
923 } // namespace remoting | 945 } // namespace remoting |
OLD | NEW |