mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
7bf7c35e9f
- Bug 1086999 - CSP: Asterisk (*) wildcard should not allow blob:, data:, or filesystem: when matching source expressions (r=sstamm) (12b7a9aa0e) - Bug 1188754 - Do not notify the audio channel agent on Firefox OS when the document activity change callback detects that the element is muted by the audio channel; r=baku (de62066c8d) - Bug 1201969 - pause element only when start playing. r=baku (26296e8451) - Bug 1214659 - HTMLMediaElement::UpdateAudioChannelPlayingState() should be easy to read, r=roc (91dac0b019) - Bug 1048926 - fix and enable the testcase because the preload action is PRELOAD_NONE on mobile platform. r=jwwang (d2e5a68d50) - Bug 1213154 - tab-sound-icon should be supported by bfcache, r=roc (9b7a1be7ef) - crashtest for bug 1179662 (eb38345d96) - bug 1184801 crashtest for AnalyserNode with channels and small fftSize (4ba66b7d2c) - test for bug 1012609 r=karlt (11c2ff26a1) - test for bug 1020205 (abd041bc8d) - test for bug 995289 (cd63ecd503) - test for bug 1041466 (cf5000997c) - test for bug 1045650 (8f4b3f6684) - Bug 1185176 - Crashtest. r=karlt (2d292812de) - Bug 1185192 - Make promise resolving sequentially consistent when switching graph driver and closing a graph during the same iteration. r=roc (a03c3d76ae) - reapply 1189506 (73b0731ade) - Bug 1219403 - r=karlt (6729b12bac) - Bug 1219403 - Account for the fact that MediaStream::Destroy can be run safely (18e4d3a748) - Bug 1219403 - Remove MOZ_ASSERT for AssertOnGraphThreadOrNotRunning since it returns void and asserts inside, on a CLOSED TREE. (2e85625d43) - bug 1224022 produce memory report after processing main thread messages r=padenot (e7b61c839b) - Bug 1216059 - SourceMediaStream::TrackData::mResamplerChannelCount is used uninitialised. r=padenot. (ba158a93d6) - Bug 1216417 - Make sure audio output streams are created after adding an audio output. r=baku,roc (2becb6417f) - Bug 943294 - Leave dealing with legacy codepages for clipboard data to Windows itself. r=jmathies. (9859fe6126) - Bug 938991 - text/rtf support for clipboard data. r=enndeakin (63f739b651)
159 lines
4.9 KiB
C++
159 lines
4.9 KiB
C++
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "mozilla/dom/ContentChild.h"
|
|
#include "nsClipboardProxy.h"
|
|
#include "nsISupportsPrimitives.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsComponentManagerUtils.h"
|
|
#include "nsXULAppAPI.h"
|
|
#include "nsContentUtils.h"
|
|
#include "nsStringStream.h"
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::dom;
|
|
|
|
NS_IMPL_ISUPPORTS(nsClipboardProxy, nsIClipboard, nsIClipboardProxy)
|
|
|
|
nsClipboardProxy::nsClipboardProxy()
|
|
: mClipboardCaps(false, false)
|
|
{
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsClipboardProxy::SetData(nsITransferable *aTransferable,
|
|
nsIClipboardOwner *anOwner, int32_t aWhichClipboard)
|
|
{
|
|
ContentChild* child = ContentChild::GetSingleton();
|
|
|
|
IPCDataTransfer ipcDataTransfer;
|
|
nsContentUtils::TransferableToIPCTransferable(aTransferable, &ipcDataTransfer,
|
|
false, child, nullptr);
|
|
|
|
bool isPrivateData = false;
|
|
aTransferable->GetIsPrivateData(&isPrivateData);
|
|
child->SendSetClipboard(ipcDataTransfer, isPrivateData, aWhichClipboard);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsClipboardProxy::GetData(nsITransferable *aTransferable, int32_t aWhichClipboard)
|
|
{
|
|
nsTArray<nsCString> types;
|
|
|
|
nsCOMPtr<nsISupportsArray> flavorList;
|
|
aTransferable->FlavorsTransferableCanImport(getter_AddRefs(flavorList));
|
|
if (flavorList) {
|
|
uint32_t flavorCount = 0;
|
|
flavorList->Count(&flavorCount);
|
|
for (uint32_t j = 0; j < flavorCount; ++j) {
|
|
nsCOMPtr<nsISupportsCString> flavor = do_QueryElementAt(flavorList, j);
|
|
if (flavor) {
|
|
nsAutoCString flavorStr;
|
|
flavor->GetData(flavorStr);
|
|
if (flavorStr.Length()) {
|
|
types.AppendElement(flavorStr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
nsresult rv;
|
|
IPCDataTransfer dataTransfer;
|
|
ContentChild::GetSingleton()->SendGetClipboard(types, aWhichClipboard, &dataTransfer);
|
|
|
|
auto& items = dataTransfer.items();
|
|
for (uint32_t j = 0; j < items.Length(); ++j) {
|
|
const IPCDataTransferItem& item = items[j];
|
|
|
|
if (item.data().type() == IPCDataTransferData::TnsString) {
|
|
nsCOMPtr<nsISupportsString> dataWrapper =
|
|
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsString data = item.data().get_nsString();
|
|
rv = dataWrapper->SetData(data);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = aTransferable->SetTransferData(item.flavor().get(), dataWrapper,
|
|
data.Length() * sizeof(char16_t));
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
} else if (item.data().type() == IPCDataTransferData::TnsCString) {
|
|
// If this is an image, convert it into an nsIInputStream.
|
|
nsCString flavor = item.flavor();
|
|
if (flavor.EqualsLiteral(kJPEGImageMime) ||
|
|
flavor.EqualsLiteral(kJPGImageMime) ||
|
|
flavor.EqualsLiteral(kPNGImageMime) ||
|
|
flavor.EqualsLiteral(kGIFImageMime)) {
|
|
nsCOMPtr<nsIInputStream> stream;
|
|
NS_NewCStringInputStream(getter_AddRefs(stream), item.data().get_nsCString());
|
|
|
|
rv = aTransferable->SetTransferData(flavor.get(), stream, sizeof(nsISupports*));
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
} else if (flavor.EqualsLiteral(kNativeHTMLMime) ||
|
|
flavor.EqualsLiteral(kRTFMime)) {
|
|
nsCOMPtr<nsISupportsCString> dataWrapper =
|
|
do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsCString data = item.data().get_nsCString();
|
|
rv = dataWrapper->SetData(data);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = aTransferable->SetTransferData(item.flavor().get(), dataWrapper,
|
|
data.Length());
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
}
|
|
}
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsClipboardProxy::EmptyClipboard(int32_t aWhichClipboard)
|
|
{
|
|
ContentChild::GetSingleton()->SendEmptyClipboard(aWhichClipboard);
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsClipboardProxy::HasDataMatchingFlavors(const char **aFlavorList,
|
|
uint32_t aLength, int32_t aWhichClipboard,
|
|
bool *aHasType)
|
|
{
|
|
*aHasType = false;
|
|
|
|
nsTArray<nsCString> types;
|
|
for (uint32_t j = 0; j < aLength; ++j) {
|
|
types.AppendElement(nsDependentCString(aFlavorList[j]));
|
|
}
|
|
|
|
ContentChild::GetSingleton()->SendClipboardHasType(types, aWhichClipboard, aHasType);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsClipboardProxy::SupportsSelectionClipboard(bool *aIsSupported)
|
|
{
|
|
*aIsSupported = mClipboardCaps.supportsSelectionClipboard();
|
|
return NS_OK;
|
|
}
|
|
|
|
|
|
NS_IMETHODIMP
|
|
nsClipboardProxy::SupportsFindClipboard(bool *aIsSupported)
|
|
{
|
|
*aIsSupported = mClipboardCaps.supportsFindClipboard();
|
|
return NS_OK;
|
|
}
|
|
|
|
void
|
|
nsClipboardProxy::SetCapabilities(const ClipboardCapabilities& aClipboardCaps)
|
|
{
|
|
mClipboardCaps = aClipboardCaps;
|
|
}
|