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

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

Issue 929323003: Separate host desktop related functionality into remoting.HostDesktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's feedback Created 5 years, 10 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
Index: remoting/webapp/crd/js/desktop_connected_view.js
diff --git a/remoting/webapp/crd/js/desktop_connected_view.js b/remoting/webapp/crd/js/desktop_connected_view.js
index 140607eebf2fd4c44e703e90707f772e52e4ad94..8692acfc2bb785118ea34ebc62b3b55f0d55a240 100644
--- a/remoting/webapp/crd/js/desktop_connected_view.js
+++ b/remoting/webapp/crd/js/desktop_connected_view.js
@@ -114,6 +114,9 @@ remoting.DesktopConnectedView = function(session, container, hostDisplayName,
/** @type {remoting.VideoFrameRecorder} @private */
this.videoFrameRecorder_ = null;
+
+ /** @private {base.Disposables} */
+ this.eventHooks_ = null;
};
base.extend(remoting.DesktopConnectedView, base.EventSourceImpl);
@@ -194,9 +197,9 @@ remoting.DesktopConnectedView.prototype.getClientArea_ = function() {
*/
remoting.DesktopConnectedView.prototype.notifyClientResolution_ = function() {
var clientArea = this.getClientArea_();
- this.plugin_.notifyClientResolution(clientArea.width * this.desktopScale_,
- clientArea.height * this.desktopScale_,
- window.devicePixelRatio);
+ this.plugin_.hostDesktop().resize(clientArea.width * this.desktopScale_,
+ clientArea.height * this.desktopScale_,
+ window.devicePixelRatio);
};
/**
@@ -293,10 +296,16 @@ remoting.DesktopConnectedView.prototype.onPluginInitialized_ = function(
this.plugin_.allowMouseLock();
}
- this.plugin_.setDesktopShapeUpdateHandler(
- this.onDesktopShapeChanged_.bind(this));
- this.plugin_.setDesktopSizeUpdateHandler(
- this.onDesktopSizeChanged_.bind(this));
+ base.dispose(this.eventHooks_);
+ var hostDesktop = this.plugin_.hostDesktop();
+ this.eventHooks_ = new base.Disposables(
+ new base.EventHook(
+ hostDesktop, remoting.HostDesktop.Events.sizeChanged,
+ this.onDesktopSizeChanged_.bind(this)),
+ new base.EventHook(
+ hostDesktop, remoting.HostDesktop.Events.shapeChanged,
+ this.onDesktopShapeChanged_.bind(this)));
+
this.plugin_.setMouseCursorHandler(this.updateMouseCursorImage_.bind(this));
this.onInitialized_(remoting.Error.NONE, this.plugin_);
@@ -310,11 +319,12 @@ remoting.DesktopConnectedView.prototype.onPluginInitialized_ = function(
* @private
*/
remoting.DesktopConnectedView.prototype.onDesktopSizeChanged_ = function() {
+ var desktop = this.plugin_.hostDesktop().getDimensions();
console.log('desktop size changed: ' +
- this.plugin_.getDesktopWidth() + 'x' +
- this.plugin_.getDesktopHeight() +' @ ' +
- this.plugin_.getDesktopXDpi() + 'x' +
- this.plugin_.getDesktopYDpi() + ' DPI');
+ desktop.width + 'x' +
+ desktop.height +' @ ' +
+ desktop.xDpi + 'x' +
+ desktop.yDpi + ' DPI');
this.updateDimensions();
this.updateScrollbarVisibility();
};
@@ -361,8 +371,7 @@ remoting.DesktopConnectedView.prototype.onResize = function() {
// avoid overloading the control channel with notifications.
if (this.resizeToClient_) {
var kResizeRateLimitMs = 1000;
- if (this.session_.hasCapability(
- remoting.ClientSession.Capability.RATE_LIMIT_RESIZE_REQUESTS)) {
+ if (this.plugin_.hostDesktop().hasResizeRateLimit()) {
kResizeRateLimitMs = 250;
}
var clientArea = this.getClientArea_();
@@ -401,6 +410,8 @@ remoting.DesktopConnectedView.prototype.onConnectionReady = function(ready) {
*/
remoting.DesktopConnectedView.prototype.removePlugin = function() {
if (this.plugin_) {
+ base.dispose(this.eventHooks_);
+ this.eventHooks_ = null;
this.plugin_.element().removeEventListener(
'focus', this.callPluginGotFocus_, false);
this.plugin_.element().removeEventListener(
@@ -734,15 +745,15 @@ remoting.DesktopConnectedView.prototype.scroll_ = function(dx, dy) {
* @return {void} Nothing.
*/
remoting.DesktopConnectedView.prototype.updateDimensions = function() {
- if (this.plugin_.getDesktopWidth() == 0 ||
- this.plugin_.getDesktopHeight() == 0) {
+ var desktopSize = this.plugin_.hostDesktop().getDimensions();
+
+ if (desktopSize.width === 0 ||
+ desktopSize.height === 0) {
return;
}
- var desktopSize = { width: this.plugin_.getDesktopWidth(),
- height: this.plugin_.getDesktopHeight() };
- var desktopDpi = { x: this.plugin_.getDesktopXDpi(),
- y: this.plugin_.getDesktopYDpi() };
+ var desktopDpi = { x: desktopSize.xDpi,
+ y: desktopSize.yDpi };
var newSize = remoting.DesktopConnectedView.choosePluginSize(
this.getClientArea_(), window.devicePixelRatio,
desktopSize, desktopDpi, this.desktopScale_,
@@ -910,15 +921,16 @@ remoting.DesktopConnectedView.prototype.updateScrollbarVisibility = function() {
// Determine whether or not horizontal or vertical scrollbars are
// required, taking into account their width.
var clientArea = this.getClientArea_();
- needsVerticalScroll = clientArea.height < this.plugin_.getDesktopHeight();
- needsHorizontalScroll = clientArea.width < this.plugin_.getDesktopWidth();
+ var desktopSize = this.plugin_.hostDesktop().getDimensions();
+ needsVerticalScroll = clientArea.height < desktopSize.height;
+ needsHorizontalScroll = clientArea.width < desktopSize.width;
var kScrollBarWidth = 16;
if (needsHorizontalScroll && !needsVerticalScroll) {
needsVerticalScroll =
- clientArea.height - kScrollBarWidth < this.plugin_.getDesktopHeight();
+ clientArea.height - kScrollBarWidth < desktopSize.height;
} else if (!needsHorizontalScroll && needsVerticalScroll) {
needsHorizontalScroll =
- clientArea.width - kScrollBarWidth < this.plugin_.getDesktopWidth();
+ clientArea.width - kScrollBarWidth < desktopSize.width;
}
}

Powered by Google App Engine
This is Rietveld 408576698