2014-06-11 09:44:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 22:32:37 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-06-11 09:44:13 +04:00
|
|
|
/* 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/ContentBridgeChild.h"
|
|
|
|
#include "mozilla/dom/ContentChild.h"
|
2014-10-08 20:15:23 +04:00
|
|
|
#include "mozilla/dom/File.h"
|
2014-06-11 09:44:13 +04:00
|
|
|
#include "mozilla/dom/TabChild.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "mozilla/dom/ipc/BlobChild.h"
|
2015-01-27 00:32:18 +03:00
|
|
|
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
2014-06-11 09:44:13 +04:00
|
|
|
#include "mozilla/ipc/InputStreamUtils.h"
|
2016-05-13 01:15:43 +03:00
|
|
|
#include "base/task.h"
|
2014-06-11 09:44:13 +04:00
|
|
|
|
|
|
|
using namespace mozilla::ipc;
|
|
|
|
using namespace mozilla::jsipc;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-06-10 20:08:00 +03:00
|
|
|
NS_IMPL_ISUPPORTS(ContentBridgeChild,
|
2015-08-31 08:53:00 +03:00
|
|
|
nsIContentChild)
|
2014-06-11 09:44:13 +04:00
|
|
|
|
2017-01-27 02:05:36 +03:00
|
|
|
ContentBridgeChild::ContentBridgeChild()
|
2014-06-11 09:44:13 +04:00
|
|
|
{}
|
|
|
|
|
|
|
|
ContentBridgeChild::~ContentBridgeChild()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
|
|
|
|
{
|
2016-05-05 11:45:00 +03:00
|
|
|
MessageLoop::current()->PostTask(NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy));
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
|
|
|
|
2017-01-27 01:40:17 +03:00
|
|
|
/*static*/ void
|
|
|
|
ContentBridgeChild::Create(Endpoint<PContentBridgeChild>&& aEndpoint)
|
2014-06-11 09:44:13 +04:00
|
|
|
{
|
2017-01-27 02:05:36 +03:00
|
|
|
RefPtr<ContentBridgeChild> bridge = new ContentBridgeChild();
|
2014-06-11 09:44:13 +04:00
|
|
|
bridge->mSelfRef = bridge;
|
|
|
|
|
2017-01-27 01:40:17 +03:00
|
|
|
DebugOnly<bool> ok = aEndpoint.Bind(bridge);
|
2014-06-11 09:44:13 +04:00
|
|
|
MOZ_ASSERT(ok);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentBridgeChild::DeferredDestroy()
|
|
|
|
{
|
|
|
|
mSelfRef = nullptr;
|
|
|
|
// |this| was just destroyed, hands off
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-06-11 09:44:13 +04:00
|
|
|
ContentBridgeChild::RecvAsyncMessage(const nsString& aMsg,
|
2015-01-16 22:58:52 +03:00
|
|
|
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
|
2016-04-09 16:50:59 +03:00
|
|
|
const IPC::Principal& aPrincipal,
|
|
|
|
const ClonedMessageData& aData)
|
2014-06-11 09:44:13 +04:00
|
|
|
{
|
2016-04-09 16:50:59 +03:00
|
|
|
return nsIContentChild::RecvAsyncMessage(aMsg, Move(aCpows), aPrincipal, aData);
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PBlobChild*
|
|
|
|
ContentBridgeChild::SendPBlobConstructor(PBlobChild* actor,
|
|
|
|
const BlobConstructorParams& params)
|
|
|
|
{
|
|
|
|
return PContentBridgeChild::SendPBlobConstructor(actor, params);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentBridgeChild::SendPBrowserConstructor(PBrowserChild* aActor,
|
2014-10-29 21:11:00 +03:00
|
|
|
const TabId& aTabId,
|
2014-06-11 09:44:13 +04:00
|
|
|
const IPCTabContext& aContext,
|
|
|
|
const uint32_t& aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
const ContentParentId& aCpID,
|
2014-06-11 09:44:13 +04:00
|
|
|
const bool& aIsForBrowser)
|
|
|
|
{
|
|
|
|
return PContentBridgeChild::SendPBrowserConstructor(aActor,
|
2014-10-29 21:11:00 +03:00
|
|
|
aTabId,
|
2014-06-11 09:44:13 +04:00
|
|
|
aContext,
|
|
|
|
aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
aCpID,
|
2014-06-11 09:44:13 +04:00
|
|
|
aIsForBrowser);
|
|
|
|
}
|
|
|
|
|
2016-09-21 13:27:26 +03:00
|
|
|
PFileDescriptorSetChild*
|
|
|
|
ContentBridgeChild::SendPFileDescriptorSetConstructor(const FileDescriptor& aFD)
|
|
|
|
{
|
|
|
|
return PContentBridgeChild::SendPFileDescriptorSetConstructor(aFD);
|
|
|
|
}
|
|
|
|
|
2017-03-14 14:28:58 +03:00
|
|
|
PChildToParentStreamChild*
|
|
|
|
ContentBridgeChild::SendPChildToParentStreamConstructor(PChildToParentStreamChild* aActor)
|
2016-09-21 13:27:26 +03:00
|
|
|
{
|
2017-03-14 14:28:58 +03:00
|
|
|
return PContentBridgeChild::SendPChildToParentStreamConstructor(aActor);
|
2016-09-21 13:27:26 +03:00
|
|
|
}
|
|
|
|
|
2014-06-11 09:44:13 +04:00
|
|
|
// This implementation is identical to ContentChild::GetCPOWManager but we can't
|
|
|
|
// move it to nsIContentChild because it calls ManagedPJavaScriptChild() which
|
|
|
|
// only exists in PContentChild and PContentBridgeChild.
|
2015-01-27 00:32:18 +03:00
|
|
|
jsipc::CPOWManager*
|
2014-06-11 09:44:13 +04:00
|
|
|
ContentBridgeChild::GetCPOWManager()
|
|
|
|
{
|
2015-12-22 18:14:23 +03:00
|
|
|
if (PJavaScriptChild* c = LoneManagedOrNullAsserts(ManagedPJavaScriptChild())) {
|
2015-10-08 03:15:56 +03:00
|
|
|
return CPOWManagerFor(c);
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
2015-01-27 00:32:18 +03:00
|
|
|
return CPOWManagerFor(SendPJavaScriptConstructor());
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::jsipc::PJavaScriptChild *
|
|
|
|
ContentBridgeChild::AllocPJavaScriptChild()
|
|
|
|
{
|
|
|
|
return nsIContentChild::AllocPJavaScriptChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentBridgeChild::DeallocPJavaScriptChild(PJavaScriptChild *child)
|
|
|
|
{
|
|
|
|
return nsIContentChild::DeallocPJavaScriptChild(child);
|
|
|
|
}
|
|
|
|
|
|
|
|
PBrowserChild*
|
2014-10-29 21:11:00 +03:00
|
|
|
ContentBridgeChild::AllocPBrowserChild(const TabId& aTabId,
|
|
|
|
const IPCTabContext &aContext,
|
2014-06-11 09:44:13 +04:00
|
|
|
const uint32_t& aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
const ContentParentId& aCpID,
|
2014-06-11 09:44:13 +04:00
|
|
|
const bool& aIsForBrowser)
|
|
|
|
{
|
2014-10-29 21:11:00 +03:00
|
|
|
return nsIContentChild::AllocPBrowserChild(aTabId,
|
|
|
|
aContext,
|
2014-06-11 09:44:13 +04:00
|
|
|
aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
aCpID,
|
2014-06-11 09:44:13 +04:00
|
|
|
aIsForBrowser);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentBridgeChild::DeallocPBrowserChild(PBrowserChild* aChild)
|
|
|
|
{
|
|
|
|
return nsIContentChild::DeallocPBrowserChild(aChild);
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-06-11 09:44:13 +04:00
|
|
|
ContentBridgeChild::RecvPBrowserConstructor(PBrowserChild* aActor,
|
2014-10-29 21:11:00 +03:00
|
|
|
const TabId& aTabId,
|
2014-06-11 09:44:13 +04:00
|
|
|
const IPCTabContext& aContext,
|
|
|
|
const uint32_t& aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
const ContentParentId& aCpID,
|
2014-06-11 09:44:13 +04:00
|
|
|
const bool& aIsForBrowser)
|
|
|
|
{
|
2016-12-01 06:16:28 +03:00
|
|
|
return nsIContentChild::RecvPBrowserConstructor(aActor,
|
|
|
|
aTabId,
|
|
|
|
aContext,
|
|
|
|
aChromeFlags,
|
|
|
|
aCpID,
|
|
|
|
aIsForBrowser);
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PBlobChild*
|
|
|
|
ContentBridgeChild::AllocPBlobChild(const BlobConstructorParams& aParams)
|
|
|
|
{
|
|
|
|
return nsIContentChild::AllocPBlobChild(aParams);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentBridgeChild::DeallocPBlobChild(PBlobChild* aActor)
|
|
|
|
{
|
|
|
|
return nsIContentChild::DeallocPBlobChild(aActor);
|
|
|
|
}
|
|
|
|
|
2017-03-14 14:28:58 +03:00
|
|
|
PChildToParentStreamChild*
|
|
|
|
ContentBridgeChild::AllocPChildToParentStreamChild()
|
2016-09-21 13:27:26 +03:00
|
|
|
{
|
2017-03-14 14:28:58 +03:00
|
|
|
return nsIContentChild::AllocPChildToParentStreamChild();
|
2016-09-21 13:27:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-03-14 14:28:58 +03:00
|
|
|
ContentBridgeChild::DeallocPChildToParentStreamChild(PChildToParentStreamChild* aActor)
|
2016-09-21 13:27:26 +03:00
|
|
|
{
|
2017-03-14 14:28:58 +03:00
|
|
|
return nsIContentChild::DeallocPChildToParentStreamChild(aActor);
|
2016-09-21 13:27:26 +03:00
|
|
|
}
|
|
|
|
|
2017-03-14 14:29:43 +03:00
|
|
|
PParentToChildStreamChild*
|
|
|
|
ContentBridgeChild::AllocPParentToChildStreamChild()
|
|
|
|
{
|
|
|
|
return nsIContentChild::AllocPParentToChildStreamChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentBridgeChild::DeallocPParentToChildStreamChild(PParentToChildStreamChild* aActor)
|
|
|
|
{
|
|
|
|
return nsIContentChild::DeallocPParentToChildStreamChild(aActor);
|
|
|
|
}
|
|
|
|
|
2016-09-21 13:27:26 +03:00
|
|
|
PFileDescriptorSetChild*
|
|
|
|
ContentBridgeChild::AllocPFileDescriptorSetChild(const FileDescriptor& aFD)
|
|
|
|
{
|
|
|
|
return nsIContentChild::AllocPFileDescriptorSetChild(aFD);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentBridgeChild::DeallocPFileDescriptorSetChild(PFileDescriptorSetChild* aActor)
|
|
|
|
{
|
|
|
|
return nsIContentChild::DeallocPFileDescriptorSetChild(aActor);
|
|
|
|
}
|
|
|
|
|
2017-03-15 04:00:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentBridgeChild::RecvActivate(PBrowserChild* aTab)
|
|
|
|
{
|
|
|
|
TabChild* tab = static_cast<TabChild*>(aTab);
|
|
|
|
return tab->RecvActivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentBridgeChild::RecvDeactivate(PBrowserChild* aTab)
|
|
|
|
{
|
|
|
|
TabChild* tab = static_cast<TabChild*>(aTab);
|
|
|
|
return tab->RecvDeactivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentBridgeChild::RecvParentActivated(PBrowserChild* aTab, const bool& aActivated)
|
|
|
|
{
|
|
|
|
TabChild* tab = static_cast<TabChild*>(aTab);
|
|
|
|
return tab->RecvParentActivated(aActivated);
|
|
|
|
}
|
|
|
|
|
2014-06-11 09:44:13 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|