| Index: remoting/webapp/crd/js/host_controller.js
|
| diff --git a/remoting/webapp/crd/js/host_controller.js b/remoting/webapp/crd/js/host_controller.js
|
| index a695a04ae00f8ff0a21cf6817305ee2298b83d29..162cb2a498fea15099dd1f084de08abca793d2f8 100644
|
| --- a/remoting/webapp/crd/js/host_controller.js
|
| +++ b/remoting/webapp/crd/js/host_controller.js
|
| @@ -158,9 +158,9 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
|
| remoting.hostList.onLocalHostStarted(hostName, newHostId, publicKey);
|
| onDone();
|
| } else if (result == remoting.HostController.AsyncResult.CANCELLED) {
|
| - onStartError(remoting.Error.CANCELLED);
|
| + onStartError(new remoting.Error(remoting.Error.Tag.CANCELLED));
|
| } else {
|
| - onStartError(remoting.Error.UNEXPECTED);
|
| + onStartError(remoting.Error.unexpected());
|
| }
|
| }
|
|
|
| @@ -234,14 +234,14 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
|
| * @param {string} hostName
|
| * @param {string} publicKey
|
| * @param {string} privateKey
|
| - * @param {XMLHttpRequest} xhr
|
| + * @param {!remoting.Xhr.Response} response
|
| */
|
| function onRegistered(
|
| - hostName, publicKey, privateKey, xhr) {
|
| - var success = (xhr.status == 200);
|
| + hostName, publicKey, privateKey, response) {
|
| + var success = (response.status == 200);
|
|
|
| if (success) {
|
| - var result = base.jsonParseSafe(xhr.responseText);
|
| + var result = base.jsonParseSafe(response.getText());
|
| if ('data' in result && 'authorizationCode' in result['data']) {
|
| that.hostDaemonFacade_.getCredentialsFromAuthCode(
|
| result['data']['authorizationCode'],
|
| @@ -260,9 +260,9 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
|
| });
|
| }
|
| } else {
|
| - console.log('Failed to register the host. Status: ' + xhr.status +
|
| - ' response: ' + xhr.responseText);
|
| - onError(remoting.Error.REGISTRATION_FAILED);
|
| + console.log('Failed to register the host. Status: ' + response.status +
|
| + ' response: ' + response.getText());
|
| + onError(new remoting.Error(remoting.Error.Tag.REGISTRATION_FAILED));
|
| }
|
| }
|
|
|
| @@ -281,16 +281,15 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
|
| publicKey: publicKey
|
| } };
|
|
|
| - remoting.xhr.start({
|
| + new remoting.Xhr({
|
| method: 'POST',
|
| url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts',
|
| urlParams: {
|
| hostClientId: hostClientId
|
| },
|
| - onDone: onRegistered.bind(null, hostName, publicKey, privateKey),
|
| jsonContent: newHostDetails,
|
| oauthToken: oauthToken
|
| - });
|
| + }).start().then(onRegistered.bind(null, hostName, publicKey, privateKey));
|
| }
|
|
|
| /**
|
| @@ -374,9 +373,9 @@ remoting.HostController.prototype.stop = function(onDone, onError) {
|
| if (result == remoting.HostController.AsyncResult.OK) {
|
| that.getLocalHostId(unregisterHost);
|
| } else if (result == remoting.HostController.AsyncResult.CANCELLED) {
|
| - onError(remoting.Error.CANCELLED);
|
| + onError(new remoting.Error(remoting.Error.Tag.CANCELLED));
|
| } else {
|
| - onError(remoting.Error.UNEXPECTED);
|
| + onError(remoting.Error.unexpected());
|
| }
|
| }
|
|
|
| @@ -411,9 +410,9 @@ remoting.HostController.prototype.updatePin = function(newPin, onDone,
|
| if (result == remoting.HostController.AsyncResult.OK) {
|
| onDone();
|
| } else if (result == remoting.HostController.AsyncResult.CANCELLED) {
|
| - onError(remoting.Error.CANCELLED);
|
| + onError(new remoting.Error(remoting.Error.Tag.CANCELLED));
|
| } else {
|
| - onError(remoting.Error.UNEXPECTED);
|
| + onError(remoting.Error.unexpected());
|
| }
|
| }
|
|
|
| @@ -429,7 +428,7 @@ remoting.HostController.prototype.updatePin = function(newPin, onDone,
|
| /** @param {Object} config */
|
| function onConfig(config) {
|
| if (!isHostConfigValid_(config)) {
|
| - onError(remoting.Error.UNEXPECTED);
|
| + onError(remoting.Error.unexpected());
|
| return;
|
| }
|
| /** @type {string} */
|
| @@ -452,7 +451,7 @@ remoting.HostController.prototype.updatePin = function(newPin, onDone,
|
| remoting.HostController.prototype.getLocalHostState = function(onDone) {
|
| /** @param {!remoting.Error} error */
|
| function onError(error) {
|
| - onDone((error.tag == remoting.Error.Tag.MISSING_PLUGIN) ?
|
| + onDone((error.hasTag(remoting.Error.Tag.MISSING_PLUGIN)) ?
|
| remoting.HostController.State.NOT_INSTALLED :
|
| remoting.HostController.State.UNKNOWN);
|
| }
|
|
|