Commit 84ad3eaa authored by wez@chromium.org's avatar wez@chromium.org

Update web-app client to use plugin notifyDeviceResolution API.

BUG=172404


Review URL: https://chromiumcodereview.appspot.com/12207099

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181987 0039d316-1c4b-4281-b951-d872f2087c98
parent 7a6934ea
......@@ -55,6 +55,7 @@ remoting.ClientPlugin.prototype.isSupportedVersion = function() {};
remoting.ClientPlugin.Feature = {
INJECT_KEY_EVENT: 'injectKeyEvent',
NOTIFY_CLIENT_DIMENSIONS: 'notifyClientDimensions',
NOTIFY_CLIENT_RESOLUTION: 'notifyClientResolution',
PAUSE_VIDEO: 'pauseVideo',
PAUSE_AUDIO: 'pauseAudio',
REMAP_KEY: 'remapKey',
......@@ -147,13 +148,14 @@ remoting.ClientPlugin.prototype.getPerfStats = function() {};
remoting.ClientPlugin.prototype.sendClipboardItem = function(mimeType, item) {};
/**
* Notifies the host that the client has the specified dimensions.
* Notifies the host that the client has the specified size and pixel density.
*
* @param {number} width The available client width.
* @param {number} height The available client height.
* @param {number} width The available client width in DIPs.
* @param {number} height The available client height in DIPs.
* @param {number} device_scale The number of device pixels per DIP.
*/
remoting.ClientPlugin.prototype.notifyClientDimensions =
function(width, height) {};
remoting.ClientPlugin.prototype.notifyClientResolution =
function(width, height, device_scale) {};
/**
* Requests that the host pause or resume sending video updates.
......
......@@ -385,18 +385,27 @@ remoting.ClientPluginAsync.prototype.sendClipboardItem =
};
/**
* Notifies the host that the client has the specified dimensions.
* Notifies the host that the client has the specified size and pixel density.
*
* @param {number} width The available client width.
* @param {number} height The available client height.
* @param {number} width The available client width in DIPs.
* @param {number} height The available client height in DIPs.
* @param {number} device_scale The number of device pixels per DIP.
*/
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 }}));
remoting.ClientPluginAsync.prototype.notifyClientResolution =
function(width, height, device_scale) {
if (this.hasFeature(remoting.ClientPlugin.Feature.NOTIFY_CLIENT_RESOLUTION)) {
var dpi = device_scale * 96;
this.plugin.postMessage(JSON.stringify(
{ method: 'notifyClientResolution',
data: { width: width * device_scale,
height: height * device_scale,
x_dpi: dpi, y_dpi: dpi }}));
} else if (this.hasFeature(
remoting.ClientPlugin.Feature.NOTIFY_CLIENT_DIMENSIONS)) {
this.plugin.postMessage(JSON.stringify(
{ method: 'notifyClientDimensions',
data: { width: width, height: height }}));
}
};
/**
......
......@@ -64,7 +64,7 @@ remoting.ClientSession = function(hostJid, clientJid,
this.onStateChange_ = null;
/** @type {number?} @private */
this.notifyClientDimensionsTimer_ = null;
this.notifyClientResolutionTimer_ = null;
/** @type {number?} @private */
this.bumpScrollTimer_ = null;
......@@ -504,7 +504,9 @@ remoting.ClientSession.prototype.setScreenMode_ =
function(shrinkToFit, resizeToClient) {
if (resizeToClient && !this.resizeToClient_) {
this.plugin.notifyClientDimensions(window.innerWidth, window.innerHeight);
this.plugin.notifyClientResolution(window.innerWidth,
window.innerHeight,
window.devicePixelRatio);
}
// If enabling shrink, reset bump-scroll offsets.
......@@ -627,7 +629,9 @@ remoting.ClientSession.prototype.onConnectionStatusUpdate_ =
if (status == remoting.ClientSession.State.CONNECTED) {
this.onDesktopSizeChanged_();
if (this.resizeToClient_) {
this.plugin.notifyClientDimensions(window.innerWidth, window.innerHeight);
this.plugin.notifyClientResolution(window.innerWidth,
window.innerHeight,
window.devicePixelRatio);
}
} else if (status == remoting.ClientSession.State.FAILED) {
this.error_ = /** @type {remoting.ClientSession.ConnectionError} */ (error);
......@@ -688,18 +692,19 @@ remoting.ClientSession.prototype.setState_ = function(newState) {
remoting.ClientSession.prototype.onResize = function() {
this.updateDimensions();
if (this.notifyClientDimensionsTimer_) {
window.clearTimeout(this.notifyClientDimensionsTimer_);
this.notifyClientDimensionsTimer_ = null;
if (this.notifyClientResolutionTimer_) {
window.clearTimeout(this.notifyClientResolutionTimer_);
this.notifyClientResolutionTimer_ = null;
}
// Defer notifying the host of the change until the window stops resizing, to
// avoid overloading the control channel with notifications.
if (this.resizeToClient_) {
this.notifyClientDimensionsTimer_ = window.setTimeout(
this.plugin.notifyClientDimensions.bind(this.plugin,
this.notifyClientResolutionTimer_ = window.setTimeout(
this.plugin.notifyClientResolution.bind(this.plugin,
window.innerWidth,
window.innerHeight),
window.innerHeight,
window.devicePixelRatio),
1000);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment