Chromium Code Reviews| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 }; | 310 }; |
| 311 | 311 |
| 312 /** | 312 /** |
| 313 * Load the WCS driver script. | 313 * Load the WCS driver script. |
| 314 * | 314 * |
| 315 * @param {string} token An OAuth2 access token. | 315 * @param {string} token An OAuth2 access token. |
| 316 * @return {void} Nothing. | 316 * @return {void} Nothing. |
| 317 * @private | 317 * @private |
| 318 */ | 318 */ |
| 319 remoting.SessionConnector.prototype.loadWcs_ = function(token) { | 319 remoting.SessionConnector.prototype.loadWcs_ = function(token) { |
| 320 remoting.wcsSandbox.setOnReady(this.onWcsLoaded_.bind(this)); | 320 remoting.wcsSandbox.setOnReady(this.onWcsLoaded_.bind(this)); |
|
Sergey Ulanov
2013/06/20 02:41:53
I think it's better to rename setOnReady() to make
Jamie
2013/06/20 17:32:20
Done.
| |
| 321 remoting.wcsSandbox.setOnError(this.onError_); | 321 remoting.wcsSandbox.setOnError(this.onError_); |
| 322 remoting.wcsSandbox.setAccessToken(token); | 322 remoting.wcsSandbox.setAccessToken(token); |
| 323 this.startAccessTokenRefreshTimer_(); | 323 this.startAccessTokenRefreshTimer_(); |
| 324 }; | 324 }; |
| 325 | 325 |
| 326 /** | 326 /** |
| 327 * Continue an IT2Me or Me2Me connection once WCS has been loaded. | 327 * Continue an IT2Me or Me2Me connection once WCS has been loaded. |
| 328 * | 328 * |
| 329 * @param {string} clientJid The full JID of the WCS client. | 329 * @param {string} clientJid The full JID of the WCS client. |
| 330 * @return {void} Nothing. | 330 * @return {void} Nothing. |
| 331 * @private | 331 * @private |
| 332 */ | 332 */ |
| 333 remoting.SessionConnector.prototype.onWcsLoaded_ = function(clientJid) { | 333 remoting.SessionConnector.prototype.onWcsLoaded_ = function(clientJid) { |
| 334 this.clientJid_ = clientJid; | 334 this.clientJid_ = clientJid; |
| 335 this.createSessionIfReady_(); | 335 this.createSessionIfReady_(); |
| 336 }; | 336 }; |
| 337 | 337 |
| 338 /** | 338 /** |
| 339 * If both the client and host JIDs are available, create a session and connect. | 339 * If both the client and host JIDs are available, create a session and connect. |
| 340 * | 340 * |
| 341 * @return {void} Nothing. | 341 * @return {void} Nothing. |
| 342 * @private | 342 * @private |
| 343 */ | 343 */ |
| 344 remoting.SessionConnector.prototype.createSessionIfReady_ = function() { | 344 remoting.SessionConnector.prototype.createSessionIfReady_ = function() { |
| 345 if (!this.clientJid_ || !this.hostJid_) { | 345 if (!this.clientJid_ || !this.hostJid_) { |
| 346 return; | 346 return; |
| 347 } | 347 } |
| 348 | 348 |
| 349 // In some circumstances, the WCS <iframe> can get reloaded, which results | |
|
Sergey Ulanov
2013/06/20 02:41:53
Would it be better to put this code in onWcsLoaded
Jamie
2013/06/20 17:32:20
Having it immediately before creating the new plug
| |
| 350 // in a new clientJid and a new callback. In this case, remove the old | |
| 351 // client plugin before instantiating a new one. | |
| 352 if (this.clientSession_) { | |
| 353 this.clientSession_.removePlugin(); | |
| 354 this.clientSession_ = null; | |
| 355 } | |
| 356 | |
| 349 var securityTypes = 'third_party,spake2_pair,spake2_hmac,spake2_plain'; | 357 var securityTypes = 'third_party,spake2_pair,spake2_hmac,spake2_plain'; |
| 350 this.clientSession_ = new remoting.ClientSession( | 358 this.clientSession_ = new remoting.ClientSession( |
| 351 this.hostJid_, this.clientJid_, this.hostPublicKey_, this.passPhrase_, | 359 this.hostJid_, this.clientJid_, this.hostPublicKey_, this.passPhrase_, |
| 352 this.fetchPin_, this.fetchThirdPartyToken_, securityTypes, this.hostId_, | 360 this.fetchPin_, this.fetchThirdPartyToken_, securityTypes, this.hostId_, |
| 353 this.connectionMode_, this.hostDisplayName_, this.clientPairingId_, | 361 this.connectionMode_, this.hostDisplayName_, this.clientPairingId_, |
| 354 this.clientPairedSecret_); | 362 this.clientPairedSecret_); |
| 355 this.clientSession_.logHostOfflineErrors(!this.refreshHostJidIfOffline_); | 363 this.clientSession_.logHostOfflineErrors(!this.refreshHostJidIfOffline_); |
| 356 this.clientSession_.setOnStateChange(this.onStateChange_.bind(this)); | 364 this.clientSession_.setOnStateChange(this.onStateChange_.bind(this)); |
| 357 this.clientSession_.createPluginAndConnect(this.pluginParent_); | 365 this.clientSession_.createPluginAndConnect(this.pluginParent_); |
| 358 }; | 366 }; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 499 * Normalize the access code entered by the user. | 507 * Normalize the access code entered by the user. |
| 500 * | 508 * |
| 501 * @param {string} accessCode The access code, as entered by the user. | 509 * @param {string} accessCode The access code, as entered by the user. |
| 502 * @return {string} The normalized form of the code (whitespace removed). | 510 * @return {string} The normalized form of the code (whitespace removed). |
| 503 */ | 511 */ |
| 504 remoting.SessionConnector.prototype.normalizeAccessCode_ = | 512 remoting.SessionConnector.prototype.normalizeAccessCode_ = |
| 505 function(accessCode) { | 513 function(accessCode) { |
| 506 // Trim whitespace. | 514 // Trim whitespace. |
| 507 return accessCode.replace(/\s/g, ''); | 515 return accessCode.replace(/\s/g, ''); |
| 508 }; | 516 }; |
| OLD | NEW |