| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 184 } |
| 185 }; | 185 }; |
| 186 | 186 |
| 187 /** @param {string} token */ | 187 /** @param {string} token */ |
| 188 var getAppHost = function(token) { | 188 var getAppHost = function(token) { |
| 189 var headers = { 'Authorization': 'OAuth ' + token }; | 189 var headers = { 'Authorization': 'OAuth ' + token }; |
| 190 remoting.xhr.post( | 190 remoting.xhr.post( |
| 191 that.runApplicationUrl(), parseAppHostResponse, '', headers); | 191 that.runApplicationUrl(), parseAppHostResponse, '', headers); |
| 192 }; | 192 }; |
| 193 | 193 |
| 194 /** @param {remoting.Error} error */ | 194 /** @param {!remoting.Error} error */ |
| 195 var onError = function(error) { | 195 var onError = function(error) { |
| 196 that.handleError(error); | 196 that.handleError(error); |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 remoting.LoadingWindow.show(); | 199 remoting.LoadingWindow.show(); |
| 200 | 200 |
| 201 remoting.identity.callWithToken(getAppHost, onError); | 201 remoting.identity.callWithToken(getAppHost, onError); |
| 202 } | 202 } |
| 203 | 203 |
| 204 /** | 204 /** |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // Cancel the ping when the connection closes. | 256 // Cancel the ping when the connection closes. |
| 257 window.clearInterval(this.pingTimerId_); | 257 window.clearInterval(this.pingTimerId_); |
| 258 | 258 |
| 259 chrome.app.window.current().close(); | 259 chrome.app.window.current().close(); |
| 260 }; | 260 }; |
| 261 | 261 |
| 262 /** | 262 /** |
| 263 * Called when the current session's connection has failed. | 263 * Called when the current session's connection has failed. |
| 264 * | 264 * |
| 265 * @param {remoting.SessionConnector} connector | 265 * @param {remoting.SessionConnector} connector |
| 266 * @param {remoting.Error} error | 266 * @param {!remoting.Error} error |
| 267 * @return {void} Nothing. | 267 * @return {void} Nothing. |
| 268 */ | 268 */ |
| 269 remoting.AppRemoting.prototype.handleConnectionFailed = function( | 269 remoting.AppRemoting.prototype.handleConnectionFailed = function( |
| 270 connector, error) { | 270 connector, error) { |
| 271 this.handleError(error); | 271 this.handleError(error); |
| 272 }; | 272 }; |
| 273 | 273 |
| 274 /** | 274 /** |
| 275 * Called when the current session has reached the point where the host has | 275 * Called when the current session has reached the point where the host has |
| 276 * started streaming video frames to the client. | 276 * started streaming video frames to the client. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 this.contextMenu_.updateConnectionRTT(now - then); | 332 this.contextMenu_.updateConnectionRTT(now - then); |
| 333 return true; | 333 return true; |
| 334 } | 334 } |
| 335 | 335 |
| 336 return false; | 336 return false; |
| 337 }; | 337 }; |
| 338 | 338 |
| 339 /** | 339 /** |
| 340 * Called when an error needs to be displayed to the user. | 340 * Called when an error needs to be displayed to the user. |
| 341 * | 341 * |
| 342 * @param {remoting.Error} errorTag The error to be localized and displayed. | 342 * @param {!remoting.Error} errorTag The error to be localized and displayed. |
| 343 * @return {void} Nothing. | 343 * @return {void} Nothing. |
| 344 */ | 344 */ |
| 345 remoting.AppRemoting.prototype.handleError = function(errorTag) { | 345 remoting.AppRemoting.prototype.handleError = function(errorTag) { |
| 346 console.error('Connection failed: ' + errorTag); | 346 console.error('Connection failed: ' + errorTag); |
| 347 remoting.LoadingWindow.close(); | 347 remoting.LoadingWindow.close(); |
| 348 remoting.MessageWindow.showErrorMessage( | 348 remoting.MessageWindow.showErrorMessage( |
| 349 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), | 349 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), |
| 350 chrome.i18n.getMessage(/** @type {string} */ (errorTag))); | 350 chrome.i18n.getMessage(/** @type {string} */ (errorTag))); |
| 351 }; | 351 }; |
| OLD | NEW |