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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 this.resizeToClientButton_ = | 159 this.resizeToClientButton_ = |
160 document.getElementById('screen-resize-to-client'); | 160 document.getElementById('screen-resize-to-client'); |
161 /** @type {HTMLElement} @private */ | 161 /** @type {HTMLElement} @private */ |
162 this.shrinkToFitButton_ = document.getElementById('screen-shrink-to-fit'); | 162 this.shrinkToFitButton_ = document.getElementById('screen-shrink-to-fit'); |
163 /** @type {HTMLElement} @private */ | 163 /** @type {HTMLElement} @private */ |
164 this.fullScreenButton_ = document.getElementById('toggle-full-screen'); | 164 this.fullScreenButton_ = document.getElementById('toggle-full-screen'); |
165 | 165 |
166 /** @type {remoting.GnubbyAuthHandler} @private */ | 166 /** @type {remoting.GnubbyAuthHandler} @private */ |
167 this.gnubbyAuthHandler_ = null; | 167 this.gnubbyAuthHandler_ = null; |
168 | 168 |
169 /** @type {remoting.CastExtensionHandler} @private */ | |
170 this.castExtensionHandler_ = null; | |
171 | |
169 if (this.mode_ == remoting.ClientSession.Mode.IT2ME) { | 172 if (this.mode_ == remoting.ClientSession.Mode.IT2ME) { |
170 // Resize-to-client is not supported for IT2Me hosts. | 173 // Resize-to-client is not supported for IT2Me hosts. |
171 this.resizeToClientButton_.hidden = true; | 174 this.resizeToClientButton_.hidden = true; |
172 } else { | 175 } else { |
173 this.resizeToClientButton_.hidden = false; | 176 this.resizeToClientButton_.hidden = false; |
174 } | 177 } |
175 | 178 |
176 this.fullScreenButton_.addEventListener( | 179 this.fullScreenButton_.addEventListener( |
177 'click', this.callToggleFullScreen_, false); | 180 'click', this.callToggleFullScreen_, false); |
178 this.defineEvents(Object.keys(remoting.ClientSession.Events)); | 181 this.defineEvents(Object.keys(remoting.ClientSession.Events)); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 * Set of capabilities for which hasCapability_() can be used to test. | 369 * Set of capabilities for which hasCapability_() can be used to test. |
367 * | 370 * |
368 * @enum {string} | 371 * @enum {string} |
369 */ | 372 */ |
370 remoting.ClientSession.Capability = { | 373 remoting.ClientSession.Capability = { |
371 // When enabled this capability causes the client to send its screen | 374 // When enabled this capability causes the client to send its screen |
372 // resolution to the host once connection has been established. See | 375 // resolution to the host once connection has been established. See |
373 // this.plugin_.notifyClientResolution(). | 376 // this.plugin_.notifyClientResolution(). |
374 SEND_INITIAL_RESOLUTION: 'sendInitialResolution', | 377 SEND_INITIAL_RESOLUTION: 'sendInitialResolution', |
375 RATE_LIMIT_RESIZE_REQUESTS: 'rateLimitResizeRequests', | 378 RATE_LIMIT_RESIZE_REQUESTS: 'rateLimitResizeRequests', |
376 VIDEO_RECORDER: 'videoRecorder' | 379 VIDEO_RECORDER: 'videoRecorder', |
380 CAST: 'casting' | |
Jamie
2014/08/13 23:21:04
I think I would call this capability chromeCast (a
aiguha
2014/08/15 07:09:56
All the Cast docs avoid using Chromecast, because
Jamie
2014/08/15 18:45:43
How about GOOGLE_CAST, since that's the name of th
| |
377 }; | 381 }; |
378 | 382 |
379 /** | 383 /** |
380 * The set of capabilities negotiated between the client and host. | 384 * The set of capabilities negotiated between the client and host. |
381 * @type {Array.<string>} | 385 * @type {Array.<string>} |
382 * @private | 386 * @private |
383 */ | 387 */ |
384 remoting.ClientSession.prototype.capabilities_ = null; | 388 remoting.ClientSession.prototype.capabilities_ = null; |
385 | 389 |
386 /** | 390 /** |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
580 }; | 584 }; |
581 | 585 |
582 this.plugin_.onConnectionStatusUpdateHandler = | 586 this.plugin_.onConnectionStatusUpdateHandler = |
583 this.onConnectionStatusUpdate_.bind(this); | 587 this.onConnectionStatusUpdate_.bind(this); |
584 this.plugin_.onConnectionReadyHandler = this.onConnectionReady_.bind(this); | 588 this.plugin_.onConnectionReadyHandler = this.onConnectionReady_.bind(this); |
585 this.plugin_.onDesktopSizeUpdateHandler = | 589 this.plugin_.onDesktopSizeUpdateHandler = |
586 this.onDesktopSizeChanged_.bind(this); | 590 this.onDesktopSizeChanged_.bind(this); |
587 this.plugin_.onSetCapabilitiesHandler = this.onSetCapabilities_.bind(this); | 591 this.plugin_.onSetCapabilitiesHandler = this.onSetCapabilities_.bind(this); |
588 this.plugin_.onGnubbyAuthHandler = this.processGnubbyAuthMessage_.bind(this); | 592 this.plugin_.onGnubbyAuthHandler = this.processGnubbyAuthMessage_.bind(this); |
589 this.plugin_.updateMouseCursorImage = this.updateMouseCursorImage_.bind(this); | 593 this.plugin_.updateMouseCursorImage = this.updateMouseCursorImage_.bind(this); |
594 this.plugin_.onCastExtensionHandler = | |
595 this.processCastExtensionMessage_.bind(this); | |
590 this.initiateConnection_(); | 596 this.initiateConnection_(); |
591 }; | 597 }; |
592 | 598 |
593 /** | 599 /** |
594 * Deletes the <embed> element from the container, without sending a | 600 * Deletes the <embed> element from the container, without sending a |
595 * session_terminate request. This is to be called when the session was | 601 * session_terminate request. This is to be called when the session was |
596 * disconnected by the Host. | 602 * disconnected by the Host. |
597 * | 603 * |
598 * @return {void} Nothing. | 604 * @return {void} Nothing. |
599 */ | 605 */ |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1102 console.log('Suppressing host-offline error.'); | 1108 console.log('Suppressing host-offline error.'); |
1103 state = remoting.ClientSession.State.CONNECTION_CANCELED; | 1109 state = remoting.ClientSession.State.CONNECTION_CANCELED; |
1104 } | 1110 } |
1105 } else if (oldState == remoting.ClientSession.State.CONNECTED && | 1111 } else if (oldState == remoting.ClientSession.State.CONNECTED && |
1106 this.state_ == remoting.ClientSession.State.FAILED) { | 1112 this.state_ == remoting.ClientSession.State.FAILED) { |
1107 state = remoting.ClientSession.State.CONNECTION_DROPPED; | 1113 state = remoting.ClientSession.State.CONNECTION_DROPPED; |
1108 } | 1114 } |
1109 this.logToServer.logClientSessionStateChange(state, this.error_, this.mode_); | 1115 this.logToServer.logClientSessionStateChange(state, this.error_, this.mode_); |
1110 if (this.state_ == remoting.ClientSession.State.CONNECTED) { | 1116 if (this.state_ == remoting.ClientSession.State.CONNECTED) { |
1111 this.createGnubbyAuthHandler_(); | 1117 this.createGnubbyAuthHandler_(); |
1118 this.createCastExtensionHandler_(); | |
1112 } | 1119 } |
1113 | 1120 |
1114 this.raiseEvent(remoting.ClientSession.Events.stateChanged, | 1121 this.raiseEvent(remoting.ClientSession.Events.stateChanged, |
1115 new remoting.ClientSession.StateEvent(newState, oldState) | 1122 new remoting.ClientSession.StateEvent(newState, oldState) |
1116 ); | 1123 ); |
1117 }; | 1124 }; |
1118 | 1125 |
1119 /** | 1126 /** |
1120 * This is a callback that gets called when the window is resized. | 1127 * This is a callback that gets called when the window is resized. |
1121 * | 1128 * |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1571 * @return {{top: number, left:number}} The top-left corner of the plugin. | 1578 * @return {{top: number, left:number}} The top-left corner of the plugin. |
1572 */ | 1579 */ |
1573 remoting.ClientSession.prototype.getPluginPositionForTesting = function() { | 1580 remoting.ClientSession.prototype.getPluginPositionForTesting = function() { |
1574 var plugin = this.plugin_.element(); | 1581 var plugin = this.plugin_.element(); |
1575 var style = plugin.style; | 1582 var style = plugin.style; |
1576 return { | 1583 return { |
1577 top: parseFloat(style.marginTop), | 1584 top: parseFloat(style.marginTop), |
1578 left: parseFloat(style.marginLeft) | 1585 left: parseFloat(style.marginLeft) |
1579 }; | 1586 }; |
1580 }; | 1587 }; |
1588 | |
1589 /** | |
1590 * Send a cast extension message to the host. | |
1591 * @param {Object} data The cast message data. | |
1592 */ | |
1593 remoting.ClientSession.prototype.sendCastExtensionMessage = function(data) { | |
1594 if (!this.plugin_) | |
1595 return; | |
Jamie
2014/08/13 23:21:04
Braces for single-line conditionals, for consisten
aiguha
2014/08/15 07:09:56
sendClipboardItem and sendGnubbbyAuthMessage don't
Jamie
2014/08/15 18:45:43
I didn't realize they weren't consistent. Since th
| |
1596 this.plugin_.sendClientMessage('cast_message', JSON.stringify(data)); | |
1597 }; | |
1598 | |
1599 /** | |
1600 * Process a remote cast extension message from the host. | |
Jamie
2014/08/13 23:21:04
s/cast/Cast/, here and below
aiguha
2014/08/15 07:09:56
Done.
| |
1601 * @param {string} data Remote cast extension data message. | |
1602 * @private | |
1603 */ | |
1604 remoting.ClientSession.prototype.processCastExtensionMessage_ = function(data) { | |
1605 if (this.castExtensionHandler_) { | |
1606 this.castExtensionHandler_.onMessage(data); | |
1607 } | |
1608 }; | |
1609 | |
1610 /** | |
1611 * Create a cast extension handler and inform the host that cast extension | |
1612 * is supported. | |
1613 * @private | |
1614 */ | |
1615 remoting.ClientSession.prototype.createCastExtensionHandler_ = function() { | |
1616 if(this.mode_ == remoting.ClientSession.Mode.ME2ME) { | |
Jamie
2014/08/13 23:21:04
Why is this restricted to Me2Me?
Jamie
2014/08/13 23:21:04
Nit: Space after 'if'
aiguha
2014/08/15 07:09:56
Done.
aiguha
2014/08/15 07:09:56
Only the remoting_me2me_host target supports the C
Jamie
2014/08/15 18:45:43
I didn't realize that. I think it's correct in tha
| |
1617 this.castExtensionHandler_ = new remoting.CastExtensionHandler(this); | |
1618 } | |
1619 }; | |
1620 | |
OLD | NEW |