summaryrefslogtreecommitdiffstats
path: root/remoting/webapp/remoting.js
diff options
context:
space:
mode:
authorsimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-02 16:58:11 +0000
committersimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-02 16:58:11 +0000
commita7e312c4450b9f600b3c4c1660f79e27380af26d (patch)
tree97b4d5134434d1ca037978380dda85f675cde130 /remoting/webapp/remoting.js
parent90b89ef0674870d7c1a6c38c1d53084d76ee3c07 (diff)
downloadchromium_src-a7e312c4450b9f600b3c4c1660f79e27380af26d.zip
chromium_src-a7e312c4450b9f600b3c4c1660f79e27380af26d.tar.gz
chromium_src-a7e312c4450b9f600b3c4c1660f79e27380af26d.tar.bz2
[Chromoting] Let the webapp put items on the clipboard.
BUG=117473 Review URL: https://chromiumcodereview.appspot.com/9969034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp/remoting.js')
-rw-r--r--remoting/webapp/remoting.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js
index 4266e0b..2780e6b 100644
--- a/remoting/webapp/remoting.js
+++ b/remoting/webapp/remoting.js
@@ -57,6 +57,7 @@ remoting.init = function() {
// The plugin's onFocus handler sends a paste command to |window|, because
// it can't send one to the plugin element itself.
window.addEventListener('paste', pluginGotPaste_, false);
+ window.addEventListener('copy', pluginGotCopy_, false);
if (isHostModeSupported_()) {
var noShare = document.getElementById('chrome-os-no-share');
@@ -136,6 +137,8 @@ remoting.clearOAuth2 = function() {
remoting.setMode(remoting.AppMode.UNAUTHENTICATED);
};
+// TODO(simonmorris): If possible, make the next two functions return void.
+
/**
* Callback function called when the browser window gets a paste operation.
*
@@ -151,6 +154,23 @@ function pluginGotPaste_(eventUncast) {
}
/**
+ * Callback function called when the browser window gets a copy operation.
+ *
+ * @param {Event} eventUncast
+ * @return {boolean}
+ */
+function pluginGotCopy_(eventUncast) {
+ var event = /** @type {remoting.ClipboardEvent} */ eventUncast;
+ if (event && event.clipboardData) {
+ if (remoting.clipboard.toOs(event.clipboardData)) {
+ // The default action may overwrite items that we added to clipboardData.
+ event.preventDefault();
+ }
+ }
+ return false;
+}
+
+/**
* If the user is authenticated, but there is no email address cached, get one.
*/
function refreshEmail_() {