Bug 1616353 - Part 7.5: Pass nsOpenWindowInfo through Geckoview, r=geckoview-reviewers,esawin,agi

The interface changes which GeckoViewNavigation.jsm is being updated for are
performed in earlier parts. This patch just covers the required changes to
frontend code to propagate this information down to the nsFrameLoader when it is
created.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2020-04-07 21:39:39 +00:00
parent b99cf8f798
commit 0799ca4e5c

View File

@ -93,8 +93,8 @@ class GeckoViewNavigation extends GeckoViewModule {
}
// There may be a GeckoViewNavigation module in another window waiting for
// us to create a browser so it can call presetOpenerWindow(), so allow them
// to do that now.
// us to create a browser so it can set openWindowInfo, so allow them to do
// that now.
Services.obs.notifyObservers(this.window, "geckoview-window-created");
}
@ -282,7 +282,7 @@ class GeckoViewNavigation extends GeckoViewModule {
});
}
waitAndSetupWindow(aSessionId, { opener, nextRemoteTabId, forceNotRemote }) {
waitAndSetupWindow(aSessionId, aOpenWindowInfo) {
if (!aSessionId) {
return Promise.resolve(null);
}
@ -294,17 +294,13 @@ class GeckoViewNavigation extends GeckoViewModule {
aTopic === "geckoview-window-created" &&
aSubject.name === aSessionId
) {
if (nextRemoteTabId) {
aSubject.browser.setAttribute(
"nextRemoteTabId",
nextRemoteTabId.toString()
);
}
// This value will be read by nsFrameLoader while it is being initialized.
aSubject.browser.openWindowInfo = aOpenWindowInfo;
if (opener) {
aSubject.browser.presetOpenerWindow(opener);
}
if (forceNotRemote && aSubject.browser.hasAttribute("remote")) {
if (
!aOpenWindowInfo.isRemote &&
aSubject.browser.hasAttribute("remote")
) {
// We cannot start in remote mode when we have an opener.
aSubject.browser.setAttribute("remote", "false");
aSubject.browser.removeAttribute("remoteType");
@ -320,7 +316,7 @@ class GeckoViewNavigation extends GeckoViewModule {
});
}
handleNewSession(aUri, aOpener, aWhere, aFlags, aNextRemoteTabId) {
handleNewSession(aUri, aOpenWindowInfo, aWhere, aFlags) {
debug`handleNewSession: uri=${aUri && aUri.spec}
where=${aWhere} flags=${aFlags}`;
@ -333,24 +329,11 @@ class GeckoViewNavigation extends GeckoViewModule {
uri: aUri ? aUri.displaySpec : "",
};
// If we have an opener, that means that the caller is expecting access
// to the nsIDOMWindow of the opened tab right away. For e10s windows,
// this means forcing the newly opened browser to be non-remote so that
// we can hand back the nsIDOMWindow. The XULBrowserWindow.shouldLoadURI
// will do the job of shuttling off the newly opened browser to run in
// the right process once it starts loading a URI.
const forceNotRemote = !!aOpener;
let browser = undefined;
this.eventDispatcher
.sendRequestForResult(message)
.then(sessionId => {
return this.waitAndSetupWindow(sessionId, {
opener:
aFlags & Ci.nsIBrowserDOMWindow.OPEN_NO_OPENER ? null : aOpener,
nextRemoteTabId: aNextRemoteTabId,
forceNotRemote,
});
return this.waitAndSetupWindow(sessionId, aOpenWindowInfo);
})
.then(
window => {
@ -371,7 +354,7 @@ class GeckoViewNavigation extends GeckoViewModule {
// nsIBrowserDOMWindow.
createContentWindow(
aUri,
aOpener,
aOpenWindowInfo,
aWhere,
aFlags,
aTriggeringPrincipal,
@ -395,7 +378,13 @@ class GeckoViewNavigation extends GeckoViewModule {
return null;
}
const browser = this.handleNewSession(aUri, aOpener, aWhere, aFlags, null);
const browser = this.handleNewSession(
aUri,
aOpenWindowInfo,
aWhere,
aFlags,
null
);
if (!browser) {
Components.returnCode = Cr.NS_ERROR_ABORT;
return null;
@ -405,17 +394,9 @@ class GeckoViewNavigation extends GeckoViewModule {
}
// nsIBrowserDOMWindow.
createContentWindowInFrame(
aUri,
aParams,
aWhere,
aFlags,
aNextRemoteTabId,
aName
) {
createContentWindowInFrame(aUri, aParams, aWhere, aFlags, aName) {
debug`createContentWindowInFrame: uri=${aUri && aUri.spec}
where=${aWhere} flags=${aFlags}
nextRemoteTabId=${aNextRemoteTabId}
name=${aName}`;
if (
@ -435,10 +416,9 @@ class GeckoViewNavigation extends GeckoViewModule {
const browser = this.handleNewSession(
aUri,
null,
aParams.openWindowInfo,
aWhere,
aFlags,
aNextRemoteTabId
aFlags
);
if (!browser) {
Components.returnCode = Cr.NS_ERROR_ABORT;
@ -450,13 +430,12 @@ class GeckoViewNavigation extends GeckoViewModule {
handleOpenUri(
aUri,
aOpener,
aOpenWindowInfo,
aWhere,
aFlags,
aTriggeringPrincipal,
aCsp,
aReferrerInfo,
aNextRemoteTabId
aReferrerInfo
) {
debug`handleOpenUri: uri=${aUri && aUri.spec}
where=${aWhere} flags=${aFlags}`;
@ -483,7 +462,7 @@ class GeckoViewNavigation extends GeckoViewModule {
) {
browser = this.handleNewSession(
aUri,
aOpener,
aOpenWindowInfo,
aWhere,
aFlags,
aTriggeringPrincipal
@ -505,15 +484,14 @@ class GeckoViewNavigation extends GeckoViewModule {
}
// nsIBrowserDOMWindow.
openURI(aUri, aOpener, aWhere, aFlags, aTriggeringPrincipal, aCsp) {
openURI(aUri, aOpenWindowInfo, aWhere, aFlags, aTriggeringPrincipal, aCsp) {
const browser = this.handleOpenUri(
aUri,
aOpener,
aOpenWindowInfo,
aWhere,
aFlags,
aTriggeringPrincipal,
aCsp,
null,
null
);
return browser && browser.browsingContext;
@ -523,13 +501,12 @@ class GeckoViewNavigation extends GeckoViewModule {
openURIInFrame(aUri, aParams, aWhere, aFlags, aNextRemoteTabId, aName) {
const browser = this.handleOpenUri(
aUri,
null,
aParams.openWindowInfo,
aWhere,
aFlags,
aParams.triggeringPrincipal,
aParams.csp,
aParams.referrerInfo,
aNextRemoteTabId
aParams.referrerInfo
);
return browser;
}