summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-02 01:23:31 +0000
committerwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-02 01:23:31 +0000
commite7abceee38257be619d799b26b57c522ac504669 (patch)
tree4cf7d7aa673c2d5d8a10de8a3db54aa089f39c4e /remoting
parent0b3ec609f485f457667127abd2b2752fd075955a (diff)
downloadchromium_src-e7abceee38257be619d799b26b57c522ac504669.zip
chromium_src-e7abceee38257be619d799b26b57c522ac504669.tar.gz
chromium_src-e7abceee38257be619d799b26b57c522ac504669.tar.bz2
Send new client dimensions to host whenever they change.
This will be manually testable by checking for NotifyClientDimensions messages logged by hosts, once the host end logging is enabled. DO NOT COMMIT THIS UNTIL CL 10262035 HAS LANDED. BUG=110212 Review URL: http://codereview.chromium.org/10265033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134846 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/webapp/client_plugin.js10
-rw-r--r--remoting/webapp/client_plugin_async.js15
-rw-r--r--remoting/webapp/client_plugin_v1.js31
-rw-r--r--remoting/webapp/client_session.js29
4 files changed, 69 insertions, 16 deletions
diff --git a/remoting/webapp/client_plugin.js b/remoting/webapp/client_plugin.js
index 99c719c..0af6005 100644
--- a/remoting/webapp/client_plugin.js
+++ b/remoting/webapp/client_plugin.js
@@ -49,6 +49,7 @@ remoting.ClientPlugin.prototype.isSupportedVersion = function() {};
remoting.ClientPlugin.Feature = {
HIGH_QUALITY_SCALING: 'highQualityScaling',
INJECT_KEY_EVENT: 'injectKeyEvent',
+ NOTIFY_CLIENT_DIMENSIONS: 'notifyClientDimensions',
REMAP_KEY: 'remapKey',
SEND_CLIPBOARD_ITEM: 'sendClipboardItem'
};
@@ -134,3 +135,12 @@ remoting.ClientPlugin.prototype.getPerfStats = function() {};
* @param {string} item The clipboard item.
*/
remoting.ClientPlugin.prototype.sendClipboardItem = function(mimeType, item) {};
+
+/**
+ * Notifies the host that the client has the specified dimensions.
+ *
+ * @param {number} width The available client width.
+ * @param {number} height The available client height.
+ */
+remoting.ClientPlugin.prototype.notifyClientDimensions =
+ function(width, height) {};
diff --git a/remoting/webapp/client_plugin_async.js b/remoting/webapp/client_plugin_async.js
index 211502c0..cb14fa4 100644
--- a/remoting/webapp/client_plugin_async.js
+++ b/remoting/webapp/client_plugin_async.js
@@ -365,6 +365,21 @@ remoting.ClientPluginAsync.prototype.sendClipboardItem =
};
/**
+ * Notifies the host that the client has the specified dimensions.
+ *
+ * @param {number} width The available client width.
+ * @param {number} height The available client height.
+ */
+remoting.ClientPluginAsync.prototype.notifyClientDimensions =
+ function(width, height) {
+ if (!this.hasFeature(remoting.ClientPlugin.Feature.NOTIFY_CLIENT_DIMENSIONS))
+ return;
+ this.plugin.postMessage(JSON.stringify(
+ { method: 'notifyClientDimensions',
+ data: { width: width, height: height }}));
+};
+
+/**
* If we haven't yet received a "hello" message from the plugin, change its
* size so that the user can confirm it if click-to-play is enabled, or can
* see the "this plugin is disabled" message if it is actually disabled.
diff --git a/remoting/webapp/client_plugin_v1.js b/remoting/webapp/client_plugin_v1.js
index e67887b..c4d4607 100644
--- a/remoting/webapp/client_plugin_v1.js
+++ b/remoting/webapp/client_plugin_v1.js
@@ -230,20 +230,20 @@ remoting.ClientPluginV1.prototype.getPerfStats = function() {
};
/**
- * This dummy method exists only so that this class implements ClientPlugin.
- *
- * @param {string} mimeType The MIME type of the clipboard item.
- * @param {string} item The clipboard item.
+ * These dummy methods exist only so that this class implements ClientPlugin.
+ */
+
+/**
+ * @param {string} mimeType
+ * @param {string} item
*/
remoting.ClientPluginV1.prototype.sendClipboardItem = function(mimeType, item) {
return;
};
/**
- * This dummy method exists only so that this class implements ClientPlugin.
- *
- * @param {number} usbKeycode The USB-style code of the key to inject.
- * @param {boolean} pressed True to inject a key press, False for a release.
+ * @param {number} usbKeycode
+ * @param {boolean} pressed
*/
remoting.ClientPluginV1.prototype.injectKeyEvent =
function(usbKeycode, pressed) {
@@ -251,12 +251,19 @@ remoting.ClientPluginV1.prototype.injectKeyEvent =
};
/**
- * Remap one USB keycode to another in all subsequent key events.
- *
- * @param {number} fromKeycode The USB-style code of the key to remap.
- * @param {number} toKeycode The USB-style code to remap the key to.
+ * @param {number} fromKeycode
+ * @param {number} toKeycode
*/
remoting.ClientPluginV1.prototype.remapKey =
function(fromKeycode, toKeycode) {
return;
};
+
+/**
+ * @param {number} width
+ * @param {number} height
+ */
+remoting.ClientPluginV1.prototype.notifyClientDimensions =
+ function(width, height) {
+ return;
+};
diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js
index 8fab461..d7dc798 100644
--- a/remoting/webapp/client_session.js
+++ b/remoting/webapp/client_session.js
@@ -58,6 +58,10 @@ remoting.ClientSession = function(hostJid, hostPublicKey, sharedSecret,
this.scaleToFit = false;
this.logToServer = new remoting.LogToServer();
this.onStateChange = onStateChange;
+
+ /** @type {number?} */
+ this.notifyClientDimensionsTimer_ = null;
+
/** @type {remoting.ClientSession} */
var that = this;
/** @type {function():void} @private */
@@ -71,20 +75,22 @@ remoting.ClientSession = function(hostJid, hostPublicKey, sharedSecret,
/** @type {function():void} @private */
this.callToggleFullScreen_ = function() { that.toggleFullScreen_(); };
/** @type {remoting.MenuButton} @private */
- this.sendKeysMenu_ = new remoting.MenuButton(
- document.getElementById('send-keys-menu')
- );
- /** @type {remoting.MenuButton} @private */
this.screenOptionsMenu_ = new remoting.MenuButton(
document.getElementById('screen-options-menu'),
function() { that.onShowOptionsMenu_(); }
);
+ /** @type {remoting.MenuButton} @private */
+ this.sendKeysMenu_ = new remoting.MenuButton(
+ document.getElementById('send-keys-menu')
+ );
+
/** @type {HTMLElement} @private */
this.shrinkToFit_ = document.getElementById('enable-shrink-to-fit');
/** @type {HTMLElement} @private */
this.originalSize_ = document.getElementById('disable-shrink-to-fit');
/** @type {HTMLElement} @private */
this.fullScreen_ = document.getElementById('toggle-full-screen');
+
this.shrinkToFit_.addEventListener('click', this.callEnableShrink_, false);
this.originalSize_.addEventListener('click', this.callDisableShrink_, false);
this.fullScreen_.addEventListener('click', this.callToggleFullScreen_, false);
@@ -504,6 +510,21 @@ remoting.ClientSession.prototype.setState_ = function(newState) {
*/
remoting.ClientSession.prototype.onResize = function() {
this.updateDimensions();
+
+ if (this.notifyClientDimensionsTimer_) {
+ window.clearTimeout(this.notifyClientDimensionsTimer_);
+ this.notifyClientDimensionsTimer_ = null;
+ }
+
+ // Defer notifying the host of the change until the window stops resizing, to
+ // avoid overloading the control channel with notifications.
+ /** @type {remoting.ClientSession} */
+ var that = this;
+ var notifyClientDimensions = function() {
+ that.plugin.notifyClientDimensions(window.innerWidth, window.innerHeight);
+ }
+ this.notifyClientDimensionsTimer_ =
+ window.setTimeout(notifyClientDimensions, 1000);
};
/**