Chromium Code Reviews| 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 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 * | 232 * |
| 233 * @return {void} Nothing. | 233 * @return {void} Nothing. |
| 234 */ | 234 */ |
| 235 remoting.DesktopRemoting.prototype.handleDisconnected = function() { | 235 remoting.DesktopRemoting.prototype.handleDisconnected = function() { |
| 236 }; | 236 }; |
| 237 | 237 |
| 238 /** | 238 /** |
| 239 * Called when the current session's connection has failed. | 239 * Called when the current session's connection has failed. |
| 240 * | 240 * |
| 241 * @param {remoting.SessionConnector} connector | 241 * @param {remoting.SessionConnector} connector |
| 242 * @param {remoting.Error} error | 242 * @param {!remoting.Error} error |
| 243 * @return {void} Nothing. | 243 * @return {void} Nothing. |
| 244 */ | 244 */ |
| 245 remoting.DesktopRemoting.prototype.handleConnectionFailed = function( | 245 remoting.DesktopRemoting.prototype.handleConnectionFailed = function( |
| 246 connector, error) { | 246 connector, error) { |
| 247 /** @type {remoting.DesktopRemoting} */ | 247 /** @type {remoting.DesktopRemoting} */ |
| 248 var that = this; | 248 var that = this; |
| 249 | 249 |
| 250 /** @param {boolean} success */ | 250 /** @param {boolean} success */ |
| 251 var onHostListRefresh = function(success) { | 251 var onHostListRefresh = function(success) { |
| 252 if (success) { | 252 if (success) { |
| 253 var host = remoting.hostList.getHostForId(connector.getHostId()); | 253 var host = remoting.hostList.getHostForId(connector.getHostId()); |
| 254 if (host) { | 254 if (host) { |
| 255 connector.retryConnectMe2Me(host); | 255 connector.retryConnectMe2Me(host); |
| 256 return; | 256 return; |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 that.handleError(error); | 259 that.handleError(error); |
| 260 }; | 260 }; |
| 261 | 261 |
| 262 if (error == remoting.Error.HOST_IS_OFFLINE && | 262 if (error.tag == remoting.Error.Tag.HOST_IS_OFFLINE && |
| 263 that.refreshHostJidIfOffline_) { | 263 that.refreshHostJidIfOffline_) { |
| 264 that.refreshHostJidIfOffline_ = false; | 264 that.refreshHostJidIfOffline_ = false; |
| 265 // The plugin will be re-created when the host finished refreshing | 265 // The plugin will be re-created when the host finished refreshing |
| 266 remoting.hostList.refresh(onHostListRefresh); | 266 remoting.hostList.refresh(onHostListRefresh); |
| 267 } else { | 267 } else { |
| 268 this.handleError(error); | 268 this.handleError(error); |
| 269 } | 269 } |
| 270 }; | 270 }; |
| 271 | 271 |
| 272 /** | 272 /** |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 284 * @return {boolean} Return true if the extension message was recognized. | 284 * @return {boolean} Return true if the extension message was recognized. |
| 285 */ | 285 */ |
| 286 remoting.DesktopRemoting.prototype.handleExtensionMessage = function( | 286 remoting.DesktopRemoting.prototype.handleExtensionMessage = function( |
| 287 type, message) { | 287 type, message) { |
| 288 return false; | 288 return false; |
| 289 }; | 289 }; |
| 290 | 290 |
| 291 /** | 291 /** |
| 292 * Called when an error needs to be displayed to the user. | 292 * Called when an error needs to be displayed to the user. |
| 293 * | 293 * |
| 294 * @param {remoting.Error} errorTag The error to be localized and displayed. | 294 * @param {!remoting.Error} error The error to be localized and displayed. |
| 295 * @return {void} Nothing. | 295 * @return {void} Nothing. |
| 296 */ | 296 */ |
| 297 remoting.DesktopRemoting.prototype.handleError = function(errorTag) { | 297 remoting.DesktopRemoting.prototype.handleError = function(error) { |
| 298 console.error('Connection failed: ' + errorTag); | 298 console.error('Connection failed: %o', error); |
|
Jamie
2015/02/26 18:57:42
IMO, the %o syntax is less clear than using "+". I
John Williams
2015/02/27 21:42:11
If `error` is an object, using %o lets you browse
Jamie
2015/03/02 18:28:09
In that case, you can achieve the same effect with
John Williams
2015/03/02 22:01:36
Done.
| |
| 299 remoting.accessCode = ''; | 299 remoting.accessCode = ''; |
| 300 | 300 |
| 301 if (errorTag === remoting.Error.AUTHENTICATION_FAILED) { | 301 if (error.tag === remoting.Error.Tag.AUTHENTICATION_FAILED) { |
| 302 remoting.setMode(remoting.AppMode.HOME); | 302 remoting.setMode(remoting.AppMode.HOME); |
| 303 remoting.handleAuthFailureAndRelaunch(); | 303 remoting.handleAuthFailureAndRelaunch(); |
| 304 return; | 304 return; |
| 305 } | 305 } |
| 306 | 306 |
| 307 // Reset the refresh flag so that the next connection will retry if needed. | 307 // Reset the refresh flag so that the next connection will retry if needed. |
| 308 this.refreshHostJidIfOffline_ = true; | 308 this.refreshHostJidIfOffline_ = true; |
| 309 | 309 |
| 310 var errorDiv = document.getElementById('connect-error-message'); | 310 var errorDiv = document.getElementById('connect-error-message'); |
| 311 l10n.localizeElementFromTag(errorDiv, /** @type {string} */ (errorTag)); | 311 l10n.localizeElementFromTag(errorDiv, error.tag); |
| 312 | 312 |
| 313 var mode = remoting.clientSession ? remoting.desktopConnectedView.getMode() | 313 var mode = remoting.clientSession ? remoting.desktopConnectedView.getMode() |
| 314 : this.app_.getSessionConnector().getConnectionMode(); | 314 : this.app_.getSessionConnector().getConnectionMode(); |
| 315 if (mode == remoting.DesktopConnectedView.Mode.IT2ME) { | 315 if (mode == remoting.DesktopConnectedView.Mode.IT2ME) { |
| 316 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); | 316 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); |
| 317 remoting.hangoutSessionEvents.raiseEvent( | 317 remoting.hangoutSessionEvents.raiseEvent( |
| 318 remoting.hangoutSessionEvents.sessionStateChanged, | 318 remoting.hangoutSessionEvents.sessionStateChanged, |
| 319 remoting.ClientSession.State.FAILED | 319 remoting.ClientSession.State.FAILED |
| 320 ); | 320 ); |
| 321 } else { | 321 } else { |
| 322 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); | 322 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); |
| 323 } | 323 } |
| 324 }; | 324 }; |
| OLD | NEW |