Bug 1545255 - [1.0] Use ReferrerInfo when loading URIs in GeckoView. r=snorp

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Eugen Sawin 2019-05-03 22:08:29 +00:00
Родитель a1e07570e5
Коммит d1db7a80be
1 изменённых файлов: 29 добавлений и 3 удалений

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

@ -15,6 +15,28 @@ XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
});
XPCOMUtils.defineLazyGetter(this, "ReferrerInfo", () =>
Components.Constructor(
"@mozilla.org/referrer-info;1",
"nsIReferrerInfo",
"init"));
// Create default ReferrerInfo instance for the given referrer URI string.
const createReferrerInfo = aReferrer => {
let referrerUri;
try {
referrerUri = Services.io.newURI(aReferrer);
} catch (ignored) {
}
return new ReferrerInfo(
Ci.nsIHttpChannel.REFERRER_POLICY_UNSET,
true,
referrerUri
);
};
// Handles navigation requests between Gecko and a GeckoView.
// Handles GeckoView:GoBack and :GoForward requests dispatched by
// GeckoView.goBack and .goForward.
@ -105,7 +127,7 @@ class GeckoViewNavigation extends GeckoViewModule {
this.browser.loadURI(parsedUri ? parsedUri.spec : uri, {
flags: navFlags,
referrerURI: referrer,
referrerInfo: createReferrerInfo(referrer),
triggeringPrincipal,
});
break;
@ -133,7 +155,7 @@ class GeckoViewNavigation extends GeckoViewModule {
this.browser.loadURI(uri, {
flags,
referrerURI: referrer,
referrerInfo: createReferrerInfo(referrer),
triggeringPrincipal: E10SUtils.deserializePrincipal(triggeringPrincipal),
});
break;
@ -272,7 +294,11 @@ class GeckoViewNavigation extends GeckoViewModule {
// Should we throw?
return null;
}
browser.loadURI(aUri.spec, null, null, null, null, aTriggeringPrincipal, aCsp);
browser.loadURI(aUri.spec, {
triggeringPrincipal: aTriggeringPrincipal,
csp: aCsp,
});
return browser;
}