2019-01-23 19:38:09 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
2019-05-24 22:23:18 +03:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
# include "mozilla/a11y/DocAccessibleParent.h"
|
|
|
|
#endif
|
2019-03-05 05:15:58 +03:00
|
|
|
#include "mozilla/dom/BrowserBridgeParent.h"
|
2019-05-07 19:07:47 +03:00
|
|
|
#include "mozilla/dom/BrowserParent.h"
|
2019-01-23 19:38:09 +03:00
|
|
|
#include "mozilla/dom/ContentParent.h"
|
|
|
|
#include "mozilla/dom/ContentProcessManager.h"
|
2019-03-14 21:50:45 +03:00
|
|
|
#include "mozilla/dom/CanonicalBrowsingContext.h"
|
|
|
|
#include "mozilla/dom/BrowsingContextGroup.h"
|
2019-05-06 11:12:21 +03:00
|
|
|
#include "mozilla/layers/InputAPZContext.h"
|
2019-01-23 19:38:09 +03:00
|
|
|
|
|
|
|
using namespace mozilla::ipc;
|
|
|
|
using namespace mozilla::layout;
|
2019-03-05 05:15:58 +03:00
|
|
|
using namespace mozilla::hal;
|
2019-01-23 19:38:09 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2019-05-24 22:23:18 +03:00
|
|
|
BrowserBridgeParent::BrowserBridgeParent()
|
2019-05-30 17:49:40 +03:00
|
|
|
:
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
mEmbedderAccessibleID(0),
|
|
|
|
#endif
|
|
|
|
mIPCOpen(false) {
|
|
|
|
}
|
2019-01-23 19:38:09 +03:00
|
|
|
|
2019-04-17 03:52:53 +03:00
|
|
|
BrowserBridgeParent::~BrowserBridgeParent() { Destroy(); }
|
2019-01-23 19:38:09 +03:00
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL,
|
2019-03-14 21:50:47 +03:00
|
|
|
const nsString& aRemoteType,
|
2019-04-09 00:22:58 +03:00
|
|
|
CanonicalBrowsingContext* aBrowsingContext,
|
2019-06-02 20:42:03 +03:00
|
|
|
const uint32_t& aChromeFlags, TabId aTabId) {
|
2019-01-23 19:40:08 +03:00
|
|
|
mIPCOpen = true;
|
|
|
|
|
2019-07-19 22:00:31 +03:00
|
|
|
// We can inherit most TabContext fields for the new BrowserParent actor from
|
|
|
|
// our Manager BrowserParent.
|
|
|
|
//
|
|
|
|
// We don't intend to support mozbrowsers with Fission currently, so we set
|
|
|
|
// |aMozBrowserElement| to be false.
|
2019-01-23 19:40:08 +03:00
|
|
|
MutableTabContext tabContext;
|
2019-07-19 22:00:31 +03:00
|
|
|
tabContext.SetTabContext(false, Manager()->ChromeOuterWindowID(),
|
|
|
|
Manager()->ShowFocusRings(),
|
|
|
|
Manager()->OriginAttributesRef(), aPresentationURL,
|
|
|
|
Manager()->GetMaxTouchPoints());
|
2019-01-23 19:40:08 +03:00
|
|
|
|
|
|
|
ProcessPriority initialPriority = PROCESS_PRIORITY_FOREGROUND;
|
|
|
|
|
|
|
|
// Get our ConstructorSender object.
|
2019-02-25 23:04:47 +03:00
|
|
|
RefPtr<ContentParent> constructorSender =
|
2019-01-23 19:40:08 +03:00
|
|
|
ContentParent::GetNewOrUsedBrowserProcess(
|
|
|
|
nullptr, aRemoteType, initialPriority, nullptr, false);
|
|
|
|
if (NS_WARN_IF(!constructorSender)) {
|
|
|
|
MOZ_ASSERT(false, "Unable to allocate content process!");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2019-03-14 21:50:45 +03:00
|
|
|
// Ensure that our content process is subscribed to our newly created
|
|
|
|
// BrowsingContextGroup.
|
2019-03-14 21:50:47 +03:00
|
|
|
aBrowsingContext->Group()->EnsureSubscribed(constructorSender);
|
|
|
|
aBrowsingContext->SetOwnerProcessId(constructorSender->ChildID());
|
2019-03-14 21:50:45 +03:00
|
|
|
|
2019-01-23 19:40:08 +03:00
|
|
|
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
2019-06-02 20:42:03 +03:00
|
|
|
cpm->RegisterRemoteFrame(aTabId, ContentParentId(0), TabId(0),
|
2019-01-23 19:40:08 +03:00
|
|
|
tabContext.AsIPCTabContext(),
|
|
|
|
constructorSender->ChildID());
|
|
|
|
|
2019-04-10 00:38:15 +03:00
|
|
|
// Construct the BrowserParent object for our subframe.
|
2019-05-15 18:34:03 +03:00
|
|
|
RefPtr<BrowserParent> browserParent(new BrowserParent(
|
2019-06-02 20:42:03 +03:00
|
|
|
constructorSender, aTabId, tabContext, aBrowsingContext, aChromeFlags));
|
2019-05-15 18:34:03 +03:00
|
|
|
browserParent->SetBrowserBridgeParent(this);
|
2019-01-23 19:40:08 +03:00
|
|
|
|
2019-04-17 03:51:38 +03:00
|
|
|
// Open a remote endpoint for our PBrowser actor. DeallocPBrowserParent
|
|
|
|
// releases the ref taken.
|
|
|
|
ManagedEndpoint<PBrowserChild> childEp =
|
2019-04-10 00:38:15 +03:00
|
|
|
constructorSender->OpenPBrowserEndpoint(do_AddRef(browserParent).take());
|
2019-04-17 03:51:38 +03:00
|
|
|
if (NS_WARN_IF(!childEp.IsValid())) {
|
|
|
|
MOZ_ASSERT(false, "Browser Open Endpoint Failed");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tell the content process to set up its PBrowserChild.
|
|
|
|
bool ok = constructorSender->SendConstructBrowser(
|
2019-06-02 20:42:03 +03:00
|
|
|
std::move(childEp), aTabId, TabId(0), tabContext.AsIPCTabContext(),
|
2019-04-17 03:51:38 +03:00
|
|
|
aBrowsingContext, aChromeFlags, constructorSender->ChildID(),
|
2019-05-29 19:35:37 +03:00
|
|
|
constructorSender->IsForBrowser(), /* aIsTopLevel */ false);
|
2019-04-17 03:51:38 +03:00
|
|
|
if (NS_WARN_IF(!ok)) {
|
2019-01-23 19:40:08 +03:00
|
|
|
MOZ_ASSERT(false, "Browser Constructor Failed");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2019-04-10 00:38:15 +03:00
|
|
|
// Set our BrowserParent object to the newly created browser.
|
|
|
|
mBrowserParent = browserParent.forget();
|
|
|
|
mBrowserParent->SetOwnerElement(Manager()->GetOwnerElement());
|
|
|
|
mBrowserParent->InitRendering();
|
2019-01-23 19:40:08 +03:00
|
|
|
|
2019-01-23 20:04:26 +03:00
|
|
|
// Send the newly created layers ID back into content.
|
2019-06-01 00:00:57 +03:00
|
|
|
Unused << SendSetLayersId(mBrowserParent->GetLayersId());
|
2019-01-23 19:38:09 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-07 19:07:47 +03:00
|
|
|
CanonicalBrowsingContext* BrowserBridgeParent::GetBrowsingContext() {
|
|
|
|
return mBrowserParent->GetBrowsingContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
BrowserParent* BrowserBridgeParent::Manager() {
|
|
|
|
MOZ_ASSERT(mIPCOpen);
|
|
|
|
return static_cast<BrowserParent*>(PBrowserBridgeParent::Manager());
|
|
|
|
}
|
|
|
|
|
2019-04-17 03:52:53 +03:00
|
|
|
void BrowserBridgeParent::Destroy() {
|
2019-04-10 00:38:15 +03:00
|
|
|
if (mBrowserParent) {
|
|
|
|
mBrowserParent->Destroy();
|
2019-07-07 19:02:11 +03:00
|
|
|
mBrowserParent->SetBrowserBridgeParent(nullptr);
|
2019-04-10 00:38:15 +03:00
|
|
|
mBrowserParent = nullptr;
|
2019-04-17 03:52:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvShow(const ScreenIntSize& aSize,
|
|
|
|
const bool& aParentIsActive,
|
|
|
|
const nsSizeMode& aSizeMode) {
|
2019-06-01 00:00:57 +03:00
|
|
|
if (!mBrowserParent->AttachLayerManager()) {
|
2019-01-23 20:04:26 +03:00
|
|
|
MOZ_CRASH();
|
|
|
|
}
|
2019-04-10 00:38:15 +03:00
|
|
|
Unused << mBrowserParent->SendShow(aSize, mBrowserParent->GetShowInfo(),
|
|
|
|
aParentIsActive, aSizeMode);
|
2019-01-23 20:04:26 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvLoadURL(const nsCString& aUrl) {
|
2019-04-10 00:38:15 +03:00
|
|
|
Unused << mBrowserParent->SendLoadURL(aUrl, mBrowserParent->GetShowInfo());
|
2019-01-23 20:04:26 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-04-17 03:53:28 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvResumeLoad(uint64_t aPendingSwitchID) {
|
2019-04-10 00:38:15 +03:00
|
|
|
mBrowserParent->ResumeLoad(aPendingSwitchID);
|
2019-04-17 03:53:28 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvUpdateDimensions(
|
2019-01-23 20:04:26 +03:00
|
|
|
const DimensionInfo& aDimensions) {
|
2019-04-10 00:38:15 +03:00
|
|
|
Unused << mBrowserParent->SendUpdateDimensions(aDimensions);
|
2019-01-23 20:04:26 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-05-15 23:26:25 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvUpdateEffects(const EffectsInfo& aEffects) {
|
|
|
|
Unused << mBrowserParent->SendUpdateEffects(aEffects);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvRenderLayers(
|
2019-01-23 20:04:26 +03:00
|
|
|
const bool& aEnabled, const bool& aForceRepaint,
|
|
|
|
const layers::LayersObserverEpoch& aEpoch) {
|
2019-04-10 00:38:15 +03:00
|
|
|
Unused << mBrowserParent->SendRenderLayers(aEnabled, aForceRepaint, aEpoch);
|
2019-01-23 20:04:26 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvNavigateByKey(
|
2019-03-05 22:33:09 +03:00
|
|
|
const bool& aForward, const bool& aForDocumentNavigation) {
|
2019-04-10 00:38:15 +03:00
|
|
|
Unused << mBrowserParent->SendNavigateByKey(aForward, aForDocumentNavigation);
|
2019-03-05 22:33:09 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-05-06 11:12:21 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvDispatchSynthesizedMouseEvent(
|
|
|
|
const WidgetMouseEvent& aEvent) {
|
|
|
|
if (aEvent.mMessage != eMouseMove ||
|
|
|
|
aEvent.mReason != WidgetMouseEvent::eSynthesized) {
|
|
|
|
return IPC_FAIL(this, "Unexpected event type");
|
|
|
|
}
|
|
|
|
|
|
|
|
WidgetMouseEvent event = aEvent;
|
|
|
|
// Convert mRefPoint from the dispatching child process coordinate space
|
|
|
|
// to the parent coordinate space. The SendRealMouseEvent call will convert
|
|
|
|
// it into the dispatchee child process coordinate space
|
|
|
|
event.mRefPoint = Manager()->TransformChildToParent(event.mRefPoint);
|
|
|
|
// We need to set up an InputAPZContext on the stack because
|
|
|
|
// BrowserParent::SendRealMouseEvent requires one. But the only thing in
|
|
|
|
// that context that is actually used in this scenario is the layers id,
|
|
|
|
// and we already have that on the mouse event.
|
|
|
|
layers::InputAPZContext context(
|
|
|
|
layers::ScrollableLayerGuid(event.mLayersId, 0,
|
|
|
|
layers::ScrollableLayerGuid::NULL_SCROLL_ID),
|
|
|
|
0, nsEventStatus_eIgnore);
|
|
|
|
mBrowserParent->SendRealMouseEvent(event);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-04-04 01:40:28 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvSkipBrowsingContextDetach() {
|
2019-06-10 18:13:24 +03:00
|
|
|
Unused << mBrowserParent->SendSkipBrowsingContextDetach();
|
2019-04-04 01:40:28 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvActivate() {
|
2019-04-10 00:38:15 +03:00
|
|
|
mBrowserParent->Activate();
|
2019-03-05 22:33:52 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-06-14 10:02:18 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvDeactivate(const bool& aWindowLowering) {
|
|
|
|
mBrowserParent->Deactivate(aWindowLowering);
|
2019-03-14 19:00:32 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-05-13 04:49:07 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvSetIsUnderHiddenEmbedderElement(
|
|
|
|
const bool& aIsUnderHiddenEmbedderElement) {
|
|
|
|
Unused << mBrowserParent->SendSetIsUnderHiddenEmbedderElement(
|
|
|
|
aIsUnderHiddenEmbedderElement);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-05-24 22:23:18 +03:00
|
|
|
IPCResult BrowserBridgeParent::RecvSetEmbedderAccessible(
|
|
|
|
PDocAccessibleParent* aDoc, uint64_t aID) {
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
mEmbedderAccessibleDoc = static_cast<a11y::DocAccessibleParent*>(aDoc);
|
|
|
|
mEmbedderAccessibleID = aID;
|
|
|
|
#endif
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-03-05 05:15:58 +03:00
|
|
|
void BrowserBridgeParent::ActorDestroy(ActorDestroyReason aWhy) {
|
2019-01-23 19:38:09 +03:00
|
|
|
mIPCOpen = false;
|
2019-04-17 03:52:53 +03:00
|
|
|
Destroy();
|
2019-01-23 19:38:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|