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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/client_session.js
diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js
index 3579b0d55327a22961752911e0d5bd42deeaa83d..c9206c7feea6e0067b34822e52fab20fb65dacde 100644
--- a/remoting/webapp/client_session.js
+++ b/remoting/webapp/client_session.js
@@ -23,6 +23,13 @@
var remoting = remoting || {};
/**
+ * True if Cast capability is supported.
+ *
+ * @type {boolean}
+ */
+remoting.enableCast = false;
+
+/**
* @param {HTMLElement} container Container element for the client view.
* @param {string} hostDisplayName A human-readable name for the host.
* @param {string} accessCode The IT2Me access code. Blank for Me2Me.
@@ -166,6 +173,9 @@ remoting.ClientSession = function(container, hostDisplayName, accessCode,
/** @type {remoting.GnubbyAuthHandler} @private */
this.gnubbyAuthHandler_ = null;
+ /** @type {remoting.CastExtensionHandler} @private */
+ this.castExtensionHandler_ = null;
+
if (this.mode_ == remoting.ClientSession.Mode.IT2ME) {
// Resize-to-client is not supported for IT2Me hosts.
this.resizeToClientButton_.hidden = true;
@@ -373,7 +383,8 @@ remoting.ClientSession.Capability = {
// this.plugin_.notifyClientResolution().
SEND_INITIAL_RESOLUTION: 'sendInitialResolution',
RATE_LIMIT_RESIZE_REQUESTS: 'rateLimitResizeRequests',
- VIDEO_RECORDER: 'videoRecorder'
+ VIDEO_RECORDER: 'videoRecorder',
+ CAST: 'casting'
};
/**
@@ -587,6 +598,8 @@ remoting.ClientSession.prototype.onPluginInitialized_ = function(initialized) {
this.plugin_.onSetCapabilitiesHandler = this.onSetCapabilities_.bind(this);
this.plugin_.onGnubbyAuthHandler = this.processGnubbyAuthMessage_.bind(this);
this.plugin_.updateMouseCursorImage = this.updateMouseCursorImage_.bind(this);
+ this.plugin_.onCastExtensionHandler =
+ this.processCastExtensionMessage_.bind(this);
this.initiateConnection_();
};
@@ -1109,6 +1122,7 @@ remoting.ClientSession.prototype.setState_ = function(newState) {
this.logToServer.logClientSessionStateChange(state, this.error_, this.mode_);
if (this.state_ == remoting.ClientSession.State.CONNECTED) {
this.createGnubbyAuthHandler_();
+ this.createCastExtensionHandler_();
}
this.raiseEvent(remoting.ClientSession.Events.stateChanged,
@@ -1578,3 +1592,43 @@ remoting.ClientSession.prototype.getPluginPositionForTesting = function() {
left: parseFloat(style.marginLeft)
};
};
+
+/**
+ * Send a Cast extension message to the host.
+ * @param {Object} data The cast message data.
+ */
+remoting.ClientSession.prototype.sendCastExtensionMessage = function(data) {
+ if (!this.plugin_)
+ return;
+ this.plugin_.sendClientMessage('cast_message', JSON.stringify(data));
+};
+
+/**
+ * Process a remote Cast extension message from the host.
+ * @param {string} data Remote cast extension data message.
+ * @private
+ */
+remoting.ClientSession.prototype.processCastExtensionMessage_ = function(data) {
+ if (this.castExtensionHandler_) {
+ try {
+ this.castExtensionHandler_.onMessage(data);
+ } catch (err) {
+ console.error('Failed to process cast message: ',
+ /** @type {*} */ (err));
+ }
+ } else {
+ console.error('Received unexpected cast message');
+ }
+};
+
+/**
+ * Create a CastExtensionHandler and inform the host that cast extension
+ * is supported.
+ * @private
+ */
+remoting.ClientSession.prototype.createCastExtensionHandler_ = function() {
+ if (remoting.enableCast && this.mode_ == remoting.ClientSession.Mode.ME2ME) {
+ this.castExtensionHandler_ = new remoting.CastExtensionHandler(this);
+ }
+};
+
« 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