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

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

Issue 7008003: Wire in OAuth2 support into non-sandboxed connections in libjingle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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) 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 371
371 return Var(); 372 return Var();
372 } 373 }
373 374
374 Var ChromotingScriptableObject::DoConnectUnsandboxed( 375 Var ChromotingScriptableObject::DoConnectUnsandboxed(
375 const std::vector<Var>& args, 376 const std::vector<Var>& args,
376 Var* exception) { 377 Var* exception) {
377 // Parameter order is: 378 // Parameter order is:
378 // host_jid 379 // host_jid
379 // username 380 // username
380 // xmpp_token 381 // auth_token
381 // access_code (optional) 382 // access_code (optional)
382 unsigned int arg = 0; 383 unsigned int arg = 0;
383 if (!args[arg].is_string()) { 384 if (!args[arg].is_string()) {
384 *exception = Var("The host_jid must be a string."); 385 *exception = Var("The host_jid must be a string.");
385 return Var(); 386 return Var();
386 } 387 }
387 std::string host_jid = args[arg++].AsString(); 388 std::string host_jid = args[arg++].AsString();
388 389
389 if (!args[arg].is_string()) { 390 if (!args[arg].is_string()) {
390 *exception = Var("The username must be a string."); 391 *exception = Var("The username must be a string.");
391 return Var(); 392 return Var();
392 } 393 }
393 std::string username = args[arg++].AsString(); 394 std::string username = args[arg++].AsString();
394 395
395 if (!args[arg].is_string()) { 396 if (!args[arg].is_string()) {
396 *exception = Var("The auth_token must be a string."); 397 *exception = Var("The auth_token_with_service must be a string.");
397 return Var(); 398 return Var();
398 } 399 }
399 std::string auth_token = args[arg++].AsString(); 400 std::string auth_token_with_service = args[arg++].AsString();
401
402 std::string auth_service;
403 std::string auth_token;
404 ParseAuthTokenWithService(auth_token_with_service, &auth_token,
405 &auth_service);
400 406
401 std::string access_code; 407 std::string access_code;
402 if (args.size() > arg) { 408 if (args.size() > arg) {
403 if (!args[arg].is_string()) { 409 if (!args[arg].is_string()) {
404 *exception = Var("The access code must be a string."); 410 *exception = Var("The access code must be a string.");
405 return Var(); 411 return Var();
406 } 412 }
407 access_code = args[arg++].AsString(); 413 access_code = args[arg++].AsString();
408 } 414 }
409 415
410 if (args.size() != arg) { 416 if (args.size() != arg) {
411 *exception = Var("Too many agruments passed to connect()."); 417 *exception = Var("Too many agruments passed to connect().");
412 return Var(); 418 return Var();
413 } 419 }
414 420
415 LogDebugInfo("Connecting to host."); 421 LogDebugInfo("Connecting to host.");
416 ClientConfig config; 422 ClientConfig config;
417 config.host_jid = host_jid; 423 config.host_jid = host_jid;
418 config.username = username; 424 config.username = username;
419 config.auth_token = auth_token; 425 config.auth_token = auth_token;
426 config.auth_service = auth_service;
420 config.nonce = access_code; 427 config.nonce = access_code;
421 VLOG(1) << "host_jid: " << host_jid << ", username: " << username 428 VLOG(1) << "host_jid: " << host_jid << ", username: " << username
429 << ", auth_service: " << auth_service
422 << ", access_code: " << access_code; 430 << ", access_code: " << access_code;
423 instance_->Connect(config); 431 instance_->Connect(config);
424 432
425 return Var(); 433 return Var();
426 } 434 }
427 435
428 Var ChromotingScriptableObject::DoDisconnect(const std::vector<Var>& args, 436 Var ChromotingScriptableObject::DoDisconnect(const std::vector<Var>& args,
429 Var* exception) { 437 Var* exception) {
430 LogDebugInfo("Disconnecting from host."); 438 LogDebugInfo("Disconnecting from host.");
431 439
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 *exception = Var("response_xml must be a string."); 493 *exception = Var("response_xml must be a string.");
486 return Var(); 494 return Var();
487 } 495 }
488 496
489 xmpp_proxy_->OnIq(args[0].AsString()); 497 xmpp_proxy_->OnIq(args[0].AsString());
490 498
491 return Var(); 499 return Var();
492 } 500 }
493 501
494 } // namespace remoting 502 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698