| 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 * Interface abstracting the Application functionality. | 7 * Interface abstracting the Application functionality. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 remoting.Application.prototype.start = function() { | 83 remoting.Application.prototype.start = function() { |
| 84 // Create global objects. | 84 // Create global objects. |
| 85 remoting.ClientPlugin.factory = new remoting.DefaultClientPluginFactory(); | 85 remoting.ClientPlugin.factory = new remoting.DefaultClientPluginFactory(); |
| 86 remoting.SessionConnector.factory = | 86 remoting.SessionConnector.factory = |
| 87 new remoting.DefaultSessionConnectorFactory(); | 87 new remoting.DefaultSessionConnectorFactory(); |
| 88 | 88 |
| 89 // TODO(garykac): This should be owned properly rather than living in the | 89 // TODO(garykac): This should be owned properly rather than living in the |
| 90 // global 'remoting' namespace. | 90 // global 'remoting' namespace. |
| 91 remoting.settings = new remoting.Settings(); | 91 remoting.settings = new remoting.Settings(); |
| 92 | 92 |
| 93 this.delegate_.init(this.getSessionConnector()); | 93 remoting.initGlobalObjects(); |
| 94 remoting.initIdentity(); |
| 95 |
| 96 this.delegate_.init(); |
| 97 remoting.identity.getToken().then( |
| 98 this.delegate_.start.bind(this.delegate_, this.getSessionConnector()), |
| 99 remoting.Error.handler(this.delegate_.signInFailed.bind(this.delegate_))); |
| 94 }; | 100 }; |
| 95 | 101 |
| 96 /** | 102 /** |
| 97 * Called when a new session has been connected. | 103 * Called when a new session has been connected. |
| 98 * | 104 * |
| 99 * @param {remoting.ClientSession} clientSession | 105 * @param {remoting.ClientSession} clientSession |
| 100 * @return {void} Nothing. | 106 * @return {void} Nothing. |
| 101 */ | 107 */ |
| 102 remoting.Application.prototype.onConnected = function(clientSession) { | 108 remoting.Application.prototype.onConnected = function(clientSession) { |
| 103 // TODO(garykac): Make clientSession a member var of Application. | 109 // TODO(garykac): Make clientSession a member var of Application. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 return this.session_connector_; | 198 return this.session_connector_; |
| 193 }; | 199 }; |
| 194 | 200 |
| 195 | 201 |
| 196 /** | 202 /** |
| 197 * @interface | 203 * @interface |
| 198 */ | 204 */ |
| 199 remoting.Application.Delegate = function() {}; | 205 remoting.Application.Delegate = function() {}; |
| 200 | 206 |
| 201 /** | 207 /** |
| 202 * Initialize the application and register all event handlers. After this | 208 * Initialize the application. This is called before an OAuth token is requested |
| 203 * is called, the app is running and waiting for user events. | 209 * and should be used for tasks such as initializing the DOM, registering event |
| 210 * handlers, etc. |
| 211 */ |
| 212 remoting.Application.Delegate.prototype.init = function() {}; |
| 213 |
| 214 /** |
| 215 * Start the application. Once start() is called, the delegate can assume that |
| 216 * the user has consented to all permissions specified in the manifest. |
| 204 * | 217 * |
| 205 * @param {remoting.SessionConnector} connector | 218 * @param {remoting.SessionConnector} connector |
| 206 * @return {void} Nothing. | 219 * @param {string} token An OAuth access token. The delegate should not cache |
| 220 * this token, but can assume that it will remain valid during application |
| 221 * start-up. |
| 207 */ | 222 */ |
| 208 remoting.Application.Delegate.prototype.init = function(connector) {}; | 223 remoting.Application.Delegate.prototype.start = function(connector, token) {}; |
| 224 |
| 225 /** |
| 226 * Report an authentication error to the user. This is called in lieu of start() |
| 227 * if the user cannot be authenticated or if they decline the app permissions. |
| 228 * |
| 229 * @param {remoting.Error} error The failure reason. |
| 230 */ |
| 231 remoting.Application.Delegate.prototype.signInFailed = function(error) {}; |
| 209 | 232 |
| 210 /** | 233 /** |
| 211 * @return {string} Application product name to be used in UI. | 234 * @return {string} Application product name to be used in UI. |
| 212 */ | 235 */ |
| 213 remoting.Application.Delegate.prototype.getApplicationName = function() {}; | 236 remoting.Application.Delegate.prototype.getApplicationName = function() {}; |
| 214 | 237 |
| 215 /** | 238 /** |
| 216 * @return {string} The default remap keys for the current platform. | 239 * @return {string} The default remap keys for the current platform. |
| 217 */ | 240 */ |
| 218 remoting.Application.Delegate.prototype.getDefaultRemapKeys = function() {}; | 241 remoting.Application.Delegate.prototype.getDefaultRemapKeys = function() {}; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 233 */ | 256 */ |
| 234 remoting.Application.Delegate.prototype.handleDisconnected = function() {}; | 257 remoting.Application.Delegate.prototype.handleDisconnected = function() {}; |
| 235 | 258 |
| 236 /** | 259 /** |
| 237 * Called when the current session's connection has failed. | 260 * Called when the current session's connection has failed. |
| 238 * | 261 * |
| 239 * @param {remoting.SessionConnector} connector | 262 * @param {remoting.SessionConnector} connector |
| 240 * @param {remoting.Error} error | 263 * @param {remoting.Error} error |
| 241 * @return {void} Nothing. | 264 * @return {void} Nothing. |
| 242 */ | 265 */ |
| 243 remoting.Application.Delegate.prototype.handleConnectionFailed = function( | 266 remoting.Application.Delegate.prototype.handleConnectionFailed = |
| 244 connector, error) {}; | 267 function(connector, error) {}; |
| 245 | 268 |
| 246 /** | 269 /** |
| 247 * Called when the current session has reached the point where the host has | 270 * Called when the current session has reached the point where the host has |
| 248 * started streaming video frames to the client. | 271 * started streaming video frames to the client. |
| 249 * | 272 * |
| 250 * @return {void} Nothing. | 273 * @return {void} Nothing. |
| 251 */ | 274 */ |
| 252 remoting.Application.Delegate.prototype.handleVideoStreamingStarted = function( | 275 remoting.Application.Delegate.prototype.handleVideoStreamingStarted = |
| 253 ) {}; | 276 function() {}; |
| 254 | 277 |
| 255 /** | 278 /** |
| 256 * Called when an extension message needs to be handled. | 279 * Called when an extension message needs to be handled. |
| 257 * | 280 * |
| 258 * @param {string} type The type of the extension message. | 281 * @param {string} type The type of the extension message. |
| 259 * @param {Object} message The parsed extension message data. | 282 * @param {Object} message The parsed extension message data. |
| 260 * @return {boolean} Return true if the extension message was recognized. | 283 * @return {boolean} Return true if the extension message was recognized. |
| 261 */ | 284 */ |
| 262 remoting.Application.Delegate.prototype.handleExtensionMessage = function( | 285 remoting.Application.Delegate.prototype.handleExtensionMessage = |
| 263 type, message) {}; | 286 function(type, message) {}; |
| 264 | 287 |
| 265 /** | 288 /** |
| 266 * Called when an error needs to be displayed to the user. | 289 * Called when an error needs to be displayed to the user. |
| 267 * | 290 * |
| 268 * @param {remoting.Error} errorTag The error to be localized and displayed. | 291 * @param {remoting.Error} errorTag The error to be localized and displayed. |
| 269 * @return {void} Nothing. | 292 * @return {void} Nothing. |
| 270 */ | 293 */ |
| 271 remoting.Application.Delegate.prototype.handleError = function(errorTag) {}; | 294 remoting.Application.Delegate.prototype.handleError = function(errorTag) {}; |
| 272 | 295 |
| 273 | 296 |
| 274 /** @type {remoting.Application} */ | 297 /** @type {remoting.Application} */ |
| 275 remoting.app = null; | 298 remoting.app = null; |
| OLD | NEW |