diff options
author | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-28 21:07:45 +0000 |
---|---|---|
committer | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-28 21:07:45 +0000 |
commit | 10c5623f391421794d2b341485cceeb16813a3d4 (patch) | |
tree | 949f7b5aca97c8c64a360a5096b89365a4a6774e /remoting/webapp/client_session.js | |
parent | fd006c762c3282e616c0d9a917e6319b0913f9a6 (diff) | |
download | chromium_src-10c5623f391421794d2b341485cceeb16813a3d4.zip chromium_src-10c5623f391421794d2b341485cceeb16813a3d4.tar.gz chromium_src-10c5623f391421794d2b341485cceeb16813a3d4.tar.bz2 |
[Chromoting] Move the onBlur handler from window to the plugin element.
This is a follow-up to codereview.chromium.org/9773033 .
Review URL: https://chromiumcodereview.appspot.com/9875031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp/client_session.js')
-rw-r--r-- | remoting/webapp/client_session.js | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js index 3258897..4b5c45a 100644 --- a/remoting/webapp/client_session.js +++ b/remoting/webapp/client_session.js @@ -61,7 +61,9 @@ remoting.ClientSession = function(hostJid, hostPublicKey, sharedSecret, /** @type {remoting.ClientSession} */ var that = this; /** @type {function():void} @private */ - this.refocusPlugin_ = function() { that.plugin.element().focus(); }; + this.callPluginLostFocus_ = function() { that.pluginLostFocus_(); }; + /** @type {function():void} @private */ + this.callPluginGotFocus_ = function() { that.pluginGotFocus_(); }; }; // Note that the positive values in both of these enums are copied directly @@ -194,7 +196,21 @@ remoting.ClientSession.prototype.pluginGotFocus_ = function() { /** @type {function(string): void } */ document.execCommand; document.execCommand("paste"); -} +}; + +/** + * Callback function called when the plugin element loses focus. + */ +remoting.ClientSession.prototype.pluginLostFocus_ = function() { + if (this.plugin) { + // Release all keys to prevent them becoming 'stuck down' on the host. + this.plugin.releaseAllKeys(); + if (this.plugin.element()) { + // Focus should stay on the element, not (for example) the toolbar. + this.plugin.element().focus(); + } + } +}; /** * Adds <embed> element to |container| and readies the sesion object. @@ -207,7 +223,6 @@ remoting.ClientSession.prototype.createPluginAndConnect = this.plugin = this.createClientPlugin_(container, this.PLUGIN_ID); this.plugin.element().focus(); - this.plugin.element().addEventListener('blur', this.refocusPlugin_, false); /** @type {remoting.ClientSession} */ var that = this; @@ -216,7 +231,9 @@ remoting.ClientSession.prototype.createPluginAndConnect = that.onPluginInitialized_(oauth2AccessToken, result); }); this.plugin.element().addEventListener( - 'focus', function() { that.pluginGotFocus_() }, false); + 'focus', this.callPluginGotFocus_, false); + this.plugin.element().addEventListener( + 'blur', this.callPluginLostFocus_, false); }; /** @@ -276,7 +293,9 @@ remoting.ClientSession.prototype.onPluginInitialized_ = remoting.ClientSession.prototype.removePlugin = function() { if (this.plugin) { this.plugin.element().removeEventListener( - 'blur', this.refocusPlugin_, false); + 'focus', this.callPluginGotFocus_, false); + this.plugin.element().removeEventListener( + 'blur', this.callPluginLostFocus_, false); this.plugin.cleanup(); this.plugin = null; } |