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

Unified Diff: remoting/webapp/remoting.js

Issue 9703003: [Chromoting] Let the webapp detect new clipboard text items when it gets focus. (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
« remoting/webapp/event_proto.js ('K') | « remoting/webapp/manifest.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/remoting.js
diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js
index a8ca35e6cbf032898bded2e497f732a04126f468..9eba4ac677c027c3229c59bc9a70aaadd61347fd 100644
--- a/remoting/webapp/remoting.js
+++ b/remoting/webapp/remoting.js
@@ -44,6 +44,7 @@ remoting.init = function() {
document.getElementById('host-list-error'));
remoting.toolbar = new remoting.Toolbar(
document.getElementById('session-toolbar'));
+ remoting.clipboard = new remoting.Clipboard();
refreshEmail_();
var email = remoting.oauth2.getCachedEmail();
@@ -51,7 +52,9 @@ remoting.init = function() {
document.getElementById('current-email').innerText = email;
}
+ window.addEventListener('focus', pluginGotFocus_, false);
window.addEventListener('blur', pluginLostFocus_, false);
+ window.addEventListener('paste', pluginGotPaste_, false);
// Parse URL parameters.
var urlParams = getUrlParameters_();
@@ -124,6 +127,28 @@ remoting.clearOAuth2 = function() {
};
/**
+ * Callback function called when the browser window gets focus.
+ */
+function pluginGotFocus_() {
+ var documentCast = /** @type {remoting.Document} */ document;
Jamie 2012/03/14 00:43:47 This can be simpler if you just annotate execComma
+ documentCast.execCommand("paste");
+}
+
+/**
+ * Callback function called when the browser window gets a paste operation.
+ *
+ * @param {Event} eventUncast
+ * @return {boolean}
+ */
+function pluginGotPaste_(eventUncast) {
+ var event = /** @type {remoting.Event} */ eventUncast;
+ if (event && event.clipboardData) {
+ remoting.clipboard.toHost(event.clipboardData);
+ }
+ return false;
+}
+
+/**
* Callback function called when the browser window loses focus. In this case,
* release all keys to prevent them becoming 'stuck down' on the host.
*/
« remoting/webapp/event_proto.js ('K') | « remoting/webapp/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698