Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: remoting/webapp/client_session.js

Issue 464133003: CastExtensionHandler for Chromoting Webapp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fix Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/webapp/client_plugin.js ('k') | remoting/webapp/js_proto/chrome_proto.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * establish connection. Specifically it: 11 * establish connection. Specifically it:
12 * - Delivers incoming/outgoing signaling messages, 12 * - Delivers incoming/outgoing signaling messages,
13 * - Adjusts plugin size and position when destop resolution changes, 13 * - Adjusts plugin size and position when destop resolution changes,
14 * 14 *
15 * This class should not access the plugin directly, instead it should 15 * This class should not access the plugin directly, instead it should
16 * do it through ClientPlugin class which abstracts plugin version 16 * do it through ClientPlugin class which abstracts plugin version
17 * differences. 17 * differences.
18 */ 18 */
19 19
20 'use strict'; 20 'use strict';
21 21
22 /** @suppress {duplicate} */ 22 /** @suppress {duplicate} */
23 var remoting = remoting || {}; 23 var remoting = remoting || {};
24 24
25 /** 25 /**
26 * True if Cast capability is supported.
27 *
28 * @type {boolean}
29 */
30 remoting.enableCast = false;
31
32 /**
26 * @param {HTMLElement} container Container element for the client view. 33 * @param {HTMLElement} container Container element for the client view.
27 * @param {string} hostDisplayName A human-readable name for the host. 34 * @param {string} hostDisplayName A human-readable name for the host.
28 * @param {string} accessCode The IT2Me access code. Blank for Me2Me. 35 * @param {string} accessCode The IT2Me access code. Blank for Me2Me.
29 * @param {function(boolean, function(string): void): void} fetchPin 36 * @param {function(boolean, function(string): void): void} fetchPin
30 * Called by Me2Me connections when a PIN needs to be obtained 37 * Called by Me2Me connections when a PIN needs to be obtained
31 * interactively. 38 * interactively.
32 * @param {function(string, string, string, 39 * @param {function(string, string, string,
33 * function(string, string): void): void} 40 * function(string, string): void): void}
34 * fetchThirdPartyToken Called by Me2Me connections when a third party 41 * fetchThirdPartyToken Called by Me2Me connections when a third party
35 * authentication token must be obtained. 42 * authentication token must be obtained.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 this.resizeToClientButton_ = 166 this.resizeToClientButton_ =
160 document.getElementById('screen-resize-to-client'); 167 document.getElementById('screen-resize-to-client');
161 /** @type {HTMLElement} @private */ 168 /** @type {HTMLElement} @private */
162 this.shrinkToFitButton_ = document.getElementById('screen-shrink-to-fit'); 169 this.shrinkToFitButton_ = document.getElementById('screen-shrink-to-fit');
163 /** @type {HTMLElement} @private */ 170 /** @type {HTMLElement} @private */
164 this.fullScreenButton_ = document.getElementById('toggle-full-screen'); 171 this.fullScreenButton_ = document.getElementById('toggle-full-screen');
165 172
166 /** @type {remoting.GnubbyAuthHandler} @private */ 173 /** @type {remoting.GnubbyAuthHandler} @private */
167 this.gnubbyAuthHandler_ = null; 174 this.gnubbyAuthHandler_ = null;
168 175
176 /** @type {remoting.CastExtensionHandler} @private */
177 this.castExtensionHandler_ = null;
178
169 if (this.mode_ == remoting.ClientSession.Mode.IT2ME) { 179 if (this.mode_ == remoting.ClientSession.Mode.IT2ME) {
170 // Resize-to-client is not supported for IT2Me hosts. 180 // Resize-to-client is not supported for IT2Me hosts.
171 this.resizeToClientButton_.hidden = true; 181 this.resizeToClientButton_.hidden = true;
172 } else { 182 } else {
173 this.resizeToClientButton_.hidden = false; 183 this.resizeToClientButton_.hidden = false;
174 } 184 }
175 185
176 this.fullScreenButton_.addEventListener( 186 this.fullScreenButton_.addEventListener(
177 'click', this.callToggleFullScreen_, false); 187 'click', this.callToggleFullScreen_, false);
178 this.defineEvents(Object.keys(remoting.ClientSession.Events)); 188 this.defineEvents(Object.keys(remoting.ClientSession.Events));
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 * Set of capabilities for which hasCapability_() can be used to test. 376 * Set of capabilities for which hasCapability_() can be used to test.
367 * 377 *
368 * @enum {string} 378 * @enum {string}
369 */ 379 */
370 remoting.ClientSession.Capability = { 380 remoting.ClientSession.Capability = {
371 // When enabled this capability causes the client to send its screen 381 // When enabled this capability causes the client to send its screen
372 // resolution to the host once connection has been established. See 382 // resolution to the host once connection has been established. See
373 // this.plugin_.notifyClientResolution(). 383 // this.plugin_.notifyClientResolution().
374 SEND_INITIAL_RESOLUTION: 'sendInitialResolution', 384 SEND_INITIAL_RESOLUTION: 'sendInitialResolution',
375 RATE_LIMIT_RESIZE_REQUESTS: 'rateLimitResizeRequests', 385 RATE_LIMIT_RESIZE_REQUESTS: 'rateLimitResizeRequests',
376 VIDEO_RECORDER: 'videoRecorder' 386 VIDEO_RECORDER: 'videoRecorder',
387 CAST: 'casting'
377 }; 388 };
378 389
379 /** 390 /**
380 * The set of capabilities negotiated between the client and host. 391 * The set of capabilities negotiated between the client and host.
381 * @type {Array.<string>} 392 * @type {Array.<string>}
382 * @private 393 * @private
383 */ 394 */
384 remoting.ClientSession.prototype.capabilities_ = null; 395 remoting.ClientSession.prototype.capabilities_ = null;
385 396
386 /** 397 /**
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 }; 591 };
581 592
582 this.plugin_.onConnectionStatusUpdateHandler = 593 this.plugin_.onConnectionStatusUpdateHandler =
583 this.onConnectionStatusUpdate_.bind(this); 594 this.onConnectionStatusUpdate_.bind(this);
584 this.plugin_.onConnectionReadyHandler = this.onConnectionReady_.bind(this); 595 this.plugin_.onConnectionReadyHandler = this.onConnectionReady_.bind(this);
585 this.plugin_.onDesktopSizeUpdateHandler = 596 this.plugin_.onDesktopSizeUpdateHandler =
586 this.onDesktopSizeChanged_.bind(this); 597 this.onDesktopSizeChanged_.bind(this);
587 this.plugin_.onSetCapabilitiesHandler = this.onSetCapabilities_.bind(this); 598 this.plugin_.onSetCapabilitiesHandler = this.onSetCapabilities_.bind(this);
588 this.plugin_.onGnubbyAuthHandler = this.processGnubbyAuthMessage_.bind(this); 599 this.plugin_.onGnubbyAuthHandler = this.processGnubbyAuthMessage_.bind(this);
589 this.plugin_.updateMouseCursorImage = this.updateMouseCursorImage_.bind(this); 600 this.plugin_.updateMouseCursorImage = this.updateMouseCursorImage_.bind(this);
601 this.plugin_.onCastExtensionHandler =
602 this.processCastExtensionMessage_.bind(this);
590 this.initiateConnection_(); 603 this.initiateConnection_();
591 }; 604 };
592 605
593 /** 606 /**
594 * Deletes the <embed> element from the container, without sending a 607 * Deletes the <embed> element from the container, without sending a
595 * session_terminate request. This is to be called when the session was 608 * session_terminate request. This is to be called when the session was
596 * disconnected by the Host. 609 * disconnected by the Host.
597 * 610 *
598 * @return {void} Nothing. 611 * @return {void} Nothing.
599 */ 612 */
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 console.log('Suppressing host-offline error.'); 1115 console.log('Suppressing host-offline error.');
1103 state = remoting.ClientSession.State.CONNECTION_CANCELED; 1116 state = remoting.ClientSession.State.CONNECTION_CANCELED;
1104 } 1117 }
1105 } else if (oldState == remoting.ClientSession.State.CONNECTED && 1118 } else if (oldState == remoting.ClientSession.State.CONNECTED &&
1106 this.state_ == remoting.ClientSession.State.FAILED) { 1119 this.state_ == remoting.ClientSession.State.FAILED) {
1107 state = remoting.ClientSession.State.CONNECTION_DROPPED; 1120 state = remoting.ClientSession.State.CONNECTION_DROPPED;
1108 } 1121 }
1109 this.logToServer.logClientSessionStateChange(state, this.error_, this.mode_); 1122 this.logToServer.logClientSessionStateChange(state, this.error_, this.mode_);
1110 if (this.state_ == remoting.ClientSession.State.CONNECTED) { 1123 if (this.state_ == remoting.ClientSession.State.CONNECTED) {
1111 this.createGnubbyAuthHandler_(); 1124 this.createGnubbyAuthHandler_();
1125 this.createCastExtensionHandler_();
1112 } 1126 }
1113 1127
1114 this.raiseEvent(remoting.ClientSession.Events.stateChanged, 1128 this.raiseEvent(remoting.ClientSession.Events.stateChanged,
1115 new remoting.ClientSession.StateEvent(newState, oldState) 1129 new remoting.ClientSession.StateEvent(newState, oldState)
1116 ); 1130 );
1117 }; 1131 };
1118 1132
1119 /** 1133 /**
1120 * This is a callback that gets called when the window is resized. 1134 * This is a callback that gets called when the window is resized.
1121 * 1135 *
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 * @return {{top: number, left:number}} The top-left corner of the plugin. 1585 * @return {{top: number, left:number}} The top-left corner of the plugin.
1572 */ 1586 */
1573 remoting.ClientSession.prototype.getPluginPositionForTesting = function() { 1587 remoting.ClientSession.prototype.getPluginPositionForTesting = function() {
1574 var plugin = this.plugin_.element(); 1588 var plugin = this.plugin_.element();
1575 var style = plugin.style; 1589 var style = plugin.style;
1576 return { 1590 return {
1577 top: parseFloat(style.marginTop), 1591 top: parseFloat(style.marginTop),
1578 left: parseFloat(style.marginLeft) 1592 left: parseFloat(style.marginLeft)
1579 }; 1593 };
1580 }; 1594 };
1595
1596 /**
1597 * Send a Cast extension message to the host.
1598 * @param {Object} data The cast message data.
1599 */
1600 remoting.ClientSession.prototype.sendCastExtensionMessage = function(data) {
1601 if (!this.plugin_)
1602 return;
1603 this.plugin_.sendClientMessage('cast_message', JSON.stringify(data));
1604 };
1605
1606 /**
1607 * Process a remote Cast extension message from the host.
1608 * @param {string} data Remote cast extension data message.
1609 * @private
1610 */
1611 remoting.ClientSession.prototype.processCastExtensionMessage_ = function(data) {
1612 if (this.castExtensionHandler_) {
1613 try {
1614 this.castExtensionHandler_.onMessage(data);
1615 } catch (err) {
1616 console.error('Failed to process cast message: ',
1617 /** @type {*} */ (err));
1618 }
1619 } else {
1620 console.error('Received unexpected cast message');
1621 }
1622 };
1623
1624 /**
1625 * Create a CastExtensionHandler and inform the host that cast extension
1626 * is supported.
1627 * @private
1628 */
1629 remoting.ClientSession.prototype.createCastExtensionHandler_ = function() {
1630 if (remoting.enableCast && this.mode_ == remoting.ClientSession.Mode.ME2ME) {
1631 this.castExtensionHandler_ = new remoting.CastExtensionHandler(this);
1632 }
1633 };
1634
OLDNEW
« no previous file with comments | « remoting/webapp/client_plugin.js ('k') | remoting/webapp/js_proto/chrome_proto.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698