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

Unified Diff: remoting/webapp/crd/js/client_session.js

Issue 761673008: Add a per-host desktopScale option, available via the JS console. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Un-wrap line Created 6 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/crd/js/client_session.js
diff --git a/remoting/webapp/crd/js/client_session.js b/remoting/webapp/crd/js/client_session.js
index 5dbf13c8ff66b5cf3d23021d07303ff0ca039ab1..09215cbf6f9b2a359bdbfd910e51aadf07db3e20 100644
--- a/remoting/webapp/crd/js/client_session.js
+++ b/remoting/webapp/crd/js/client_session.js
@@ -138,6 +138,8 @@ remoting.ClientSession = function(signalStrategy, container, hostDisplayName,
/** @private */
this.resizeToClient_ = true;
/** @private */
+ this.desktopScale_ = 1.0;
+ /** @private */
this.remapKeys_ = '';
/** @private */
this.hasReceivedFrame_ = false;
@@ -386,6 +388,7 @@ remoting.ClientSession.STATS_KEY_ROUNDTRIP_LATENCY = 'roundtripLatency';
remoting.ClientSession.KEY_REMAP_KEYS = 'remapKeys';
remoting.ClientSession.KEY_RESIZE_TO_CLIENT = 'resizeToClient';
remoting.ClientSession.KEY_SHRINK_TO_FIT = 'shrinkToFit';
+remoting.ClientSession.KEY_DESKTOP_SCALE = 'desktopScale';
/**
* Set of capabilities for which hasCapability_() can be used to test.
@@ -506,6 +509,12 @@ remoting.ClientSession.prototype.onHostSettingsLoaded_ = function(options) {
this.shrinkToFit_ = /** @type {boolean} */
options[remoting.ClientSession.KEY_SHRINK_TO_FIT];
}
+ if (remoting.ClientSession.KEY_DESKTOP_SCALE in options &&
+ typeof(options[remoting.ClientSession.KEY_DESKTOP_SCALE]) ==
+ 'number') {
+ this.desktopScale_ = /** @type {number} */
+ options[remoting.ClientSession.KEY_DESKTOP_SCALE];
+ }
/** @param {boolean} result */
this.plugin_.initialize(this.onPluginInitialized_.bind(this));
@@ -774,6 +783,26 @@ remoting.ClientSession.prototype.sendPrintScreen = function() {
}
/**
+ * Sets and stores the scale factor to apply to host sizing requests.
+ * The desktopScale applies to the dimensions reported to the host, not
+ * to the client DPI reported to it.
+ *
+ * @param {number} desktopScale Scale factor to apply.
+ */
+remoting.ClientSession.prototype.setDesktopScale = function(desktopScale) {
+ this.desktopScale_ = desktopScale;
+
+ // onResize() will update the plugin size and scrollbars for the new
+ // scaled plugin dimensions, and send a client resolution notification.
+ this.onResize();
+
+ // Save the new desktop scale setting.
+ var options = {};
+ options[remoting.ClientSession.KEY_DESKTOP_SCALE] = this.desktopScale_;
+ remoting.HostSettings.save(this.hostId_, options);
+}
+
+/**
* Sets and stores the key remapping setting for the current host.
*
* @param {string} remappings Comma separated list of key remappings.
@@ -844,10 +873,7 @@ remoting.ClientSession.prototype.applyRemapKeys_ = function(apply) {
remoting.ClientSession.prototype.setScreenMode =
function(shrinkToFit, resizeToClient) {
if (resizeToClient && !this.resizeToClient_) {
- var clientArea = this.getClientArea_();
- this.plugin_.notifyClientResolution(clientArea.width,
- clientArea.height,
- window.devicePixelRatio);
+ this.notifyClientResolution_();
}
// If enabling shrink, reset bump-scroll offsets.
@@ -1010,10 +1036,7 @@ remoting.ClientSession.prototype.onConnectionStatusUpdate_ =
this.setFocusHandlers_();
this.onDesktopSizeChanged_();
if (this.resizeToClient_) {
- var clientArea = this.getClientArea_();
- this.plugin_.notifyClientResolution(clientArea.width,
- clientArea.height,
- window.devicePixelRatio);
+ this.notifyClientResolution_();
}
// Activate full-screen related UX.
remoting.fullscreen.addListener(this.callOnFullScreenChanged_);
@@ -1106,10 +1129,7 @@ remoting.ClientSession.prototype.onSetCapabilities_ = function(capabilities) {
this.capabilities_ = capabilities;
if (this.hasCapability_(
remoting.ClientSession.Capability.SEND_INITIAL_RESOLUTION)) {
- var clientArea = this.getClientArea_();
- this.plugin_.notifyClientResolution(clientArea.width,
- clientArea.height,
- window.devicePixelRatio);
+ this.notifyClientResolution_();
}
if (this.hasCapability_(remoting.ClientSession.Capability.GOOGLE_DRIVE)) {
this.sendGoogleDriveAccessToken_();
@@ -1178,10 +1198,7 @@ remoting.ClientSession.prototype.onResize = function() {
}
var clientArea = this.getClientArea_();
this.notifyClientResolutionTimer_ = window.setTimeout(
- this.plugin_.notifyClientResolution.bind(this.plugin_,
- clientArea.width,
- clientArea.height,
- window.devicePixelRatio),
+ this.notifyClientResolution_.bind(this),
kResizeRateLimitMs);
}
@@ -1289,6 +1306,10 @@ remoting.ClientSession.prototype.updateDimensions = function() {
var hostPixelRatioY = Math.ceil(this.plugin_.getDesktopYDpi() / 96);
var hostPixelRatio = Math.min(hostPixelRatioX, hostPixelRatioY);
+ // Include the desktopScale in the hostPixelRatio before comparing it with
+ // the client devicePixelRatio to determine the "natural" scale to use.
+ hostPixelRatio *= this.desktopScale_;
+
// Down-scale by the smaller of the client and host ratios.
var scale = 1.0 / Math.min(window.devicePixelRatio, hostPixelRatio);
@@ -1635,6 +1656,18 @@ remoting.ClientSession.prototype.getClientArea_ = function() {
};
/**
+ * Notifies the host of the client's current dimensions and DPI.
+ * Also takes into account per-host scaling factor, if configured.
+ * @private
+ */
+remoting.ClientSession.prototype.notifyClientResolution_ = function() {
+ var clientArea = this.getClientArea_();
+ this.plugin_.notifyClientResolution(clientArea.width * this.desktopScale_,
+ clientArea.height * this.desktopScale_,
+ window.devicePixelRatio);
+}
+
+/**
* @param {string} url
* @param {number} hotspotX
* @param {number} hotspotY
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698