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 1a70ccda3e9d7be56489bbaf8b90d5e0e107b55b..57c24f8ec038eae6a42c451fcb2ae1d09bb0fc76 100644 |
--- a/remoting/webapp/crd/js/host_controller.js |
+++ b/remoting/webapp/crd/js/host_controller.js |
@@ -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} xhrr |
*/ |
function onRegistered( |
- hostName, publicKey, privateKey, xhr) { |
- var success = (xhr.status == 200); |
+ hostName, publicKey, privateKey, xhrr) { |
+ var success = (xhrr.status == 200); |
if (success) { |
- var result = base.jsonParseSafe(xhr.responseText); |
+ var result = base.jsonParseSafe(xhrr.responseText); |
if ('data' in result && 'authorizationCode' in result['data']) { |
that.hostDaemonFacade_.getCredentialsFromAuthCode( |
result['data']['authorizationCode'], |
@@ -260,8 +260,8 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone, |
}); |
} |
} else { |
- console.log('Failed to register the host. Status: ' + xhr.status + |
- ' response: ' + xhr.responseText); |
+ console.log('Failed to register the host. Status: ' + xhrr.status + |
+ ' response: ' + xhrr.responseText); |
onError(remoting.Error.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 |
- }); |
+ }).then(onRegistered.bind(null, hostName, publicKey, privateKey)); |
} |
/** |