| Index: remoting/webapp/app_remoting/js/app_remoting.js
|
| diff --git a/remoting/webapp/app_remoting/js/app_remoting.js b/remoting/webapp/app_remoting/js/app_remoting.js
|
| index 3d3b58566dc50bdee4b5e19897d15abb322564af..46a0555461c99d09e03f15d1ea16a0e54406e6ff 100644
|
| --- a/remoting/webapp/app_remoting/js/app_remoting.js
|
| +++ b/remoting/webapp/app_remoting/js/app_remoting.js
|
| @@ -104,11 +104,11 @@ remoting.AppRemoting.prototype.start = function(connector, token) {
|
| /** @type {remoting.AppRemoting} */
|
| var that = this;
|
|
|
| - /** @param {XMLHttpRequest} xhr */
|
| - var parseAppHostResponse = function(xhr) {
|
| - if (xhr.status == 200) {
|
| + /** @param {!remoting.Xhr.Response} xhrResponse */
|
| + var parseAppHostResponse = function(xhrResponse) {
|
| + if (xhrResponse.status == 200) {
|
| var response = /** @type {remoting.AppRemoting.AppHostResponse} */
|
| - (base.jsonParseSafe(xhr.responseText));
|
| + (base.jsonParseSafe(xhrResponse.getText()));
|
| if (response &&
|
| response.status &&
|
| response.status == 'done' &&
|
| @@ -148,33 +148,37 @@ remoting.AppRemoting.prototype.start = function(connector, token) {
|
|
|
| connector.connectMe2App(host, fetchThirdPartyToken);
|
| } else if (response && response.status == 'pending') {
|
| - that.handleError(remoting.Error.SERVICE_UNAVAILABLE);
|
| + that.handleError(new remoting.Error(
|
| + remoting.Error.Tag.SERVICE_UNAVAILABLE));
|
| }
|
| } else {
|
| console.error('Invalid "runApplication" response from server.');
|
| // TODO(garykac) Start using remoting.Error.fromHttpStatus once it has
|
| // been updated to properly report 'unknown' errors (rather than
|
| // reporting them as AUTHENTICATION_FAILED).
|
| - if (xhr.status == 0) {
|
| - that.handleError(remoting.Error.NETWORK_FAILURE);
|
| - } else if (xhr.status == 401) {
|
| - that.handleError(remoting.Error.AUTHENTICATION_FAILED);
|
| - } else if (xhr.status == 403) {
|
| - that.handleError(remoting.Error.APP_NOT_AUTHORIZED);
|
| - } else if (xhr.status == 502 || xhr.status == 503) {
|
| - that.handleError(remoting.Error.SERVICE_UNAVAILABLE);
|
| + if (xhrResponse.status == 0) {
|
| + that.handleError(new remoting.Error(
|
| + remoting.Error.Tag.NETWORK_FAILURE));
|
| + } else if (xhrResponse.status == 401) {
|
| + that.handleError(new remoting.Error(
|
| + remoting.Error.Tag.AUTHENTICATION_FAILED));
|
| + } else if (xhrResponse.status == 403) {
|
| + that.handleError(new remoting.Error(
|
| + remoting.Error.Tag.APP_NOT_AUTHORIZED));
|
| + } else if (xhrResponse.status == 502 || xhrResponse.status == 503) {
|
| + that.handleError(new remoting.Error(
|
| + remoting.Error.Tag.SERVICE_UNAVAILABLE));
|
| } else {
|
| - that.handleError(remoting.Error.UNEXPECTED);
|
| + that.handleError(remoting.Error.unexpected());
|
| }
|
| }
|
| };
|
|
|
| - remoting.xhr.start({
|
| + new remoting.Xhr({
|
| method: 'POST',
|
| url: that.runApplicationUrl(),
|
| - onDone: parseAppHostResponse,
|
| oauthToken: token
|
| - });
|
| + }).start().then(parseAppHostResponse);
|
| };
|
|
|
| /**
|
| @@ -332,11 +336,11 @@ remoting.AppRemoting.prototype.handleExtensionMessage = function(
|
| * @return {void} Nothing.
|
| */
|
| remoting.AppRemoting.prototype.handleError = function(error) {
|
| - console.error('Connection failed: ' + error.tag);
|
| + console.error('Connection failed: ' + error.toString());
|
| remoting.LoadingWindow.close();
|
| remoting.MessageWindow.showErrorMessage(
|
| chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'),
|
| - chrome.i18n.getMessage(/** @type {string} */ (error.tag)));
|
| + chrome.i18n.getMessage(error.getTag()));
|
| };
|
|
|
| /**
|
|
|