diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-06-08 02:00:10 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-06-08 02:00:10 +0200 |
commit | 94fe9a684db8182110109b6d3a8ef1bad1075a6b (patch) | |
tree | 01cdfa3f10e22167549befad365ce8149a05e412 /lib/clipboard.js | |
parent | 47511aa190e467bf711fcfa5fde1225275a3aaa8 (diff) | |
download | bugzilla-triage-94fe9a684db8182110109b6d3a8ef1bad1075a6b.tar.gz |
Added getCurrentFlavors with tests to the clipboard module.
Diffstat (limited to 'lib/clipboard.js')
-rw-r--r-- | lib/clipboard.js | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/clipboard.js b/lib/clipboard.js index b87c477..ea14903 100644 --- a/lib/clipboard.js +++ b/lib/clipboard.js @@ -108,7 +108,7 @@ function createSupportsWString() { createInstance(Ci.nsISupportsWString); } -var flavorsMethod = exports.getCurrentFlavors = function flavorsMethod() { +var flavorsMethod = exports.getCurrentFlavors = function flavorsMethod(test) { // currently the only possible flavors in Jetpack-prototype are "plain" and // "html", i.e., "text/plain" (or text/unicode?) and "text/html" (or // application/xml+xhtml?) @@ -117,13 +117,18 @@ var flavorsMethod = exports.getCurrentFlavors = function flavorsMethod() { "text/plain": "plain", "text/html": "html" }; - var flavourArray = []; - - for (mime in possibleTypes) { - var kSuppString = createSupportsWString(); - kSuppString.data = mime; - // FIXME Missing some kind of if (mime in flavors) ... - flavourArray.add(possibleTypes[mime]); + var flavorArray = []; + var clip = getClipboard(); + + for (var flavor in possibleTypes) { + var presentFlavor = clip.hasDataMatchingFlavors( + [flavor], + 1, + clip.kGlobalClipboard + ); + if (presentFlavor) { + flavorArray.push(possibleTypes[flavor]) + } } - return flavourArray; -}; + return flavorArray; +};
\ No newline at end of file |