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

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: 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
Index: remoting/webapp/clipboard.js
diff --git a/remoting/webapp/clipboard.js b/remoting/webapp/clipboard.js
new file mode 100644
index 0000000000000000000000000000000000000000..f16e19ee742e808523375fde96084981ac7818c6
--- /dev/null
+++ b/remoting/webapp/clipboard.js
@@ -0,0 +1,54 @@
+// 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() {
+};
+
+/** @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';
Jamie 2012/03/14 00:43:47 Since this is a constant, I'd be inclined to move
+ for (var i = 0; i < clipboardData.types.length; i++) {
+ var type = clipboardData.types[i];
+ if (type == textType) {
+ 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;

Powered by Google App Engine
This is Rietveld 408576698