| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 console.log('Starting session...'); | 307 console.log('Starting session...'); |
| 308 var accessCode = document.getElementById('access-code-entry'); | 308 var accessCode = document.getElementById('access-code-entry'); |
| 309 accessCode.value = ''; // The code has been validated and won't work again. | 309 accessCode.value = ''; // The code has been validated and won't work again. |
| 310 remoting.clientSession = | 310 remoting.clientSession = |
| 311 new remoting.ClientSession( | 311 new remoting.ClientSession( |
| 312 remoting.hostJid, remoting.hostPublicKey, | 312 remoting.hostJid, remoting.hostPublicKey, |
| 313 remoting.accessCode, 'v1_token', '', | 313 remoting.accessCode, 'v1_token', '', |
| 314 /** @type {string} */ (remoting.oauth2.getCachedEmail()), | 314 /** @type {string} */ (remoting.oauth2.getCachedEmail()), |
| 315 remoting.ClientSession.Mode.IT2ME, | 315 remoting.ClientSession.Mode.IT2ME, |
| 316 onClientStateChange_); | 316 onClientStateChange_); |
| 317 /** @param {string} token The auth token. */ | 317 /** @param {string?} token The auth token. */ |
| 318 var createPluginAndConnect = function(token) { | 318 var createPluginAndConnect = function(token) { |
| 319 remoting.clientSession.createPluginAndConnect( | 319 if (token) { |
| 320 document.getElementById('session-mode'), | 320 remoting.clientSession.createPluginAndConnect( |
| 321 token); | 321 document.getElementById('session-mode'), |
| 322 token); |
| 323 } else { |
| 324 showConnectError_(remoting.Error.AUTHENTICATION_FAILED); |
| 325 } |
| 322 }; | 326 }; |
| 323 remoting.oauth2.callWithToken(createPluginAndConnect); | 327 remoting.oauth2.callWithToken(createPluginAndConnect); |
| 324 } | 328 } |
| 325 | 329 |
| 326 /** | 330 /** |
| 327 * Show a client-side error message. | 331 * Show a client-side error message. |
| 328 * | 332 * |
| 329 * @param {remoting.Error} errorTag The error to be localized and | 333 * @param {remoting.Error} errorTag The error to be localized and |
| 330 * displayed. | 334 * displayed. |
| 331 * @return {void} Nothing. | 335 * @return {void} Nothing. |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 pin, 'spake2_hmac,spake2_plain', remoting.hostId, | 528 pin, 'spake2_hmac,spake2_plain', remoting.hostId, |
| 525 /** @type {string} */ (remoting.oauth2.getCachedEmail()), | 529 /** @type {string} */ (remoting.oauth2.getCachedEmail()), |
| 526 remoting.ClientSession.Mode.ME2ME, onClientStateChange_); | 530 remoting.ClientSession.Mode.ME2ME, onClientStateChange_); |
| 527 remoting.clientSession.createPluginAndConnect( | 531 remoting.clientSession.createPluginAndConnect( |
| 528 document.getElementById('session-mode'), | 532 document.getElementById('session-mode'), |
| 529 token); | 533 token); |
| 530 } else { | 534 } else { |
| 531 showConnectError_(remoting.Error.AUTHENTICATION_FAILED); | 535 showConnectError_(remoting.Error.AUTHENTICATION_FAILED); |
| 532 } | 536 } |
| 533 } | 537 } |
| OLD | NEW |