Chromium Code Reviews| Index: remoting/webapp/client_plugin.js |
| diff --git a/remoting/webapp/client_plugin.js b/remoting/webapp/client_plugin.js |
| index 181abcc83e5800433af723d752f46e6acd1cc128..076de9e44f7be8d8ab2d88da9d0e1d8daefbb0f0 100644 |
| --- a/remoting/webapp/client_plugin.js |
| +++ b/remoting/webapp/client_plugin.js |
| @@ -24,24 +24,8 @@ var remoting = remoting || {}; |
| * @constructor |
| */ |
| remoting.ClientPlugin = function(container, onExtensionMessage) { |
| - this.plugin_ = /** @type {remoting.ViewerPlugin} */ |
| - document.createElement('embed'); |
| - |
| + this.plugin_ = remoting.ClientPlugin.createPluginElement_(); |
| this.plugin_.id = 'session-client-plugin'; |
| - if (remoting.settings.CLIENT_PLUGIN_TYPE == 'pnacl') { |
| - this.plugin_.src = 'remoting_client_pnacl.nmf'; |
| - this.plugin_.type = 'application/x-pnacl'; |
| - } else if (remoting.settings.CLIENT_PLUGIN_TYPE == 'nacl') { |
| - this.plugin_.src = 'remoting_client_nacl.nmf'; |
| - this.plugin_.type = 'application/x-nacl'; |
| - } else { |
| - this.plugin_.src = 'about://none'; |
| - this.plugin_.type = 'application/vnd.chromium.remoting-viewer'; |
| - } |
| - |
| - this.plugin_.width = 0; |
| - this.plugin_.height = 0; |
| - this.plugin_.tabIndex = 0; // Required, otherwise focus() doesn't work. |
| container.appendChild(this.plugin_); |
| this.onExtensionMessage_ = onExtensionMessage; |
| @@ -116,6 +100,41 @@ remoting.ClientPlugin = function(container, onExtensionMessage) { |
| }; |
| /** |
| + * Creates plugin element without adding it to a container. |
| + * |
| + * @return {remoting.ViewerPlugin} Plugin element |
| + */ |
| +remoting.ClientPlugin.createPluginElement_ = function() { |
| + var plugin = /** @type {remoting.ViewerPlugin} */ |
| + document.createElement('embed'); |
| + if (remoting.settings.CLIENT_PLUGIN_TYPE == 'pnacl') { |
| + plugin.src = 'remoting_client_pnacl.nmf'; |
| + plugin.type = 'application/x-pnacl'; |
| + } else if (remoting.settings.CLIENT_PLUGIN_TYPE == 'nacl') { |
| + plugin.src = 'remoting_client_nacl.nmf'; |
| + plugin.type = 'application/x-nacl'; |
| + } else { |
| + plugin.src = 'about://none'; |
| + plugin.type = 'application/vnd.chromium.remoting-viewer'; |
| + } |
| + plugin.width = 0; |
| + plugin.height = 0; |
| + plugin.tabIndex = 0; // Required, otherwise focus() doesn't work. |
| + return plugin; |
| +} |
| + |
| +/** |
| + * 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; |
| + |
| + document.body.appendChild(remoting.ClientPlugin.createPluginElement_()); |
|
Wez
2014/08/12 22:03:31
Do we need to make sure the plugin is hidden?
Jamie
2014/08/12 22:35:58
We'll end up with 2 plugins; is that okay? It migh
Jamie
2014/08/12 22:35:58
It mustn't have the hidden attribute set, or Chrom
Sergey Ulanov
2014/08/15 01:00:17
Yes, the plugin handles multiple instances just fi
|
| +} |
| + |
| +/** |
| * Set of features for which hasFeature() can be used to test. |
| * |
| * @enum {string} |