Chromium Code Reviews| 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; |