OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview |
| 7 * A class for moving clipboard items between the plugin and the OS. |
| 8 */ |
| 9 |
| 10 'use strict'; |
| 11 |
| 12 /** @suppress {duplicate} */ |
| 13 var remoting = remoting || {}; |
| 14 |
| 15 /** |
| 16 * @constructor |
| 17 */ |
| 18 remoting.Clipboard = function() { |
| 19 }; |
| 20 |
| 21 /** |
| 22 * @private |
| 23 * @enum {string} |
| 24 */ |
| 25 remoting.Clipboard.prototype.ItemTypes = { |
| 26 TEXT_TYPE: 'text/plain' |
| 27 }; |
| 28 |
| 29 /** |
| 30 * @private |
| 31 * @type {string} |
| 32 */ |
| 33 remoting.Clipboard.prototype.recentItemText = ""; |
| 34 |
| 35 /** |
| 36 * Accepts a clipboard from the OS, and sends any changed clipboard items to |
| 37 * the host. |
| 38 * |
| 39 * Currently only text items are supported. |
| 40 * |
| 41 * @param {remoting.ClipboardData} clipboardData |
| 42 * @return {void} Nothing. |
| 43 */ |
| 44 remoting.Clipboard.prototype.toHost = function(clipboardData) { |
| 45 if (!clipboardData || !clipboardData.types || !clipboardData.getData) { |
| 46 return; |
| 47 } |
| 48 var textType = 'text/plain'; |
| 49 for (var i = 0; i < clipboardData.types.length; i++) { |
| 50 var type = clipboardData.types[i]; |
| 51 if (type == this.ItemTypes.TEXT_TYPE) { |
| 52 var item = clipboardData.getData(type); |
| 53 if (!item) { |
| 54 item = ""; |
| 55 } |
| 56 if (item != this.recentItemText) { |
| 57 // TODO(simonmorris): Pass the clipboard text item to the plugin. |
| 58 this.recentItemText = item; |
| 59 } |
| 60 } |
| 61 } |
| 62 }; |
| 63 |
| 64 /** @type {remoting.Clipboard} */ |
| 65 remoting.clipboard = null; |
OLD | NEW |