| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * This class implements the functionality that is specific to application | 7 * This class implements the functionality that is specific to application |
| 8 * remoting ("AppRemoting" or AR). | 8 * remoting ("AppRemoting" or AR). |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 */ | 141 */ |
| 142 var fetchThirdPartyToken = function( | 142 var fetchThirdPartyToken = function( |
| 143 tokenUrl, hostPublicKey, scope, onThirdPartyTokenFetched) { | 143 tokenUrl, hostPublicKey, scope, onThirdPartyTokenFetched) { |
| 144 // Use the authentication tokens returned by the app-remoting server. | 144 // Use the authentication tokens returned by the app-remoting server. |
| 145 onThirdPartyTokenFetched(host['authorizationCode'], | 145 onThirdPartyTokenFetched(host['authorizationCode'], |
| 146 host['sharedSecret']); | 146 host['sharedSecret']); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 connector.connectMe2App(host, fetchThirdPartyToken); | 149 connector.connectMe2App(host, fetchThirdPartyToken); |
| 150 } else if (response && response.status == 'pending') { | 150 } else if (response && response.status == 'pending') { |
| 151 that.handleError(remoting.Error.SERVICE_UNAVAILABLE); | 151 that.handleError(new remoting.Error( |
| 152 remoting.Error.Tag.SERVICE_UNAVAILABLE)); |
| 152 } | 153 } |
| 153 } else { | 154 } else { |
| 154 console.error('Invalid "runApplication" response from server.'); | 155 console.error('Invalid "runApplication" response from server.'); |
| 155 // TODO(garykac) Start using remoting.Error.fromHttpStatus once it has | 156 // TODO(garykac) Start using remoting.Error.fromHttpStatus once it has |
| 156 // been updated to properly report 'unknown' errors (rather than | 157 // been updated to properly report 'unknown' errors (rather than |
| 157 // reporting them as AUTHENTICATION_FAILED). | 158 // reporting them as AUTHENTICATION_FAILED). |
| 158 if (xhr.status == 0) { | 159 if (xhr.status == 0) { |
| 159 that.handleError(remoting.Error.NETWORK_FAILURE); | 160 that.handleError(new remoting.Error( |
| 161 remoting.Error.Tag.NETWORK_FAILURE)); |
| 160 } else if (xhr.status == 401) { | 162 } else if (xhr.status == 401) { |
| 161 that.handleError(remoting.Error.AUTHENTICATION_FAILED); | 163 that.handleError(new remoting.Error( |
| 164 remoting.Error.Tag.AUTHENTICATION_FAILED)); |
| 162 } else if (xhr.status == 403) { | 165 } else if (xhr.status == 403) { |
| 163 that.handleError(remoting.Error.APP_NOT_AUTHORIZED); | 166 that.handleError(new remoting.Error( |
| 167 remoting.Error.Tag.APP_NOT_AUTHORIZED)); |
| 164 } else if (xhr.status == 502 || xhr.status == 503) { | 168 } else if (xhr.status == 502 || xhr.status == 503) { |
| 165 that.handleError(remoting.Error.SERVICE_UNAVAILABLE); | 169 that.handleError(new remoting.Error( |
| 170 remoting.Error.Tag.SERVICE_UNAVAILABLE)); |
| 166 } else { | 171 } else { |
| 167 that.handleError(remoting.Error.UNEXPECTED); | 172 that.handleError(remoting.Error.unexpected()); |
| 168 } | 173 } |
| 169 } | 174 } |
| 170 }; | 175 }; |
| 171 | 176 |
| 172 remoting.xhr.start({ | 177 remoting.xhr.start({ |
| 173 method: 'POST', | 178 method: 'POST', |
| 174 url: that.runApplicationUrl(), | 179 url: that.runApplicationUrl(), |
| 175 onDone: parseAppHostResponse, | 180 onDone: parseAppHostResponse, |
| 176 oauthToken: token | 181 oauthToken: token |
| 177 }); | 182 }); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), | 343 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), |
| 339 chrome.i18n.getMessage(/** @type {string} */ (error.tag))); | 344 chrome.i18n.getMessage(/** @type {string} */ (error.tag))); |
| 340 }; | 345 }; |
| 341 | 346 |
| 342 /** | 347 /** |
| 343 * Close the loading window before exiting. | 348 * Close the loading window before exiting. |
| 344 */ | 349 */ |
| 345 remoting.AppRemoting.prototype.handleExit = function() { | 350 remoting.AppRemoting.prototype.handleExit = function() { |
| 346 remoting.LoadingWindow.close(); | 351 remoting.LoadingWindow.close(); |
| 347 }; | 352 }; |
| OLD | NEW |