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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // Indicates that the client supports the video frame-recording extension. | 254 // Indicates that the client supports the video frame-recording extension. |
255 VIDEO_RECORDER: 'videoRecorder', | 255 VIDEO_RECORDER: 'videoRecorder', |
256 | 256 |
257 // Indicates that the client supports 'cast'ing the video stream to a | 257 // Indicates that the client supports 'cast'ing the video stream to a |
258 // cast-enabled device. | 258 // cast-enabled device. |
259 CAST: 'casting', | 259 CAST: 'casting', |
260 }; | 260 }; |
261 | 261 |
262 /** | 262 /** |
263 * The set of capabilities negotiated between the client and host. | 263 * The set of capabilities negotiated between the client and host. |
264 * @type {Array.<string>} | 264 * @type {Array<string>} |
265 * @private | 265 * @private |
266 */ | 266 */ |
267 remoting.ClientSession.prototype.capabilities_ = null; | 267 remoting.ClientSession.prototype.capabilities_ = null; |
268 | 268 |
269 /** | 269 /** |
270 * @param {remoting.ClientSession.Capability} capability The capability to test | 270 * @param {remoting.ClientSession.Capability} capability The capability to test |
271 * for. | 271 * for. |
272 * @return {boolean} True if the capability has been negotiated between | 272 * @return {boolean} True if the capability has been negotiated between |
273 * the client and host. | 273 * the client and host. |
274 */ | 274 */ |
275 remoting.ClientSession.prototype.hasCapability = function(capability) { | 275 remoting.ClientSession.prototype.hasCapability = function(capability) { |
276 if (this.capabilities_ == null) | 276 if (this.capabilities_ == null) |
277 return false; | 277 return false; |
278 | 278 |
279 return this.capabilities_.indexOf(capability) > -1; | 279 return this.capabilities_.indexOf(capability) > -1; |
280 }; | 280 }; |
281 | 281 |
282 /** | 282 /** |
283 * Adds <embed> element to the UI container and readies the session object. | 283 * Adds <embed> element to the UI container and readies the session object. |
284 * | 284 * |
285 * @param {function(string, string):boolean} onExtensionMessage The handler for | 285 * @param {function(string, string):boolean} onExtensionMessage The handler for |
286 * protocol extension messages. Returns true if a message is recognized; | 286 * protocol extension messages. Returns true if a message is recognized; |
287 * false otherwise. | 287 * false otherwise. |
288 * @param {Array.<string>} requiredCapabilities A list of capabilities | 288 * @param {Array<string>} requiredCapabilities A list of capabilities |
289 * required by this application. | 289 * required by this application. |
290 */ | 290 */ |
291 remoting.ClientSession.prototype.createPluginAndConnect = | 291 remoting.ClientSession.prototype.createPluginAndConnect = |
292 function(onExtensionMessage, requiredCapabilities) { | 292 function(onExtensionMessage, requiredCapabilities) { |
293 this.uiHandler_.createPluginAndConnect(onExtensionMessage, | 293 this.uiHandler_.createPluginAndConnect(onExtensionMessage, |
294 requiredCapabilities); | 294 requiredCapabilities); |
295 }; | 295 }; |
296 | 296 |
297 /** | 297 /** |
298 * @param {remoting.Error} error | 298 * @param {remoting.Error} error |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 | 597 |
598 this.uiHandler_.onConnectionReady(ready); | 598 this.uiHandler_.onConnectionReady(ready); |
599 | 599 |
600 this.raiseEvent(remoting.ClientSession.Events.videoChannelStateChanged, | 600 this.raiseEvent(remoting.ClientSession.Events.videoChannelStateChanged, |
601 ready); | 601 ready); |
602 }; | 602 }; |
603 | 603 |
604 /** | 604 /** |
605 * Called when the client-host capabilities negotiation is complete. | 605 * Called when the client-host capabilities negotiation is complete. |
606 * | 606 * |
607 * @param {!Array.<string>} capabilities The set of capabilities negotiated | 607 * @param {!Array<string>} capabilities The set of capabilities negotiated |
608 * between the client and host. | 608 * between the client and host. |
609 * @return {void} Nothing. | 609 * @return {void} Nothing. |
610 * @private | 610 * @private |
611 */ | 611 */ |
612 remoting.ClientSession.prototype.onSetCapabilities_ = function(capabilities) { | 612 remoting.ClientSession.prototype.onSetCapabilities_ = function(capabilities) { |
613 if (this.capabilities_ != null) { | 613 if (this.capabilities_ != null) { |
614 console.error('onSetCapabilities_() is called more than once'); | 614 console.error('onSetCapabilities_() is called more than once'); |
615 return; | 615 return; |
616 } | 616 } |
617 | 617 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 * @param {Object} message The parsed extension message data. | 840 * @param {Object} message The parsed extension message data. |
841 * @return {boolean} True if the message was recognized, false otherwise. | 841 * @return {boolean} True if the message was recognized, false otherwise. |
842 */ | 842 */ |
843 remoting.ClientSession.prototype.handleExtensionMessage = | 843 remoting.ClientSession.prototype.handleExtensionMessage = |
844 function(type, message) { | 844 function(type, message) { |
845 if (this.uiHandler_.handleExtensionMessage(type, message)) { | 845 if (this.uiHandler_.handleExtensionMessage(type, message)) { |
846 return true; | 846 return true; |
847 } | 847 } |
848 return false; | 848 return false; |
849 }; | 849 }; |
OLD | NEW |