OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_scriptable_object.h" | 5 #include "remoting/client/plugin/chromoting_scriptable_object.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "ppapi/cpp/var.h" | 9 #include "ppapi/cpp/var.h" |
| 10 #include "remoting/base/auth_token_util.h" |
10 #include "remoting/client/client_config.h" | 11 #include "remoting/client/client_config.h" |
11 #include "remoting/client/chromoting_stats.h" | 12 #include "remoting/client/chromoting_stats.h" |
12 #include "remoting/client/plugin/chromoting_instance.h" | 13 #include "remoting/client/plugin/chromoting_instance.h" |
13 #include "remoting/client/plugin/pepper_xmpp_proxy.h" | 14 #include "remoting/client/plugin/pepper_xmpp_proxy.h" |
14 | 15 |
15 using pp::Var; | 16 using pp::Var; |
16 | 17 |
17 namespace remoting { | 18 namespace remoting { |
18 | 19 |
19 namespace { | 20 namespace { |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 | 381 |
381 return Var(); | 382 return Var(); |
382 } | 383 } |
383 | 384 |
384 Var ChromotingScriptableObject::DoConnectUnsandboxed( | 385 Var ChromotingScriptableObject::DoConnectUnsandboxed( |
385 const std::vector<Var>& args, | 386 const std::vector<Var>& args, |
386 Var* exception) { | 387 Var* exception) { |
387 // Parameter order is: | 388 // Parameter order is: |
388 // host_jid | 389 // host_jid |
389 // username | 390 // username |
390 // xmpp_token | 391 // auth_token |
391 // access_code (optional) | 392 // access_code (optional) |
392 unsigned int arg = 0; | 393 unsigned int arg = 0; |
393 if (!args[arg].is_string()) { | 394 if (!args[arg].is_string()) { |
394 *exception = Var("The host_jid must be a string."); | 395 *exception = Var("The host_jid must be a string."); |
395 return Var(); | 396 return Var(); |
396 } | 397 } |
397 std::string host_jid = args[arg++].AsString(); | 398 std::string host_jid = args[arg++].AsString(); |
398 | 399 |
399 if (!args[arg].is_string()) { | 400 if (!args[arg].is_string()) { |
400 *exception = Var("The username must be a string."); | 401 *exception = Var("The username must be a string."); |
401 return Var(); | 402 return Var(); |
402 } | 403 } |
403 std::string username = args[arg++].AsString(); | 404 std::string username = args[arg++].AsString(); |
404 | 405 |
405 if (!args[arg].is_string()) { | 406 if (!args[arg].is_string()) { |
406 *exception = Var("The auth_token must be a string."); | 407 *exception = Var("The auth_token_with_service must be a string."); |
407 return Var(); | 408 return Var(); |
408 } | 409 } |
409 std::string auth_token = args[arg++].AsString(); | 410 std::string auth_token_with_service = args[arg++].AsString(); |
| 411 |
| 412 std::string auth_service; |
| 413 std::string auth_token; |
| 414 ParseAuthTokenWithService(auth_token_with_service, &auth_token, |
| 415 &auth_service); |
410 | 416 |
411 std::string access_code; | 417 std::string access_code; |
412 if (args.size() > arg) { | 418 if (args.size() > arg) { |
413 if (!args[arg].is_string()) { | 419 if (!args[arg].is_string()) { |
414 *exception = Var("The access code must be a string."); | 420 *exception = Var("The access code must be a string."); |
415 return Var(); | 421 return Var(); |
416 } | 422 } |
417 access_code = args[arg++].AsString(); | 423 access_code = args[arg++].AsString(); |
418 } | 424 } |
419 | 425 |
420 if (args.size() != arg) { | 426 if (args.size() != arg) { |
421 *exception = Var("Too many agruments passed to connect()."); | 427 *exception = Var("Too many agruments passed to connect()."); |
422 return Var(); | 428 return Var(); |
423 } | 429 } |
424 | 430 |
425 LogDebugInfo("Connecting to host."); | 431 LogDebugInfo("Connecting to host."); |
426 ClientConfig config; | 432 ClientConfig config; |
427 config.host_jid = host_jid; | 433 config.host_jid = host_jid; |
428 config.username = username; | 434 config.username = username; |
429 config.auth_token = auth_token; | 435 config.auth_token = auth_token; |
| 436 config.auth_service = auth_service; |
430 config.nonce = access_code; | 437 config.nonce = access_code; |
431 VLOG(1) << "host_jid: " << host_jid << ", username: " << username | 438 VLOG(1) << "host_jid: " << host_jid << ", username: " << username |
| 439 << ", auth_service: " << auth_service |
432 << ", access_code: " << access_code; | 440 << ", access_code: " << access_code; |
433 instance_->Connect(config); | 441 instance_->Connect(config); |
434 | 442 |
435 return Var(); | 443 return Var(); |
436 } | 444 } |
437 | 445 |
438 Var ChromotingScriptableObject::DoDisconnect(const std::vector<Var>& args, | 446 Var ChromotingScriptableObject::DoDisconnect(const std::vector<Var>& args, |
439 Var* exception) { | 447 Var* exception) { |
440 LogDebugInfo("Disconnecting from host."); | 448 LogDebugInfo("Disconnecting from host."); |
441 | 449 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 *exception = Var("response_xml must be a string."); | 503 *exception = Var("response_xml must be a string."); |
496 return Var(); | 504 return Var(); |
497 } | 505 } |
498 | 506 |
499 xmpp_proxy_->OnIq(args[0].AsString()); | 507 xmpp_proxy_->OnIq(args[0].AsString()); |
500 | 508 |
501 return Var(); | 509 return Var(); |
502 } | 510 } |
503 | 511 |
504 } // namespace remoting | 512 } // namespace remoting |
OLD | NEW |