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 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Functions related to the 'client screen' for Chromoting. | 7 * Functions related to the 'client screen' for Chromoting. |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 remoting.clientSession.state != remoting.ClientSession.State.CONNECTED) { | 397 remoting.clientSession.state != remoting.ClientSession.State.CONNECTED) { |
398 return; | 398 return; |
399 } | 399 } |
400 var stats = remoting.clientSession.stats(); | 400 var stats = remoting.clientSession.stats(); |
401 remoting.debug.updateStatistics(stats); | 401 remoting.debug.updateStatistics(stats); |
402 remoting.clientSession.logStatistics(stats); | 402 remoting.clientSession.logStatistics(stats); |
403 // Update the stats once per second. | 403 // Update the stats once per second. |
404 window.setTimeout(updateStatistics_, 1000); | 404 window.setTimeout(updateStatistics_, 1000); |
405 } | 405 } |
406 | 406 |
| 407 /** |
| 408 * @return {boolean} true if the client plugin supports PIN auth. |
| 409 */ |
| 410 remoting.isPinAuthSupported = function () { |
| 411 var plugin = /** @type {remoting.ViewerPlugin} */ |
| 412 document.createElement('embed'); |
| 413 plugin.src = 'about://none'; |
| 414 plugin.type = 'pepper-application/x-chromoting'; |
| 415 plugin.width = 0; |
| 416 plugin.height = 0; |
| 417 document.body.appendChild(plugin); |
| 418 var version = plugin.apiVersion; |
| 419 document.body.removeChild(plugin); |
| 420 return version && version >= 4; |
| 421 }; |
407 | 422 |
408 /** | 423 /** |
409 * Shows PIN entry screen. | 424 * Shows PIN entry screen. |
410 * | 425 * |
411 * @param {string} hostId The unique id of the host. | 426 * @param {string} hostId The unique id of the host. |
412 * @param {boolean} retryIfOffline If true and the host can't be contacted, | 427 * @param {boolean} retryIfOffline If true and the host can't be contacted, |
413 * refresh the host list and try again. This allows bookmarked hosts to | 428 * refresh the host list and try again. This allows bookmarked hosts to |
414 * work even if they reregister with Talk and get a different Jid. | 429 * work even if they reregister with Talk and get a different Jid. |
415 * @return {void} Nothing. | 430 * @return {void} Nothing. |
416 */ | 431 */ |
417 remoting.connectMe2Me = function(hostId, retryIfOffline) { | 432 remoting.connectMe2Me = function(hostId, retryIfOffline) { |
418 remoting.currentConnectionType = remoting.ConnectionType.Me2Me; | 433 remoting.currentConnectionType = remoting.ConnectionType.Me2Me; |
419 remoting.hostId = hostId; | 434 remoting.hostId = hostId; |
420 remoting.retryIfOffline = retryIfOffline; | 435 remoting.retryIfOffline = retryIfOffline; |
421 | 436 |
422 // TODO(sergeyu): Ask pin only when it is necessary: crbug.com/111290 . | 437 if (!remoting.isPinAuthSupported()) { |
| 438 showConnectError_(remoting.Error.BAD_PLUGIN_VERSION); |
| 439 return; |
| 440 } |
| 441 |
423 remoting.setMode(remoting.AppMode.CLIENT_PIN_PROMPT); | 442 remoting.setMode(remoting.AppMode.CLIENT_PIN_PROMPT); |
424 }; | 443 }; |
425 | 444 |
426 /** | 445 /** |
427 * Start a connection to the specified host, using the cached details | 446 * Start a connection to the specified host, using the cached details |
428 * and the PIN entered by the user. | 447 * and the PIN entered by the user. |
429 * | 448 * |
430 * @return {void} Nothing. | 449 * @return {void} Nothing. |
431 */ | 450 */ |
432 remoting.connectMe2MeWithPin = function() { | 451 remoting.connectMe2MeWithPin = function() { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 /** @type {string} */ (remoting.oauth2.getCachedEmail()), | 484 /** @type {string} */ (remoting.oauth2.getCachedEmail()), |
466 remoting.ClientSession.Mode.ME2ME, onClientStateChange_); | 485 remoting.ClientSession.Mode.ME2ME, onClientStateChange_); |
467 remoting.clientSession.createPluginAndConnect( | 486 remoting.clientSession.createPluginAndConnect( |
468 document.getElementById('session-mode'), | 487 document.getElementById('session-mode'), |
469 token); | 488 token); |
470 remoting.setScaleToFit(remoting.clientSession.getScaleToFit()); | 489 remoting.setScaleToFit(remoting.clientSession.getScaleToFit()); |
471 } else { | 490 } else { |
472 showConnectError_(remoting.Error.AUTHENTICATION_FAILED); | 491 showConnectError_(remoting.Error.AUTHENTICATION_FAILED); |
473 } | 492 } |
474 } | 493 } |
OLD | NEW |