Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: remoting/webapp/app_remoting/js/app_remoting.js

Issue 1004513002: Eliminated named constants for instances of remoting.Error. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/application.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 return false; 330 return false;
326 }; 331 };
327 332
328 /** 333 /**
329 * Called when an error needs to be displayed to the user. 334 * Called when an error needs to be displayed to the user.
330 * 335 *
331 * @param {!remoting.Error} error The error to be localized and displayed. 336 * @param {!remoting.Error} error The error to be localized and displayed.
332 * @return {void} Nothing. 337 * @return {void} Nothing.
333 */ 338 */
334 remoting.AppRemoting.prototype.handleError = function(error) { 339 remoting.AppRemoting.prototype.handleError = function(error) {
335 console.error('Connection failed: ' + error.tag); 340 console.error('Connection failed: ' + error.toString());
336 remoting.LoadingWindow.close(); 341 remoting.LoadingWindow.close();
337 remoting.MessageWindow.showErrorMessage( 342 remoting.MessageWindow.showErrorMessage(
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(error.getTag()));
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 };
OLDNEW
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/application.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698