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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
9 | 9 |
10 /** @constructor */ | 10 /** @constructor */ |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } | 299 } |
300 | 300 |
301 /** | 301 /** |
302 * @param {string} hostName | 302 * @param {string} hostName |
303 * @param {string} privateKey | 303 * @param {string} privateKey |
304 * @param {string} publicKey | 304 * @param {string} publicKey |
305 * @param {string} hostClientId | 305 * @param {string} hostClientId |
306 */ | 306 */ |
307 function onHostClientId( | 307 function onHostClientId( |
308 hostName, privateKey, publicKey, hostClientId) { | 308 hostName, privateKey, publicKey, hostClientId) { |
309 remoting.identity.callWithToken( | 309 remoting.identity.getToken().then( |
310 doRegisterHost.bind( | 310 doRegisterHost.bind( |
311 null, hostName, privateKey, publicKey, hostClientId), onError); | 311 null, hostName, privateKey, publicKey, hostClientId), |
| 312 remoting.Error.handler(onError)); |
312 } | 313 } |
313 | 314 |
314 /** | 315 /** |
315 * @param {string} hostName | 316 * @param {string} hostName |
316 * @param {string} privateKey | 317 * @param {string} privateKey |
317 * @param {string} publicKey | 318 * @param {string} publicKey |
318 * @param {boolean} hasFeature | 319 * @param {boolean} hasFeature |
319 */ | 320 */ |
320 function onHasFeatureOAuthClient( | 321 function onHasFeatureOAuthClient( |
321 hostName, privateKey, publicKey, hasFeature) { | 322 hostName, privateKey, publicKey, hasFeature) { |
322 if (hasFeature) { | 323 if (hasFeature) { |
323 that.hostDaemonFacade_.getHostClientId( | 324 that.hostDaemonFacade_.getHostClientId( |
324 onHostClientId.bind(null, hostName, privateKey, publicKey), onError); | 325 onHostClientId.bind(null, hostName, privateKey, publicKey), onError); |
325 } else { | 326 } else { |
326 remoting.identity.callWithToken( | 327 remoting.identity.getToken().then( |
327 doRegisterHost.bind( | 328 doRegisterHost.bind( |
328 null, hostName, privateKey, publicKey, null), onError); | 329 null, hostName, privateKey, publicKey, null), |
| 330 remoting.Error.handler(onError)); |
329 } | 331 } |
330 } | 332 } |
331 | 333 |
332 /** | 334 /** |
333 * @param {string} hostName | 335 * @param {string} hostName |
334 * @param {string} privateKey | 336 * @param {string} privateKey |
335 * @param {string} publicKey | 337 * @param {string} publicKey |
336 */ | 338 */ |
337 function onKeyGenerated(hostName, privateKey, publicKey) { | 339 function onKeyGenerated(hostName, privateKey, publicKey) { |
338 that.hasFeature( | 340 that.hasFeature( |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 onError(error); | 553 onError(error); |
552 break; | 554 break; |
553 } | 555 } |
554 }; | 556 }; |
555 | 557 |
556 signalStrategy = remoting.SignalStrategy.create(); | 558 signalStrategy = remoting.SignalStrategy.create(); |
557 signalStrategy.setStateChangedCallback(onState); | 559 signalStrategy.setStateChangedCallback(onState); |
558 | 560 |
559 /** @param {string} token */ | 561 /** @param {string} token */ |
560 function connectSignalingWithToken(token) { | 562 function connectSignalingWithToken(token) { |
561 remoting.identity.getEmail( | 563 remoting.identity.getEmail().then( |
562 connectSignalingWithTokenAndEmail.bind(null, token), onError); | 564 connectSignalingWithTokenAndEmail.bind(null, token), |
| 565 remoting.Error.handler(onError)); |
563 } | 566 } |
564 | 567 |
565 /** | 568 /** |
566 * @param {string} token | 569 * @param {string} token |
567 * @param {string} email | 570 * @param {string} email |
568 */ | 571 */ |
569 function connectSignalingWithTokenAndEmail(token, email) { | 572 function connectSignalingWithTokenAndEmail(token, email) { |
570 signalStrategy.connect( | 573 signalStrategy.connect( |
571 remoting.settings.XMPP_SERVER_FOR_CLIENT, email, token); | 574 remoting.settings.XMPP_SERVER_FOR_CLIENT, email, token); |
572 } | 575 } |
573 | 576 |
574 remoting.identity.callWithToken(connectSignalingWithToken, onError); | 577 remoting.identity.getToken().then( |
| 578 connectSignalingWithToken, remoting.Error.handler(onError)); |
575 }; | 579 }; |
576 | 580 |
577 /** @type {remoting.HostController} */ | 581 /** @type {remoting.HostController} */ |
578 remoting.hostController = null; | 582 remoting.hostController = null; |
OLD | NEW |