| Index: remoting/webapp/crd/js/client_plugin_impl.js
|
| diff --git a/remoting/webapp/crd/js/client_plugin_impl.js b/remoting/webapp/crd/js/client_plugin_impl.js
|
| index af0fc723fbf5f618d6139be682443333135b71c3..16d0eab3fbbc506269f88ecdc85e35e3b2e9614f 100644
|
| --- a/remoting/webapp/crd/js/client_plugin_impl.js
|
| +++ b/remoting/webapp/crd/js/client_plugin_impl.js
|
| @@ -35,7 +35,8 @@ remoting.ClientPluginMessage = function() {
|
| * @constructor
|
| * @implements {remoting.ClientPlugin}
|
| */
|
| -remoting.ClientPluginImpl = function(container, onExtensionMessage,
|
| +remoting.ClientPluginImpl = function(container,
|
| + onExtensionMessage,
|
| requiredCapabilities) {
|
| this.plugin_ = remoting.ClientPluginImpl.createPluginElement_();
|
| this.plugin_.id = 'session-client-plugin';
|
| @@ -48,15 +49,6 @@ remoting.ClientPluginImpl = function(container, onExtensionMessage,
|
| */
|
| this.requiredCapabilities_ = requiredCapabilities;
|
|
|
| - /** @private */
|
| - this.desktopWidth_ = 0;
|
| - /** @private */
|
| - this.desktopHeight_ = 0;
|
| - /** @private */
|
| - this.desktopXDpi_ = 96;
|
| - /** @private */
|
| - this.desktopYDpi_ = 96;
|
| -
|
| /**
|
| * @param {string} iq The Iq stanza received from the host.
|
| * @private
|
| @@ -180,6 +172,9 @@ remoting.ClientPluginImpl = function(container, onExtensionMessage,
|
| if (remoting.settings.CLIENT_PLUGIN_TYPE == 'native') {
|
| window.setTimeout(this.showPluginForClickToPlay_.bind(this), 500);
|
| }
|
| +
|
| + this.hostDesktop_ = new remoting.ClientPlugin.HostDesktopImpl(
|
| + this, this.postMessage_.bind(this));
|
| };
|
|
|
| /**
|
| @@ -425,21 +420,11 @@ remoting.ClientPluginImpl.prototype.handleMessageMethod_ = function(message) {
|
| this.onRouteChangedHandler_(channel, connectionType);
|
|
|
| } else if (message.method == 'onDesktopSize') {
|
| - this.desktopWidth_ = getNumberAttr(message.data, 'width');
|
| - this.desktopHeight_ = getNumberAttr(message.data, 'height');
|
| - this.desktopXDpi_ = getNumberAttr(message.data, 'x_dpi', 96);
|
| - this.desktopYDpi_ = getNumberAttr(message.data, 'y_dpi', 96);
|
| + this.hostDesktop_.onSizeUpdated(message);
|
| this.onDesktopSizeUpdateHandler_();
|
|
|
| } else if (message.method == 'onDesktopShape') {
|
| - var rects = getArrayAttr(message.data, 'rects');
|
| - for (var i = 0; i < rects.length; ++i) {
|
| - /** @type {Array.<number>} */
|
| - var rect = rects[i];
|
| - if (typeof rect != 'object' || rect.length != 4) {
|
| - throw 'Received invalid onDesktopShape message';
|
| - }
|
| - }
|
| + var rects = this.hostDesktop_.onShapeUpdated(message);
|
| this.onDesktopShapeUpdateHandler_(rects);
|
|
|
| } else if (message.method == 'onPerfStats') {
|
| @@ -482,6 +467,7 @@ remoting.ClientPluginImpl.prototype.handleMessageMethod_ = function(message) {
|
| } else if (message.method == 'setCapabilities') {
|
| /** @type {!Array.<string>} */
|
| var capabilities = tokenize(getStringAttr(message.data, 'capabilities'));
|
| + this.hostDesktop_.onSetCapabilities(capabilities);
|
| this.onSetCapabilitiesHandler_(capabilities);
|
|
|
| } else if (message.method == 'fetchThirdPartyToken') {
|
| @@ -758,14 +744,7 @@ remoting.ClientPluginImpl.prototype.sendClipboardItem =
|
| */
|
| remoting.ClientPluginImpl.prototype.notifyClientResolution =
|
| function(width, height, device_scale) {
|
| - if (this.hasFeature(remoting.ClientPlugin.Feature.NOTIFY_CLIENT_RESOLUTION)) {
|
| - var dpi = Math.floor(device_scale * 96);
|
| - this.plugin_.postMessage(JSON.stringify(
|
| - { method: 'notifyClientResolution',
|
| - data: { width: Math.floor(width * device_scale),
|
| - height: Math.floor(height * device_scale),
|
| - x_dpi: dpi, y_dpi: dpi }}));
|
| - }
|
| + this.hostDesktop_.resize(width, height, device_scale);
|
| };
|
|
|
| /**
|
| @@ -907,21 +886,27 @@ remoting.ClientPluginImpl.prototype.sendClientMessage =
|
|
|
| };
|
|
|
| +remoting.ClientPluginImpl.prototype.hostDesktop = function() {
|
| + return this.hostDesktop_;
|
| +};
|
| +
|
| +// TODO(kelvinp): Fix all call sites to use ClientPlugin.HostDesktop and remove
|
| +// the four methods below.
|
| remoting.ClientPluginImpl.prototype.getDesktopWidth = function() {
|
| - return this.desktopWidth_;
|
| -}
|
| + return this.hostDesktop_.getDimensions().width;
|
| +};
|
|
|
| remoting.ClientPluginImpl.prototype.getDesktopHeight = function() {
|
| - return this.desktopHeight_;
|
| -}
|
| + return this.hostDesktop_.getDimensions().height;
|
| +};
|
|
|
| remoting.ClientPluginImpl.prototype.getDesktopXDpi = function() {
|
| - return this.desktopXDpi_;
|
| -}
|
| + return this.hostDesktop_.getDimensions().xDpi;
|
| +};
|
|
|
| remoting.ClientPluginImpl.prototype.getDesktopYDpi = function() {
|
| - return this.desktopYDpi_;
|
| -}
|
| + return this.hostDesktop_.getDimensions().yDpi;
|
| +};
|
|
|
| /**
|
| * If we haven't yet received a "hello" message from the plugin, change its
|
| @@ -956,6 +941,17 @@ remoting.ClientPluginImpl.prototype.hidePluginForClickToPlay_ = function() {
|
| this.plugin_.style.position = '';
|
| };
|
|
|
| +/**
|
| + * Callback passed to submodules to post a message to the plugin.
|
| + *
|
| + * @param {Object} objectLiteral
|
| + * @private
|
| + */
|
| +remoting.ClientPluginImpl.prototype.postMessage_ = function(objectLiteral) {
|
| + if (this.plugin_ && this.plugin_.postMessage) {
|
| + this.plugin_.postMessage(JSON.stringify(objectLiteral));
|
| + }
|
| +};
|
|
|
| /**
|
| * @constructor
|
|
|