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

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

Issue 7042022: Add separate nonce version of connect call. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: really remove webapp files 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/client/client_config.h" 10 #include "remoting/client/client_config.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 // Statistics. 79 // Statistics.
80 AddAttribute(kVideoBandwidthAttribute, Var()); 80 AddAttribute(kVideoBandwidthAttribute, Var());
81 AddAttribute(kVideoCaptureLatencyAttribute, Var()); 81 AddAttribute(kVideoCaptureLatencyAttribute, Var());
82 AddAttribute(kVideoEncodeLatencyAttribute, Var()); 82 AddAttribute(kVideoEncodeLatencyAttribute, Var());
83 AddAttribute(kVideoDecodeLatencyAttribute, Var()); 83 AddAttribute(kVideoDecodeLatencyAttribute, Var());
84 AddAttribute(kVideoRenderLatencyAttribute, Var()); 84 AddAttribute(kVideoRenderLatencyAttribute, Var());
85 AddAttribute(kRoundTripLatencyAttribute, Var()); 85 AddAttribute(kRoundTripLatencyAttribute, Var());
86 86
87 AddMethod("connect", &ChromotingScriptableObject::DoConnect); 87 AddMethod("connect", &ChromotingScriptableObject::DoConnect);
88 AddMethod("connectNonce", &ChromotingScriptableObject::DoConnectNonce);
88 AddMethod("connectSandboxed", 89 AddMethod("connectSandboxed",
89 &ChromotingScriptableObject::DoConnectSandboxed); 90 &ChromotingScriptableObject::DoConnectSandboxed);
91 AddMethod("connectSandboxedNonce",
92 &ChromotingScriptableObject::DoConnectSandboxedNonce);
Wez 2011/05/20 22:38:59 Why are you still adding these?
90 AddMethod("disconnect", &ChromotingScriptableObject::DoDisconnect); 93 AddMethod("disconnect", &ChromotingScriptableObject::DoDisconnect);
91 AddMethod("submitLoginInfo", &ChromotingScriptableObject::DoSubmitLogin); 94 AddMethod("submitLoginInfo", &ChromotingScriptableObject::DoSubmitLogin);
92 AddMethod("setScaleToFit", &ChromotingScriptableObject::DoSetScaleToFit); 95 AddMethod("setScaleToFit", &ChromotingScriptableObject::DoSetScaleToFit);
93 AddMethod("onIq", &ChromotingScriptableObject::DoOnIq); 96 AddMethod("onIq", &ChromotingScriptableObject::DoOnIq);
94 } 97 }
95 98
96 bool ChromotingScriptableObject::HasProperty(const Var& name, Var* exception) { 99 bool ChromotingScriptableObject::HasProperty(const Var& name, Var* exception) {
97 // TODO(ajwong): Check if all these name.is_string() sentinels are required. 100 // TODO(ajwong): Check if all these name.is_string() sentinels are required.
98 if (!name.is_string()) { 101 if (!name.is_string()) {
99 *exception = Var("HasProperty expects a string for the name."); 102 *exception = Var("HasProperty expects a string for the name.");
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 323
321 void ChromotingScriptableObject::SendIq(const std::string& message_xml) { 324 void ChromotingScriptableObject::SendIq(const std::string& message_xml) {
322 Var exception; 325 Var exception;
323 Var cb = GetProperty(Var(kSendIq), &exception); 326 Var cb = GetProperty(Var(kSendIq), &exception);
324 327
325 // Var() means call the object directly as a function rather than calling 328 // Var() means call the object directly as a function rather than calling
326 // a method in the object. 329 // a method in the object.
327 cb.Call(Var(), Var(message_xml), &exception); 330 cb.Call(Var(), Var(message_xml), &exception);
328 331
329 if (!exception.is_undefined()) 332 if (!exception.is_undefined())
330 LogDebugInfo("Exception when invoking loginChallenge JS callback."); 333 LogDebugInfo("Exception when invoking sendiq JS callback.");
Wez 2011/05/20 22:38:59 Is This the correct callback name?
331 } 334 }
332 335
333 Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args, 336 Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args,
334 Var* exception) { 337 Var* exception) {
335 if (args.size() != 4) { 338 if (args.size() != 3) {
336 *exception = Var("Usage: connect(username, host_jid, auth_token)"); 339 *exception = Var("Usage: connect(username, host_jid, auth_token)");
337 return Var(); 340 return Var();
338 } 341 }
339 342
343 return DoConnect_(args, exception, false);
344 }
345
346 Var ChromotingScriptableObject::DoConnectNonce(const std::vector<Var>& args,
347 Var* exception) {
348 if (args.size() != 4) {
349 *exception = Var("Usage: connect(username, host_jid, auth_token, nonce)");
350 return Var();
351 }
352
353 return DoConnect_(args, exception, true);
354 }
355
356 Var ChromotingScriptableObject::DoConnect_(const std::vector<Var>& args,
357 Var* exception,
358 bool require_nonce) {
340 ClientConfig config; 359 ClientConfig config;
341 360
342 if (!args[0].is_string()) { 361 if (!args[0].is_string()) {
343 *exception = Var("The username must be a string."); 362 *exception = Var("The username must be a string.");
344 return Var(); 363 return Var();
345 } 364 }
346 config.username = args[0].AsString(); 365 config.username = args[0].AsString();
347 366
348 if (!args[1].is_string()) { 367 if (!args[1].is_string()) {
349 *exception = Var("The host_jid must be a string."); 368 *exception = Var("The host_jid must be a string.");
350 return Var(); 369 return Var();
351 } 370 }
352 config.host_jid = args[1].AsString(); 371 config.host_jid = args[1].AsString();
353 372
354 if (!args[2].is_string()) { 373 if (!args[2].is_string()) {
355 *exception = Var("The auth_token must be a string."); 374 *exception = Var("The auth_token must be a string.");
356 return Var(); 375 return Var();
357 } 376 }
358 config.auth_token = args[2].AsString(); 377 config.auth_token = args[2].AsString();
359 378
360 if (!args[3].is_string()) { 379 if (require_nonce) {
361 *exception = Var("nonce must be a string."); 380 if (!args[3].is_string()) {
362 return Var(); 381 *exception = Var("nonce must be a string.");
382 return Var();
383 }
384 config.nonce = args[3].AsString();
363 } 385 }
364 config.nonce = args[3].AsString();
365 386
366 LogDebugInfo("Connecting to host."); 387 LogDebugInfo("Connecting to host.");
367 instance_->Connect(config); 388 instance_->Connect(config);
368 389
369 return Var(); 390 return Var();
370 } 391 }
371 392
372 Var ChromotingScriptableObject::DoConnectSandboxed( 393 Var ChromotingScriptableObject::DoConnectSandboxed(
373 const std::vector<Var>& args, Var* exception) { 394 const std::vector<Var>& args, Var* exception) {
395 if (args.size() != 2) {
396 *exception = Var("Usage: connectSandboxed(your_jid, host_jid)");
397 return Var();
398 }
399
400 return DoConnectSandboxed_(args, exception, false);
401 }
402
403 Var ChromotingScriptableObject::DoConnectSandboxedNonce(
404 const std::vector<Var>& args, Var* exception) {
374 if (args.size() != 3) { 405 if (args.size() != 3) {
375 *exception = Var("Usage: connectSandboxed(your_jid, host_jid, nonce)"); 406 *exception = Var("Usage: connectSandboxed(your_jid, host_jid, nonce)");
376 return Var(); 407 return Var();
377 } 408 }
378 409
410 return DoConnectSandboxed_(args, exception, true);
411 }
412
413 Var ChromotingScriptableObject::DoConnectSandboxed_(
414 const std::vector<Var>& args, Var* exception, bool require_nonce) {
379 std::string your_jid; 415 std::string your_jid;
380 if (!args[0].is_string()) { 416 if (!args[0].is_string()) {
381 *exception = Var("your_jid must be a string."); 417 *exception = Var("your_jid must be a string.");
382 return Var(); 418 return Var();
383 } 419 }
384 your_jid = args[0].AsString(); 420 your_jid = args[0].AsString();
385 421
386 std::string host_jid; 422 std::string host_jid;
387 if (!args[1].is_string()) { 423 if (!args[1].is_string()) {
388 *exception = Var("host_jid must be a string."); 424 *exception = Var("host_jid must be a string.");
389 return Var(); 425 return Var();
390 } 426 }
391 host_jid = args[1].AsString(); 427 host_jid = args[1].AsString();
392 428
393 std::string nonce; 429 std::string nonce;
394 if (!args[2].is_string()) { 430 if (require_nonce) {
395 *exception = Var("nonce must be a string."); 431 if (!args[2].is_string()) {
396 return Var(); 432 *exception = Var("nonce must be a string.");
433 return Var();
434 }
435 nonce = args[2].AsString();
397 } 436 }
398 nonce = args[2].AsString();
399 437
400 VLOG(1) << "your_jid: " << your_jid << ", host_jid: " << host_jid 438 VLOG(1) << "your_jid: " << your_jid << ", host_jid: " << host_jid
401 << ", nonce: " << nonce; 439 << ", nonce: " << nonce;
402 instance_->ConnectSandboxed(your_jid, host_jid, nonce); 440 instance_->ConnectSandboxed(your_jid, host_jid, nonce);
403 441
404 return Var(); 442 return Var();
405 } 443 }
406 444
407 Var ChromotingScriptableObject::DoDisconnect(const std::vector<Var>& args, 445 Var ChromotingScriptableObject::DoDisconnect(const std::vector<Var>& args,
408 Var* exception) { 446 Var* exception) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 *exception = Var("response_xml must be a string."); 502 *exception = Var("response_xml must be a string.");
465 return Var(); 503 return Var();
466 } 504 }
467 505
468 xmpp_proxy_->OnIq(args[0].AsString()); 506 xmpp_proxy_->OnIq(args[0].AsString());
469 507
470 return Var(); 508 return Var();
471 } 509 }
472 510
473 } // namespace remoting 511 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698