| Index: remoting/webapp/client_plugin_impl.js
|
| diff --git a/remoting/webapp/client_plugin.js b/remoting/webapp/client_plugin_impl.js
|
| similarity index 74%
|
| copy from remoting/webapp/client_plugin.js
|
| copy to remoting/webapp/client_plugin_impl.js
|
| index 197eeffd743adc58c351534895344d6494181be2..28a973d1edae21ec69f6d864e0e4497172742a36 100644
|
| --- a/remoting/webapp/client_plugin.js
|
| +++ b/remoting/webapp/client_plugin_impl.js
|
| @@ -22,75 +22,130 @@ var remoting = remoting || {};
|
| * protocol extension messages. Returns true if a message is recognized;
|
| * false otherwise.
|
| * @constructor
|
| + * @implements {remoting.ClientPlugin}
|
| */
|
| -remoting.ClientPlugin = function(container, onExtensionMessage) {
|
| - this.plugin_ = remoting.ClientPlugin.createPluginElement_();
|
| +remoting.ClientPluginImpl = function(container, onExtensionMessage) {
|
| + this.plugin_ = remoting.ClientPluginImpl.createPluginElement_();
|
| this.plugin_.id = 'session-client-plugin';
|
| container.appendChild(this.plugin_);
|
|
|
| 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. */
|
| - this.onConnectionReadyHandler = function(ready) {};
|
| + this.onConnectionStatusUpdateHandler_ = function(state, error) {};
|
| + /**
|
| + * @param {boolean} ready Connection ready state.
|
| + * @private
|
| + */
|
| + 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} */
|
| + /** @type {remoting.ClientPluginImpl} */
|
| var that = this;
|
| /** @param {Event} event Message event from the plugin. */
|
| this.plugin_.addEventListener('message', function(event) {
|
| @@ -107,7 +162,7 @@ remoting.ClientPlugin = function(container, onExtensionMessage) {
|
| *
|
| * @return {remoting.ViewerPlugin} Plugin element
|
| */
|
| -remoting.ClientPlugin.createPluginElement_ = function() {
|
| +remoting.ClientPluginImpl.createPluginElement_ = function() {
|
| var plugin = /** @type {remoting.ViewerPlugin} */
|
| document.createElement('embed');
|
| if (remoting.settings.CLIENT_PLUGIN_TYPE == 'pnacl') {
|
| @@ -127,42 +182,6 @@ remoting.ClientPlugin.createPluginElement_ = function() {
|
| }
|
|
|
| /**
|
| - * Preloads the plugin to make instantiation faster when the user tries
|
| - * to connect.
|
| - */
|
| -remoting.ClientPlugin.preload = function() {
|
| - if (remoting.settings.CLIENT_PLUGIN_TYPE != 'pnacl') {
|
| - return;
|
| - }
|
| -
|
| - var plugin = remoting.ClientPlugin.createPluginElement_();
|
| - plugin.addEventListener(
|
| - 'loadend', function() { document.body.removeChild(plugin); }, false);
|
| - document.body.appendChild(plugin);
|
| -}
|
| -
|
| -/**
|
| - * Set of features for which hasFeature() can be used to test.
|
| - *
|
| - * @enum {string}
|
| - */
|
| -remoting.ClientPlugin.Feature = {
|
| - INJECT_KEY_EVENT: 'injectKeyEvent',
|
| - NOTIFY_CLIENT_RESOLUTION: 'notifyClientResolution',
|
| - ASYNC_PIN: 'asyncPin',
|
| - PAUSE_VIDEO: 'pauseVideo',
|
| - PAUSE_AUDIO: 'pauseAudio',
|
| - REMAP_KEY: 'remapKey',
|
| - SEND_CLIPBOARD_ITEM: 'sendClipboardItem',
|
| - THIRD_PARTY_AUTH: 'thirdPartyAuth',
|
| - TRAP_KEY: 'trapKey',
|
| - PINLESS_AUTH: 'pinlessAuth',
|
| - EXTENSION_MESSAGE: 'extensionMessage',
|
| - MEDIA_SOURCE_RENDERING: 'mediaSourceRendering',
|
| - VIDEO_CONTROL: 'videoControl'
|
| -};
|
| -
|
| -/**
|
| * Chromoting session API version (for this javascript).
|
| * This is compared with the plugin API version to verify that they are
|
| * compatible.
|
| @@ -170,7 +189,7 @@ remoting.ClientPlugin.Feature = {
|
| * @const
|
| * @private
|
| */
|
| -remoting.ClientPlugin.prototype.API_VERSION_ = 6;
|
| +remoting.ClientPluginImpl.prototype.API_VERSION_ = 6;
|
|
|
| /**
|
| * The oldest API version that we support.
|
| @@ -180,14 +199,97 @@ remoting.ClientPlugin.prototype.API_VERSION_ = 6;
|
| * @const
|
| * @private
|
| */
|
| -remoting.ClientPlugin.prototype.API_MIN_VERSION_ = 5;
|
| +remoting.ClientPluginImpl.prototype.API_MIN_VERSION_ = 5;
|
| +
|
| +/**
|
| + * @param {function(string):void} handler
|
| + */
|
| +remoting.ClientPluginImpl.prototype.setOnOutgoingIqHandler = function(handler) {
|
| + this.onOutgoingIqHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(string):void} handler
|
| + */
|
| +remoting.ClientPluginImpl.prototype.setOnDebugMessageHandler =
|
| + function(handler) {
|
| + this.onDebugMessageHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(number, number):void} handler
|
| + */
|
| +remoting.ClientPluginImpl.prototype.setConnectionStatusUpdateHandler =
|
| + function(handler) {
|
| + this.onConnectionStatusUpdateHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(boolean):void} handler
|
| + */
|
| +remoting.ClientPluginImpl.prototype.setConnectionReadyHandler =
|
| + function(handler) {
|
| + this.onConnectionReadyHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function():void} handler
|
| + */
|
| +remoting.ClientPluginImpl.prototype.setDesktopSizeUpdateHandler =
|
| + function(handler) {
|
| + this.onDesktopSizeUpdateHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(!Array.<string>):void} handler
|
| + */
|
| +remoting.ClientPluginImpl.prototype.setCapabilitiesHandler = function(handler) {
|
| + this.onSetCapabilitiesHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(string):void} handler
|
| + */
|
| +remoting.ClientPluginImpl.prototype.setGnubbyAuthHandler = function(handler) {
|
| + this.onGnubbyAuthHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(string):void} handler
|
| + */
|
| +remoting.ClientPluginImpl.prototype.setCastExtensionHandler =
|
| + function(handler) {
|
| + this.onCastExtensionHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(string, number, number):void} handler
|
| + */
|
| +remoting.ClientPluginImpl.prototype.setMouseCursorHandler = function(handler) {
|
| + this.updateMouseCursorImage_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(string, string, string):void} handler
|
| + */
|
| +remoting.ClientPluginImpl.prototype.setFetchThirdPartyTokenHandler =
|
| + function(handler) {
|
| + this.fetchThirdPartyTokenHandler_ = handler;
|
| +};
|
| +
|
| +/**
|
| + * @param {function(boolean):void} handler
|
| + */
|
| +remoting.ClientPluginImpl.prototype.setFetchPinHandler = function(handler) {
|
| + this.fetchPinHandler_ = handler;
|
| +};
|
|
|
| /**
|
| * @param {string|{method:string, data:Object.<string,*>}}
|
| * rawMessage Message from the plugin.
|
| * @private
|
| */
|
| -remoting.ClientPlugin.prototype.handleMessage_ = function(rawMessage) {
|
| +remoting.ClientPluginImpl.prototype.handleMessage_ = function(rawMessage) {
|
| var message =
|
| /** @type {{method:string, data:Object.<string,*>}} */
|
| ((typeof(rawMessage) == 'string') ? jsonParseSafe(rawMessage)
|
| @@ -209,7 +311,7 @@ remoting.ClientPlugin.prototype.handleMessage_ = function(rawMessage) {
|
| * message Parsed message from the plugin.
|
| * @private
|
| */
|
| -remoting.ClientPlugin.prototype.handleMessageMethod_ = function(message) {
|
| +remoting.ClientPluginImpl.prototype.handleMessageMethod_ = function(message) {
|
| /**
|
| * Splits a string into a list of words delimited by spaces.
|
| * @param {string} str String that should be split.
|
| @@ -285,24 +387,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 +433,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 +441,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 +464,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 +499,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 +527,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.ClientPluginImpl.prototype.dispose = function() {
|
| if (this.plugin_) {
|
| this.plugin_.parentNode.removeChild(this.plugin_);
|
| this.plugin_ = null;
|
| @@ -442,14 +544,14 @@ remoting.ClientPlugin.prototype.cleanup = function() {
|
| /**
|
| * @return {HTMLEmbedElement} HTML element that corresponds to the plugin.
|
| */
|
| -remoting.ClientPlugin.prototype.element = function() {
|
| +remoting.ClientPluginImpl.prototype.element = function() {
|
| return this.plugin_;
|
| };
|
|
|
| /**
|
| * @param {function(boolean): void} onDone
|
| */
|
| -remoting.ClientPlugin.prototype.initialize = function(onDone) {
|
| +remoting.ClientPluginImpl.prototype.initialize = function(onDone) {
|
| if (this.helloReceived_) {
|
| onDone(true);
|
| } else {
|
| @@ -460,7 +562,7 @@ remoting.ClientPlugin.prototype.initialize = function(onDone) {
|
| /**
|
| * @return {boolean} True if the plugin and web-app versions are compatible.
|
| */
|
| -remoting.ClientPlugin.prototype.isSupportedVersion = function() {
|
| +remoting.ClientPluginImpl.prototype.isSupportedVersion = function() {
|
| if (!this.helloReceived_) {
|
| console.error(
|
| "isSupportedVersion() is called before the plugin is initialized.");
|
| @@ -474,7 +576,7 @@ remoting.ClientPlugin.prototype.isSupportedVersion = function() {
|
| * @param {remoting.ClientPlugin.Feature} feature The feature to test for.
|
| * @return {boolean} True if the plugin supports the named feature.
|
| */
|
| -remoting.ClientPlugin.prototype.hasFeature = function(feature) {
|
| +remoting.ClientPluginImpl.prototype.hasFeature = function(feature) {
|
| if (!this.helloReceived_) {
|
| console.error(
|
| "hasFeature() is called before the plugin is initialized.");
|
| @@ -486,14 +588,14 @@ remoting.ClientPlugin.prototype.hasFeature = function(feature) {
|
| /**
|
| * @return {boolean} True if the plugin supports the injectKeyEvent API.
|
| */
|
| -remoting.ClientPlugin.prototype.isInjectKeyEventSupported = function() {
|
| +remoting.ClientPluginImpl.prototype.isInjectKeyEventSupported = function() {
|
| return this.pluginApiVersion_ >= 6;
|
| };
|
|
|
| /**
|
| * @param {string} iq Incoming IQ stanza.
|
| */
|
| -remoting.ClientPlugin.prototype.onIncomingIq = function(iq) {
|
| +remoting.ClientPluginImpl.prototype.onIncomingIq = function(iq) {
|
| if (this.plugin_ && this.plugin_.postMessage) {
|
| this.plugin_.postMessage(JSON.stringify(
|
| { method: 'incomingIq', data: { iq: iq } }));
|
| @@ -521,7 +623,7 @@ remoting.ClientPlugin.prototype.onIncomingIq = function(iq) {
|
| * @param {string} clientPairedSecret For paired Me2Me connections, the
|
| * paired secret for this client, as issued by the host.
|
| */
|
| -remoting.ClientPlugin.prototype.connect = function(
|
| +remoting.ClientPluginImpl.prototype.connect = function(
|
| hostJid, hostPublicKey, localJid, sharedSecret,
|
| authenticationMethods, authenticationTag,
|
| clientPairingId, clientPairedSecret) {
|
| @@ -552,7 +654,7 @@ remoting.ClientPlugin.prototype.connect = function(
|
| /**
|
| * Release all currently pressed keys.
|
| */
|
| -remoting.ClientPlugin.prototype.releaseAllKeys = function() {
|
| +remoting.ClientPluginImpl.prototype.releaseAllKeys = function() {
|
| this.plugin_.postMessage(JSON.stringify(
|
| { method: 'releaseAllKeys', data: {} }));
|
| };
|
| @@ -563,7 +665,7 @@ remoting.ClientPlugin.prototype.releaseAllKeys = function() {
|
| * @param {number} usbKeycode The USB-style code of the key to inject.
|
| * @param {boolean} pressed True to inject a key press, False for a release.
|
| */
|
| -remoting.ClientPlugin.prototype.injectKeyEvent =
|
| +remoting.ClientPluginImpl.prototype.injectKeyEvent =
|
| function(usbKeycode, pressed) {
|
| this.plugin_.postMessage(JSON.stringify(
|
| { method: 'injectKeyEvent', data: {
|
| @@ -578,7 +680,7 @@ remoting.ClientPlugin.prototype.injectKeyEvent =
|
| * @param {number} fromKeycode The USB-style code of the key to remap.
|
| * @param {number} toKeycode The USB-style code to remap the key to.
|
| */
|
| -remoting.ClientPlugin.prototype.remapKey =
|
| +remoting.ClientPluginImpl.prototype.remapKey =
|
| function(fromKeycode, toKeycode) {
|
| this.plugin_.postMessage(JSON.stringify(
|
| { method: 'remapKey', data: {
|
| @@ -593,7 +695,7 @@ remoting.ClientPlugin.prototype.remapKey =
|
| * @param {number} keycode The USB-style code of the key.
|
| * @param {Boolean} trap True to enable trapping, False to disable.
|
| */
|
| -remoting.ClientPlugin.prototype.trapKey = function(keycode, trap) {
|
| +remoting.ClientPluginImpl.prototype.trapKey = function(keycode, trap) {
|
| this.plugin_.postMessage(JSON.stringify(
|
| { method: 'trapKey', data: {
|
| 'keycode': keycode,
|
| @@ -606,7 +708,7 @@ remoting.ClientPlugin.prototype.trapKey = function(keycode, trap) {
|
| *
|
| * @return {remoting.ClientSession.PerfStats} The connection statistics.
|
| */
|
| -remoting.ClientPlugin.prototype.getPerfStats = function() {
|
| +remoting.ClientPluginImpl.prototype.getPerfStats = function() {
|
| return this.perfStats_;
|
| };
|
|
|
| @@ -616,7 +718,7 @@ remoting.ClientPlugin.prototype.getPerfStats = function() {
|
| * @param {string} mimeType The MIME type of the clipboard item.
|
| * @param {string} item The clipboard item.
|
| */
|
| -remoting.ClientPlugin.prototype.sendClipboardItem =
|
| +remoting.ClientPluginImpl.prototype.sendClipboardItem =
|
| function(mimeType, item) {
|
| if (!this.hasFeature(remoting.ClientPlugin.Feature.SEND_CLIPBOARD_ITEM))
|
| return;
|
| @@ -632,7 +734,7 @@ remoting.ClientPlugin.prototype.sendClipboardItem =
|
| * @param {number} height The available client height in DIPs.
|
| * @param {number} device_scale The number of device pixels per DIP.
|
| */
|
| -remoting.ClientPlugin.prototype.notifyClientResolution =
|
| +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);
|
| @@ -649,7 +751,7 @@ remoting.ClientPlugin.prototype.notifyClientResolution =
|
| *
|
| * @param {boolean} pause True to suspend video updates, false otherwise.
|
| */
|
| -remoting.ClientPlugin.prototype.pauseVideo =
|
| +remoting.ClientPluginImpl.prototype.pauseVideo =
|
| function(pause) {
|
| if (this.hasFeature(remoting.ClientPlugin.Feature.VIDEO_CONTROL)) {
|
| this.plugin_.postMessage(JSON.stringify(
|
| @@ -665,7 +767,7 @@ remoting.ClientPlugin.prototype.pauseVideo =
|
| *
|
| * @param {boolean} pause True to suspend audio updates, false otherwise.
|
| */
|
| -remoting.ClientPlugin.prototype.pauseAudio =
|
| +remoting.ClientPluginImpl.prototype.pauseAudio =
|
| function(pause) {
|
| if (!this.hasFeature(remoting.ClientPlugin.Feature.PAUSE_AUDIO)) {
|
| return;
|
| @@ -679,7 +781,7 @@ remoting.ClientPlugin.prototype.pauseAudio =
|
| *
|
| * @param {boolean} wantLossless True to request lossless encoding.
|
| */
|
| -remoting.ClientPlugin.prototype.setLosslessEncode =
|
| +remoting.ClientPluginImpl.prototype.setLosslessEncode =
|
| function(wantLossless) {
|
| if (!this.hasFeature(remoting.ClientPlugin.Feature.VIDEO_CONTROL)) {
|
| return;
|
| @@ -693,7 +795,7 @@ remoting.ClientPlugin.prototype.setLosslessEncode =
|
| *
|
| * @param {boolean} wantLossless True to request lossless color.
|
| */
|
| -remoting.ClientPlugin.prototype.setLosslessColor =
|
| +remoting.ClientPluginImpl.prototype.setLosslessColor =
|
| function(wantLossless) {
|
| if (!this.hasFeature(remoting.ClientPlugin.Feature.VIDEO_CONTROL)) {
|
| return;
|
| @@ -707,7 +809,7 @@ remoting.ClientPlugin.prototype.setLosslessColor =
|
| *
|
| * @param {string} pin The PIN.
|
| */
|
| -remoting.ClientPlugin.prototype.onPinFetched =
|
| +remoting.ClientPluginImpl.prototype.onPinFetched =
|
| function(pin) {
|
| if (!this.hasFeature(remoting.ClientPlugin.Feature.ASYNC_PIN)) {
|
| return;
|
| @@ -719,7 +821,7 @@ remoting.ClientPlugin.prototype.onPinFetched =
|
| /**
|
| * Tells the plugin to ask for the PIN asynchronously.
|
| */
|
| -remoting.ClientPlugin.prototype.useAsyncPinDialog =
|
| +remoting.ClientPluginImpl.prototype.useAsyncPinDialog =
|
| function() {
|
| if (!this.hasFeature(remoting.ClientPlugin.Feature.ASYNC_PIN)) {
|
| return;
|
| @@ -734,7 +836,7 @@ remoting.ClientPlugin.prototype.useAsyncPinDialog =
|
| * @param {string} token The token received from the token URL.
|
| * @param {string} sharedSecret Shared secret received from the token URL.
|
| */
|
| -remoting.ClientPlugin.prototype.onThirdPartyTokenFetched = function(
|
| +remoting.ClientPluginImpl.prototype.onThirdPartyTokenFetched = function(
|
| token, sharedSecret) {
|
| this.plugin_.postMessage(JSON.stringify(
|
| { method: 'onThirdPartyTokenFetched',
|
| @@ -748,7 +850,7 @@ remoting.ClientPlugin.prototype.onThirdPartyTokenFetched = function(
|
| * @param {function(string, string):void} onDone, Callback to receive the
|
| * client id and shared secret when they are available.
|
| */
|
| -remoting.ClientPlugin.prototype.requestPairing =
|
| +remoting.ClientPluginImpl.prototype.requestPairing =
|
| function(clientName, onDone) {
|
| if (!this.hasFeature(remoting.ClientPlugin.Feature.PINLESS_AUTH)) {
|
| return;
|
| @@ -764,7 +866,7 @@ remoting.ClientPlugin.prototype.requestPairing =
|
| * @param {string} type The message type.
|
| * @param {string} message The message payload.
|
| */
|
| -remoting.ClientPlugin.prototype.sendClientMessage =
|
| +remoting.ClientPluginImpl.prototype.sendClientMessage =
|
| function(type, message) {
|
| if (!this.hasFeature(remoting.ClientPlugin.Feature.EXTENSION_MESSAGE)) {
|
| return;
|
| @@ -780,7 +882,7 @@ remoting.ClientPlugin.prototype.sendClientMessage =
|
| *
|
| * @param {remoting.MediaSourceRenderer} mediaSourceRenderer
|
| */
|
| -remoting.ClientPlugin.prototype.enableMediaSourceRendering =
|
| +remoting.ClientPluginImpl.prototype.enableMediaSourceRendering =
|
| function(mediaSourceRenderer) {
|
| if (!this.hasFeature(remoting.ClientPlugin.Feature.MEDIA_SOURCE_RENDERING)) {
|
| return;
|
| @@ -790,13 +892,29 @@ remoting.ClientPlugin.prototype.enableMediaSourceRendering =
|
| { method: 'enableMediaSourceRendering', data: {} }));
|
| };
|
|
|
| +remoting.ClientPluginImpl.prototype.getDesktopWidth = function() {
|
| + return this.desktopWidth_;
|
| +}
|
| +
|
| +remoting.ClientPluginImpl.prototype.getDesktopHeight = function() {
|
| + return this.desktopHeight_;
|
| +}
|
| +
|
| +remoting.ClientPluginImpl.prototype.getDesktopXDpi = function() {
|
| + return this.desktopXDpi_;
|
| +}
|
| +
|
| +remoting.ClientPluginImpl.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
|
| * see the "this plugin is disabled" message if it is actually disabled.
|
| * @private
|
| */
|
| -remoting.ClientPlugin.prototype.showPluginForClickToPlay_ = function() {
|
| +remoting.ClientPluginImpl.prototype.showPluginForClickToPlay_ = function() {
|
| if (!this.helloReceived_) {
|
| var width = 200;
|
| var height = 200;
|
| @@ -815,10 +933,38 @@ remoting.ClientPlugin.prototype.showPluginForClickToPlay_ = function() {
|
| * Undo the CSS rules needed to make the plugin clickable for click-to-play.
|
| * @private
|
| */
|
| -remoting.ClientPlugin.prototype.hidePluginForClickToPlay_ = function() {
|
| +remoting.ClientPluginImpl.prototype.hidePluginForClickToPlay_ = function() {
|
| this.plugin_.style.width = '';
|
| this.plugin_.style.height = '';
|
| this.plugin_.style.top = '';
|
| 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.ClientPlugin}
|
| + */
|
| +remoting.DefaultClientPluginFactory.prototype.createPlugin =
|
| + function(container, onExtensionMessage) {
|
| + return new remoting.ClientPluginImpl(container, onExtensionMessage);
|
| +};
|
| +
|
| +remoting.DefaultClientPluginFactory.prototype.preloadPlugin = function() {
|
| + if (remoting.settings.CLIENT_PLUGIN_TYPE != 'pnacl') {
|
| + return;
|
| + }
|
| +
|
| + var plugin = remoting.ClientPluginImpl.createPluginElement_();
|
| + plugin.addEventListener(
|
| + 'loadend', function() { document.body.removeChild(plugin); }, false);
|
| + document.body.appendChild(plugin);
|
| +};
|
|
|