| Index: remoting/webapp/client_plugin.js
|
| diff --git a/remoting/webapp/client_plugin.js b/remoting/webapp/client_plugin.js
|
| index 197eeffd743adc58c351534895344d6494181be2..837d5f32b7373a8ecd599141518e2da8539faabf 100644
|
| --- a/remoting/webapp/client_plugin.js
|
| +++ b/remoting/webapp/client_plugin.js
|
| @@ -22,6 +22,7 @@ var remoting = remoting || {};
|
| * protocol extension messages. Returns true if a message is recognized;
|
| * false otherwise.
|
| * @constructor
|
| + * @implements {remoting.ClientPluginInterface}
|
| */
|
| remoting.ClientPlugin = function(container, onExtensionMessage) {
|
| this.plugin_ = remoting.ClientPlugin.createPluginElement_();
|
| @@ -30,64 +31,118 @@ remoting.ClientPlugin = function(container, onExtensionMessage) {
|
|
|
| this.onExtensionMessage_ = onExtensionMessage;
|
|
|
| - this.desktopWidth = 0;
|
| - this.desktopHeight = 0;
|
| - this.desktopXDpi = 96;
|
| - this.desktopYDpi = 96;
|
| + /** @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. */
|
| - this.onOutgoingIqHandler = function (iq) {};
|
| - /** @param {string} message Log message. */
|
| - this.onDebugMessageHandler = function (message) {};
|
| + /**
|
| + * @param {string} iq The Iq stanza received from the host.
|
| + * @private
|
| + */
|
| + this.onOutgoingIqHandler_ = function (iq) {};
|
| + /**
|
| + * @param {string} message Log message.
|
| + * @private
|
| + */
|
| + this.onDebugMessageHandler_ = function (message) {};
|
| /**
|
| * @param {number} state The connection state.
|
| * @param {number} error The error code, if any.
|
| + * @private
|
| + */
|
| + this.onConnectionStatusUpdateHandler_ = function(state, error) {};
|
| + /**
|
| + * @param {boolean} ready Connection ready state.
|
| + * @private
|
| */
|
| - this.onConnectionStatusUpdateHandler = function(state, error) {};
|
| - /** @param {boolean} ready Connection ready state. */
|
| - this.onConnectionReadyHandler = function(ready) {};
|
| + this.onConnectionReadyHandler_ = function(ready) {};
|
|
|
| /**
|
| * @param {string} tokenUrl Token-request URL, received from the host.
|
| * @param {string} hostPublicKey Public key for the host.
|
| * @param {string} scope OAuth scope to request the token for.
|
| + * @private
|
| */
|
| - this.fetchThirdPartyTokenHandler = function(
|
| + this.fetchThirdPartyTokenHandler_ = function(
|
| tokenUrl, hostPublicKey, scope) {};
|
| - this.onDesktopSizeUpdateHandler = function () {};
|
| - /** @param {!Array.<string>} capabilities The negotiated capabilities. */
|
| - this.onSetCapabilitiesHandler = function (capabilities) {};
|
| - this.fetchPinHandler = function (supportsPairing) {};
|
| - /** @param {string} data Remote gnubbyd data. */
|
| - this.onGnubbyAuthHandler = function(data) {};
|
| + /** @private */
|
| + this.onDesktopSizeUpdateHandler_ = function () {};
|
| + /**
|
| + * @param {!Array.<string>} capabilities The negotiated capabilities.
|
| + * @private
|
| + */
|
| + this.onSetCapabilitiesHandler_ = function (capabilities) {};
|
| + /** @private */
|
| + this.fetchPinHandler_ = function (supportsPairing) {};
|
| + /**
|
| + * @param {string} data Remote gnubbyd data.
|
| + * @private
|
| + */
|
| + this.onGnubbyAuthHandler_ = function(data) {};
|
| /**
|
| * @param {string} url
|
| * @param {number} hotspotX
|
| * @param {number} hotspotY
|
| + * @private
|
| */
|
| - this.updateMouseCursorImage = function(url, hotspotX, hotspotY) {};
|
| + this.updateMouseCursorImage_ = function(url, hotspotX, hotspotY) {};
|
|
|
| - /** @param {string} data Remote cast extension message. */
|
| - this.onCastExtensionHandler = function(data) {};
|
| + /**
|
| + * @param {string} data Remote cast extension message.
|
| + * @private
|
| + */
|
| + this.onCastExtensionHandler_ = function(data) {};
|
|
|
| - /** @type {remoting.MediaSourceRenderer} */
|
| + /**
|
| + * @type {remoting.MediaSourceRenderer}
|
| + * @private
|
| + */
|
| this.mediaSourceRenderer_ = null;
|
|
|
| - /** @type {number} */
|
| + /**
|
| + * @type {number}
|
| + * @private
|
| + */
|
| this.pluginApiVersion_ = -1;
|
| - /** @type {Array.<string>} */
|
| + /**
|
| + * @type {Array.<string>}
|
| + * @private
|
| + */
|
| this.pluginApiFeatures_ = [];
|
| - /** @type {number} */
|
| + /**
|
| + * @type {number}
|
| + * @private
|
| + */
|
| this.pluginApiMinVersion_ = -1;
|
| - /** @type {!Array.<string>} */
|
| + /**
|
| + * @type {!Array.<string>}
|
| + * @private
|
| + */
|
| this.capabilities_ = [];
|
| - /** @type {boolean} */
|
| + /**
|
| + * @type {boolean}
|
| + * @private
|
| + */
|
| this.helloReceived_ = false;
|
| - /** @type {function(boolean)|null} */
|
| + /**
|
| + * @type {function(boolean)|null}
|
| + * @private
|
| + */
|
| this.onInitializedCallback_ = null;
|
| - /** @type {function(string, string):void} */
|
| + /**
|
| + * @type {function(string, string):void}
|
| + * @private
|
| + */
|
| this.onPairingComplete_ = function(clientId, sharedSecret) {};
|
| - /** @type {remoting.ClientSession.PerfStats} */
|
| + /**
|
| + * @type {remoting.ClientSession.PerfStats}
|
| + * @private
|
| + */
|
| this.perfStats_ = new remoting.ClientSession.PerfStats();
|
|
|
| /** @type {remoting.ClientPlugin} */
|
| @@ -183,6 +238,86 @@ remoting.ClientPlugin.prototype.API_VERSION_ = 6;
|
| remoting.ClientPlugin.prototype.API_MIN_VERSION_ = 5;
|
|
|
| /**
|
| + * @param {function(string):void} handler
|
| + */
|
| +remoting.ClientPlugin.prototype.setOnOutgoingIqHandler = function(handler) {
|
| + this.onOutgoingIqHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(string):void} handler
|
| + */
|
| +remoting.ClientPlugin.prototype.setOnDebugMessageHandler = function(handler) {
|
| + this.onDebugMessageHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(number, number):void} handler
|
| + */
|
| +remoting.ClientPlugin.prototype.setConnectionStatusUpdateHandler =
|
| + function(handler) {
|
| + this.onConnectionStatusUpdateHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(boolean):void} handler
|
| + */
|
| +remoting.ClientPlugin.prototype.setConnectionReadyHandler = function(handler) {
|
| + this.onConnectionReadyHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function():void} handler
|
| + */
|
| +remoting.ClientPlugin.prototype.setDesktopSizeUpdateHandler =
|
| + function(handler) {
|
| + this.onDesktopSizeUpdateHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(!Array.<string>):void} handler
|
| + */
|
| +remoting.ClientPlugin.prototype.setCapabilitiesHandler = function(handler) {
|
| + this.onSetCapabilitiesHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(string):void} handler
|
| + */
|
| +remoting.ClientPlugin.prototype.setGnubbyAuthHandler = function(handler) {
|
| + this.onGnubbyAuthHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(string):void} handler
|
| + */
|
| +remoting.ClientPlugin.prototype.setCastExtensionHandler = function(handler) {
|
| + this.onCastExtensionHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(string, number, number):void} handler
|
| + */
|
| +remoting.ClientPlugin.prototype.setMouseCursorHandler = function(handler) {
|
| + this.updateMouseCursorImage_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(string, string, string):void} handler
|
| + */
|
| +remoting.ClientPlugin.prototype.setFetchThirdPartyTokenHandler =
|
| + function(handler) {
|
| + this.fetchThirdPartyTokenHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(boolean):void} handler
|
| + */
|
| +remoting.ClientPlugin.prototype.setFetchPinHandler = function(handler) {
|
| + this.fetchPinHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| * @param {string|{method:string, data:Object.<string,*>}}
|
| * rawMessage Message from the plugin.
|
| * @private
|
| @@ -285,24 +420,24 @@ remoting.ClientPlugin.prototype.handleMessageMethod_ = function(message) {
|
| }
|
|
|
| } else if (message.method == 'sendOutgoingIq') {
|
| - this.onOutgoingIqHandler(getStringAttr(message.data, 'iq'));
|
| + this.onOutgoingIqHandler_(getStringAttr(message.data, 'iq'));
|
|
|
| } else if (message.method == 'logDebugMessage') {
|
| - this.onDebugMessageHandler(getStringAttr(message.data, 'message'));
|
| + this.onDebugMessageHandler_(getStringAttr(message.data, 'message'));
|
|
|
| } else if (message.method == 'onConnectionStatus') {
|
| var state = remoting.ClientSession.State.fromString(
|
| getStringAttr(message.data, 'state'))
|
| var error = remoting.ClientSession.ConnectionError.fromString(
|
| getStringAttr(message.data, 'error'));
|
| - this.onConnectionStatusUpdateHandler(state, error);
|
| + this.onConnectionStatusUpdateHandler_(state, error);
|
|
|
| } 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.onDesktopSizeUpdateHandler();
|
| + 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.onDesktopSizeUpdateHandler_();
|
|
|
| } else if (message.method == 'onPerfStats') {
|
| // Return value is ignored. These calls will throw an error if the value
|
| @@ -331,7 +466,7 @@ remoting.ClientPlugin.prototype.handleMessageMethod_ = function(message) {
|
|
|
| } else if (message.method == 'onConnectionReady') {
|
| var ready = getBooleanAttr(message.data, 'ready');
|
| - this.onConnectionReadyHandler(ready);
|
| + this.onConnectionReadyHandler_(ready);
|
|
|
| } else if (message.method == 'fetchPin') {
|
| // The pairingSupported value in the dictionary indicates whether both
|
| @@ -339,18 +474,18 @@ remoting.ClientPlugin.prototype.handleMessageMethod_ = function(message) {
|
| // then the value won't be there at all, so give it a default of false.
|
| var pairingSupported = getBooleanAttr(message.data, 'pairingSupported',
|
| false)
|
| - this.fetchPinHandler(pairingSupported);
|
| + this.fetchPinHandler_(pairingSupported);
|
|
|
| } else if (message.method == 'setCapabilities') {
|
| /** @type {!Array.<string>} */
|
| var capabilities = tokenize(getStringAttr(message.data, 'capabilities'));
|
| - this.onSetCapabilitiesHandler(capabilities);
|
| + this.onSetCapabilitiesHandler_(capabilities);
|
|
|
| } else if (message.method == 'fetchThirdPartyToken') {
|
| var tokenUrl = getStringAttr(message.data, 'tokenUrl');
|
| var hostPublicKey = getStringAttr(message.data, 'hostPublicKey');
|
| var scope = getStringAttr(message.data, 'scope');
|
| - this.fetchThirdPartyTokenHandler(tokenUrl, hostPublicKey, scope);
|
| + this.fetchThirdPartyTokenHandler_(tokenUrl, hostPublicKey, scope);
|
|
|
| } else if (message.method == 'pairingResponse') {
|
| var clientId = getStringAttr(message.data, 'clientId');
|
| @@ -362,13 +497,13 @@ remoting.ClientPlugin.prototype.handleMessageMethod_ = function(message) {
|
| var extMsgData = getStringAttr(message.data, 'data');
|
| switch (extMsgType) {
|
| case 'gnubby-auth':
|
| - this.onGnubbyAuthHandler(extMsgData);
|
| + this.onGnubbyAuthHandler_(extMsgData);
|
| break;
|
| case 'test-echo-reply':
|
| console.log('Got echo reply: ' + extMsgData);
|
| break;
|
| case 'cast_message':
|
| - this.onCastExtensionHandler(extMsgData);
|
| + this.onCastExtensionHandler_(extMsgData);
|
| break;
|
| default:
|
| this.onExtensionMessage_(extMsgType, extMsgData);
|
| @@ -397,7 +532,7 @@ remoting.ClientPlugin.prototype.handleMessageMethod_ = function(message) {
|
| (/** @type {ArrayBuffer} */ message.data['buffer']), keyframe);
|
|
|
| } else if (message.method == 'unsetCursorShape') {
|
| - this.updateMouseCursorImage('', 0, 0);
|
| + this.updateMouseCursorImage_('', 0, 0);
|
|
|
| } else if (message.method == 'setCursorShape') {
|
| var width = getNumberAttr(message.data, 'width');
|
| @@ -425,14 +560,14 @@ remoting.ClientPlugin.prototype.handleMessageMethod_ = function(message) {
|
| }
|
|
|
| context.putImageData(imageData, 0, 0);
|
| - this.updateMouseCursorImage(canvas.toDataURL(), hotspotX, hotspotY);
|
| + this.updateMouseCursorImage_(canvas.toDataURL(), hotspotX, hotspotY);
|
| }
|
| };
|
|
|
| /**
|
| * Deletes the plugin.
|
| */
|
| -remoting.ClientPlugin.prototype.cleanup = function() {
|
| +remoting.ClientPlugin.prototype.dispose = function() {
|
| if (this.plugin_) {
|
| this.plugin_.parentNode.removeChild(this.plugin_);
|
| this.plugin_ = null;
|
| @@ -790,6 +925,22 @@ remoting.ClientPlugin.prototype.enableMediaSourceRendering =
|
| { method: 'enableMediaSourceRendering', data: {} }));
|
| };
|
|
|
| +remoting.ClientPlugin.prototype.getDesktopWidth = function() {
|
| + return this.desktopWidth_;
|
| +}
|
| +
|
| +remoting.ClientPlugin.prototype.getDesktopHeight = function() {
|
| + return this.desktopHeight_;
|
| +}
|
| +
|
| +remoting.ClientPlugin.prototype.getDesktopXDpi = function() {
|
| + return this.desktopXDpi_;
|
| +}
|
| +
|
| +remoting.ClientPlugin.prototype.getDesktopYDpi = function() {
|
| + return this.desktopYDpi_;
|
| +}
|
| +
|
| /**
|
| * 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
|
| @@ -822,3 +973,25 @@ remoting.ClientPlugin.prototype.hidePluginForClickToPlay_ = function() {
|
| this.plugin_.style.left = '';
|
| this.plugin_.style.position = '';
|
| };
|
| +
|
| +
|
| +/**
|
| + * @constructor
|
| + * @implements {remoting.ClientPluginFactory}
|
| + */
|
| +remoting.DefaultClientPluginFactory = function() {};
|
| +
|
| +/**
|
| + * @param {Element} container
|
| + * @param {function(string, string):boolean} onExtensionMessage
|
| + * @return {remoting.ClientPluginInterface}
|
| + */
|
| +remoting.DefaultClientPluginFactory.prototype.createPlugin =
|
| + function(container, onExtensionMessage) {
|
| + return new remoting.ClientPlugin(container, onExtensionMessage);
|
| +}
|
| +
|
| +/**
|
| + * @type {remoting.ClientPluginFactory}
|
| + */
|
| +remoting.ClientPlugin.factory = new remoting.DefaultClientPluginFactory();
|
|
|