Commit 6b106853 authored by sergeyu@chromium.org's avatar sergeyu@chromium.org

Cleanup client plugin handling code in the webapp.

Previously the <embed> element was created in client_session.js , while
it's owned by the ClientPlugin object. Moved plugin creation code where
it belongs, to client_plugin.js .

R=jamiewalch@chromium.org

Review URL: https://codereview.chromium.org/469453003

Cr-Commit-Position: refs/heads/master@{#289323}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289323 0039d316-1c4b-4281-b951-d872f2087c98
parent a134813c
This diff is collapsed.
...@@ -355,13 +355,6 @@ remoting.ClientSession.KEY_REMAP_KEYS = 'remapKeys'; ...@@ -355,13 +355,6 @@ remoting.ClientSession.KEY_REMAP_KEYS = 'remapKeys';
remoting.ClientSession.KEY_RESIZE_TO_CLIENT = 'resizeToClient'; remoting.ClientSession.KEY_RESIZE_TO_CLIENT = 'resizeToClient';
remoting.ClientSession.KEY_SHRINK_TO_FIT = 'shrinkToFit'; remoting.ClientSession.KEY_SHRINK_TO_FIT = 'shrinkToFit';
/**
* The id of the client plugin
*
* @const
*/
remoting.ClientSession.prototype.PLUGIN_ID = 'session-client-plugin';
/** /**
* Set of capabilities for which hasCapability_() can be used to test. * Set of capabilities for which hasCapability_() can be used to test.
* *
...@@ -397,39 +390,6 @@ remoting.ClientSession.prototype.hasCapability_ = function(capability) { ...@@ -397,39 +390,6 @@ remoting.ClientSession.prototype.hasCapability_ = function(capability) {
return this.capabilities_.indexOf(capability) > -1; return this.capabilities_.indexOf(capability) > -1;
}; };
/**
* @param {string} id Id to use for the plugin element .
* @param {function(string, string):boolean} onExtensionMessage The handler for
* protocol extension messages. Returns true if a message is recognized;
* false otherwise.
* @return {remoting.ClientPlugin} Create plugin object for the locally
* installed plugin.
*/
remoting.ClientSession.prototype.createClientPlugin_ =
function(id, onExtensionMessage) {
var plugin = /** @type {remoting.ViewerPlugin} */
document.createElement('embed');
plugin.id = id;
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.
this.container_.querySelector('.client-plugin-container').appendChild(plugin);
return new remoting.ClientPlugin(plugin, onExtensionMessage);
};
/** /**
* Callback function called when the plugin element gets focus. * Callback function called when the plugin element gets focus.
*/ */
...@@ -449,8 +409,7 @@ remoting.ClientSession.prototype.pluginLostFocus_ = function() { ...@@ -449,8 +409,7 @@ remoting.ClientSession.prototype.pluginLostFocus_ = function() {
// Due to crbug.com/246335, we can't restore the focus immediately, // Due to crbug.com/246335, we can't restore the focus immediately,
// otherwise the plugin gets confused about whether or not it has focus. // otherwise the plugin gets confused about whether or not it has focus.
window.setTimeout( window.setTimeout(
this.plugin_.element().focus.bind(this.plugin_.element()), this.plugin_.element().focus.bind(this.plugin_.element()), 0);
0);
} }
} }
}; };
...@@ -464,7 +423,9 @@ remoting.ClientSession.prototype.pluginLostFocus_ = function() { ...@@ -464,7 +423,9 @@ remoting.ClientSession.prototype.pluginLostFocus_ = function() {
*/ */
remoting.ClientSession.prototype.createPluginAndConnect = remoting.ClientSession.prototype.createPluginAndConnect =
function(onExtensionMessage) { function(onExtensionMessage) {
this.plugin_ = this.createClientPlugin_(this.PLUGIN_ID, onExtensionMessage); this.plugin_ = new remoting.ClientPlugin(
this.container_.querySelector('.client-plugin-container'),
onExtensionMessage);
remoting.HostSettings.load(this.hostId_, remoting.HostSettings.load(this.hostId_,
this.onHostSettingsLoaded_.bind(this)); this.onHostSettingsLoaded_.bind(this));
}; };
...@@ -515,7 +476,7 @@ remoting.ClientSession.prototype.setFocusHandlers_ = function() { ...@@ -515,7 +476,7 @@ remoting.ClientSession.prototype.setFocusHandlers_ = function() {
*/ */
remoting.ClientSession.prototype.resetWithError_ = function(error) { remoting.ClientSession.prototype.resetWithError_ = function(error) {
this.plugin_.cleanup(); this.plugin_.cleanup();
delete this.plugin_; this.plugin_ = null;
this.error_ = error; this.error_ = error;
this.setState_(remoting.ClientSession.State.FAILED); this.setState_(remoting.ClientSession.State.FAILED);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment