blob: dcf55d8092eb4707a2fcae0e79dff7078c515fd4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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;
|