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

Unified Diff: remoting/webapp/client_plugin.js

Issue 467903002: Preload PNaCl plugin when the webapp is started. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | remoting/webapp/remoting.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/client_plugin.js
diff --git a/remoting/webapp/client_plugin.js b/remoting/webapp/client_plugin.js
index 181abcc83e5800433af723d752f46e6acd1cc128..4e95626af65498b3479559fe6f4d7f80d3dfa3ad 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,45 @@ 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;
+ }
+
+ 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}
« no previous file with comments | « no previous file | remoting/webapp/remoting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698