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

Unified Diff: remoting/webapp/clipboard.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/remoting.gyp ('k') | remoting/webapp/clipboard_event_proto.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/clipboard.js
diff --git a/remoting/webapp/clipboard.js b/remoting/webapp/clipboard.js
new file mode 100644
index 0000000000000000000000000000000000000000..dcf55d8092eb4707a2fcae0e79dff7078c515fd4
--- /dev/null
+++ b/remoting/webapp/clipboard.js
@@ -0,0 +1,65 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview
+ * A class for moving clipboard items between the plugin and the OS.
+ */
+
+'use strict';
+
+/** @suppress {duplicate} */
+var remoting = remoting || {};
+
+/**
+ * @constructor
+ */
+remoting.Clipboard = function() {
+};
+
+/**
+ * @private
+ * @enum {string}
+ */
+remoting.Clipboard.prototype.ItemTypes = {
+ TEXT_TYPE: 'text/plain'
+};
+
+/**
+ * @private
+ * @type {string}
+ */
+remoting.Clipboard.prototype.recentItemText = "";
+
+/**
+ * Accepts a clipboard from the OS, and sends any changed clipboard items to
+ * the host.
+ *
+ * Currently only text items are supported.
+ *
+ * @param {remoting.ClipboardData} clipboardData
+ * @return {void} Nothing.
+ */
+remoting.Clipboard.prototype.toHost = function(clipboardData) {
+ if (!clipboardData || !clipboardData.types || !clipboardData.getData) {
+ return;
+ }
+ var textType = 'text/plain';
+ for (var i = 0; i < clipboardData.types.length; i++) {
+ var type = clipboardData.types[i];
+ if (type == this.ItemTypes.TEXT_TYPE) {
+ var item = clipboardData.getData(type);
+ if (!item) {
+ item = "";
+ }
+ if (item != this.recentItemText) {
+ // TODO(simonmorris): Pass the clipboard text item to the plugin.
+ this.recentItemText = item;
+ }
+ }
+ }
+};
+
+/** @type {remoting.Clipboard} */
+remoting.clipboard = null;
« no previous file with comments | « remoting/remoting.gyp ('k') | remoting/webapp/clipboard_event_proto.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698