Bug 1566833 - Update to use ReferrerInfo in nsIWebBrowserChrome3 r=Gijs,snorp

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Thomas Nguyen 2019-07-29 10:13:45 +00:00
Родитель 53c3e8c0ce
Коммит 180aa6b0a1
11 изменённых файлов: 45 добавлений и 49 удалений

Просмотреть файл

@ -5452,7 +5452,7 @@ var XULBrowserWindow = {
shouldLoadURI(
aDocShell,
aURI,
aReferrer,
aReferrerInfo,
aHasPostData,
aTriggeringPrincipal,
aCsp
@ -5474,14 +5474,14 @@ var XULBrowserWindow = {
return true;
}
if (!E10SUtils.shouldLoadURI(aDocShell, aURI, aReferrer, aHasPostData)) {
if (!E10SUtils.shouldLoadURI(aDocShell, aURI, aHasPostData)) {
// XXX: Do we want to complain if we have post data but are still
// redirecting the load? Perhaps a telemetry probe? Theoretically we
// shouldn't do this, as it throws out data. See bug 1348018.
E10SUtils.redirectLoad(
aDocShell,
aURI,
aReferrer,
aReferrerInfo,
aTriggeringPrincipal,
false,
null,

Просмотреть файл

@ -52,16 +52,16 @@ var WebBrowserChrome = {
shouldLoadURI(
aDocShell,
aURI,
aReferrer,
aReferrerInfo,
aHasPostData,
aTriggeringPrincipal,
aCsp
) {
if (!E10SUtils.shouldLoadURI(aDocShell, aURI, aReferrer, aHasPostData)) {
if (!E10SUtils.shouldLoadURI(aDocShell, aURI, aHasPostData)) {
E10SUtils.redirectLoad(
aDocShell,
aURI,
aReferrer,
aReferrerInfo,
aTriggeringPrincipal,
false,
null,
@ -83,7 +83,7 @@ var WebBrowserChrome = {
reloadInFreshProcess(
aDocShell,
aURI,
aReferrer,
aReferrerInfo,
aTriggeringPrincipal,
aLoadFlags,
aCsp
@ -91,7 +91,7 @@ var WebBrowserChrome = {
E10SUtils.redirectLoad(
aDocShell,
aURI,
aReferrer,
aReferrerInfo,
aTriggeringPrincipal,
true,
aLoadFlags,

Просмотреть файл

@ -9538,14 +9538,10 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
nsCOMPtr<nsIWebBrowserChrome3> browserChrome3 = do_GetInterface(mTreeOwner);
if (browserChrome3) {
bool shouldLoad;
nsCOMPtr<nsIURI> referrer;
nsIReferrerInfo* referrerInfo = aLoadState->GetReferrerInfo();
if (referrerInfo) {
referrerInfo->GetOriginalReferrer(getter_AddRefs(referrer));
}
rv = browserChrome3->ShouldLoadURI(
this, aLoadState->URI(), referrer, !!aLoadState->PostDataStream(),
aLoadState->TriggeringPrincipal(), aLoadState->Csp(), &shouldLoad);
this, aLoadState->URI(), aLoadState->GetReferrerInfo(),
!!aLoadState->PostDataStream(), aLoadState->TriggeringPrincipal(),
aLoadState->Csp(), &shouldLoad);
if (NS_SUCCEEDED(rv) && !shouldLoad) {
return NS_OK;
}

Просмотреть файл

@ -9354,13 +9354,9 @@ bool nsContentUtils::AttemptLargeAllocationLoad(nsIHttpChannel* aChannel) {
NS_ENSURE_SUCCESS(rv, false);
NS_ENSURE_TRUE(uri, false);
nsCOMPtr<nsIURI> referrer;
nsCOMPtr<nsIReferrerInfo> referrerInfo;
rv = aChannel->GetReferrerInfo(getter_AddRefs(referrerInfo));
NS_ENSURE_SUCCESS(rv, false);
if (referrerInfo) {
referrer = referrerInfo->GetComputedReferrer();
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
nsCOMPtr<nsIPrincipal> triggeringPrincipal = loadInfo->TriggeringPrincipal();
@ -9382,8 +9378,9 @@ bool nsContentUtils::AttemptLargeAllocationLoad(nsIHttpChannel* aChannel) {
// Actually perform the cross process load
bool reloadSucceeded = false;
rv = wbc3->ReloadInFreshProcess(docShell, uri, referrer, triggeringPrincipal,
webnavLoadFlags, csp, &reloadSucceeded);
rv = wbc3->ReloadInFreshProcess(docShell, uri, referrerInfo,
triggeringPrincipal, webnavLoadFlags, csp,
&reloadSucceeded);
NS_ENSURE_SUCCESS(rv, false);
return reloadSucceeded;

Просмотреть файл

@ -104,18 +104,18 @@ class GeckoViewNavigationChild extends GeckoViewChildModule {
shouldLoadURI(
aDocShell,
aURI,
aReferrer,
aReferrerInfo,
aHasPostData,
aTriggeringPrincipal,
aCsp
) {
debug`shouldLoadURI ${aURI.displaySpec}`;
if (!E10SUtils.shouldLoadURI(aDocShell, aURI, aReferrer, aHasPostData)) {
if (!E10SUtils.shouldLoadURI(aDocShell, aURI, aHasPostData)) {
E10SUtils.redirectLoad(
aDocShell,
aURI,
aReferrer,
aReferrerInfo,
aTriggeringPrincipal,
false,
null,
@ -139,7 +139,7 @@ class GeckoViewNavigationChild extends GeckoViewChildModule {
reloadInFreshProcess(
aDocShell,
aURI,
aReferrer,
aReferrerInfo,
aTriggeringPrincipal,
aLoadFlags,
aCsp
@ -148,7 +148,7 @@ class GeckoViewNavigationChild extends GeckoViewChildModule {
E10SUtils.redirectLoad(
aDocShell,
aURI,
aReferrer,
aReferrerInfo,
aTriggeringPrincipal,
true,
aLoadFlags,

Просмотреть файл

@ -194,7 +194,7 @@ class GeckoViewNavigation extends GeckoViewModule {
const {
uri,
flags,
referrer,
referrerInfo,
triggeringPrincipal,
} = aMsg.data.loadOptions;
@ -202,7 +202,7 @@ class GeckoViewNavigation extends GeckoViewModule {
this.browser.loadURI(uri, {
flags,
referrerInfo: createReferrerInfo(referrer),
referrerInfo: E10SUtils.deserializeReferrerInfo(referrerInfo),
triggeringPrincipal: E10SUtils.deserializePrincipal(
triggeringPrincipal
),

Просмотреть файл

@ -10,6 +10,7 @@ interface nsIInputStream;
interface nsIRunnable;
interface nsIPrincipal;
interface nsIContentSecurityPolicy;
interface nsIReferrerInfo;
webidl Node;
@ -45,8 +46,8 @@ interface nsIWebBrowserChrome3 : nsIWebBrowserChrome2
* The docshell performing the load.
* @param aURI
* The URI being loaded.
* @param aReferrer
* The referrer of the load.
* @param aReferrerInfo
* The referrerInfo of the load.
* @param aHasPostData
* True if the load which is being asked about has associated post data
* which would be discarded if the load was redirected across process
@ -59,7 +60,7 @@ interface nsIWebBrowserChrome3 : nsIWebBrowserChrome2
*/
bool shouldLoadURI(in nsIDocShell aDocShell,
in nsIURI aURI,
in nsIURI aReferrer,
in nsIReferrerInfo aReferrerInfo,
in boolean aHasPostData,
in nsIPrincipal aTriggeringPrincipal,
in nsIContentSecurityPolicy aCsp);
@ -78,7 +79,7 @@ interface nsIWebBrowserChrome3 : nsIWebBrowserChrome2
*/
bool reloadInFreshProcess(in nsIDocShell aDocShell,
in nsIURI aURI,
in nsIURI aReferrer,
in nsIReferrerInfo aReferrerInfo,
in nsIPrincipal aTriggeringPrincipal,
in uint32_t aLoadFlags,
in nsIContentSecurityPolicy aCsp);

Просмотреть файл

@ -346,7 +346,7 @@ var WebBrowserChrome = {
);
},
shouldLoadURI(docShell, URI, referrer, hasPostData, triggeringPrincipal) {
shouldLoadURI(docShell, URI, referrerInfo, hasPostData, triggeringPrincipal) {
return true;
},
@ -359,7 +359,7 @@ var WebBrowserChrome = {
reloadInFreshProcess(
docShell,
URI,
referrer,
referrerInfo,
triggeringPrincipal,
loadFlags
) {

Просмотреть файл

@ -614,7 +614,7 @@ var E10SUtils = {
);
},
shouldLoadURI(aDocShell, aURI, aReferrer, aHasPostData) {
shouldLoadURI(aDocShell, aURI, aHasPostData) {
let remoteSubframes = aDocShell.useRemoteSubframes;
// Inner frames should always load in the current process
@ -699,7 +699,7 @@ var E10SUtils = {
redirectLoad(
aDocShell,
aURI,
aReferrer,
aReferrerInfo,
aTriggeringPrincipal,
aFreshProcess,
aFlags,
@ -714,7 +714,7 @@ var E10SUtils = {
loadOptions: {
uri: aURI.spec,
flags: aFlags || Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
referrer: aReferrer ? aReferrer.spec : null,
referrerInfo: this.serializeReferrerInfo(aReferrerInfo),
triggeringPrincipal: this.serializePrincipal(
aTriggeringPrincipal ||
Services.scriptSecurityManager.createNullPrincipal({})

Просмотреть файл

@ -361,16 +361,16 @@ NS_IMETHODIMP nsContentTreeOwner::OnBeforeLinkTraversal(
}
NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURI(
nsIDocShell* aDocShell, nsIURI* aURI, nsIURI* aReferrer, bool aHasPostData,
nsIPrincipal* aTriggeringPrincipal, nsIContentSecurityPolicy* aCsp,
bool* _retval) {
nsIDocShell* aDocShell, nsIURI* aURI, nsIReferrerInfo* aReferrerInfo,
bool aHasPostData, nsIPrincipal* aTriggeringPrincipal,
nsIContentSecurityPolicy* aCsp, bool* _retval) {
NS_ENSURE_STATE(mXULWindow);
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
if (xulBrowserWindow)
return xulBrowserWindow->ShouldLoadURI(aDocShell, aURI, aReferrer,
return xulBrowserWindow->ShouldLoadURI(aDocShell, aURI, aReferrerInfo,
aHasPostData, aTriggeringPrincipal,
aCsp, _retval);
@ -386,7 +386,7 @@ NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURIInThisProcess(nsIURI* aURI,
}
NS_IMETHODIMP nsContentTreeOwner::ReloadInFreshProcess(
nsIDocShell* aDocShell, nsIURI* aURI, nsIURI* aReferrer,
nsIDocShell* aDocShell, nsIURI* aURI, nsIReferrerInfo* aReferrerInfo,
nsIPrincipal* aTriggeringPrincipal, uint32_t aLoadFlags,
nsIContentSecurityPolicy* aCsp, bool* aRetVal) {
NS_WARNING("Cannot reload in fresh process from a nsContentTreeOwner!");

Просмотреть файл

@ -15,6 +15,8 @@ interface nsIRemoteTab;
interface nsIPrincipal;
interface mozIDOMWindowProxy;
interface nsIContentSecurityPolicy;
interface nsIReferrerInfo;
webidl Element;
webidl Node;
@ -54,8 +56,8 @@ interface nsIXULBrowserWindow : nsISupports
* The docshell performing the load.
* @param aURI
* The URI being loaded.
* @param aReferrer
* The referrer of the load.
* @param aReferrerInfo
* The referrerInfo of the load.
* @param aHasPostData
* True if the load which is being asked about has associated post data
* which would be discarded if the load was redirected across process
@ -66,11 +68,11 @@ interface nsIXULBrowserWindow : nsISupports
* The CSP to be used for that load. That is the CSP that e.g. upgrades
* the load to HTTPS in case upgrade-insecure-requests is set
*/
bool shouldLoadURI(in nsIDocShell aDocShell,
in nsIURI aURI,
in nsIURI aReferrer,
in boolean aHasPostData,
in nsIPrincipal aTriggeringPrincipal,
bool shouldLoadURI(in nsIDocShell aDocShell,
in nsIURI aURI,
in nsIReferrerInfo aReferrerInfo,
in boolean aHasPostData,
in nsIPrincipal aTriggeringPrincipal,
in nsIContentSecurityPolicy aCsp);
/**
* Show/hide a tooltip (when the user mouses over a link, say).