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

Unified Diff: remoting/webapp/client_session.js

Issue 9875031: [Chromoting] Move the onBlur handler from window to the plugin element. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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_session.js
diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js
index f2862e56865e767d0610fdacd0dffeccc43effb8..cab82ecfa58876bc2536f0c1c647ad53ff2917fd 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;
}
« 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