Index: remoting/webapp/remoting.js |
diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js |
index 15b0968a157dc5c8afc42de061fbfc3b9bb50452..e7df0b39752d2a29d992471f9706ceadfaac3c38 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); |
if (isHostModeSupported_()) { |
var noShare = document.getElementById('chrome-os-no-share'); |
@@ -131,6 +134,29 @@ remoting.clearOAuth2 = function() { |
}; |
/** |
+ * Callback function called when the browser window gets focus. |
+ */ |
+function pluginGotFocus_() { |
+ /** @type {function(string): void} */ |
+ document.execCommand; |
+ document.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.ClipboardEvent} */ 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. |
*/ |