Chromium Code Reviews| 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 /** @type {string} */ | |
| 22 remoting.Clipboard.prototype.recentItemText = ""; | |
| 23 | |
| 24 /** | |
| 25 * Accepts a clipboard from the OS, and sends any changed clipboard items to | |
| 26 * the host. | |
| 27 * | |
| 28 * Currently only text items are supported. | |
| 29 * | |
| 30 * @param {remoting.ClipboardData} clipboardData | |
| 31 * @return {void} Nothing. | |
| 32 */ | |
| 33 remoting.Clipboard.prototype.toHost = function(clipboardData) { | |
| 34 if (!clipboardData || !clipboardData.types || !clipboardData.getData) { | |
| 35 return; | |
| 36 } | |
| 37 var textType = 'text/plain'; | |
|
Jamie
2012/03/14 00:43:47
Since this is a constant, I'd be inclined to move
| |
| 38 for (var i = 0; i < clipboardData.types.length; i++) { | |
| 39 var type = clipboardData.types[i]; | |
| 40 if (type == textType) { | |
| 41 var item = clipboardData.getData(type); | |
| 42 if (!item) { | |
| 43 item = ""; | |
| 44 } | |
| 45 if (item != this.recentItemText) { | |
| 46 // TODO(simonmorris): Pass the clipboard text item to the plugin. | |
| 47 this.recentItemText = item; | |
| 48 } | |
| 49 } | |
| 50 } | |
| 51 }; | |
| 52 | |
| 53 /** @type {remoting.Clipboard} */ | |
| 54 remoting.clipboard = null; | |
| OLD | NEW |