| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 /** | 151 /** |
| 152 * @param {string} hostName | 152 * @param {string} hostName |
| 153 * @param {string} publicKey | 153 * @param {string} publicKey |
| 154 * @param {remoting.HostController.AsyncResult} result | 154 * @param {remoting.HostController.AsyncResult} result |
| 155 */ | 155 */ |
| 156 function onStarted(hostName, publicKey, result) { | 156 function onStarted(hostName, publicKey, result) { |
| 157 if (result == remoting.HostController.AsyncResult.OK) { | 157 if (result == remoting.HostController.AsyncResult.OK) { |
| 158 remoting.hostList.onLocalHostStarted(hostName, newHostId, publicKey); | 158 remoting.hostList.onLocalHostStarted(hostName, newHostId, publicKey); |
| 159 onDone(); | 159 onDone(); |
| 160 } else if (result == remoting.HostController.AsyncResult.CANCELLED) { | 160 } else if (result == remoting.HostController.AsyncResult.CANCELLED) { |
| 161 onStartError(remoting.Error.CANCELLED); | 161 onStartError(new remoting.Error(remoting.Error.Tag.CANCELLED)); |
| 162 } else { | 162 } else { |
| 163 onStartError(remoting.Error.UNEXPECTED); | 163 onStartError(remoting.Error.unexpected()); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 /** | 167 /** |
| 168 * @param {string} hostName | 168 * @param {string} hostName |
| 169 * @param {string} publicKey | 169 * @param {string} publicKey |
| 170 * @param {string} privateKey | 170 * @param {string} privateKey |
| 171 * @param {?string} xmppLogin | 171 * @param {?string} xmppLogin |
| 172 * @param {?string} refreshToken | 172 * @param {?string} refreshToken |
| 173 * @param {?string} clientBaseJid | 173 * @param {?string} clientBaseJid |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 that.hostDaemonFacade_.getPinHash( | 255 that.hostDaemonFacade_.getPinHash( |
| 256 newHostId, hostPin, startHostWithHash.bind( | 256 newHostId, hostPin, startHostWithHash.bind( |
| 257 null, hostName, publicKey, privateKey, | 257 null, hostName, publicKey, privateKey, |
| 258 email, remoting.oauth2.getRefreshToken(), email), | 258 email, remoting.oauth2.getRefreshToken(), email), |
| 259 onError); | 259 onError); |
| 260 }); | 260 }); |
| 261 } | 261 } |
| 262 } else { | 262 } else { |
| 263 console.log('Failed to register the host. Status: ' + xhr.status + | 263 console.log('Failed to register the host. Status: ' + xhr.status + |
| 264 ' response: ' + xhr.responseText); | 264 ' response: ' + xhr.responseText); |
| 265 onError(remoting.Error.REGISTRATION_FAILED); | 265 onError(new remoting.Error(remoting.Error.Tag.REGISTRATION_FAILED)); |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 | 268 |
| 269 /** | 269 /** |
| 270 * @param {string} hostName | 270 * @param {string} hostName |
| 271 * @param {string} privateKey | 271 * @param {string} privateKey |
| 272 * @param {string} publicKey | 272 * @param {string} publicKey |
| 273 * @param {?string} hostClientId | 273 * @param {?string} hostClientId |
| 274 * @param {string} oauthToken | 274 * @param {string} oauthToken |
| 275 */ | 275 */ |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 return; | 367 return; |
| 368 } | 368 } |
| 369 onDone(); | 369 onDone(); |
| 370 } | 370 } |
| 371 | 371 |
| 372 /** @param {remoting.HostController.AsyncResult} result */ | 372 /** @param {remoting.HostController.AsyncResult} result */ |
| 373 function onStopped(result) { | 373 function onStopped(result) { |
| 374 if (result == remoting.HostController.AsyncResult.OK) { | 374 if (result == remoting.HostController.AsyncResult.OK) { |
| 375 that.getLocalHostId(unregisterHost); | 375 that.getLocalHostId(unregisterHost); |
| 376 } else if (result == remoting.HostController.AsyncResult.CANCELLED) { | 376 } else if (result == remoting.HostController.AsyncResult.CANCELLED) { |
| 377 onError(remoting.Error.CANCELLED); | 377 onError(new remoting.Error(remoting.Error.Tag.CANCELLED)); |
| 378 } else { | 378 } else { |
| 379 onError(remoting.Error.UNEXPECTED); | 379 onError(remoting.Error.unexpected()); |
| 380 } | 380 } |
| 381 } | 381 } |
| 382 | 382 |
| 383 this.hostDaemonFacade_.stopDaemon(onStopped, onError); | 383 this.hostDaemonFacade_.stopDaemon(onStopped, onError); |
| 384 }; | 384 }; |
| 385 | 385 |
| 386 /** | 386 /** |
| 387 * Check the host configuration is valid (non-null, and contains both host_id | 387 * Check the host configuration is valid (non-null, and contains both host_id |
| 388 * and xmpp_login keys). | 388 * and xmpp_login keys). |
| 389 * @param {Object} config The host configuration. | 389 * @param {Object} config The host configuration. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 404 remoting.HostController.prototype.updatePin = function(newPin, onDone, | 404 remoting.HostController.prototype.updatePin = function(newPin, onDone, |
| 405 onError) { | 405 onError) { |
| 406 /** @type {remoting.HostController} */ | 406 /** @type {remoting.HostController} */ |
| 407 var that = this; | 407 var that = this; |
| 408 | 408 |
| 409 /** @param {remoting.HostController.AsyncResult} result */ | 409 /** @param {remoting.HostController.AsyncResult} result */ |
| 410 function onConfigUpdated(result) { | 410 function onConfigUpdated(result) { |
| 411 if (result == remoting.HostController.AsyncResult.OK) { | 411 if (result == remoting.HostController.AsyncResult.OK) { |
| 412 onDone(); | 412 onDone(); |
| 413 } else if (result == remoting.HostController.AsyncResult.CANCELLED) { | 413 } else if (result == remoting.HostController.AsyncResult.CANCELLED) { |
| 414 onError(remoting.Error.CANCELLED); | 414 onError(new remoting.Error(remoting.Error.Tag.CANCELLED)); |
| 415 } else { | 415 } else { |
| 416 onError(remoting.Error.UNEXPECTED); | 416 onError(remoting.Error.unexpected()); |
| 417 } | 417 } |
| 418 } | 418 } |
| 419 | 419 |
| 420 /** @param {string} pinHash */ | 420 /** @param {string} pinHash */ |
| 421 function updateDaemonConfigWithHash(pinHash) { | 421 function updateDaemonConfigWithHash(pinHash) { |
| 422 var newConfig = { | 422 var newConfig = { |
| 423 host_secret_hash: pinHash | 423 host_secret_hash: pinHash |
| 424 }; | 424 }; |
| 425 that.hostDaemonFacade_.updateDaemonConfig(newConfig, onConfigUpdated, | 425 that.hostDaemonFacade_.updateDaemonConfig(newConfig, onConfigUpdated, |
| 426 onError); | 426 onError); |
| 427 } | 427 } |
| 428 | 428 |
| 429 /** @param {Object} config */ | 429 /** @param {Object} config */ |
| 430 function onConfig(config) { | 430 function onConfig(config) { |
| 431 if (!isHostConfigValid_(config)) { | 431 if (!isHostConfigValid_(config)) { |
| 432 onError(remoting.Error.UNEXPECTED); | 432 onError(remoting.Error.unexpected()); |
| 433 return; | 433 return; |
| 434 } | 434 } |
| 435 /** @type {string} */ | 435 /** @type {string} */ |
| 436 var hostId = config['host_id']; | 436 var hostId = config['host_id']; |
| 437 that.hostDaemonFacade_.getPinHash( | 437 that.hostDaemonFacade_.getPinHash( |
| 438 hostId, newPin, updateDaemonConfigWithHash, onError); | 438 hostId, newPin, updateDaemonConfigWithHash, onError); |
| 439 } | 439 } |
| 440 | 440 |
| 441 // TODO(sergeyu): When crbug.com/121518 is fixed: replace this call | 441 // TODO(sergeyu): When crbug.com/121518 is fixed: replace this call |
| 442 // with an unprivileged version if that is necessary. | 442 // with an unprivileged version if that is necessary. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 signalStrategy.connect( | 569 signalStrategy.connect( |
| 570 remoting.settings.XMPP_SERVER_FOR_CLIENT, email, token); | 570 remoting.settings.XMPP_SERVER_FOR_CLIENT, email, token); |
| 571 } | 571 } |
| 572 | 572 |
| 573 remoting.identity.getToken().then( | 573 remoting.identity.getToken().then( |
| 574 connectSignalingWithToken, remoting.Error.handler(onError)); | 574 connectSignalingWithToken, remoting.Error.handler(onError)); |
| 575 }; | 575 }; |
| 576 | 576 |
| 577 /** @type {remoting.HostController} */ | 577 /** @type {remoting.HostController} */ |
| 578 remoting.hostController = null; | 578 remoting.hostController = null; |
| OLD | NEW |