mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1529684 - Part 2: Create BrowsingContext for remote browsers in parent, r=farre
Depends on D21095 Differential Revision: https://phabricator.services.mozilla.com/D21096 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
6a04609cc9
commit
eaf6c2306e
@ -237,6 +237,10 @@ void BrowsingContext::Detach(bool aFromIPC) {
|
||||
|
||||
Group()->Unregister(this);
|
||||
|
||||
// By definition, we no longer are the current process for this
|
||||
// BrowsingContext - clear our now-dead nsDocShell reference.
|
||||
mDocShell = nullptr;
|
||||
|
||||
if (!aFromIPC && XRE_IsContentProcess()) {
|
||||
auto cc = ContentChild::GetSingleton();
|
||||
MOZ_DIAGNOSTIC_ASSERT(cc);
|
||||
|
@ -37,6 +37,29 @@ void BrowsingContextGroup::Unsubscribe(ContentParent* aOriginProcess) {
|
||||
aOriginProcess->OnBrowsingContextGroupUnsubscribe(this);
|
||||
}
|
||||
|
||||
void BrowsingContextGroup::EnsureSubscribed(ContentParent* aProcess) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aProcess);
|
||||
if (mSubscribers.Contains(aProcess)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(
|
||||
mContexts.Count() == 1,
|
||||
"EnsureSubscribed doesn't work on non-fresh BrowsingContextGroups yet!");
|
||||
|
||||
// Subscribe to the BrowsingContext, and send down initial state!
|
||||
Subscribe(aProcess);
|
||||
|
||||
// XXX(nika): We can't send down existing BrowsingContextGroups reliably yet
|
||||
// due to ordering issues! (Bug ?)
|
||||
for (auto iter = mContexts.Iter(); !iter.Done(); iter.Next()) {
|
||||
RefPtr<BrowsingContext> bc = iter.Get()->GetKey();
|
||||
Unused << aProcess->SendAttachBrowsingContext(
|
||||
bc->GetParent(), bc->GetOpener(), BrowsingContextId(bc->Id()),
|
||||
bc->Name());
|
||||
}
|
||||
}
|
||||
|
||||
BrowsingContextGroup::~BrowsingContextGroup() {
|
||||
for (auto iter = mSubscribers.Iter(); !iter.Done(); iter.Next()) {
|
||||
nsRefPtrHashKey<ContentParent>* entry = iter.Get();
|
||||
|
@ -43,6 +43,9 @@ class BrowsingContextGroup final : public nsWrapperCache {
|
||||
void Subscribe(ContentParent* aOriginProcess);
|
||||
void Unsubscribe(ContentParent* aOriginProcess);
|
||||
|
||||
// Force the given ContentParent to subscribe to our BrowsingContextGroup.
|
||||
void EnsureSubscribed(ContentParent* aProcess);
|
||||
|
||||
ContentParents::Iterator ContentParentsIter() { return mSubscribers.Iter(); }
|
||||
|
||||
// Get a reference to the list of toplevel contexts in this
|
||||
|
@ -35,6 +35,8 @@ class CanonicalBrowsingContext final : public BrowsingContext {
|
||||
}
|
||||
uint64_t OwnerProcessId() const { return mProcessId; }
|
||||
|
||||
void SetOwnerProcessId(uint64_t aProcessId) { mProcessId = aProcessId; }
|
||||
|
||||
void GetWindowGlobals(nsTArray<RefPtr<WindowGlobalParent>>& aWindows);
|
||||
|
||||
// Called by WindowGlobalParent to register and unregister window globals.
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "mozilla/dom/BrowserBridgeParent.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/ContentProcessManager.h"
|
||||
#include "mozilla/dom/CanonicalBrowsingContext.h"
|
||||
#include "mozilla/dom/BrowsingContextGroup.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
using namespace mozilla::layout;
|
||||
@ -48,6 +50,17 @@ nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// FIXME: This BrowsingContext should be provided by our embedder!
|
||||
RefPtr<CanonicalBrowsingContext> browsingContext =
|
||||
BrowsingContext::Create(nullptr, nullptr, EmptyString(),
|
||||
BrowsingContext::Type::Content)
|
||||
.downcast<CanonicalBrowsingContext>();
|
||||
|
||||
// Ensure that our content process is subscribed to our newly created
|
||||
// BrowsingContextGroup.
|
||||
browsingContext->Group()->EnsureSubscribed(constructorSender);
|
||||
browsingContext->SetOwnerProcessId(constructorSender->ChildID());
|
||||
|
||||
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
||||
TabId tabId(nsContentUtils::GenerateTabId());
|
||||
cpm->RegisterRemoteFrame(tabId, ContentParentId(0), TabId(0),
|
||||
@ -56,13 +69,14 @@ nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL,
|
||||
|
||||
// Construct the TabParent object for our subframe.
|
||||
uint32_t chromeFlags = 0;
|
||||
RefPtr<TabParent> tabParent(
|
||||
new TabParent(constructorSender, tabId, tabContext, chromeFlags, this));
|
||||
RefPtr<TabParent> tabParent(new TabParent(constructorSender, tabId,
|
||||
tabContext, browsingContext,
|
||||
chromeFlags, this));
|
||||
|
||||
PBrowserParent* browser = constructorSender->SendPBrowserConstructor(
|
||||
// DeallocPBrowserParent() releases this ref.
|
||||
tabParent.forget().take(), tabId, TabId(0), tabContext.AsIPCTabContext(),
|
||||
chromeFlags, constructorSender->ChildID(),
|
||||
chromeFlags, constructorSender->ChildID(), browsingContext,
|
||||
constructorSender->IsForBrowser());
|
||||
if (NS_WARN_IF(!browser)) {
|
||||
MOZ_ASSERT(false, "Browser Constructor Failed");
|
||||
|
@ -912,9 +912,15 @@ nsresult ContentChild::ProvideWindowCommon(
|
||||
tabGroup = new TabGroup();
|
||||
}
|
||||
|
||||
RefPtr<BrowsingContext> openerBC =
|
||||
aParent ? nsPIDOMWindowOuter::From(aParent)->GetBrowsingContext()
|
||||
: nullptr;
|
||||
RefPtr<BrowsingContext> browsingContext = BrowsingContext::Create(
|
||||
nullptr, openerBC, aName, BrowsingContext::Type::Content);
|
||||
|
||||
TabContext newTabContext = aTabOpener ? *aTabOpener : TabContext();
|
||||
RefPtr<TabChild> newChild =
|
||||
new TabChild(this, tabId, tabGroup, newTabContext, aChromeFlags);
|
||||
RefPtr<TabChild> newChild = new TabChild(this, tabId, tabGroup, newTabContext,
|
||||
browsingContext, aChromeFlags);
|
||||
|
||||
if (aTabOpener) {
|
||||
MOZ_ASSERT(ipcContext->type() == IPCTabContext::TPopupIPCTabContext);
|
||||
@ -928,7 +934,7 @@ nsresult ContentChild::ProvideWindowCommon(
|
||||
Unused << SendPBrowserConstructor(
|
||||
// We release this ref in DeallocPBrowserChild
|
||||
RefPtr<TabChild>(newChild).forget().take(), tabId, TabId(0), *ipcContext,
|
||||
aChromeFlags, GetID(), IsForBrowser());
|
||||
aChromeFlags, GetID(), browsingContext, IsForBrowser());
|
||||
|
||||
// Now that |newChild| has had its IPC link established, call |Init| to set it
|
||||
// up.
|
||||
@ -1697,12 +1703,11 @@ bool ContentChild::DeallocPJavaScriptChild(PJavaScriptChild* aChild) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PBrowserChild* ContentChild::AllocPBrowserChild(const TabId& aTabId,
|
||||
const TabId& aSameTabGroupAs,
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForBrowser) {
|
||||
PBrowserChild* ContentChild::AllocPBrowserChild(
|
||||
const TabId& aTabId, const TabId& aSameTabGroupAs,
|
||||
const IPCTabContext& aContext, const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID, BrowsingContext* aBrowsingContext,
|
||||
const bool& aIsForBrowser) {
|
||||
// We'll happily accept any kind of IPCTabContext here; we don't need to
|
||||
// check that it's of a certain type for security purposes, because we
|
||||
// believe whatever the parent process tells us.
|
||||
@ -1716,9 +1721,9 @@ PBrowserChild* ContentChild::AllocPBrowserChild(const TabId& aTabId,
|
||||
MOZ_CRASH("Invalid TabContext received from the parent process.");
|
||||
}
|
||||
|
||||
RefPtr<TabChild> child =
|
||||
TabChild::Create(static_cast<ContentChild*>(this), aTabId,
|
||||
aSameTabGroupAs, tc.GetTabContext(), aChromeFlags);
|
||||
RefPtr<TabChild> child = TabChild::Create(
|
||||
static_cast<ContentChild*>(this), aTabId, aSameTabGroupAs,
|
||||
tc.GetTabContext(), aBrowsingContext, aChromeFlags);
|
||||
|
||||
// The ref here is released in DeallocPBrowserChild.
|
||||
return child.forget().take();
|
||||
@ -1727,20 +1732,22 @@ PBrowserChild* ContentChild::AllocPBrowserChild(const TabId& aTabId,
|
||||
bool ContentChild::SendPBrowserConstructor(
|
||||
PBrowserChild* aActor, const TabId& aTabId, const TabId& aSameTabGroupAs,
|
||||
const IPCTabContext& aContext, const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID, const bool& aIsForBrowser) {
|
||||
const ContentParentId& aCpID, BrowsingContext* aBrowsingContext,
|
||||
const bool& aIsForBrowser) {
|
||||
if (IsShuttingDown()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return PContentChild::SendPBrowserConstructor(aActor, aTabId, aSameTabGroupAs,
|
||||
aContext, aChromeFlags, aCpID,
|
||||
aIsForBrowser);
|
||||
aBrowsingContext, aIsForBrowser);
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvPBrowserConstructor(
|
||||
PBrowserChild* aActor, const TabId& aTabId, const TabId& aSameTabGroupAs,
|
||||
const IPCTabContext& aContext, const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID, const bool& aIsForBrowser) {
|
||||
const ContentParentId& aCpID, BrowsingContext* aBrowsingContext,
|
||||
const bool& aIsForBrowser) {
|
||||
MOZ_ASSERT(!IsShuttingDown());
|
||||
|
||||
static bool hasRunOnce = false;
|
||||
|
@ -198,6 +198,7 @@ class ContentChild final : public PContentChild,
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
BrowsingContext* aBrowsingContext,
|
||||
const bool& aIsForBrowser);
|
||||
|
||||
bool DeallocPBrowserChild(PBrowserChild*);
|
||||
@ -515,12 +516,14 @@ class ContentChild final : public PContentChild,
|
||||
const IPCTabContext& context,
|
||||
const uint32_t& chromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
BrowsingContext* aBrowsingContext,
|
||||
const bool& aIsForBrowser);
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvPBrowserConstructor(
|
||||
PBrowserChild* aCctor, const TabId& aTabId, const TabId& aSameTabGroupAs,
|
||||
const IPCTabContext& aContext, const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID, const bool& aIsForBrowser) override;
|
||||
const ContentParentId& aCpID, BrowsingContext* aBrowsingContext,
|
||||
const bool& aIsForBrowser) override;
|
||||
|
||||
FORWARD_SHMEM_ALLOCATOR_TO(PContentChild)
|
||||
|
||||
|
@ -1142,6 +1142,18 @@ TabParent* ContentParent::CreateBrowser(const TabContext& aContext,
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: This BrowsingContext should be provided by the nsFrameLoader.
|
||||
// (bug 1523636)
|
||||
RefPtr<CanonicalBrowsingContext> browsingContext =
|
||||
BrowsingContext::Create(nullptr, nullptr, EmptyString(),
|
||||
BrowsingContext::Type::Content)
|
||||
.downcast<CanonicalBrowsingContext>();
|
||||
|
||||
// Ensure that our content process is subscribed to our newly created
|
||||
// BrowsingContextGroup.
|
||||
browsingContext->Group()->EnsureSubscribed(constructorSender);
|
||||
|
||||
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
||||
cpm->RegisterRemoteFrame(tabId, ContentParentId(0), openerTabId,
|
||||
aContext.AsIPCTabContext(),
|
||||
@ -1172,15 +1184,17 @@ TabParent* ContentParent::CreateBrowser(const TabContext& aContext,
|
||||
if (tabId == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<TabParent> tp(
|
||||
new TabParent(constructorSender, tabId, aContext, chromeFlags));
|
||||
RefPtr<TabParent> tp = new TabParent(constructorSender, tabId, aContext,
|
||||
browsingContext, chromeFlags);
|
||||
|
||||
browsingContext->SetOwnerProcessId(constructorSender->ChildID());
|
||||
|
||||
PBrowserParent* browser = constructorSender->SendPBrowserConstructor(
|
||||
// DeallocPBrowserParent() releases this ref.
|
||||
tp.forget().take(), tabId,
|
||||
aSameTabGroupAs ? aSameTabGroupAs->GetTabId() : TabId(0),
|
||||
aContext.AsIPCTabContext(), chromeFlags, constructorSender->ChildID(),
|
||||
constructorSender->IsForBrowser());
|
||||
browsingContext, constructorSender->IsForBrowser());
|
||||
|
||||
if (remoteType.EqualsLiteral(LARGE_ALLOCATION_REMOTE_TYPE)) {
|
||||
// Tell the TabChild object that it was created due to a Large-Allocation
|
||||
@ -3223,7 +3237,8 @@ bool ContentParent::CanOpenBrowser(const IPCTabContext& aContext) {
|
||||
PBrowserParent* ContentParent::AllocPBrowserParent(
|
||||
const TabId& aTabId, const TabId& aSameTabGroupAs,
|
||||
const IPCTabContext& aContext, const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpId, const bool& aIsForBrowser) {
|
||||
const ContentParentId& aCpId, BrowsingContext* aBrowsingContext,
|
||||
const bool& aIsForBrowser) {
|
||||
MOZ_ASSERT(!aSameTabGroupAs);
|
||||
|
||||
Unused << aCpId;
|
||||
@ -3281,10 +3296,17 @@ PBrowserParent* ContentParent::AllocPBrowserParent(
|
||||
// window is remote.
|
||||
chromeFlags |= nsIWebBrowserChrome::CHROME_REMOTE_WINDOW;
|
||||
|
||||
CanonicalBrowsingContext* browsingContext =
|
||||
CanonicalBrowsingContext::Cast(aBrowsingContext);
|
||||
if (NS_WARN_IF(!browsingContext->IsOwnedByProcess(ChildID()))) {
|
||||
MOZ_ASSERT(false, "BrowsingContext not owned by the correct process!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MaybeInvalidTabContext tc(aContext);
|
||||
MOZ_ASSERT(tc.IsValid());
|
||||
TabParent* parent = new TabParent(static_cast<ContentParent*>(this), aTabId,
|
||||
tc.GetTabContext(), chromeFlags);
|
||||
TabParent* parent = new TabParent(this, aTabId, tc.GetTabContext(),
|
||||
browsingContext, chromeFlags);
|
||||
|
||||
// We release this ref in DeallocPBrowserParent()
|
||||
NS_ADDREF(parent);
|
||||
@ -3300,7 +3322,8 @@ bool ContentParent::DeallocPBrowserParent(PBrowserParent* frame) {
|
||||
mozilla::ipc::IPCResult ContentParent::RecvPBrowserConstructor(
|
||||
PBrowserParent* actor, const TabId& tabId, const TabId& sameTabGroupAs,
|
||||
const IPCTabContext& context, const uint32_t& chromeFlags,
|
||||
const ContentParentId& cpId, const bool& isForBrowser) {
|
||||
const ContentParentId& cpId, BrowsingContext* aBrowsingContext,
|
||||
const bool& isForBrowser) {
|
||||
TabParent* parent = TabParent::GetFrom(actor);
|
||||
// When enabling input event prioritization, input events may preempt other
|
||||
// normal priority IPC messages. To prevent the input events preempt
|
||||
|
@ -822,6 +822,7 @@ class ContentParent final : public PContentParent,
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpId,
|
||||
BrowsingContext* aBrowsingContext,
|
||||
const bool& aIsForBrowser);
|
||||
|
||||
bool DeallocPBrowserParent(PBrowserParent* frame);
|
||||
@ -829,7 +830,8 @@ class ContentParent final : public PContentParent,
|
||||
virtual mozilla::ipc::IPCResult RecvPBrowserConstructor(
|
||||
PBrowserParent* actor, const TabId& tabId, const TabId& sameTabGroupAs,
|
||||
const IPCTabContext& context, const uint32_t& chromeFlags,
|
||||
const ContentParentId& cpId, const bool& isForBrowser) override;
|
||||
const ContentParentId& cpId, BrowsingContext* aBrowsingContext,
|
||||
const bool& isForBrowser) override;
|
||||
|
||||
PIPCBlobInputStreamParent* AllocPIPCBlobInputStreamParent(
|
||||
const nsID& aID, const uint64_t& aSize);
|
||||
|
@ -620,8 +620,6 @@ parent:
|
||||
sync SetPrefersReducedMotionOverrideForTest(bool aValue);
|
||||
sync ResetPrefersReducedMotionOverrideForTest();
|
||||
|
||||
async RootBrowsingContext(BrowsingContext aContext);
|
||||
|
||||
child:
|
||||
/**
|
||||
* Notify the remote browser that it has been Show()n on this
|
||||
|
@ -389,7 +389,8 @@ both:
|
||||
// Keep the last 3 attributes in sync with GetProcessAttributes!
|
||||
async PBrowser(TabId tabId, TabId sameTabGroupAs,
|
||||
IPCTabContext context, uint32_t chromeFlags,
|
||||
ContentParentId cpId, bool isForBrowser);
|
||||
ContentParentId cpId, BrowsingContext browsingContext,
|
||||
bool isForBrowser);
|
||||
|
||||
async PFileDescriptorSet(FileDescriptor fd);
|
||||
|
||||
|
@ -354,20 +354,22 @@ already_AddRefed<TabChild> TabChild::Create(ContentChild* aManager,
|
||||
const TabId& aTabId,
|
||||
const TabId& aSameTabGroupAs,
|
||||
const TabContext& aContext,
|
||||
BrowsingContext* aBrowsingContext,
|
||||
uint32_t aChromeFlags) {
|
||||
RefPtr<TabChild> groupChild = FindTabChild(aSameTabGroupAs);
|
||||
dom::TabGroup* group = groupChild ? groupChild->TabGroup() : nullptr;
|
||||
RefPtr<TabChild> iframe =
|
||||
new TabChild(aManager, aTabId, group, aContext, aChromeFlags);
|
||||
RefPtr<TabChild> iframe = new TabChild(aManager, aTabId, group, aContext,
|
||||
aBrowsingContext, aChromeFlags);
|
||||
return iframe.forget();
|
||||
}
|
||||
|
||||
TabChild::TabChild(ContentChild* aManager, const TabId& aTabId,
|
||||
dom::TabGroup* aTabGroup, const TabContext& aContext,
|
||||
uint32_t aChromeFlags)
|
||||
BrowsingContext* aBrowsingContext, uint32_t aChromeFlags)
|
||||
: TabContext(aContext),
|
||||
mTabGroup(aTabGroup),
|
||||
mManager(aManager),
|
||||
mBrowsingContext(aBrowsingContext),
|
||||
mChromeFlags(aChromeFlags),
|
||||
mMaxTouchPoints(0),
|
||||
mLayersId{0},
|
||||
@ -521,9 +523,8 @@ nsresult TabChild::Init(mozIDOMWindowProxy* aParent) {
|
||||
nullptr // HandleWidgetEvent
|
||||
);
|
||||
|
||||
mWebBrowser =
|
||||
nsWebBrowser::Create(this, mPuppetWidget, OriginAttributesRef(), aParent,
|
||||
nsIDocShellTreeItem::typeContentWrapper);
|
||||
mWebBrowser = nsWebBrowser::Create(this, mPuppetWidget, OriginAttributesRef(),
|
||||
mBrowsingContext);
|
||||
nsIWebBrowser* webBrowser = mWebBrowser;
|
||||
|
||||
mWebNav = do_QueryInterface(webBrowser);
|
||||
@ -553,11 +554,6 @@ nsresult TabChild::Init(mozIDOMWindowProxy* aParent) {
|
||||
loadContext->SetRemoteTabs(mChromeFlags &
|
||||
nsIWebBrowserChrome::CHROME_REMOTE_WINDOW);
|
||||
|
||||
// Send our browsing context to the parent process.
|
||||
RefPtr<BrowsingContext> browsingContext =
|
||||
nsDocShell::Cast(docShell)->GetBrowsingContext();
|
||||
SendRootBrowsingContext(browsingContext);
|
||||
|
||||
// Few lines before, baseWindow->Create() will end up creating a new
|
||||
// window root in nsGlobalWindow::SetDocShell.
|
||||
// Then this chrome event handler, will be inherited to inner windows.
|
||||
|
@ -232,7 +232,8 @@ class TabChild final : public TabChildBase,
|
||||
* Create a new TabChild object.
|
||||
*/
|
||||
TabChild(ContentChild* aManager, const TabId& aTabId, TabGroup* aTabGroup,
|
||||
const TabContext& aContext, uint32_t aChromeFlags);
|
||||
const TabContext& aContext, BrowsingContext* aBrowsingContext,
|
||||
uint32_t aChromeFlags);
|
||||
|
||||
nsresult Init(mozIDOMWindowProxy* aParent);
|
||||
|
||||
@ -241,6 +242,7 @@ class TabChild final : public TabChildBase,
|
||||
const TabId& aTabId,
|
||||
const TabId& aSameTabGroupAs,
|
||||
const TabContext& aContext,
|
||||
BrowsingContext* aBrowsingContext,
|
||||
uint32_t aChromeFlags);
|
||||
|
||||
// Let managees query if it is safe to send messages.
|
||||
@ -805,6 +807,7 @@ class TabChild final : public TabChildBase,
|
||||
RefPtr<PuppetWidget> mPuppetWidget;
|
||||
nsCOMPtr<nsIURI> mLastURI;
|
||||
RefPtr<ContentChild> mManager;
|
||||
RefPtr<BrowsingContext> mBrowsingContext;
|
||||
uint32_t mChromeFlags;
|
||||
uint32_t mMaxTouchPoints;
|
||||
layers::LayersId mLayersId;
|
||||
|
@ -149,7 +149,7 @@ NS_IMPL_ISUPPORTS(TabParent, nsITabParent, nsIAuthPromptProvider,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
TabParent::TabParent(ContentParent* aManager, const TabId& aTabId,
|
||||
const TabContext& aContext, uint32_t aChromeFlags,
|
||||
const TabContext& aContext, CanonicalBrowsingContext* aBrowsingContext, uint32_t aChromeFlags,
|
||||
BrowserBridgeParent* aBrowserBridgeParent)
|
||||
: TabContext(aContext),
|
||||
mFrameElement(nullptr),
|
||||
@ -168,6 +168,7 @@ TabParent::TabParent(ContentParent* aManager, const TabId& aTabId,
|
||||
mIsDestroyed(false),
|
||||
mChromeFlags(aChromeFlags),
|
||||
mDragValid(false),
|
||||
mBrowsingContext(aBrowsingContext),
|
||||
mBrowserBridgeParent(aBrowserBridgeParent),
|
||||
mTabId(aTabId),
|
||||
mCreatingWindow(false),
|
||||
@ -3507,14 +3508,6 @@ mozilla::ipc::IPCResult TabParent::RecvGetSystemFont(nsCString* aFontName) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult TabParent::RecvRootBrowsingContext(
|
||||
BrowsingContext* aBrowsingContext) {
|
||||
MOZ_ASSERT(!mBrowsingContext, "May only set browsing context once!");
|
||||
mBrowsingContext = CanonicalBrowsingContext::Cast(aBrowsingContext);
|
||||
MOZ_ASSERT(mBrowsingContext, "Invalid ID!");
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FakeChannel::OnAuthAvailable(nsISupports* aContext,
|
||||
nsIAuthInformation* aAuthInfo) {
|
||||
|
@ -103,7 +103,8 @@ class TabParent final : public PBrowserParent,
|
||||
NS_DECL_NSIDOMEVENTLISTENER
|
||||
|
||||
TabParent(ContentParent* aManager, const TabId& aTabId,
|
||||
const TabContext& aContext, uint32_t aChromeFlags,
|
||||
const TabContext& aContext,
|
||||
CanonicalBrowsingContext* aBrowsingContext, uint32_t aChromeFlags,
|
||||
BrowserBridgeParent* aBrowserBridgeParent = nullptr);
|
||||
|
||||
Element* GetOwnerElement() const { return mFrameElement; }
|
||||
@ -630,8 +631,6 @@ class TabParent final : public PBrowserParent,
|
||||
mozilla::ipc::IPCResult RecvShowCanvasPermissionPrompt(
|
||||
const nsCString& aFirstPartyURI, const bool& aHideDoorHanger);
|
||||
|
||||
mozilla::ipc::IPCResult RecvRootBrowsingContext(BrowsingContext* aContext);
|
||||
|
||||
mozilla::ipc::IPCResult RecvSetSystemFont(const nsCString& aFontName);
|
||||
mozilla::ipc::IPCResult RecvGetSystemFont(nsCString* aFontName);
|
||||
|
||||
|
@ -102,9 +102,10 @@ nsIWidget* nsWebBrowser::EnsureWidget() {
|
||||
/* static */
|
||||
already_AddRefed<nsWebBrowser> nsWebBrowser::Create(
|
||||
nsIWebBrowserChrome* aContainerWindow, nsIWidget* aParentWidget,
|
||||
const OriginAttributes& aOriginAttributes, mozIDOMWindowProxy* aOpener,
|
||||
int aItemType) {
|
||||
RefPtr<nsWebBrowser> browser = new nsWebBrowser(aItemType);
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
dom::BrowsingContext* aBrowsingContext) {
|
||||
RefPtr<nsWebBrowser> browser = new nsWebBrowser(
|
||||
aBrowsingContext->IsContent() ? typeContentWrapper : typeChromeWrapper);
|
||||
|
||||
// nsWebBrowser::SetContainer also calls nsWebBrowser::EnsureDocShellTreeOwner
|
||||
NS_ENSURE_SUCCESS(browser->SetContainerWindow(aContainerWindow), nullptr);
|
||||
@ -115,19 +116,7 @@ already_AddRefed<nsWebBrowser> nsWebBrowser::Create(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// XXX(nika): Consider supporting creating nsWebBrowser for an existing
|
||||
// BrowsingContext (e.g. during a X-process load).
|
||||
using BrowsingContext = mozilla::dom::BrowsingContext;
|
||||
RefPtr<BrowsingContext> openerContext =
|
||||
aOpener ? nsPIDOMWindowOuter::From(aOpener)->GetBrowsingContext()
|
||||
: nullptr;
|
||||
|
||||
RefPtr<BrowsingContext> browsingContext = BrowsingContext::Create(
|
||||
/* aParent */ nullptr, openerContext, EmptyString(),
|
||||
aItemType != typeChromeWrapper ? BrowsingContext::Type::Content
|
||||
: BrowsingContext::Type::Chrome);
|
||||
|
||||
RefPtr<nsDocShell> docShell = nsDocShell::Create(browsingContext);
|
||||
RefPtr<nsDocShell> docShell = nsDocShell::Create(aBrowsingContext);
|
||||
if (NS_WARN_IF(!docShell)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class nsWebBrowser final : public nsIWebBrowser,
|
||||
static already_AddRefed<nsWebBrowser> Create(
|
||||
nsIWebBrowserChrome* aContainerWindow, nsIWidget* aParentWidget,
|
||||
const mozilla::OriginAttributes& aOriginAttributes,
|
||||
mozIDOMWindowProxy* aOpener, int aItemType);
|
||||
mozilla::dom::BrowsingContext* aBrowsingContext);
|
||||
|
||||
protected:
|
||||
virtual ~nsWebBrowser();
|
||||
|
@ -52,6 +52,7 @@
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using mozilla::dom::BrowsingContext;
|
||||
using mozilla::intl::LocaleService;
|
||||
|
||||
// Default URL for the hidden window, can be overridden by a pref on Mac
|
||||
@ -470,13 +471,17 @@ nsAppShellService::CreateWindowlessBrowser(bool aIsChrome,
|
||||
widget->Create(nullptr, 0, LayoutDeviceIntRect(0, 0, 0, 0), nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Create a BrowsingContext for our windowless browser.
|
||||
RefPtr<BrowsingContext> browsingContext =
|
||||
BrowsingContext::Create(nullptr, nullptr, EmptyString(),
|
||||
aIsChrome ? BrowsingContext::Type::Chrome
|
||||
: BrowsingContext::Type::Content);
|
||||
|
||||
/* Next, we create an instance of nsWebBrowser. Instances of this class have
|
||||
* an associated doc shell, which is what we're interested in.
|
||||
*/
|
||||
nsCOMPtr<nsIWebBrowser> browser =
|
||||
nsWebBrowser::Create(stub, widget, OriginAttributes(), nullptr,
|
||||
aIsChrome ? nsIDocShellTreeItem::typeChromeWrapper
|
||||
: nsIDocShellTreeItem::typeContentWrapper);
|
||||
nsWebBrowser::Create(stub, widget, OriginAttributes(), browsingContext);
|
||||
|
||||
if (NS_WARN_IF(!browser)) {
|
||||
NS_ERROR("Couldn't create instance of nsWebBrowser!");
|
||||
|
Loading…
Reference in New Issue
Block a user