diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index bfd13920ad45..e3461160666e 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -79,6 +79,7 @@ #include "nsThreadManager.h" #include "nsAnonymousTemporaryFile.h" #include "nsISpellChecker.h" +#include "nsClipboardProxy.h" #include "IHistory.h" #include "nsNetUtil.h" @@ -717,9 +718,16 @@ ContentChild::InitXPCOM() NS_WARNING("Couldn't register console listener for child process"); bool isOffline; - SendGetXPCOMProcessAttributes(&isOffline, &mAvailableDictionaries); + ClipboardCapabilities clipboardCaps; + SendGetXPCOMProcessAttributes(&isOffline, &mAvailableDictionaries, &clipboardCaps); RecvSetOffline(isOffline); + nsCOMPtr clipboard(do_GetService("@mozilla.org/widget/clipboard;1")); + MOZ_ASSERT(clipboard, "should have gotten a clipboard proxy"); + + auto clipboardProxy = static_cast(clipboard.get()); + clipboardProxy->SetCapabilities(clipboardCaps); + DebugOnly observer = FileUpdateDispatcher::GetSingleton(); NS_ASSERTION(observer, "FileUpdateDispatcher is null"); diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index d9bdcf1713c3..b3ade7486cd7 100755 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -2498,8 +2498,13 @@ ContentParent::RecvAddNewProcess(const uint32_t& aPid, // Update offline settings. bool isOffline; InfallibleTArray unusedDictionaries; - RecvGetXPCOMProcessAttributes(&isOffline, &unusedDictionaries); + ClipboardCapabilities clipboardCaps; + RecvGetXPCOMProcessAttributes(&isOffline, &unusedDictionaries, + &clipboardCaps); content->SendSetOffline(isOffline); + MOZ_ASSERT(!clipboardCaps.supportsSelectionClipboard() && + !clipboardCaps.supportsFindClipboard(), + "Unexpected values"); PreallocatedProcessManager::PublishSpareProcess(content); return true; @@ -2747,7 +2752,8 @@ ContentParent::RecvGetProcessAttributes(uint64_t* aId, bool ContentParent::RecvGetXPCOMProcessAttributes(bool* aIsOffline, - InfallibleTArray* dictionaries) + InfallibleTArray* dictionaries, + ClipboardCapabilities* clipboardCaps) { nsCOMPtr io(do_GetIOService()); MOZ_ASSERT(io, "No IO service?"); @@ -2759,6 +2765,15 @@ ContentParent::RecvGetXPCOMProcessAttributes(bool* aIsOffline, spellChecker->GetDictionaryList(dictionaries); + nsCOMPtr clipboard(do_GetService("@mozilla.org/widget/clipboard;1")); + MOZ_ASSERT(clipboard, "No clipboard?"); + + rv = clipboard->SupportsSelectionClipboard(&clipboardCaps->supportsSelectionClipboard()); + MOZ_ASSERT(NS_SUCCEEDED(rv)); + + rv = clipboard->SupportsFindClipboard(&clipboardCaps->supportsFindClipboard()); + MOZ_ASSERT(NS_SUCCEEDED(rv)); + return true; } diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index c38705e98149..0c27d575814d 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -413,7 +413,8 @@ private: bool* aIsForApp, bool* aIsForBrowser) MOZ_OVERRIDE; virtual bool RecvGetXPCOMProcessAttributes(bool* aIsOffline, - InfallibleTArray* dictionaries) + InfallibleTArray* dictionaries, + ClipboardCapabilities* clipboardCaps) MOZ_OVERRIDE; virtual bool DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*) MOZ_OVERRIDE; diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index c8d3defa0767..0378dc846b02 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -314,6 +314,11 @@ struct VolumeInfo { bool isUnmounting; }; +struct ClipboardCapabilities { + bool supportsSelectionClipboard; + bool supportsFindClipboard; +}; + union MaybeFileDesc { FileDescriptor; void_t; @@ -507,7 +512,8 @@ parent: sync GetProcessAttributes() returns (uint64_t id, bool isForApp, bool isForBrowser); sync GetXPCOMProcessAttributes() - returns (bool isOffline, nsString[] dictionaries); + returns (bool isOffline, nsString[] dictionaries, + ClipboardCapabilities clipboardCaps); sync CreateChildProcess(IPCTabContext context, ProcessPriority priority) diff --git a/widget/xpwidgets/nsClipboardProxy.cpp b/widget/xpwidgets/nsClipboardProxy.cpp index 2f345a419672..f0efebab18cb 100644 --- a/widget/xpwidgets/nsClipboardProxy.cpp +++ b/widget/xpwidgets/nsClipboardProxy.cpp @@ -10,17 +10,18 @@ #include "nsXULAppAPI.h" using namespace mozilla; -using mozilla::dom::ContentChild; +using namespace mozilla::dom; NS_IMPL_ISUPPORTS(nsClipboardProxy, nsIClipboard) nsClipboardProxy::nsClipboardProxy() + : mClipboardCaps(false, false) { } NS_IMETHODIMP nsClipboardProxy::SetData(nsITransferable *aTransferable, - nsIClipboardOwner *anOwner, int32_t aWhichClipboard) + nsIClipboardOwner *anOwner, int32_t aWhichClipboard) { nsCOMPtr tmp; uint32_t len; @@ -36,7 +37,7 @@ nsClipboardProxy::SetData(nsITransferable *aTransferable, bool isPrivateData = false; aTransferable->GetIsPrivateData(&isPrivateData); ContentChild::GetSingleton()->SendSetClipboardText(buffer, isPrivateData, - aWhichClipboard); + aWhichClipboard); return NS_OK; } @@ -87,7 +88,7 @@ nsClipboardProxy::HasDataMatchingFlavors(const char **aFlavorList, NS_IMETHODIMP nsClipboardProxy::SupportsSelectionClipboard(bool *aIsSupported) { - *aIsSupported = false; + *aIsSupported = mClipboardCaps.supportsSelectionClipboard(); return NS_OK; } @@ -95,6 +96,12 @@ nsClipboardProxy::SupportsSelectionClipboard(bool *aIsSupported) NS_IMETHODIMP nsClipboardProxy::SupportsFindClipboard(bool *aIsSupported) { - *aIsSupported = false; + *aIsSupported = mClipboardCaps.supportsFindClipboard(); return NS_OK; } + +void +nsClipboardProxy::SetCapabilities(const ClipboardCapabilities& aClipboardCaps) +{ + mClipboardCaps = aClipboardCaps; +} diff --git a/widget/xpwidgets/nsClipboardProxy.h b/widget/xpwidgets/nsClipboardProxy.h index c4bd70da70b3..1deafa955916 100644 --- a/widget/xpwidgets/nsClipboardProxy.h +++ b/widget/xpwidgets/nsClipboardProxy.h @@ -7,16 +7,24 @@ #define NS_CLIPBOARD_PROXY_H #include "nsIClipboard.h" +#include "mozilla/dom/PContent.h" class nsClipboardProxy MOZ_FINAL : public nsIClipboard { - ~nsClipboardProxy() {} + typedef mozilla::dom::ClipboardCapabilities ClipboardCapabilities; public: NS_DECL_ISUPPORTS NS_DECL_NSICLIPBOARD nsClipboardProxy(); + + void SetCapabilities(const ClipboardCapabilities& aClipboardCaps); + +private: + ~nsClipboardProxy() {} + + ClipboardCapabilities mClipboardCaps; }; #endif