| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * Class handling creation and teardown of a remoting client session. | 7 * Class handling creation and teardown of a remoting client session. |
| 8 * | 8 * |
| 9 * The ClientSession class controls lifetime of the client plugin | 9 * The ClientSession class controls lifetime of the client plugin |
| 10 * object and provides the plugin with the functionality it needs to | 10 * object and provides the plugin with the functionality it needs to |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 * @param {remoting.Host} host The host to connect to. | 35 * @param {remoting.Host} host The host to connect to. |
| 36 * @param {remoting.SignalStrategy} signalStrategy Signal strategy. | 36 * @param {remoting.SignalStrategy} signalStrategy Signal strategy. |
| 37 * @param {remoting.CredentialsProvider} credentialsProvider | 37 * @param {remoting.CredentialsProvider} credentialsProvider |
| 38 * The credentialsProvider to authenticate the client with the host. | 38 * The credentialsProvider to authenticate the client with the host. |
| 39 * @param {HTMLElement} container Container element for the client view. | 39 * @param {HTMLElement} container Container element for the client view. |
| 40 * @param {remoting.DesktopConnectedView.Mode} mode The mode of this connection. | 40 * @param {remoting.DesktopConnectedView.Mode} mode The mode of this connection. |
| 41 * @param {string} defaultRemapKeys The default set of remap keys, to use | 41 * @param {string} defaultRemapKeys The default set of remap keys, to use |
| 42 * when the client doesn't define any. | 42 * when the client doesn't define any. |
| 43 * @constructor | 43 * @constructor |
| 44 * @extends {base.EventSourceImpl} | 44 * @extends {base.EventSourceImpl} |
| 45 * @implements {base.Disposable} |
| 45 */ | 46 */ |
| 46 remoting.ClientSession = function(host, signalStrategy, credentialsProvider, | 47 remoting.ClientSession = function(host, signalStrategy, credentialsProvider, |
| 47 container, mode, defaultRemapKeys) { | 48 container, mode, defaultRemapKeys) { |
| 48 /** @private */ | 49 /** @private */ |
| 49 this.state_ = remoting.ClientSession.State.CREATED; | 50 this.state_ = remoting.ClientSession.State.CREATED; |
| 50 | 51 |
| 51 /** @private */ | 52 /** @private */ |
| 52 this.error_ = remoting.Error.NONE; | 53 this.error_ = remoting.Error.NONE; |
| 53 | 54 |
| 54 /** @private */ | 55 /** @private */ |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 /** | 305 /** |
| 305 * Deletes the <embed> element from the container, without sending a | 306 * Deletes the <embed> element from the container, without sending a |
| 306 * session_terminate request. This is to be called when the session was | 307 * session_terminate request. This is to be called when the session was |
| 307 * disconnected by the Host. | 308 * disconnected by the Host. |
| 308 * | 309 * |
| 309 * @return {void} Nothing. | 310 * @return {void} Nothing. |
| 310 */ | 311 */ |
| 311 remoting.ClientSession.prototype.removePlugin = function() { | 312 remoting.ClientSession.prototype.removePlugin = function() { |
| 312 this.uiHandler_.removePlugin(); | 313 this.uiHandler_.removePlugin(); |
| 313 this.plugin_ = null; | 314 this.plugin_ = null; |
| 315 remoting.desktopConnectedView = null; |
| 314 }; | 316 }; |
| 315 | 317 |
| 316 /** | 318 /** |
| 317 * Disconnect the current session with a particular |error|. The session will | 319 * Disconnect the current session with a particular |error|. The session will |
| 318 * raise a |stateChanged| event in response to it. The caller should then call | 320 * raise a |stateChanged| event in response to it. The caller should then call |
| 319 * |cleanup| to remove and destroy the <embed> element. | 321 * dispose() to remove and destroy the <embed> element. |
| 320 * | 322 * |
| 321 * @param {remoting.Error} error The reason for the disconnection. Use | 323 * @param {remoting.Error} error The reason for the disconnection. Use |
| 322 * remoting.Error.NONE if there is no error. | 324 * remoting.Error.NONE if there is no error. |
| 323 * @return {void} Nothing. | 325 * @return {void} Nothing. |
| 324 */ | 326 */ |
| 325 remoting.ClientSession.prototype.disconnect = function(error) { | 327 remoting.ClientSession.prototype.disconnect = function(error) { |
| 326 var state = (error == remoting.Error.NONE) ? | 328 var state = (error == remoting.Error.NONE) ? |
| 327 remoting.ClientSession.State.CLOSED : | 329 remoting.ClientSession.State.CLOSED : |
| 328 remoting.ClientSession.State.FAILED; | 330 remoting.ClientSession.State.FAILED; |
| 329 | 331 |
| 330 // The plugin won't send a state change notification, so we explicitly log | 332 // The plugin won't send a state change notification, so we explicitly log |
| 331 // the fact that the connection has closed. | 333 // the fact that the connection has closed. |
| 332 this.logToServer.logClientSessionStateChange(state, error); | 334 this.logToServer.logClientSessionStateChange(state, error); |
| 333 this.error_ = error; | 335 this.error_ = error; |
| 334 this.setState_(state); | 336 this.setState_(state); |
| 335 }; | 337 }; |
| 336 | 338 |
| 337 /** | 339 /** |
| 338 * Deletes the <embed> element from the container and disconnects. | 340 * Deletes the <embed> element from the container and disconnects. |
| 339 * | 341 * |
| 340 * @return {void} Nothing. | 342 * @return {void} Nothing. |
| 341 */ | 343 */ |
| 342 remoting.ClientSession.prototype.cleanup = function() { | 344 remoting.ClientSession.prototype.dispose = function() { |
| 343 this.sendIq_( | 345 this.sendIq_( |
| 344 '<cli:iq ' + | 346 '<cli:iq ' + |
| 345 'to="' + this.host_.jabberId + '" ' + | 347 'to="' + this.host_.jabberId + '" ' + |
| 346 'type="set" ' + | 348 'type="set" ' + |
| 347 'id="session-terminate" ' + | 349 'id="session-terminate" ' + |
| 348 'xmlns:cli="jabber:client">' + | 350 'xmlns:cli="jabber:client">' + |
| 349 '<jingle ' + | 351 '<jingle ' + |
| 350 'xmlns="urn:xmpp:jingle:1" ' + | 352 'xmlns="urn:xmpp:jingle:1" ' + |
| 351 'action="session-terminate" ' + | 353 'action="session-terminate" ' + |
| 352 'sid="' + this.sessionId_ + '">' + | 354 'sid="' + this.sessionId_ + '">' + |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 * @param {boolean} enable True to enable rendering. | 766 * @param {boolean} enable True to enable rendering. |
| 765 */ | 767 */ |
| 766 remoting.ClientSession.prototype.enableDebugRegion = function(enable) { | 768 remoting.ClientSession.prototype.enableDebugRegion = function(enable) { |
| 767 if (enable) { | 769 if (enable) { |
| 768 this.plugin_.setDebugDirtyRegionHandler( | 770 this.plugin_.setDebugDirtyRegionHandler( |
| 769 this.uiHandler_.handleDebugRegion.bind(this.uiHandler_)); | 771 this.uiHandler_.handleDebugRegion.bind(this.uiHandler_)); |
| 770 } else { | 772 } else { |
| 771 this.plugin_.setDebugDirtyRegionHandler(null); | 773 this.plugin_.setDebugDirtyRegionHandler(null); |
| 772 } | 774 } |
| 773 } | 775 } |
| OLD | NEW |