OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 * Connect set-up state machine for Me2Me and IT2Me | 7 * Connect set-up state machine for Me2Me and IT2Me |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 /** | 329 /** |
330 * Get host ID. | 330 * Get host ID. |
331 * | 331 * |
332 * @return {string} | 332 * @return {string} |
333 */ | 333 */ |
334 remoting.SessionConnector.prototype.getHostId = function() { | 334 remoting.SessionConnector.prototype.getHostId = function() { |
335 return this.hostId_; | 335 return this.hostId_; |
336 }; | 336 }; |
337 | 337 |
338 /** | 338 /** |
339 * Get host display name. | |
340 * | |
341 * @return {string} | |
342 */ | |
343 remoting.SessionConnector.prototype.getHostDisplayName = function() { | |
344 return this.hostDisplayName_; | |
345 }; | |
346 | |
347 /** | |
348 * Continue an IT2Me connection once an access token has been obtained. | 339 * Continue an IT2Me connection once an access token has been obtained. |
349 * | 340 * |
350 * @param {string} token An OAuth2 access token. | 341 * @param {string} token An OAuth2 access token. |
351 * @return {void} Nothing. | 342 * @return {void} Nothing. |
352 * @private | 343 * @private |
353 */ | 344 */ |
354 remoting.SessionConnector.prototype.connectIT2MeWithToken_ = function(token) { | 345 remoting.SessionConnector.prototype.connectIT2MeWithToken_ = function(token) { |
355 // Resolve the host id to get the host JID. | 346 // Resolve the host id to get the host JID. |
356 this.pendingXhr_ = remoting.xhr.get( | 347 this.pendingXhr_ = remoting.xhr.get( |
357 remoting.settings.DIRECTORY_API_BASE_URL + '/support-hosts/' + | 348 remoting.settings.DIRECTORY_API_BASE_URL + '/support-hosts/' + |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 // in a new clientJid and a new callback. In this case, remove the old | 386 // in a new clientJid and a new callback. In this case, remove the old |
396 // client plugin before instantiating a new one. | 387 // client plugin before instantiating a new one. |
397 if (this.clientSession_) { | 388 if (this.clientSession_) { |
398 this.clientSession_.removePlugin(); | 389 this.clientSession_.removePlugin(); |
399 this.clientSession_ = null; | 390 this.clientSession_ = null; |
400 } | 391 } |
401 | 392 |
402 var authenticationMethods = | 393 var authenticationMethods = |
403 'third_party,spake2_pair,spake2_hmac,spake2_plain'; | 394 'third_party,spake2_pair,spake2_hmac,spake2_plain'; |
404 this.clientSession_ = new remoting.ClientSession( | 395 this.clientSession_ = new remoting.ClientSession( |
405 this.passPhrase_, this.fetchPin_, this.fetchThirdPartyToken_, | 396 this.hostDisplayName_, this.passPhrase_, this.fetchPin_, |
406 authenticationMethods, this.hostId_, this.hostJid_, this.hostPublicKey_, | 397 this.fetchThirdPartyToken_, authenticationMethods, this.hostId_, |
407 this.connectionMode_, this.clientPairingId_, this.clientPairedSecret_); | 398 this.hostJid_, this.hostPublicKey_, this.connectionMode_, |
| 399 this.clientPairingId_, this.clientPairedSecret_); |
408 this.clientSession_.logHostOfflineErrors(!this.refreshHostJidIfOffline_); | 400 this.clientSession_.logHostOfflineErrors(!this.refreshHostJidIfOffline_); |
409 this.clientSession_.addEventListener( | 401 this.clientSession_.addEventListener( |
410 remoting.ClientSession.Events.stateChanged, | 402 remoting.ClientSession.Events.stateChanged, |
411 this.bound_.onStateChange); | 403 this.bound_.onStateChange); |
412 this.clientSession_.createPluginAndConnect(this.pluginParent_, | 404 this.clientSession_.createPluginAndConnect(this.pluginParent_, |
413 this.onExtensionMessage_); | 405 this.onExtensionMessage_); |
414 }; | 406 }; |
415 | 407 |
416 /** | 408 /** |
417 * Handle a change in the state of the client session prior to successful | 409 * Handle a change in the state of the client session prior to successful |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 * Normalize the access code entered by the user. | 518 * Normalize the access code entered by the user. |
527 * | 519 * |
528 * @param {string} accessCode The access code, as entered by the user. | 520 * @param {string} accessCode The access code, as entered by the user. |
529 * @return {string} The normalized form of the code (whitespace removed). | 521 * @return {string} The normalized form of the code (whitespace removed). |
530 */ | 522 */ |
531 remoting.SessionConnector.prototype.normalizeAccessCode_ = | 523 remoting.SessionConnector.prototype.normalizeAccessCode_ = |
532 function(accessCode) { | 524 function(accessCode) { |
533 // Trim whitespace. | 525 // Trim whitespace. |
534 return accessCode.replace(/\s/g, ''); | 526 return accessCode.replace(/\s/g, ''); |
535 }; | 527 }; |
OLD | NEW |