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

Side by Side Diff: remoting/webapp/crd/js/desktop_remoting.js

Issue 955283002: Converted remoting.Error from an enum to a class (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
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 desktop 7 * This class implements the functionality that is specific to desktop
8 * remoting ("Chromoting" or CRD). 8 * remoting ("Chromoting" or CRD).
9 */ 9 */
10 10
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 document.getElementById('current-email').innerText = email; 130 document.getElementById('current-email').innerText = email;
131 document.getElementById('get-started-it2me').disabled = false; 131 document.getElementById('get-started-it2me').disabled = false;
132 document.getElementById('get-started-me2me').disabled = false; 132 document.getElementById('get-started-me2me').disabled = false;
133 }); 133 });
134 }; 134 };
135 135
136 /** 136 /**
137 * Report an authentication error to the user. This is called in lieu of start() 137 * Report an authentication error to the user. This is called in lieu of start()
138 * if the user cannot be authenticated or if they decline the app permissions. 138 * if the user cannot be authenticated or if they decline the app permissions.
139 * 139 *
140 * @param {remoting.Error} error The failure reason. 140 * @param {!remoting.Error} error The failure reason.
141 */ 141 */
142 remoting.DesktopRemoting.prototype.signInFailed = function(error) { 142 remoting.DesktopRemoting.prototype.signInFailed = function(error) {
143 if (error == remoting.Error.CANCELLED) { 143 if (error == remoting.Error.CANCELLED) {
144 chrome.app.window.current().close(); 144 chrome.app.window.current().close();
145 } else { 145 } else {
146 remoting.showErrorMessage(error); 146 remoting.showErrorMessage(error);
147 } 147 }
148 }; 148 };
149 149
150 /** 150 /**
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); 243 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME);
244 } else { 244 } else {
245 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); 245 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME);
246 } 246 }
247 }; 247 };
248 248
249 /** 249 /**
250 * Called when the current session's connection has failed. 250 * Called when the current session's connection has failed.
251 * 251 *
252 * @param {remoting.SessionConnector} connector 252 * @param {remoting.SessionConnector} connector
253 * @param {remoting.Error} error 253 * @param {!remoting.Error} error
254 * @return {void} Nothing. 254 * @return {void} Nothing.
255 */ 255 */
256 remoting.DesktopRemoting.prototype.handleConnectionFailed = function( 256 remoting.DesktopRemoting.prototype.handleConnectionFailed = function(
257 connector, error) { 257 connector, error) {
258 /** @type {remoting.DesktopRemoting} */ 258 /** @type {remoting.DesktopRemoting} */
259 var that = this; 259 var that = this;
260 260
261 /** @param {boolean} success */ 261 /** @param {boolean} success */
262 var onHostListRefresh = function(success) { 262 var onHostListRefresh = function(success) {
263 if (success) { 263 if (success) {
264 var host = remoting.hostList.getHostForId(connector.getHostId()); 264 var host = remoting.hostList.getHostForId(connector.getHostId());
265 if (host) { 265 if (host) {
266 connector.retryConnectMe2Me(host); 266 connector.retryConnectMe2Me(host);
267 return; 267 return;
268 } 268 }
269 } 269 }
270 that.handleError(error); 270 that.handleError(error);
271 }; 271 };
272 272
273 if (error == remoting.Error.HOST_IS_OFFLINE && 273 if (error.tag == remoting.Error.Tag.HOST_IS_OFFLINE &&
274 that.refreshHostJidIfOffline_) { 274 that.refreshHostJidIfOffline_) {
275 that.refreshHostJidIfOffline_ = false; 275 that.refreshHostJidIfOffline_ = false;
276 // The plugin will be re-created when the host finished refreshing 276 // The plugin will be re-created when the host finished refreshing
277 remoting.hostList.refresh(onHostListRefresh); 277 remoting.hostList.refresh(onHostListRefresh);
278 } else { 278 } else {
279 this.handleError(error); 279 this.handleError(error);
280 } 280 }
281 }; 281 };
282 282
283 /** 283 /**
(...skipping 11 matching lines...) Expand all
295 * @return {boolean} Return true if the extension message was recognized. 295 * @return {boolean} Return true if the extension message was recognized.
296 */ 296 */
297 remoting.DesktopRemoting.prototype.handleExtensionMessage = function( 297 remoting.DesktopRemoting.prototype.handleExtensionMessage = function(
298 type, message) { 298 type, message) {
299 return false; 299 return false;
300 }; 300 };
301 301
302 /** 302 /**
303 * Called when an error needs to be displayed to the user. 303 * Called when an error needs to be displayed to the user.
304 * 304 *
305 * @param {remoting.Error} errorTag The error to be localized and displayed. 305 * @param {!remoting.Error} error The error to be localized and displayed.
306 * @return {void} Nothing. 306 * @return {void} Nothing.
307 */ 307 */
308 remoting.DesktopRemoting.prototype.handleError = function(errorTag) { 308 remoting.DesktopRemoting.prototype.handleError = function(error) {
309 console.error('Connection failed: ' + errorTag); 309 console.error('Connection failed:', error.tag);
310 remoting.accessCode = ''; 310 remoting.accessCode = '';
311 311
312 if (errorTag === remoting.Error.AUTHENTICATION_FAILED) { 312 if (error.tag === remoting.Error.Tag.AUTHENTICATION_FAILED) {
313 remoting.setMode(remoting.AppMode.HOME); 313 remoting.setMode(remoting.AppMode.HOME);
314 remoting.handleAuthFailureAndRelaunch(); 314 remoting.handleAuthFailureAndRelaunch();
315 return; 315 return;
316 } 316 }
317 317
318 // Reset the refresh flag so that the next connection will retry if needed. 318 // Reset the refresh flag so that the next connection will retry if needed.
319 this.refreshHostJidIfOffline_ = true; 319 this.refreshHostJidIfOffline_ = true;
320 320
321 var errorDiv = document.getElementById('connect-error-message'); 321 var errorDiv = document.getElementById('connect-error-message');
322 l10n.localizeElementFromTag(errorDiv, /** @type {string} */ (errorTag)); 322 l10n.localizeElementFromTag(errorDiv, error.tag);
323 323
324 var mode = remoting.clientSession ? remoting.desktopConnectedView.getMode() 324 var mode = remoting.clientSession ? remoting.desktopConnectedView.getMode()
325 : this.app_.getSessionConnector().getConnectionMode(); 325 : this.app_.getSessionConnector().getConnectionMode();
326 if (mode == remoting.DesktopConnectedView.Mode.IT2ME) { 326 if (mode == remoting.DesktopConnectedView.Mode.IT2ME) {
327 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); 327 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME);
328 } else { 328 } else {
329 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); 329 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME);
330 } 330 }
331 }; 331 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698