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

Unified Diff: remoting/webapp/client_plugin_async.js

Issue 13932020: Set the initial resolution of an RDP session to the client screen resolution if it is available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Clang Created 7 years, 8 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/client_session.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/client_plugin_async.js
diff --git a/remoting/webapp/client_plugin_async.js b/remoting/webapp/client_plugin_async.js
index e9b1f6564bb65678d8433516493f0eb0caa44f77..71ec21f6dc6523074902d68a6bd8a5cc7043093e 100644
--- a/remoting/webapp/client_plugin_async.js
+++ b/remoting/webapp/client_plugin_async.js
@@ -41,6 +41,8 @@ remoting.ClientPluginAsync = function(plugin) {
/** @param {boolean} ready Connection ready state. */
this.onConnectionReadyHandler = function(ready) {};
this.onDesktopSizeUpdateHandler = function () {};
+ /** @param {!Array.<string>} capabilities The negotiated capabilities. */
+ this.onSetCapabilitiesHandler = function (capabilities) {};
this.fetchPinHandler = function () {};
/** @type {number} */
@@ -49,6 +51,8 @@ remoting.ClientPluginAsync = function(plugin) {
this.pluginApiFeatures_ = [];
/** @type {number} */
this.pluginApiMinVersion_ = -1;
+ /** @type {!Array.<string>} */
+ this.capabilities_ = [];
/** @type {boolean} */
this.helloReceived_ = false;
/** @type {function(boolean)|null} */
@@ -98,6 +102,17 @@ remoting.ClientPluginAsync.prototype.handleMessage_ = function(messageStr) {
return;
}
+ /**
+ * Splits a string into a list of words delimited by spaces.
+ * @param {string} str String that should be split.
+ * @return {!Array.<string>} List of words.
+ */
+ var tokenize = function(str) {
+ /** @type {Array.<string>} */
+ var tokens = str.match(/\S+/g);
+ return tokens ? tokens : [];
+ };
+
if (message.method == 'hello') {
// Reset the size in case we had to enlarge it to support click-to-play.
this.plugin.width = 0;
@@ -108,13 +123,47 @@ remoting.ClientPluginAsync.prototype.handleMessage_ = function(messageStr) {
return;
}
this.pluginApiVersion_ = /** @type {number} */ message.data['apiVersion'];
+
if (this.pluginApiVersion_ >= 7) {
if (typeof message.data['apiFeatures'] != 'string') {
console.error('Received invalid hello message: ' + messageStr);
return;
}
this.pluginApiFeatures_ =
- /** @type {Array.<string>} */ message.data['apiFeatures'].split(' ');
+ /** @type {Array.<string>} */ tokenize(message.data['apiFeatures']);
+
+ // Negotiate capabilities.
+
+ /** @type {!Array.<string>} */
+ var requestedCapabilities = [];
+ if ('requestedCapabilities' in message.data) {
+ if (typeof message.data['requestedCapabilities'] != 'string') {
+ console.error('Received invalid hello message: ' + messageStr);
+ return;
+ }
+ requestedCapabilities = tokenize(message.data['requestedCapabilities']);
+ }
+
+ /** @type {!Array.<string>} */
+ var supportedCapabilities = [];
+ if ('supportedCapabilities' in message.data) {
+ if (typeof message.data['supportedCapabilities'] != 'string') {
+ console.error('Received invalid hello message: ' + messageStr);
+ return;
+ }
+ supportedCapabilities = tokenize(message.data['supportedCapabilities']);
+ }
+
+ // At the moment the webapp does not recognize any of
+ // 'requestedCapabilities' capabilities (so they all should be disabled)
+ // and do not care about any of 'supportedCapabilities' capabilities (so
+ // they all can be enabled).
+ this.capabilities_ = supportedCapabilities;
+
+ // Let the host know that the webapp can be requested to always send
+ // the client's dimensions.
+ this.capabilities_.push(
+ remoting.ClientSession.Capability.SEND_INITIAL_RESOLUTION);
} else if (this.pluginApiVersion_ >= 6) {
this.pluginApiFeatures_ = ['highQualityScaling', 'injectKeyEvent'];
} else {
@@ -208,6 +257,15 @@ remoting.ClientPluginAsync.prototype.handleMessage_ = function(messageStr) {
this.onConnectionReadyHandler(ready);
} else if (message.method == 'fetchPin') {
this.fetchPinHandler();
+ } else if (message.method == 'setCapabilities') {
+ if (typeof message.data['capabilities'] != 'string') {
+ console.error('Received incorrect setCapabilities message.');
+ return;
+ }
+
+ /** @type {!Array.<string>} */
+ var capabilities = tokenize(message.data['capabilities']);
+ this.onSetCapabilitiesHandler(capabilities);
}
};
@@ -306,7 +364,8 @@ remoting.ClientPluginAsync.prototype.connect = function(
localJid: localJid,
sharedSecret: sharedSecret,
authenticationMethods: authenticationMethods,
- authenticationTag: authenticationTag
+ authenticationTag: authenticationTag,
+ capabilities: this.capabilities_.join(" ")
}
}));
};
« no previous file with comments | « remoting/webapp/client_plugin.js ('k') | remoting/webapp/client_session.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698