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

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: Sync. 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 | « 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 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.
*/
« no previous file with comments | « remoting/webapp/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698