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/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
9 // TODO(wez): Remove this when crbug.com/86353 is complete. | 9 // TODO(wez): Remove this when crbug.com/86353 is complete. |
10 #include "ppapi/cpp/private/var_private.h" | 10 #include "ppapi/cpp/private/var_private.h" |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 LOG(ERROR) << "Exception when invoking sendiq JS callback."; | 358 LOG(ERROR) << "Exception when invoking sendiq JS callback."; |
359 } | 359 } |
360 | 360 |
361 Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args, | 361 Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args, |
362 Var* exception) { | 362 Var* exception) { |
363 // Parameter order is: | 363 // Parameter order is: |
364 // host_jid | 364 // host_jid |
365 // host_public_key | 365 // host_public_key |
366 // client_jid | 366 // client_jid |
367 // access_code (optional) | 367 // access_code (optional) |
368 // use_p2p_api (optional) | |
369 unsigned int arg = 0; | 368 unsigned int arg = 0; |
370 if (!args[arg].is_string()) { | 369 if (!args[arg].is_string()) { |
371 *exception = Var("The host_jid must be a string."); | 370 *exception = Var("The host_jid must be a string."); |
372 return Var(); | 371 return Var(); |
373 } | 372 } |
374 std::string host_jid = args[arg++].AsString(); | 373 std::string host_jid = args[arg++].AsString(); |
375 | 374 |
376 if (!args[arg].is_string()) { | 375 if (!args[arg].is_string()) { |
377 *exception = Var("The host_public_key must be a string."); | 376 *exception = Var("The host_public_key must be a string."); |
378 return Var(); | 377 return Var(); |
379 } | 378 } |
380 std::string host_public_key = args[arg++].AsString(); | 379 std::string host_public_key = args[arg++].AsString(); |
381 | 380 |
382 if (!args[arg].is_string()) { | 381 if (!args[arg].is_string()) { |
383 *exception = Var("The client_jid must be a string."); | 382 *exception = Var("The client_jid must be a string."); |
384 return Var(); | 383 return Var(); |
385 } | 384 } |
386 std::string client_jid = args[arg++].AsString(); | 385 std::string client_jid = args[arg++].AsString(); |
387 | 386 |
388 std::string access_code; | 387 std::string access_code; |
389 if (args.size() > arg) { | 388 if (args.size() > arg) { |
390 if (!args[arg].is_string()) { | 389 if (!args[arg].is_string()) { |
391 *exception = Var("The access code must be a string."); | 390 *exception = Var("The access code must be a string."); |
392 return Var(); | 391 return Var(); |
393 } | 392 } |
394 access_code = args[arg++].AsString(); | 393 access_code = args[arg++].AsString(); |
395 } | 394 } |
396 | 395 |
397 bool use_p2p_api = false; | |
398 if (args.size() > arg) { | |
399 if (!args[arg].is_bool()) { | |
400 *exception = Var("The use_p2p_api parameter must be a boolean."); | |
401 return Var(); | |
402 } | |
403 use_p2p_api = args[arg++].AsBool(); | |
404 } | |
405 | |
406 if (args.size() != arg) { | 396 if (args.size() != arg) { |
407 *exception = Var("Too many agruments passed to connect()."); | 397 *exception = Var("Too many agruments passed to connect()."); |
408 return Var(); | 398 return Var(); |
409 } | 399 } |
410 | 400 |
411 LOG(INFO) << "Connecting to host."; | 401 LOG(INFO) << "Connecting to host."; |
412 VLOG(1) << "client_jid: " << client_jid << ", host_jid: " << host_jid | 402 VLOG(1) << "client_jid: " << client_jid << ", host_jid: " << host_jid |
413 << ", access_code: " << access_code; | 403 << ", access_code: " << access_code; |
414 ClientConfig config; | 404 ClientConfig config; |
415 config.local_jid = client_jid; | 405 config.local_jid = client_jid; |
416 config.host_jid = host_jid; | 406 config.host_jid = host_jid; |
417 config.host_public_key = host_public_key; | 407 config.host_public_key = host_public_key; |
418 config.access_code = access_code; | 408 config.access_code = access_code; |
419 instance_->Connect(config, use_p2p_api); | 409 instance_->Connect(config); |
420 | 410 |
421 return Var(); | 411 return Var(); |
422 } | 412 } |
423 | 413 |
424 Var ChromotingScriptableObject::DoDisconnect(const std::vector<Var>& args, | 414 Var ChromotingScriptableObject::DoDisconnect(const std::vector<Var>& args, |
425 Var* exception) { | 415 Var* exception) { |
426 LOG(INFO) << "Disconnecting from host."; | 416 LOG(INFO) << "Disconnecting from host."; |
427 | 417 |
428 instance_->Disconnect(); | 418 instance_->Disconnect(); |
429 return Var(); | 419 return Var(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 const std::vector<pp::Var>& args, pp::Var* exception) { | 481 const std::vector<pp::Var>& args, pp::Var* exception) { |
492 if (args.size() != 0) { | 482 if (args.size() != 0) { |
493 *exception = Var("Usage: DoReleaseAllKeys()"); | 483 *exception = Var("Usage: DoReleaseAllKeys()"); |
494 return Var(); | 484 return Var(); |
495 } | 485 } |
496 instance_->ReleaseAllKeys(); | 486 instance_->ReleaseAllKeys(); |
497 return Var(); | 487 return Var(); |
498 } | 488 } |
499 | 489 |
500 } // namespace remoting | 490 } // namespace remoting |
OLD | NEW |