Bug 1616353 - Part 7.2: Create and use nsOpenWindowInfo types in nsWindowWatcher logic, r=kmag

This patch builds on top of part 7.1 by creating this object within
nsWindowWatcher and ContentParent to carry the relevant information through
provider interfaces when creating new content windows. The nsOpenWindowInfo
object is not created for new chrome windows.

This patch does not propagate these flags all of the way through to the
nsFrameLoader. That change is performed in later parts to keep each part
smaller.

Differential Revision: https://phabricator.services.mozilla.com/D67051

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2020-04-06 14:30:02 +00:00
parent e34d793539
commit 0d1eecbd25
22 changed files with 354 additions and 333 deletions

View File

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsOpenURIInFrameParams.h"
#include "nsIOpenWindowInfo.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ToJSValue.h"
@ -20,12 +21,17 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsOpenURIInFrameParams)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsOpenURIInFrameParams)
nsOpenURIInFrameParams::nsOpenURIInFrameParams(
const mozilla::OriginAttributes& aOriginAttributes,
mozilla::dom::Element* aOpener)
: mOpenerOriginAttributes(aOriginAttributes), mOpenerBrowser(aOpener) {}
nsIOpenWindowInfo* aOpenWindowInfo, mozilla::dom::Element* aOpener)
: mOpenWindowInfo(aOpenWindowInfo), mOpenerBrowser(aOpener) {}
nsOpenURIInFrameParams::~nsOpenURIInFrameParams() = default;
NS_IMETHODIMP
nsOpenURIInFrameParams::GetOpenWindowInfo(nsIOpenWindowInfo** aOpenWindowInfo) {
NS_IF_ADDREF(*aOpenWindowInfo = mOpenWindowInfo);
return NS_OK;
}
NS_IMETHODIMP
nsOpenURIInFrameParams::GetReferrerInfo(nsIReferrerInfo** aReferrerInfo) {
NS_IF_ADDREF(*aReferrerInfo = mReferrerInfo);
@ -41,7 +47,7 @@ nsOpenURIInFrameParams::SetReferrerInfo(nsIReferrerInfo* aReferrerInfo) {
NS_IMETHODIMP
nsOpenURIInFrameParams::GetIsPrivate(bool* aIsPrivate) {
NS_ENSURE_ARG_POINTER(aIsPrivate);
*aIsPrivate = mOpenerOriginAttributes.mPrivateBrowsingId > 0;
*aIsPrivate = mOpenWindowInfo->GetOriginAttributes().mPrivateBrowsingId > 0;
return NS_OK;
}
@ -83,7 +89,5 @@ nsresult nsOpenURIInFrameParams::GetOpenerBrowser(
NS_IMETHODIMP
nsOpenURIInFrameParams::GetOpenerOriginAttributes(
JSContext* aCx, JS::MutableHandle<JS::Value> aValue) {
bool ok = ToJSValue(aCx, mOpenerOriginAttributes, aValue);
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
return NS_OK;
return mOpenWindowInfo->GetScriptableOriginAttributes(aCx, aValue);
}

View File

@ -26,14 +26,13 @@ class nsOpenURIInFrameParams final : public nsIOpenURIInFrameParams {
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIOPENURIINFRAMEPARAMS
explicit nsOpenURIInFrameParams(
const mozilla::OriginAttributes& aOriginAttributes,
mozilla::dom::Element* aOpener);
explicit nsOpenURIInFrameParams(nsIOpenWindowInfo* aOpenWindowInfo,
mozilla::dom::Element* aOpener);
private:
~nsOpenURIInFrameParams();
mozilla::OriginAttributes mOpenerOriginAttributes;
nsCOMPtr<nsIOpenWindowInfo> mOpenWindowInfo;
RefPtr<mozilla::dom::Element> mOpenerBrowser;
nsCOMPtr<nsIReferrerInfo> mReferrerInfo;
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;

View File

@ -11,12 +11,15 @@ interface nsIURI;
interface nsIPrincipal;
interface nsIContentSecurityPolicy;
interface nsIReferrerInfo;
interface nsIOpenWindowInfo;
webidl BrowsingContext;
webidl Element;
[scriptable, uuid(e774db14-79ac-4156-a7a3-aa3fd0a22c10)]
interface nsIOpenURIInFrameParams : nsISupports
{
readonly attribute nsIOpenWindowInfo openWindowInfo;
attribute nsIReferrerInfo referrerInfo;
readonly attribute boolean isPrivate;
attribute nsIPrincipal triggeringPrincipal;
@ -107,7 +110,7 @@ interface nsIBrowserDOMWindow : nsISupports
* @param aURI the URI to be opened in the window (can be null).
* @param aWhere see possible values described above.
* @param aOpener window requesting the creation (can be null).
* @param aOpenWindowInfo info about the creation (can be null).
* @param aFlags flags which control the behavior of the load. The
* OPEN_EXTERNAL/OPEN_NEW flag is only used when
* aWhere == OPEN_DEFAULTWINDOW.
@ -117,7 +120,7 @@ interface nsIBrowserDOMWindow : nsISupports
* @return the window into which the URI would have been opened.
*/
BrowsingContext
createContentWindow(in nsIURI aURI, in mozIDOMWindowProxy aOpener,
createContentWindow(in nsIURI aURI, in nsIOpenWindowInfo aOpenWindowInfo,
in short aWhere, in long aFlags,
in nsIPrincipal aTriggeringPrincipal,
[optional] in nsIContentSecurityPolicy aCsp);
@ -127,14 +130,12 @@ interface nsIBrowserDOMWindow : nsISupports
* returned as Element, QI'd back to nsFrameLoaderOwner as needed.
*
* Additional Parameters:
* @param aNextRemoteTabId The RemoteTab to associate the window with.
* @param aName The name to give the window opened in the new tab.
* @return The frame element for the newly opened window.
*/
Element
createContentWindowInFrame(in nsIURI aURI, in nsIOpenURIInFrameParams params,
in short aWhere, in long aFlags,
in unsigned long long aNextRemoteTabId,
in AString aName);
/**
@ -143,7 +144,7 @@ interface nsIBrowserDOMWindow : nsISupports
* @param aURI the URI to open. null is not allowed. To create the window
* without loading the URI, use createContentWindow instead.
* @param aWhere see possible values described above.
* @param aOpener window requesting the open (can be null).
* @param aOpenWindowInfo info about the open (can be null).
* @param aFlags flags which control the behavior of the load. The
* OPEN_EXTERNAL/OPEN_NEW flag is only used when
* aWhere == OPEN_DEFAULTWINDOW.
@ -152,7 +153,7 @@ interface nsIBrowserDOMWindow : nsISupports
* @return the window into which the URI was opened.
*/
BrowsingContext
openURI(in nsIURI aURI, in mozIDOMWindowProxy aOpener,
openURI(in nsIURI aURI, in nsIOpenWindowInfo aOpenWindowInfo,
in short aWhere, in long aFlags, in nsIPrincipal aTriggeringPrincipal,
[optional] in nsIContentSecurityPolicy aCsp);
@ -161,7 +162,6 @@ interface nsIBrowserDOMWindow : nsISupports
* returned as Element, QI'd back to nsFrameLoaderOwner as needed.
*
* Additional Parameters:
* @param aNextRemoteTabId The RemoteTab to associate the window with.
* @param aName The name to give the window opened in the new tab.
* @return The frame element for the newly opened window.
// XXXbz is this the right API?
@ -170,7 +170,6 @@ interface nsIBrowserDOMWindow : nsISupports
Element
openURIInFrame(in nsIURI aURI, in nsIOpenURIInFrameParams params,
in short aWhere, in long aFlags,
in unsigned long long aNextRemoteTabId,
in AString aName);
/**

View File

@ -116,6 +116,7 @@
#include "nsIWebProgress.h"
#include "nsLayoutUtils.h"
#include "nsNetUtil.h"
#include "nsIOpenWindowInfo.h"
#include "nsPIDOMWindow.h"
#include "nsPIWindowRoot.h"
#include "nsPointerHashKeys.h"
@ -877,19 +878,21 @@ BrowserChild::GetInterface(const nsIID& aIID, void** aSink) {
}
NS_IMETHODIMP
BrowserChild::ProvideWindow(mozIDOMWindowProxy* aParent, uint32_t aChromeFlags,
bool aCalledFromJS, bool aWidthSpecified,
nsIURI* aURI, const nsAString& aName,
const nsACString& aFeatures, bool aForceNoOpener,
bool aForceNoReferrer,
BrowserChild::ProvideWindow(nsIOpenWindowInfo* aOpenWindowInfo,
uint32_t aChromeFlags, bool aCalledFromJS,
bool aWidthSpecified, nsIURI* aURI,
const nsAString& aName, const nsACString& aFeatures,
bool aForceNoOpener, bool aForceNoReferrer,
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
BrowsingContext** aReturn) {
*aReturn = nullptr;
// If aParent is inside an <iframe mozbrowser> and this isn't a request to
RefPtr<BrowsingContext> parent = aOpenWindowInfo->GetParent();
// If parent is inside an <iframe mozbrowser> and this isn't a request to
// open a modal-type window, we're going to create a new <iframe mozbrowser>
// and return its window here.
nsCOMPtr<nsIDocShell> docshell = do_GetInterface(aParent);
nsCOMPtr<nsIDocShell> docshell = parent->GetDocShell();
bool iframeMoz =
(docshell && docshell->GetIsInMozBrowser() &&
!(aChromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
@ -898,8 +901,7 @@ BrowserChild::ProvideWindow(mozIDOMWindowProxy* aParent, uint32_t aChromeFlags,
if (!iframeMoz) {
int32_t openLocation = nsWindowWatcher::GetWindowOpenLocation(
nsPIDOMWindowOuter::From(aParent), aChromeFlags, aCalledFromJS,
aWidthSpecified);
parent->GetDOMWindow(), aChromeFlags, aCalledFromJS, aWidthSpecified);
// If it turns out we're opening in the current browser, just hand over the
// current browser's docshell.
@ -921,7 +923,7 @@ BrowserChild::ProvideWindow(mozIDOMWindowProxy* aParent, uint32_t aChromeFlags,
// open window call was canceled. It's important that we pass this error
// code back to our caller.
ContentChild* cc = ContentChild::GetSingleton();
return cc->ProvideWindowCommon(this, aParent, iframeMoz, aChromeFlags,
return cc->ProvideWindowCommon(this, aOpenWindowInfo, iframeMoz, aChromeFlags,
aCalledFromJS, aWidthSpecified, aURI, aName,
aFeatures, aForceNoOpener, aForceNoReferrer,
aLoadState, aWindowIsNew, aReturn);

View File

@ -115,6 +115,7 @@
#include "nsIURIMutator.h"
#include "nsIInputStreamChannel.h"
#include "nsFocusManager.h"
#include "nsIOpenWindowInfo.h"
#if !defined(XP_WIN)
# include "mozilla/Omnijar.h"
@ -775,20 +776,20 @@ void ContentChild::SetProcessName(const nsAString& aName) {
}
NS_IMETHODIMP
ContentChild::ProvideWindow(mozIDOMWindowProxy* aParent, uint32_t aChromeFlags,
bool aCalledFromJS, bool aWidthSpecified,
nsIURI* aURI, const nsAString& aName,
const nsACString& aFeatures, bool aForceNoOpener,
bool aForceNoReferrer,
ContentChild::ProvideWindow(nsIOpenWindowInfo* aOpenWindowInfo,
uint32_t aChromeFlags, bool aCalledFromJS,
bool aWidthSpecified, nsIURI* aURI,
const nsAString& aName, const nsACString& aFeatures,
bool aForceNoOpener, bool aForceNoReferrer,
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
BrowsingContext** aReturn) {
return ProvideWindowCommon(nullptr, aParent, false, aChromeFlags,
return ProvideWindowCommon(nullptr, aOpenWindowInfo, false, aChromeFlags,
aCalledFromJS, aWidthSpecified, aURI, aName,
aFeatures, aForceNoOpener, aForceNoReferrer,
aLoadState, aWindowIsNew, aReturn);
}
static nsresult GetCreateWindowParams(mozIDOMWindowProxy* aParent,
static nsresult GetCreateWindowParams(nsIOpenWindowInfo* aOpenWindowInfo,
nsDocShellLoadState* aLoadState,
bool aForceNoReferrer, float* aFullZoom,
nsIReferrerInfo** aReferrerInfo,
@ -813,10 +814,12 @@ static nsresult GetCreateWindowParams(mozIDOMWindowProxy* aParent,
referrerInfo = aLoadState->GetReferrerInfo();
}
auto* opener = nsPIDOMWindowOuter::From(aParent);
RefPtr<BrowsingContext> parent = aOpenWindowInfo->GetParent();
nsCOMPtr<nsPIDOMWindowOuter> opener =
parent ? parent->GetDOMWindow() : nullptr;
if (!opener) {
nsCOMPtr<nsIPrincipal> nullPrincipal =
NullPrincipal::CreateWithoutOriginAttributes();
NullPrincipal::Create(aOpenWindowInfo->GetOriginAttributes());
if (!referrerInfo) {
referrerInfo = new ReferrerInfo(nullptr, ReferrerPolicy::_empty);
}
@ -863,11 +866,12 @@ static nsresult GetCreateWindowParams(mozIDOMWindowProxy* aParent,
}
nsresult ContentChild::ProvideWindowCommon(
BrowserChild* aTabOpener, mozIDOMWindowProxy* aParent, bool aIframeMoz,
uint32_t aChromeFlags, bool aCalledFromJS, bool aWidthSpecified,
nsIURI* aURI, const nsAString& aName, const nsACString& aFeatures,
bool aForceNoOpener, bool aForceNoReferrer, nsDocShellLoadState* aLoadState,
bool* aWindowIsNew, BrowsingContext** aReturn) {
BrowserChild* aTabOpener, nsIOpenWindowInfo* aOpenWindowInfo,
bool aIframeMoz, uint32_t aChromeFlags, bool aCalledFromJS,
bool aWidthSpecified, nsIURI* aURI, const nsAString& aName,
const nsACString& aFeatures, bool aForceNoOpener, bool aForceNoReferrer,
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
BrowsingContext** aReturn) {
*aReturn = nullptr;
UniquePtr<IPCTabContext> ipcContext;
@ -877,8 +881,9 @@ nsresult ContentChild::ProvideWindowCommon(
nsresult rv;
MOZ_ASSERT(!aParent || aTabOpener,
"If aParent is non-null, we should have an aTabOpener");
RefPtr<BrowsingContext> parent = aOpenWindowInfo->GetParent();
MOZ_ASSERT(!parent || aTabOpener,
"If parent is non-null, we should have an aTabOpener");
// Cache the boolean preference for allowing noopener windows to open in a
// separate process.
@ -901,14 +906,10 @@ nsresult ContentChild::ProvideWindowCommon(
bool loadInDifferentProcess =
aForceNoOpener && sNoopenerNewProcess && !useRemoteSubframes;
if (aTabOpener && !loadInDifferentProcess && aURI) {
nsCOMPtr<nsILoadContext> context;
if (aParent) {
context = do_GetInterface(aTabOpener->WebNavigation());
}
// Only special-case cross-process loads if Fission is disabled. With
// Fission enabled, the initial in-process load will automatically be
// retargeted to the correct process.
if (!(context && context->UseRemoteSubframes())) {
if (!(parent && parent->UseRemoteSubframes())) {
nsCOMPtr<nsIWebBrowserChrome3> browserChrome3;
rv = aTabOpener->GetWebBrowserChrome(getter_AddRefs(browserChrome3));
if (NS_SUCCEEDED(rv) && browserChrome3) {
@ -926,8 +927,8 @@ nsresult ContentChild::ProvideWindowCommon(
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
nsCOMPtr<nsIContentSecurityPolicy> csp;
nsCOMPtr<nsIReferrerInfo> referrerInfo;
rv = GetCreateWindowParams(aParent, aLoadState, aForceNoReferrer, &fullZoom,
getter_AddRefs(referrerInfo),
rv = GetCreateWindowParams(aOpenWindowInfo, aLoadState, aForceNoReferrer,
&fullZoom, getter_AddRefs(referrerInfo),
getter_AddRefs(triggeringPrincipal),
getter_AddRefs(csp));
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -941,8 +942,9 @@ nsresult ContentChild::ProvideWindowCommon(
MOZ_DIAGNOSTIC_ASSERT(!nsContentUtils::IsSpecialName(name));
Unused << SendCreateWindowInDifferentProcess(
aTabOpener, aChromeFlags, aCalledFromJS, aWidthSpecified, aURI,
features, fullZoom, name, triggeringPrincipal, csp, referrerInfo);
aTabOpener, parent, aChromeFlags, aCalledFromJS, aWidthSpecified, aURI,
features, fullZoom, name, triggeringPrincipal, csp, referrerInfo,
aOpenWindowInfo->GetOriginAttributes());
// We return NS_ERROR_ABORT, so that the caller knows that we've abandoned
// the window open as far as it is concerned.
@ -973,15 +975,18 @@ nsresult ContentChild::ProvideWindowCommon(
if (aTabOpener && !aForceNoOpener) {
// The new actor will use the same tab group as the opener.
tabGroup = aTabOpener->TabGroup();
if (aParent) {
openerBC = nsPIDOMWindowOuter::From(aParent)->GetBrowsingContext();
}
openerBC = parent;
} else {
tabGroup = new TabGroup();
}
RefPtr<BrowsingContext> browsingContext = BrowsingContext::Create(
RefPtr<BrowsingContext> browsingContext = BrowsingContext::CreateDetached(
nullptr, openerBC, aName, BrowsingContext::Type::Content);
MOZ_ALWAYS_SUCCEEDS(browsingContext->SetRemoteTabs(true));
MOZ_ALWAYS_SUCCEEDS(browsingContext->SetRemoteSubframes(useRemoteSubframes));
MOZ_ALWAYS_SUCCEEDS(browsingContext->SetOriginAttributes(
aOpenWindowInfo->GetOriginAttributes()));
browsingContext->EnsureAttached();
browsingContext->SetPendingInitialization(true);
auto unsetPending = MakeScopeExit([browsingContext]() {
@ -990,6 +995,9 @@ nsresult ContentChild::ProvideWindowCommon(
TabContext newTabContext = aTabOpener ? *aTabOpener : TabContext();
MOZ_ASSERT(newTabContext.OriginAttributesRef().EqualsIgnoringFPD(
browsingContext->OriginAttributesRef()));
// The initial about:blank document we generate within the nsDocShell will
// almost certainly be replaced at some point. Unfortunately, getting the
// principal right here causes bugs due to frame scripts not getting events
@ -999,7 +1007,7 @@ nsresult ContentChild::ProvideWindowCommon(
// that we can act the same as we did before when not predicting a result
// principal. This `PWindowGlobal` will almost immediately be destroyed.
nsCOMPtr<nsIPrincipal> initialPrincipal =
NullPrincipal::Create(newTabContext.OriginAttributesRef());
NullPrincipal::Create(browsingContext->OriginAttributesRef());
WindowGlobalInit windowInit = WindowGlobalActor::AboutBlankInitializer(
browsingContext, initialPrincipal);
@ -1046,7 +1054,8 @@ nsresult ContentChild::ProvideWindowCommon(
// Now that |newChild| has had its IPC link established, call |Init| to set it
// up.
if (NS_FAILED(newChild->Init(aParent, windowChild))) {
nsPIDOMWindowOuter* parentWindow = parent ? parent->GetDOMWindow() : nullptr;
if (NS_FAILED(newChild->Init(parentWindow, windowChild))) {
return NS_ERROR_ABORT;
}
@ -1089,9 +1098,7 @@ nsresult ContentChild::ProvideWindowCommon(
}
ParentShowInfo showInfo(EmptyString(), false, true, false, 0, 0, 0);
auto* opener = nsPIDOMWindowOuter::From(aParent);
nsIDocShell* openerShell;
if (opener && (openerShell = opener->GetDocShell())) {
if (aTabOpener) {
showInfo = ParentShowInfo(
EmptyString(), false, true, false, aTabOpener->WebWidget()->GetDPI(),
aTabOpener->WebWidget()->RoundsWidgetCoordinatesTo(),
@ -1105,10 +1112,7 @@ nsresult ContentChild::ProvideWindowCommon(
if (nsCOMPtr<nsPIDOMWindowOuter> outer =
do_GetInterface(newChild->WebNavigation())) {
BrowsingContext* bc = outer->GetBrowsingContext();
auto parentBC =
aParent
? nsPIDOMWindowOuter::From(aParent)->GetBrowsingContext()->Id()
: 0;
auto parentBC = parent ? parent->Id() : 0;
if (aForceNoOpener) {
MOZ_DIAGNOSTIC_ASSERT(!*aWindowIsNew || !bc->HadOriginalOpener());
@ -1179,18 +1183,19 @@ nsresult ContentChild::ProvideWindowCommon(
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
nsCOMPtr<nsIContentSecurityPolicy> csp;
nsCOMPtr<nsIReferrerInfo> referrerInfo;
rv = GetCreateWindowParams(aParent, aLoadState, aForceNoReferrer, &fullZoom,
getter_AddRefs(referrerInfo),
rv = GetCreateWindowParams(aOpenWindowInfo, aLoadState, aForceNoReferrer,
&fullZoom, getter_AddRefs(referrerInfo),
getter_AddRefs(triggeringPrincipal),
getter_AddRefs(csp));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
SendCreateWindow(aTabOpener, newChild, aChromeFlags, aCalledFromJS,
SendCreateWindow(aTabOpener, parent, newChild, aChromeFlags, aCalledFromJS,
aWidthSpecified, aURI, features, fullZoom,
Principal(triggeringPrincipal), csp, referrerInfo,
std::move(resolve), std::move(reject));
aOpenWindowInfo->GetOriginAttributes(), std::move(resolve),
std::move(reject));
}
// =======================

View File

@ -43,6 +43,7 @@ class nsIURIClassifierCallback;
struct LookAndFeelInt;
class nsDocShellLoadState;
class nsFrameLoader;
class nsIOpenWindowInfo;
namespace mozilla {
class RemoteSpellcheckEngineChild;
@ -109,10 +110,10 @@ class ContentChild final
};
nsresult ProvideWindowCommon(BrowserChild* aTabOpener,
mozIDOMWindowProxy* aParent, bool aIframeMoz,
uint32_t aChromeFlags, bool aCalledFromJS,
bool aWidthSpecified, nsIURI* aURI,
const nsAString& aName,
nsIOpenWindowInfo* aOpenWindowInfo,
bool aIframeMoz, uint32_t aChromeFlags,
bool aCalledFromJS, bool aWidthSpecified,
nsIURI* aURI, const nsAString& aName,
const nsACString& aFeatures, bool aForceNoOpener,
bool aForceNoReferrer,
nsDocShellLoadState* aLoadState,

View File

@ -229,6 +229,7 @@
#include "prio.h"
#include "private/pprio.h"
#include "xpcpublic.h"
#include "nsOpenWindowInfo.h"
#ifdef MOZ_WEBRTC
# include "signaling/src/peerconnection/WebrtcGlobalParent.h"
@ -4603,16 +4604,15 @@ bool ContentParent::DeallocPWebBrowserPersistDocumentParent(
}
mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
PBrowserParent* aThisTab, bool aSetOpener, const uint32_t& aChromeFlags,
const bool& aCalledFromJS, const bool& aWidthSpecified, nsIURI* aURIToLoad,
const nsCString& aFeatures, const float& aFullZoom,
uint64_t aNextRemoteTabId, const nsString& aName, nsresult& aResult,
nsCOMPtr<nsIRemoteTab>& aNewRemoteTab, bool* aWindowIsNew,
int32_t& aOpenLocation, nsIPrincipal* aTriggeringPrincipal,
nsIReferrerInfo* aReferrerInfo, bool aLoadURI,
nsIContentSecurityPolicy* aCsp)
{
PBrowserParent* aThisTab, BrowsingContext* aParent, bool aSetOpener,
const uint32_t& aChromeFlags, const bool& aCalledFromJS,
const bool& aWidthSpecified, nsIURI* aURIToLoad, const nsCString& aFeatures,
const float& aFullZoom, uint64_t aNextRemoteTabId, const nsString& aName,
nsresult& aResult, nsCOMPtr<nsIRemoteTab>& aNewRemoteTab,
bool* aWindowIsNew, int32_t& aOpenLocation,
nsIPrincipal* aTriggeringPrincipal, nsIReferrerInfo* aReferrerInfo,
bool aLoadURI, nsIContentSecurityPolicy* aCsp,
const OriginAttributes& aOriginAttributes) {
// The content process should never be in charge of computing whether or
// not a window should be private - the parent will do that.
const uint32_t badFlags = nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW |
@ -4622,6 +4622,13 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
return IPC_FAIL(this, "Forbidden aChromeFlags passed");
}
RefPtr<nsOpenWindowInfo> openInfo = new nsOpenWindowInfo();
openInfo->mForceNoOpener = !aSetOpener;
openInfo->mParent = aParent;
openInfo->mIsRemote = true;
openInfo->mNextRemoteBrowserId = aNextRemoteTabId;
openInfo->mOriginAttributes = aOriginAttributes;
RefPtr<BrowserParent> topParent = BrowserParent::GetFrom(aThisTab);
while (topParent && topParent->GetBrowserBridgeParent()) {
topParent = topParent->GetBrowserBridgeParent()->Manager();
@ -4629,18 +4636,22 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
RefPtr<BrowserHost> thisBrowserHost =
topParent ? topParent->GetBrowserHost() : nullptr;
MOZ_ASSERT_IF(topParent, thisBrowserHost);
RefPtr<BrowsingContext> topBC =
topParent ? topParent->GetBrowsingContext() : nullptr;
MOZ_ASSERT_IF(topParent, topBC);
// The content process should not have set its remote or fission flags if the
// parent doesn't also have these set.
if (thisBrowserHost) {
nsCOMPtr<nsILoadContext> context = thisBrowserHost->GetLoadContext();
// The content process should have set its remote and fission flags correctly.
if (topBC) {
if ((!!(aChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW) !=
context->UseRemoteTabs()) ||
topBC->UseRemoteTabs()) ||
(!!(aChromeFlags & nsIWebBrowserChrome::CHROME_FISSION_WINDOW) !=
context->UseRemoteSubframes())) {
topBC->UseRemoteSubframes())) {
return IPC_FAIL(this, "Unexpected aChromeFlags passed");
}
if (!aOriginAttributes.EqualsIgnoringFPD(topBC->OriginAttributesRef())) {
return IPC_FAIL(this, "Passed-in OriginAttributes does not match opener");
}
}
nsCOMPtr<nsIContent> frame;
@ -4689,15 +4700,6 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
MOZ_ASSERT(aOpenLocation == nsIBrowserDOMWindow::OPEN_NEWTAB ||
aOpenLocation == nsIBrowserDOMWindow::OPEN_NEWWINDOW);
// Read the origin attributes for the tab from the opener browserParent.
OriginAttributes openerOriginAttributes;
if (thisBrowserHost) {
nsCOMPtr<nsILoadContext> loadContext = thisBrowserHost->GetLoadContext();
loadContext->GetOriginAttributes(openerOriginAttributes);
} else if (Preferences::GetBool("browser.privatebrowsing.autostart")) {
openerOriginAttributes.mPrivateBrowsingId = 1;
}
if (aOpenLocation == nsIBrowserDOMWindow::OPEN_NEWTAB) {
if (NS_WARN_IF(!browserDOMWin)) {
aResult = NS_ERROR_ABORT;
@ -4707,7 +4709,7 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
RefPtr<Element> openerElement = do_QueryObject(frame);
nsCOMPtr<nsIOpenURIInFrameParams> params =
new nsOpenURIInFrameParams(openerOriginAttributes, openerElement);
new nsOpenURIInFrameParams(openInfo, openerElement);
params->SetReferrerInfo(aReferrerInfo);
MOZ_ASSERT(aTriggeringPrincipal, "need a valid triggeringPrincipal");
params->SetTriggeringPrincipal(aTriggeringPrincipal);
@ -4716,13 +4718,13 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
RefPtr<Element> el;
if (aLoadURI) {
aResult = browserDOMWin->OpenURIInFrame(
aURIToLoad, params, aOpenLocation, nsIBrowserDOMWindow::OPEN_NEW,
aNextRemoteTabId, aName, getter_AddRefs(el));
aResult = browserDOMWin->OpenURIInFrame(aURIToLoad, params, aOpenLocation,
nsIBrowserDOMWindow::OPEN_NEW,
aName, getter_AddRefs(el));
} else {
aResult = browserDOMWin->CreateContentWindowInFrame(
aURIToLoad, params, aOpenLocation, nsIBrowserDOMWindow::OPEN_NEW,
aNextRemoteTabId, aName, getter_AddRefs(el));
aName, getter_AddRefs(el));
}
RefPtr<nsFrameLoaderOwner> frameLoaderOwner = do_QueryObject(el);
if (NS_SUCCEEDED(aResult) && frameLoaderOwner) {
@ -4757,9 +4759,9 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
return IPC_OK();
}
aResult = pwwatch->OpenWindowWithRemoteTab(
thisBrowserHost, aFeatures, aCalledFromJS, aFullZoom, aNextRemoteTabId,
!aSetOpener, getter_AddRefs(aNewRemoteTab));
aResult = pwwatch->OpenWindowWithRemoteTab(thisBrowserHost, aFeatures,
aCalledFromJS, aFullZoom, openInfo,
getter_AddRefs(aNewRemoteTab));
if (NS_WARN_IF(NS_FAILED(aResult))) {
return IPC_OK();
}
@ -4793,7 +4795,7 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
}
MOZ_ASSERT(newBrowserHost->GetBrowsingContext()->OriginAttributesRef() ==
openerOriginAttributes);
aOriginAttributes);
if (aURIToLoad && aLoadURI) {
nsCOMPtr<mozIDOMWindowProxy> openerWindow;
@ -4808,7 +4810,7 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
}
RefPtr<BrowsingContext> bc;
aResult = newBrowserDOMWin->OpenURI(
aURIToLoad, openerWindow, nsIBrowserDOMWindow::OPEN_CURRENTWINDOW,
aURIToLoad, openInfo, nsIBrowserDOMWindow::OPEN_CURRENTWINDOW,
nsIBrowserDOMWindow::OPEN_NEW, aTriggeringPrincipal, aCsp,
getter_AddRefs(bc));
}
@ -4817,11 +4819,12 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
}
mozilla::ipc::IPCResult ContentParent::RecvCreateWindow(
PBrowserParent* aThisTab, PBrowserParent* aNewTab,
const uint32_t& aChromeFlags, const bool& aCalledFromJS,
const bool& aWidthSpecified, nsIURI* aURIToLoad, const nsCString& aFeatures,
const float& aFullZoom, const IPC::Principal& aTriggeringPrincipal,
nsIContentSecurityPolicy* aCsp, nsIReferrerInfo* aReferrerInfo,
PBrowserParent* aThisTab, const MaybeDiscarded<BrowsingContext>& aParent,
PBrowserParent* aNewTab, const uint32_t& aChromeFlags,
const bool& aCalledFromJS, const bool& aWidthSpecified, nsIURI* aURIToLoad,
const nsCString& aFeatures, const float& aFullZoom,
const IPC::Principal& aTriggeringPrincipal, nsIContentSecurityPolicy* aCsp,
nsIReferrerInfo* aReferrerInfo, const OriginAttributes& aOriginAttributes,
CreateWindowResolver&& aResolve) {
nsresult rv = NS_OK;
CreatedWindowInfo cwi;
@ -4839,6 +4842,7 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindow(
aResolve(cwi);
});
RefPtr<BrowserParent> thisTab = BrowserParent::GetFrom(aThisTab);
RefPtr<BrowserParent> newTab = BrowserParent::GetFrom(aNewTab);
MOZ_ASSERT(newTab);
@ -4851,6 +4855,45 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindow(
}
});
// Don't continue to try to create a new window if we've been discarded.
if (aParent.IsDiscarded()) {
rv = NS_ERROR_FAILURE;
return IPC_OK();
}
// Validate that our new BrowsingContext looks as we would expect it.
RefPtr<BrowsingContext> newBC = newTab->GetBrowsingContext();
if (!newBC) {
return IPC_FAIL(this, "Missing BrowsingContext for new tab");
}
RefPtr<BrowsingContext> newBCOpener = newBC->GetOpener();
if (newBCOpener && aParent.get() != newBCOpener) {
return IPC_FAIL(this, "Invalid opener BrowsingContext for new tab");
}
if (newBC->GetParent() != nullptr) {
return IPC_FAIL(this,
"Unexpected non-toplevel BrowsingContext for new tab");
}
if (!!(aChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW) !=
newBC->UseRemoteTabs() ||
!!(aChromeFlags & nsIWebBrowserChrome::CHROME_FISSION_WINDOW) !=
newBC->UseRemoteSubframes()) {
return IPC_FAIL(this, "Unexpected aChromeFlags passed");
}
if (!aOriginAttributes.EqualsIgnoringFPD(newBC->OriginAttributesRef())) {
return IPC_FAIL(this, "Opened tab has mismatched OriginAttributes");
}
if (thisTab && BrowserParent::GetFrom(thisTab)->GetBrowsingContext()) {
BrowsingContext* thisTabBC = thisTab->GetBrowsingContext();
if (thisTabBC->UseRemoteTabs() != newBC->UseRemoteTabs() ||
thisTabBC->UseRemoteSubframes() != newBC->UseRemoteSubframes() ||
thisTabBC->UsePrivateBrowsing() != newBC->UsePrivateBrowsing()) {
return IPC_FAIL(this, "New BrowsingContext has mismatched LoadContext");
}
}
BrowserParent::AutoUseNewTab aunt(newTab, &cwi.urlToLoad());
const uint64_t nextRemoteTabId = ++sNextRemoteTabId;
sNextBrowserParents.Put(nextRemoteTabId, newTab);
@ -4858,11 +4901,11 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindow(
nsCOMPtr<nsIRemoteTab> newRemoteTab;
int32_t openLocation = nsIBrowserDOMWindow::OPEN_NEWWINDOW;
mozilla::ipc::IPCResult ipcResult = CommonCreateWindow(
aThisTab, /* aSetOpener = */ true, aChromeFlags, aCalledFromJS,
aThisTab, aParent.get(), !!newBCOpener, aChromeFlags, aCalledFromJS,
aWidthSpecified, aURIToLoad, aFeatures, aFullZoom, nextRemoteTabId,
VoidString(), rv, newRemoteTab, &cwi.windowOpened(), openLocation,
aTriggeringPrincipal, aReferrerInfo,
/* aLoadUri = */ false, aCsp);
/* aLoadUri = */ false, aCsp, aOriginAttributes);
if (!ipcResult) {
return ipcResult;
}
@ -4892,13 +4935,19 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindow(
}
mozilla::ipc::IPCResult ContentParent::RecvCreateWindowInDifferentProcess(
PBrowserParent* aThisTab, const uint32_t& aChromeFlags,
const bool& aCalledFromJS, const bool& aWidthSpecified, nsIURI* aURIToLoad,
const nsCString& aFeatures, const float& aFullZoom, const nsString& aName,
PBrowserParent* aThisTab, const MaybeDiscarded<BrowsingContext>& aParent,
const uint32_t& aChromeFlags, const bool& aCalledFromJS,
const bool& aWidthSpecified, nsIURI* aURIToLoad, const nsCString& aFeatures,
const float& aFullZoom, const nsString& aName,
nsIPrincipal* aTriggeringPrincipal, nsIContentSecurityPolicy* aCsp,
nsIReferrerInfo* aReferrerInfo) {
nsIReferrerInfo* aReferrerInfo, const OriginAttributes& aOriginAttributes) {
MOZ_DIAGNOSTIC_ASSERT(!nsContentUtils::IsSpecialName(aName));
// Don't continue to try to create a new window if we've been discarded.
if (NS_WARN_IF(aParent.IsDiscarded())) {
return IPC_OK();
}
nsCOMPtr<nsIRemoteTab> newRemoteTab;
bool windowIsNew;
int32_t openLocation = nsIBrowserDOMWindow::OPEN_NEWWINDOW;
@ -4930,11 +4979,11 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindowInDifferentProcess(
nsresult rv;
mozilla::ipc::IPCResult ipcResult = CommonCreateWindow(
aThisTab, /* aSetOpener = */ false, aChromeFlags, aCalledFromJS,
aWidthSpecified, aURIToLoad, aFeatures, aFullZoom,
aThisTab, aParent.get(), /* aSetOpener = */ false, aChromeFlags,
aCalledFromJS, aWidthSpecified, aURIToLoad, aFeatures, aFullZoom,
/* aNextRemoteTabId = */ 0, aName, rv, newRemoteTab, &windowIsNew,
openLocation, aTriggeringPrincipal, aReferrerInfo,
/* aLoadUri = */ true, aCsp);
/* aLoadUri = */ true, aCsp, aOriginAttributes);
if (!ipcResult) {
return ipcResult;
}

View File

@ -519,20 +519,24 @@ class ContentParent final
void ForkNewProcess(bool aBlocking);
mozilla::ipc::IPCResult RecvCreateWindow(
PBrowserParent* aThisBrowserParent, PBrowserParent* aNewTab,
PBrowserParent* aThisBrowserParent,
const MaybeDiscarded<BrowsingContext>& aParent, PBrowserParent* aNewTab,
const uint32_t& aChromeFlags, const bool& aCalledFromJS,
const bool& aWidthSpecified, nsIURI* aURIToLoad,
const nsCString& aFeatures, const float& aFullZoom,
const IPC::Principal& aTriggeringPrincipal,
nsIContentSecurityPolicy* aCsp, nsIReferrerInfo* aReferrerInfo,
const OriginAttributes& aOriginAttributes,
CreateWindowResolver&& aResolve);
mozilla::ipc::IPCResult RecvCreateWindowInDifferentProcess(
PBrowserParent* aThisTab, const uint32_t& aChromeFlags,
const bool& aCalledFromJS, const bool& aWidthSpecified,
nsIURI* aURIToLoad, const nsCString& aFeatures, const float& aFullZoom,
const nsString& aName, nsIPrincipal* aTriggeringPrincipal,
nsIContentSecurityPolicy* aCsp, nsIReferrerInfo* aReferrerInfo);
PBrowserParent* aThisTab, const MaybeDiscarded<BrowsingContext>& aParent,
const uint32_t& aChromeFlags, const bool& aCalledFromJS,
const bool& aWidthSpecified, nsIURI* aURIToLoad,
const nsCString& aFeatures, const float& aFullZoom, const nsString& aName,
nsIPrincipal* aTriggeringPrincipal, nsIContentSecurityPolicy* aCsp,
nsIReferrerInfo* aReferrerInfo,
const OriginAttributes& aOriginAttributes);
static void BroadcastBlobURLRegistration(
const nsACString& aURI, BlobImpl* aBlobImpl, nsIPrincipal* aPrincipal,
@ -724,14 +728,16 @@ class ContentParent final
// window. aURIToLoad should always be provided, if available, to ensure
// compatibility with GeckoView.
mozilla::ipc::IPCResult CommonCreateWindow(
PBrowserParent* aThisTab, bool aSetOpener, const uint32_t& aChromeFlags,
const bool& aCalledFromJS, const bool& aWidthSpecified,
nsIURI* aURIToLoad, const nsCString& aFeatures, const float& aFullZoom,
PBrowserParent* aThisTab, BrowsingContext* aParent, bool aSetOpener,
const uint32_t& aChromeFlags, const bool& aCalledFromJS,
const bool& aWidthSpecified, nsIURI* aURIToLoad,
const nsCString& aFeatures, const float& aFullZoom,
uint64_t aNextRemoteTabId, const nsString& aName, nsresult& aResult,
nsCOMPtr<nsIRemoteTab>& aNewRemoteTab, bool* aWindowIsNew,
int32_t& aOpenLocation, nsIPrincipal* aTriggeringPrincipal,
nsIReferrerInfo* aReferrerInfo, bool aLoadUri,
nsIContentSecurityPolicy* aCsp);
nsIContentSecurityPolicy* aCsp,
const OriginAttributes& aOriginAttributes);
explicit ContentParent(int32_t aPluginID)
: ContentParent(nullptr, EmptyString(), aPluginID) {}

View File

@ -1354,6 +1354,7 @@ parent:
sync GetHyphDict(nsIURI aURI) returns (Handle aHandle, uint32_t aSize);
async CreateWindow(nullable PBrowser aThisTab,
MaybeDiscardedBrowsingContext aParent,
PBrowser aNewTab,
uint32_t aChromeFlags,
bool aCalledFromJS,
@ -1363,11 +1364,13 @@ parent:
float aFullZoom,
Principal aTriggeringPrincipal,
nsIContentSecurityPolicy aCsp,
nsIReferrerInfo aReferrerInfo)
nsIReferrerInfo aReferrerInfo,
OriginAttributes aOriginAttributes)
returns (CreatedWindowInfo window);
async CreateWindowInDifferentProcess(
PBrowser aThisTab,
MaybeDiscardedBrowsingContext aParent,
uint32_t aChromeFlags,
bool aCalledFromJS,
bool aWidthSpecified,
@ -1377,7 +1380,8 @@ parent:
nsString aName,
nsIPrincipal aTriggeringPrincipal,
nsIContentSecurityPolicy aCsp,
nsIReferrerInfo aReferrerInfo);
nsIReferrerInfo aReferrerInfo,
OriginAttributes aOriginAttributes);
/**
* Tells the parent to ungrab the pointer on the default display.

View File

@ -582,10 +582,8 @@ nsAppStartup::GetInterrupted(bool* aInterrupted) {
NS_IMETHODIMP
nsAppStartup::CreateChromeWindow(nsIWebBrowserChrome* aParent,
uint32_t aChromeFlags,
nsIRemoteTab* aOpeningTab,
mozIDOMWindowProxy* aOpener,
uint64_t aNextRemoteTabId, bool* aCancel,
nsIWebBrowserChrome** _retval) {
nsIOpenWindowInfo* aOpenWindowInfo,
bool* aCancel, nsIWebBrowserChrome** _retval) {
NS_ENSURE_ARG_POINTER(aCancel);
NS_ENSURE_ARG_POINTER(_retval);
*aCancel = false;
@ -612,14 +610,14 @@ nsAppStartup::CreateChromeWindow(nsIWebBrowserChrome* aParent,
"may work.");
if (appParent)
appParent->CreateNewWindow(aChromeFlags, aOpeningTab, aOpener,
aNextRemoteTabId, getter_AddRefs(newWindow));
appParent->CreateNewWindow(aChromeFlags, aOpenWindowInfo,
getter_AddRefs(newWindow));
// And if it fails, don't try again without a parent. It could fail
// intentionally (bug 115969).
} else { // try using basic methods:
MOZ_RELEASE_ASSERT(aNextRemoteTabId == 0,
"Unexpected aNextRemoteTabId, we shouldn't ever have a "
"next actor ID without a parent");
MOZ_RELEASE_ASSERT(!aOpenWindowInfo,
"Unexpected aOpenWindowInfo, we shouldn't ever have an "
"nsIOpenWindowInfo without a parent");
/* You really shouldn't be making dependent windows without a parent.
But unparented modal (and therefore dependent) windows happen
@ -633,8 +631,7 @@ nsAppStartup::CreateChromeWindow(nsIWebBrowserChrome* aParent,
appShell->CreateTopLevelWindow(
0, 0, aChromeFlags, nsIAppShellService::SIZE_TO_CONTENT,
nsIAppShellService::SIZE_TO_CONTENT, aOpeningTab, aOpener,
getter_AddRefs(newWindow));
nsIAppShellService::SIZE_TO_CONTENT, getter_AddRefs(newWindow));
}
// if anybody gave us anything to work with, use it

View File

@ -15,6 +15,7 @@
#include "nsISupports.idl"
interface nsIOpenWindowInfo;
interface nsIRemoteTab;
interface nsIURI;
interface nsIWebBrowserChrome;
@ -30,12 +31,8 @@ interface nsIWindowCreator : nsISupports {
the parent, if any (and if the concept applies
to the underlying OS).
@param chromeFlags Chrome features from nsIWebBrowserChrome
@param aOpeningTab The RemoteTab that is trying to open this new chrome
window. Can be nullptr.
@param aOpener The window which is trying to open this new chrome window.
Can be nullptr
@param aNextRemoteTabId The integer ID of the next remote tab actor to use.
0 means there is no next remote tab ID to use.
@param aOpenWindowInfo Information used to open initial content in
the new chrome window. Can be nullptr.
@param cancel Return |true| to reject window creation. If true the
implementation has determined the window should not
be created at all. The caller should not default
@ -44,9 +41,7 @@ interface nsIWindowCreator : nsISupports {
*/
nsIWebBrowserChrome createChromeWindow(in nsIWebBrowserChrome parent,
in uint32_t chromeFlags,
in nsIRemoteTab aOpeningTab,
in mozIDOMWindowProxy aOpener,
in unsigned long long aNextRemoteTabId,
in nsIOpenWindowInfo aOpenWindowInfo,
out boolean cancel);
};

View File

@ -20,6 +20,7 @@ class nsDocShellLoadState;
webidl BrowsingContext;
interface mozIDOMWindowProxy;
interface nsIURI;
interface nsIOpenWindowInfo;
native nsDocShellLoadStatePtr(nsDocShellLoadState*);
/**
@ -39,11 +40,8 @@ interface nsIWindowProvider : nsISupports
* those is the caller's responsibility. The provider can always return null
* to have the caller create a brand-new window.
*
* @param aParent Must not be null. This is the window that the caller wants
* to use as the parent for the new window. Generally,
* nsIWindowProvider implementors can expect to be somehow related to
* aParent; the relationship may depend on the nsIWindowProvider
* implementation.
* @param aOpenWindowInfo Must not be null. This is the information the
* caller wants to be used to construct the new window.
*
* @param aChromeFlags The chrome flags the caller will use to create a new
* window if this provider returns null. See nsIWebBrowserChrome for
@ -83,7 +81,7 @@ interface nsIWindowProvider : nsISupports
* false if the window being returned existed before the
* provideWindow() call. The value of this out parameter is
* meaningless if provideWindow() returns null.
*
* @return A window the caller should use or null if the caller should just
* create a new window. The returned window may be newly opened by
* the nsIWindowProvider implementation or may be a window that
@ -95,7 +93,7 @@ interface nsIWindowProvider : nsISupports
* @see nsIWindowWatcher for more information on aFeatures.
* @see nsIWebBrowserChrome for more information on aChromeFlags.
*/
BrowsingContext provideWindow(in mozIDOMWindowProxy aParent,
BrowsingContext provideWindow(in nsIOpenWindowInfo aOpenWindowInfo,
in unsigned long aChromeFlags,
in boolean aCalledFromJS,
in boolean aWidthSpecified,

View File

@ -21,6 +21,7 @@ interface nsIWebBrowserChrome;
interface nsIDocShellTreeItem;
interface nsIArray;
interface nsIRemoteTab;
interface nsIOpenWindowInfo;
native nsDocShellLoadStatePtr(nsDocShellLoadState*);
[uuid(d162f9c4-19d5-4723-931f-f1e51bfa9f68)]
@ -106,12 +107,9 @@ interface nsPIWindowWatcher : nsISupports
* @param aOpenerFullZoom
* The current zoom multiplier for the opener tab. This is then
* applied to the newly opened window.
* @param aNextRemoteTabId
* The integer ID for the next remote tab actor.
* 0 means there is no next remote tab actor to use.
* @param aForceNoOpener
* If true, then aOpeningTab will not be used to set the opener
* for the newly created window.
* @param aOpenWindowInfo
* Information used to create the initial content browser in the new
* window.
*
* @return the nsIRemoteTab of the initial browser for the newly opened
* window.
@ -120,7 +118,6 @@ interface nsPIWindowWatcher : nsISupports
in ACString aFeatures,
in boolean aCalledFromJS,
in float aOpenerFullZoom,
in unsigned long long aNextRemoteTabId,
in boolean aForceNoOpener);
in nsIOpenWindowInfo aOpenWindowInfo);
};

View File

@ -49,6 +49,7 @@
#include "nsIDOMStorageManager.h"
#include "nsIWidget.h"
#include "nsFocusManager.h"
#include "nsOpenWindowInfo.h"
#include "nsPresContext.h"
#include "nsContentUtils.h"
#include "nsIPrefBranch.h"
@ -410,11 +411,12 @@ static bool CheckUserContextCompatibility(nsIDocShell* aDocShell) {
return subjectPrincipal->GetUserContextId() == userContextId;
}
nsresult nsWindowWatcher::CreateChromeWindow(
const nsACString& aFeatures, nsIWebBrowserChrome* aParentChrome,
uint32_t aChromeFlags, nsIRemoteTab* aOpeningBrowserParent,
mozIDOMWindowProxy* aOpener, uint64_t aNextRemoteTabId,
nsIWebBrowserChrome** aResult) {
nsresult nsWindowWatcher::CreateChromeWindow(const nsACString& aFeatures,
nsIWebBrowserChrome* aParentChrome,
uint32_t aChromeFlags,
nsIOpenWindowInfo* aOpenWindowInfo,
nsIWebBrowserChrome** aResult) {
if (NS_WARN_IF(!mWindowCreator)) {
return NS_ERROR_UNEXPECTED;
}
@ -422,8 +424,8 @@ nsresult nsWindowWatcher::CreateChromeWindow(
bool cancel = false;
nsCOMPtr<nsIWebBrowserChrome> newWindowChrome;
nsresult rv = mWindowCreator->CreateChromeWindow(
aParentChrome, aChromeFlags, aOpeningBrowserParent, aOpener,
aNextRemoteTabId, &cancel, getter_AddRefs(newWindowChrome));
aParentChrome, aChromeFlags, aOpenWindowInfo, &cancel,
getter_AddRefs(newWindowChrome));
if (NS_SUCCEEDED(rv) && cancel) {
newWindowChrome = nullptr;
@ -463,10 +465,12 @@ void nsWindowWatcher::MaybeDisablePersistence(
}
NS_IMETHODIMP
nsWindowWatcher::OpenWindowWithRemoteTab(
nsIRemoteTab* aRemoteTab, const nsACString& aFeatures, bool aCalledFromJS,
float aOpenerFullZoom, uint64_t aNextRemoteTabId, bool aForceNoOpener,
nsIRemoteTab** aResult) {
nsWindowWatcher::OpenWindowWithRemoteTab(nsIRemoteTab* aRemoteTab,
const nsACString& aFeatures,
bool aCalledFromJS,
float aOpenerFullZoom,
nsIOpenWindowInfo* aOpenWindowInfo,
nsIRemoteTab** aResult) {
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(mWindowCreator);
@ -484,20 +488,18 @@ nsWindowWatcher::OpenWindowWithRemoteTab(
Preferences::GetBool("browser.privatebrowsing.autostart");
nsCOMPtr<nsPIDOMWindowOuter> parentWindowOuter;
if (aRemoteTab) {
// We need to examine the window that aRemoteTab belongs to in
// order to inform us of what kind of window we're going to open.
BrowserHost* openingTab = BrowserHost::GetFrom(aRemoteTab);
parentWindowOuter = openingTab->GetParentWindowOuter();
// Propagate the privacy & fission status of the parent window, if
// available, to the child.
nsCOMPtr<nsILoadContext> parentContext = openingTab->GetLoadContext();
if (parentContext) {
isFissionWindow = parentContext->UseRemoteSubframes();
isPrivateBrowsingWindow =
isPrivateBrowsingWindow || parentContext->UsePrivateBrowsing();
RefPtr<BrowsingContext> parentBC = aOpenWindowInfo->GetParent();
if (parentBC) {
RefPtr<Element> browserElement = parentBC->Top()->GetEmbedderElement();
if (browserElement && browserElement->GetOwnerGlobal() &&
browserElement->GetOwnerGlobal()->AsInnerWindow()) {
parentWindowOuter =
browserElement->GetOwnerGlobal()->AsInnerWindow()->GetOuterWindow();
}
isFissionWindow = parentBC->UseRemoteSubframes();
isPrivateBrowsingWindow =
isPrivateBrowsingWindow || parentBC->UsePrivateBrowsing();
}
if (!parentWindowOuter) {
@ -542,9 +544,8 @@ nsWindowWatcher::OpenWindowWithRemoteTab(
nsCOMPtr<nsIWebBrowserChrome> parentChrome(do_GetInterface(parentTreeOwner));
nsCOMPtr<nsIWebBrowserChrome> newWindowChrome;
CreateChromeWindow(aFeatures, parentChrome, chromeFlags,
aForceNoOpener ? nullptr : aRemoteTab, nullptr,
aNextRemoteTabId, getter_AddRefs(newWindowChrome));
CreateChromeWindow(aFeatures, parentChrome, chromeFlags, aOpenWindowInfo,
getter_AddRefs(newWindowChrome));
if (NS_WARN_IF(!newWindowChrome)) {
return NS_ERROR_UNEXPECTED;
@ -780,6 +781,29 @@ nsresult nsWindowWatcher::OpenWindowInternal(
}
}
// Information used when opening new content windows. This object will be
// passed through to the inner nsFrameLoader.
RefPtr<nsOpenWindowInfo> openWindowInfo;
if (!newBC && !windowTypeIsChrome) {
openWindowInfo = new nsOpenWindowInfo();
openWindowInfo->mForceNoOpener = aForceNoOpener;
openWindowInfo->mParent = parentBC;
// We're going to want the window to be immediately available, meaning we
// want it to match the current remoteness.
openWindowInfo->mIsRemote = XRE_IsContentProcess();
// If we have a non-system non-expanded subject principal, we can inherit
// our OriginAttributes from it.
nsCOMPtr<nsIPrincipal> subjectPrincipal =
nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller();
if (subjectPrincipal &&
!nsContentUtils::IsSystemOrExpandedPrincipal(subjectPrincipal)) {
openWindowInfo->mOriginAttributes =
subjectPrincipal->OriginAttributesRef();
}
}
uint32_t activeDocsSandboxFlags = 0;
if (!newBC) {
// We're going to either open up a new window ourselves or ask a
@ -806,6 +830,8 @@ nsresult nsWindowWatcher::OpenWindowInternal(
!(chromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
nsIWebBrowserChrome::CHROME_OPENAS_CHROME))) {
MOZ_ASSERT(openWindowInfo);
nsCOMPtr<nsIWindowProvider> provider;
if (parentTreeOwner) {
provider = do_GetInterface(parentTreeOwner);
@ -816,10 +842,11 @@ nsresult nsWindowWatcher::OpenWindowInternal(
}
if (provider) {
rv = provider->ProvideWindow(
aParent, chromeFlags, aCalledFromJS, sizeSpec.WidthSpecified(),
uriToLoad, name, features, aForceNoOpener, aForceNoReferrer,
aLoadState, &windowIsNew, getter_AddRefs(newBC));
rv = provider->ProvideWindow(openWindowInfo, chromeFlags, aCalledFromJS,
sizeSpec.WidthSpecified(), uriToLoad, name,
features, aForceNoOpener, aForceNoReferrer,
aLoadState, &windowIsNew,
getter_AddRefs(newBC));
if (NS_SUCCEEDED(rv) && newBC) {
nsCOMPtr<nsIDocShell> newDocShell = newBC->GetDocShell();
@ -914,9 +941,8 @@ nsresult nsWindowWatcher::OpenWindowInternal(
completely honest: we clear that indicator if the opener is chrome, so
that the downstream consumer can treat the indicator to mean simply
that the new window is subject to popup control. */
mozIDOMWindowProxy* openerWindow = aForceNoOpener ? nullptr : aParent;
rv = CreateChromeWindow(features, parentChrome, chromeFlags, nullptr,
openerWindow, 0, getter_AddRefs(newChrome));
rv = CreateChromeWindow(features, parentChrome, chromeFlags,
openWindowInfo, getter_AddRefs(newChrome));
if (parentTopInnerWindow) {
parentTopInnerWindow->Resume();

View File

@ -20,6 +20,7 @@
#include "mozilla/Maybe.h"
#include "nsIWindowCreator.h" // for stupid compilers
#include "nsIWindowWatcher.h"
#include "nsIOpenWindowInfo.h"
#include "nsIPromptFactory.h"
#include "nsIRemoteTab.h"
#include "nsPIWindowWatcher.h"
@ -115,9 +116,7 @@ class nsWindowWatcher : public nsIWindowWatcher,
nsresult CreateChromeWindow(const nsACString& aFeatures,
nsIWebBrowserChrome* aParentChrome,
uint32_t aChromeFlags,
nsIRemoteTab* aOpeningBrowserParent,
mozIDOMWindowProxy* aOpener,
uint64_t aNextRemoteTabId,
nsIOpenWindowInfo* aOpenWindowInfo,
nsIWebBrowserChrome** aResult);
void MaybeDisablePersistence(const nsACString& aFeatures,

View File

@ -32,6 +32,7 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsIIOService.h"
#include "nsIObserverService.h"
#include "nsIOpenWindowInfo.h"
#include "nsIWindowMediator.h"
#include "nsIScreenManager.h"
#include "nsIScreen.h"
@ -126,7 +127,6 @@ AppWindow::AppWindow(uint32_t aChromeFlags)
mPersistentAttributesDirty(0),
mPersistentAttributesMask(0),
mChromeFlags(aChromeFlags),
mNextRemoteTabId(0),
mSPTimerLock("AppWindow.mSPTimerLock"),
mWidgetListenerDelegate(this) {}
@ -157,8 +157,7 @@ NS_INTERFACE_MAP_END
nsresult AppWindow::Initialize(nsIAppWindow* aParent, nsIAppWindow* aOpener,
int32_t aInitialWidth, int32_t aInitialHeight,
bool aIsHiddenWindow, nsIRemoteTab* aOpeningTab,
mozIDOMWindowProxy* aOpenerWindow,
bool aIsHiddenWindow,
nsWidgetInitData& widgetInitData) {
nsresult rv;
nsCOMPtr<nsIWidget> parentWidget;
@ -230,22 +229,17 @@ nsresult AppWindow::Initialize(nsIAppWindow* aParent, nsIAppWindow* aOpener,
// since we no longer use content child widgets.
mWindow->SetBackgroundColor(NS_RGB(255, 255, 255));
// Create web shell
RefPtr<BrowsingContext> openerContext =
aOpenerWindow
? nsPIDOMWindowOuter::From(aOpenerWindow)->GetBrowsingContext()
: nullptr;
// All Chrome BCs exist within the same BrowsingContextGroup, so we don't need
// to pass in the opener window here. The opener is set later, if needed, by
// nsWindowWatcher.
RefPtr<BrowsingContext> browsingContext =
BrowsingContext::Create(/* aParent */ nullptr, openerContext,
BrowsingContext::Create(/* aParent */ nullptr, /* aOpener */ nullptr,
EmptyString(), BrowsingContext::Type::Chrome);
// Create web shell
mDocShell = nsDocShell::Create(browsingContext);
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
// XXX(nika): This is used to handle propagating opener across remote tab
// creation. We should come up with a better system for doing this (probably
// based on BrowsingContext).
mDocShell->SetOpener(aOpeningTab);
// Make sure to set the item type on the docshell _before_ calling
// Create() so it knows what type it is.
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(mDocShell);
@ -268,16 +262,6 @@ nsresult AppWindow::Initialize(nsIAppWindow* aParent, nsIAppWindow* aOpener,
nsIWebProgress::NOTIFY_STATE_NETWORK);
}
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
if (aOpenerWindow) {
BrowsingContext* bc = mDocShell->GetBrowsingContext();
BrowsingContext* openerBC =
nsPIDOMWindowOuter::From(aOpenerWindow)->GetBrowsingContext();
MOZ_DIAGNOSTIC_ASSERT(bc->GetOpenerId() == openerBC->Id());
MOZ_DIAGNOSTIC_ASSERT(bc->HadOriginalOpener());
}
#endif
return rv;
}
@ -2105,26 +2089,21 @@ NS_IMETHODIMP AppWindow::ExitModalLoop(nsresult aStatus) {
// top-level function to create a new window
NS_IMETHODIMP AppWindow::CreateNewWindow(int32_t aChromeFlags,
nsIRemoteTab* aOpeningTab,
mozIDOMWindowProxy* aOpener,
uint64_t aNextRemoteTabId,
nsIOpenWindowInfo* aOpenWindowInfo,
nsIAppWindow** _retval) {
NS_ENSURE_ARG_POINTER(_retval);
if (aChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME) {
MOZ_RELEASE_ASSERT(
aNextRemoteTabId == 0,
"Unexpected next remote tab ID, should never have a non-zero "
"aNextRemoteTabId when creating a new chrome window");
return CreateNewChromeWindow(aChromeFlags, aOpeningTab, aOpener, _retval);
!aOpenWindowInfo,
"Unexpected nsOpenWindowInfo when creating a new chrome window");
return CreateNewChromeWindow(aChromeFlags, _retval);
}
return CreateNewContentWindow(aChromeFlags, aOpeningTab, aOpener,
aNextRemoteTabId, _retval);
return CreateNewContentWindow(aChromeFlags, aOpenWindowInfo, _retval);
}
NS_IMETHODIMP AppWindow::CreateNewChromeWindow(int32_t aChromeFlags,
nsIRemoteTab* aOpeningTab,
mozIDOMWindowProxy* aOpener,
nsIAppWindow** _retval) {
nsCOMPtr<nsIAppShellService> appShell(
do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
@ -2134,8 +2113,7 @@ NS_IMETHODIMP AppWindow::CreateNewChromeWindow(int32_t aChromeFlags,
nsCOMPtr<nsIAppWindow> newWindow;
appShell->CreateTopLevelWindow(
this, nullptr, aChromeFlags, nsIAppShellService::SIZE_TO_CONTENT,
nsIAppShellService::SIZE_TO_CONTENT, aOpeningTab, aOpener,
getter_AddRefs(newWindow));
nsIAppShellService::SIZE_TO_CONTENT, getter_AddRefs(newWindow));
NS_ENSURE_TRUE(newWindow, NS_ERROR_FAILURE);
@ -2144,11 +2122,9 @@ NS_IMETHODIMP AppWindow::CreateNewChromeWindow(int32_t aChromeFlags,
return NS_OK;
}
NS_IMETHODIMP AppWindow::CreateNewContentWindow(int32_t aChromeFlags,
nsIRemoteTab* aOpeningTab,
mozIDOMWindowProxy* aOpener,
uint64_t aNextRemoteTabId,
nsIAppWindow** _retval) {
NS_IMETHODIMP AppWindow::CreateNewContentWindow(
int32_t aChromeFlags, nsIOpenWindowInfo* aOpenWindowInfo,
nsIAppWindow** _retval) {
nsCOMPtr<nsIAppShellService> appShell(
do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
NS_ENSURE_TRUE(appShell, NS_ERROR_FAILURE);
@ -2175,34 +2151,20 @@ NS_IMETHODIMP AppWindow::CreateNewContentWindow(int32_t aChromeFlags,
nsCOMPtr<nsIAppWindow> newWindow;
{
AutoNoJSAPI nojsapi;
// We actually want this toplevel window which we are creating to have a
// null opener, as we will be creating the content xul:browser window inside
// of it, so we pass nullptr as our aOpener.
appShell->CreateTopLevelWindow(this, uri, aChromeFlags, 615, 480,
aOpeningTab, nullptr,
getter_AddRefs(newWindow));
NS_ENSURE_TRUE(newWindow, NS_ERROR_FAILURE);
}
// Specify that we want the window to remain locked until the chrome has
// loaded.
AppWindow* appWin =
static_cast<AppWindow*>(static_cast<nsIAppWindow*>(newWindow));
if (aNextRemoteTabId) {
appWin->mNextRemoteTabId = aNextRemoteTabId;
}
if (aOpener) {
nsCOMPtr<nsIDocShell> docShell;
appWin->GetDocShell(getter_AddRefs(docShell));
MOZ_ASSERT(docShell);
nsCOMPtr<nsPIDOMWindowOuter> window = docShell->GetWindow();
MOZ_ASSERT(window);
window->SetOpenerForInitialContentBrowser(
nsPIDOMWindowOuter::From(aOpener)->GetBrowsingContext());
}
// Specify which flags should be used by browser.xhtml to create the initial
// content browser window.
appWin->mInitialOpenWindowInfo = aOpenWindowInfo;
// Specify that we want the window to remain locked until the chrome has
// loaded.
appWin->LockUntilChromeLoad();
{
@ -2212,7 +2174,8 @@ NS_IMETHODIMP AppWindow::CreateNewContentWindow(int32_t aChromeFlags,
NS_ENSURE_STATE(appWin->mPrimaryContentShell ||
appWin->mPrimaryBrowserParent);
MOZ_ASSERT_IF(appWin->mPrimaryContentShell, aNextRemoteTabId == 0);
MOZ_ASSERT_IF(appWin->mPrimaryContentShell,
aOpenWindowInfo->GetNextRemoteBrowserId() == 0);
newWindow.forget(_retval);
@ -2610,9 +2573,10 @@ nsresult AppWindow::GetTabCount(uint32_t* aResult) {
return NS_OK;
}
nsresult AppWindow::GetNextRemoteTabId(uint64_t* aNextRemoteTabId) {
NS_ENSURE_ARG_POINTER(aNextRemoteTabId);
*aNextRemoteTabId = mNextRemoteTabId;
nsresult AppWindow::GetInitialOpenWindowInfo(
nsIOpenWindowInfo** aOpenWindowInfo) {
NS_ENSURE_ARG_POINTER(aOpenWindowInfo);
*aOpenWindowInfo = do_AddRef(mInitialOpenWindowInfo).take();
return NS_OK;
}

View File

@ -139,9 +139,7 @@ class AppWindow final : public nsIBaseWindow,
// AppWindow methods...
nsresult Initialize(nsIAppWindow* aParent, nsIAppWindow* aOpener,
int32_t aInitialWidth, int32_t aInitialHeight,
bool aIsHiddenWindow, nsIRemoteTab* aOpeningTab,
mozIDOMWindowProxy* aOpenerWindow,
nsWidgetInitData& widgetInitData);
bool aIsHiddenWindow, nsWidgetInitData& widgetInitData);
nsIDocShell* GetDocShell() { return mDocShell; }
@ -228,13 +226,9 @@ class AppWindow final : public nsIBaseWindow,
int32_t aCY);
NS_IMETHOD ExitModalLoop(nsresult aStatus);
NS_IMETHOD CreateNewChromeWindow(int32_t aChromeFlags,
nsIRemoteTab* aOpeningTab,
mozIDOMWindowProxy* aOpenerWindow,
nsIAppWindow** _retval);
NS_IMETHOD CreateNewContentWindow(int32_t aChromeFlags,
nsIRemoteTab* aOpeningTab,
mozIDOMWindowProxy* aOpenerWindow,
uint64_t aNextRemoteTabId,
nsIOpenWindowInfo* aOpenWindowInfo,
nsIAppWindow** _retval);
NS_IMETHOD GetHasPrimaryContent(bool* aResult);
@ -283,7 +277,7 @@ class AppWindow final : public nsIBaseWindow,
uint32_t mPersistentAttributesDirty; // persistentAttributes
uint32_t mPersistentAttributesMask;
uint32_t mChromeFlags;
uint64_t mNextRemoteTabId;
nsCOMPtr<nsIOpenWindowInfo> mInitialOpenWindowInfo;
nsString mTitle;
nsIntRect mOpenerScreenRect; // the screen rect of the opener

View File

@ -129,9 +129,8 @@ nsAppShellService::CreateHiddenWindow() {
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<AppWindow> newWindow;
rv =
JustCreateTopWindow(nullptr, url, chromeMask, initialWidth, initialHeight,
true, nullptr, nullptr, getter_AddRefs(newWindow));
rv = JustCreateTopWindow(nullptr, url, chromeMask, initialWidth,
initialHeight, true, getter_AddRefs(newWindow));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocShell> docShell;
@ -160,20 +159,18 @@ nsAppShellService::DestroyHiddenWindow() {
* Create a new top level window and display the given URL within it...
*/
NS_IMETHODIMP
nsAppShellService::CreateTopLevelWindow(
nsIAppWindow* aParent, nsIURI* aUrl, uint32_t aChromeMask,
int32_t aInitialWidth, int32_t aInitialHeight, nsIRemoteTab* aOpeningTab,
mozIDOMWindowProxy* aOpenerWindow, nsIAppWindow** aResult)
{
nsAppShellService::CreateTopLevelWindow(nsIAppWindow* aParent, nsIURI* aUrl,
uint32_t aChromeMask,
int32_t aInitialWidth,
int32_t aInitialHeight,
nsIAppWindow** aResult) {
nsresult rv;
StartupTimeline::RecordOnce(StartupTimeline::CREATE_TOP_LEVEL_WINDOW);
RefPtr<AppWindow> newWindow;
rv = JustCreateTopWindow(aParent, aUrl, aChromeMask, aInitialWidth,
aInitialHeight, false, aOpeningTab, aOpenerWindow,
getter_AddRefs(newWindow));
aInitialHeight, false, getter_AddRefs(newWindow));
newWindow.forget(aResult);
if (NS_SUCCEEDED(rv)) {
@ -553,7 +550,6 @@ static bool CheckForFullscreenWindow() {
nsresult nsAppShellService::JustCreateTopWindow(
nsIAppWindow* aParent, nsIURI* aUrl, uint32_t aChromeMask,
int32_t aInitialWidth, int32_t aInitialHeight, bool aIsHiddenWindow,
nsIRemoteTab* aOpeningTab, mozIDOMWindowProxy* aOpenerWindow,
AppWindow** aResult) {
*aResult = nullptr;
NS_ENSURE_STATE(!mXPCOMWillShutDown);
@ -678,9 +674,9 @@ nsresult nsAppShellService::JustCreateTopWindow(
widgetInitData.mRTL = LocaleService::GetInstance()->IsAppLocaleRTL();
nsresult rv = window->Initialize(
parent, center ? aParent : nullptr, aInitialWidth, aInitialHeight,
aIsHiddenWindow, aOpeningTab, aOpenerWindow, widgetInitData);
nsresult rv =
window->Initialize(parent, center ? aParent : nullptr, aInitialWidth,
aInitialHeight, aIsHiddenWindow, widgetInitData);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -39,8 +39,6 @@ class nsAppShellService final : public nsIAppShellService, public nsIObserver {
nsresult JustCreateTopWindow(nsIAppWindow* aParent, nsIURI* aUrl,
uint32_t aChromeMask, int32_t aInitialWidth,
int32_t aInitialHeight, bool aIsHiddenWindow,
nsIRemoteTab* aOpeningTab,
mozIDOMWindowProxy* aOpenerWindow,
mozilla::AppWindow** aResult);
uint32_t CalculateWindowZLevel(nsIAppWindow* aParent, uint32_t aChromeMask);

View File

@ -14,6 +14,7 @@
#include "nsIDOMChromeWindow.h"
#include "nsIBrowserDOMWindow.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIOpenWindowInfo.h"
#include "nsIPrompt.h"
#include "nsIAuthPrompt.h"
#include "nsIXULBrowserWindow.h"
@ -616,16 +617,14 @@ NS_IMETHODIMP nsContentTreeOwner::SetTitle(const nsAString& aTitle) {
//*****************************************************************************
NS_IMETHODIMP
nsContentTreeOwner::ProvideWindow(
mozIDOMWindowProxy* aParent, uint32_t aChromeFlags, bool aCalledFromJS,
bool aWidthSpecified, nsIURI* aURI, const nsAString& aName,
const nsACString& aFeatures, bool aForceNoOpener, bool aForceNoReferrer,
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
nsIOpenWindowInfo* aOpenWindowInfo, uint32_t aChromeFlags,
bool aCalledFromJS, bool aWidthSpecified, nsIURI* aURI,
const nsAString& aName, const nsACString& aFeatures, bool aForceNoOpener,
bool aForceNoReferrer, nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
BrowsingContext** aReturn) {
NS_ENSURE_ARG_POINTER(aParent);
NS_ENSURE_ARG_POINTER(aOpenWindowInfo);
auto* parentWin = nsPIDOMWindowOuter::From(aParent);
dom::BrowsingContext* parent =
parentWin ? parentWin->GetBrowsingContext() : nullptr;
RefPtr<dom::BrowsingContext> parent = aOpenWindowInfo->GetParent();
*aReturn = nullptr;
@ -634,9 +633,9 @@ nsContentTreeOwner::ProvideWindow(
return NS_OK;
}
nsCOMPtr<nsIDocShell> docshell = parent->GetDocShell();
#ifdef DEBUG
nsCOMPtr<nsIWebNavigation> parentNav = do_GetInterface(aParent);
nsCOMPtr<nsIDocShellTreeOwner> parentOwner = do_GetInterface(parentNav);
nsCOMPtr<nsIDocShellTreeOwner> parentOwner = do_GetInterface(docshell);
NS_ASSERTION(
SameCOMIdentity(parentOwner, static_cast<nsIDocShellTreeOwner*>(this)),
"Parent from wrong docshell tree?");
@ -645,7 +644,6 @@ nsContentTreeOwner::ProvideWindow(
// If aParent is inside an <iframe mozbrowser> and this isn't a request to
// open a modal-type window, we're going to create a new <iframe mozbrowser>
// and return its window here.
nsCOMPtr<nsIDocShell> docshell = do_GetInterface(aParent);
if (docshell && docshell->GetIsInMozBrowser() &&
!(aChromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
@ -680,7 +678,7 @@ nsContentTreeOwner::ProvideWindow(
}
int32_t openLocation = nsWindowWatcher::GetWindowOpenLocation(
parentWin, aChromeFlags, aCalledFromJS, aWidthSpecified);
parent->GetDOMWindow(), aChromeFlags, aCalledFromJS, aWidthSpecified);
if (openLocation != nsIBrowserDOMWindow::OPEN_NEWTAB &&
openLocation != nsIBrowserDOMWindow::OPEN_CURRENTWINDOW) {
@ -724,8 +722,9 @@ nsContentTreeOwner::ProvideWindow(
// ourselves.
RefPtr<NullPrincipal> nullPrincipal =
NullPrincipal::CreateWithoutOriginAttributes();
return browserDOMWin->CreateContentWindow(
aURI, aParent, openLocation, flags, nullPrincipal, nullptr, aReturn);
return browserDOMWin->CreateContentWindow(aURI, aOpenWindowInfo,
openLocation, flags,
nullPrincipal, nullptr, aReturn);
}
}

View File

@ -36,19 +36,13 @@ interface nsIAppShellService : nsISupports
* tag in the XUL. Set to NS_SIZETOCONTENT to force
* the window to wrap to its contents.
* @param aInitialHeight like aInitialWidth, but subtly different.
* @param aOpeningTab The RemoteTab that requested that this window be opened.
* Can be left null.
* @param aOpenerWindow The Window Proxy which requested that this window be opened.
* Can be left null.
*/
const long SIZE_TO_CONTENT = -1;
nsIAppWindow createTopLevelWindow(in nsIAppWindow aParent,
in nsIURI aUrl,
in uint32_t aChromeMask,
in long aInitialWidth,
in long aInitialHeight,
in nsIRemoteTab aOpeningTab,
in mozIDOMWindowProxy aOpenerWindow);
in long aInitialHeight);
/**
* This is the constructor for creating an invisible DocShell.

View File

@ -23,6 +23,7 @@ interface nsIDocShellTreeItem;
interface nsIXULBrowserWindow;
interface nsIRemoteTab;
interface mozIDOMWindowProxy;
interface nsIOpenWindowInfo;
native LiveResizeListenerArray(nsTArray<RefPtr<mozilla::LiveResizeListener>>);
@ -126,17 +127,12 @@ interface nsIAppWindow : nsISupports
/**
* Create a new window.
* @param aChromeFlags see nsIWebBrowserChrome
* @param aOpeningTab the RemoteTab that requested this new window be opened.
* Can be left null.
* @param aOpener The window which is requesting that this new window be opened.
* @param aNextRemoteTabId The integer ID of the next remote tab actor to use.
* 0 means there is no next remote tab actor to use.
* @param aOpenWindowInfo information about the request for a content window
* to be opened. Will be null for non-content loads.
* @return the newly minted window
*/
nsIAppWindow createNewWindow(in int32_t aChromeFlags,
in nsIRemoteTab aOpeningTab,
in mozIDOMWindowProxy aOpener,
in unsigned long long aNextRemoteTabId);
in nsIOpenWindowInfo aOpenWindowInfo);
attribute nsIXULBrowserWindow XULBrowserWindow;
@ -179,9 +175,8 @@ interface nsIAppWindow : nsISupports
in int32_t shellItemHeight);
/**
* If the window was opened as a content window by script, this will return the
* integer ID of the next RemoteTab actor to use.
* If the window was opened as a content window, this will return the initial
* nsIOpenWindowInfo to use.
*/
[noscript]
readonly attribute unsigned long long nextRemoteTabId;
readonly attribute nsIOpenWindowInfo initialOpenWindowInfo;
};