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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 302 |
303 var normalizedAccessCode = this.normalizeAccessCode_(accessCode); | 303 var normalizedAccessCode = this.normalizeAccessCode_(accessCode); |
304 if (normalizedAccessCode.length != kAccessCodeLen) { | 304 if (normalizedAccessCode.length != kAccessCodeLen) { |
305 this.onError_(remoting.Error.INVALID_ACCESS_CODE); | 305 this.onError_(remoting.Error.INVALID_ACCESS_CODE); |
306 return; | 306 return; |
307 } | 307 } |
308 | 308 |
309 var hostId = normalizedAccessCode.substring(0, kSupportIdLen); | 309 var hostId = normalizedAccessCode.substring(0, kSupportIdLen); |
310 this.passPhrase_ = normalizedAccessCode; | 310 this.passPhrase_ = normalizedAccessCode; |
311 this.connectionMode_ = remoting.DesktopConnectedView.Mode.IT2ME; | 311 this.connectionMode_ = remoting.DesktopConnectedView.Mode.IT2ME; |
312 remoting.identity.callWithToken( | 312 remoting.identity.getToken().then( |
313 this.connectIT2MeWithToken_.bind(this, hostId), this.onError_); | 313 this.connectIT2MeWithToken_.bind(this, hostId), |
| 314 remoting.Error.handler(this.onError_)); |
314 }; | 315 }; |
315 | 316 |
316 /** | 317 /** |
317 * Reconnect a closed connection. | 318 * Reconnect a closed connection. |
318 * | 319 * |
319 * @return {void} Nothing. | 320 * @return {void} Nothing. |
320 */ | 321 */ |
321 remoting.SessionConnectorImpl.prototype.reconnect = function() { | 322 remoting.SessionConnectorImpl.prototype.reconnect = function() { |
322 if (this.connectionMode_ == remoting.DesktopConnectedView.Mode.IT2ME) { | 323 if (this.connectionMode_ == remoting.DesktopConnectedView.Mode.IT2ME) { |
323 console.error('reconnect not supported for IT2Me.'); | 324 console.error('reconnect not supported for IT2Me.'); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 */ | 368 */ |
368 remoting.SessionConnectorImpl.prototype.connectSignaling_ = function() { | 369 remoting.SessionConnectorImpl.prototype.connectSignaling_ = function() { |
369 base.dispose(this.signalStrategy_); | 370 base.dispose(this.signalStrategy_); |
370 this.signalStrategy_ = null; | 371 this.signalStrategy_ = null; |
371 | 372 |
372 /** @type {remoting.SessionConnectorImpl} */ | 373 /** @type {remoting.SessionConnectorImpl} */ |
373 var that = this; | 374 var that = this; |
374 | 375 |
375 /** @param {string} token */ | 376 /** @param {string} token */ |
376 function connectSignalingWithToken(token) { | 377 function connectSignalingWithToken(token) { |
377 remoting.identity.getUserInfo( | 378 remoting.identity.getUserInfo().then( |
378 connectSignalingWithTokenAndUserInfo.bind(null, token), that.onError_); | 379 connectSignalingWithTokenAndUserInfo.bind(null, token), |
| 380 remoting.Error.handler(that.onError_)); |
379 } | 381 } |
380 | 382 |
381 /** | 383 /** |
382 * Success callback for when the email and fullName have been retrieved | 384 * Success callback for when the email and fullName have been retrieved |
383 * for this user. | 385 * for this user. |
384 * Note that the full name will be null unless the webapp has requested | 386 * Note that the full name will be null unless the webapp has requested |
385 * and been granted the userinfo.profile permission. | 387 * and been granted the userinfo.profile permission. |
386 * | 388 * |
387 * @param {string} token | 389 * @param {string} token |
388 * @param {string} email | 390 * @param {{email: string, name: string}} userInfo |
389 * @param {string} fullName | |
390 */ | 391 */ |
391 function connectSignalingWithTokenAndUserInfo(token, email, fullName) { | 392 function connectSignalingWithTokenAndUserInfo(token, userInfo) { |
392 that.signalStrategy_.connect( | 393 that.signalStrategy_.connect( |
393 remoting.settings.XMPP_SERVER_FOR_CLIENT, email, token); | 394 remoting.settings.XMPP_SERVER_FOR_CLIENT, userInfo.email, token); |
394 } | 395 } |
395 | 396 |
396 this.signalStrategy_ = remoting.SignalStrategy.create(); | 397 this.signalStrategy_ = remoting.SignalStrategy.create(); |
397 this.signalStrategy_.setStateChangedCallback( | 398 this.signalStrategy_.setStateChangedCallback( |
398 this.onSignalingState_.bind(this)); | 399 this.onSignalingState_.bind(this)); |
399 | 400 |
400 remoting.identity.callWithToken(connectSignalingWithToken, this.onError_); | 401 remoting.identity.getToken().then( |
| 402 connectSignalingWithToken, |
| 403 remoting.Error.handler(this.onError_)); |
401 }; | 404 }; |
402 | 405 |
403 /** | 406 /** |
404 * @private | 407 * @private |
405 * @param {remoting.SignalStrategy.State} state | 408 * @param {remoting.SignalStrategy.State} state |
406 */ | 409 */ |
407 remoting.SessionConnectorImpl.prototype.onSignalingState_ = function(state) { | 410 remoting.SessionConnectorImpl.prototype.onSignalingState_ = function(state) { |
408 switch (state) { | 411 switch (state) { |
409 case remoting.SignalStrategy.State.CONNECTED: | 412 case remoting.SignalStrategy.State.CONNECTED: |
410 // Proceed only if the connection hasn't been canceled. | 413 // Proceed only if the connection hasn't been canceled. |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 */ | 623 */ |
621 remoting.DefaultSessionConnectorFactory.prototype.createConnector = | 624 remoting.DefaultSessionConnectorFactory.prototype.createConnector = |
622 function(clientContainer, onConnected, onError, onExtensionMessage, | 625 function(clientContainer, onConnected, onError, onExtensionMessage, |
623 onConnectionFailed, requiredCapabilities, defaultRemapKeys) { | 626 onConnectionFailed, requiredCapabilities, defaultRemapKeys) { |
624 return new remoting.SessionConnectorImpl(clientContainer, onConnected, | 627 return new remoting.SessionConnectorImpl(clientContainer, onConnected, |
625 onError, onExtensionMessage, | 628 onError, onExtensionMessage, |
626 onConnectionFailed, | 629 onConnectionFailed, |
627 requiredCapabilities, | 630 requiredCapabilities, |
628 defaultRemapKeys); | 631 defaultRemapKeys); |
629 }; | 632 }; |
OLD | NEW |