mirror of
https://github.com/ManchildProductions/UXP-Fixed.git
synced 2026-07-21 03:48:43 +00:00
Bug 1329032 - Extend loadURIWithOptions by a triggeringPrincipal (without an hard e10s)
This commit is contained in:
@@ -204,6 +204,9 @@ ContentRestoreInternal.prototype = {
|
||||
: Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT);
|
||||
let postData = loadArguments.postData ?
|
||||
Utils.makeInputStream(loadArguments.postData) : null;
|
||||
let triggeringPrincipal = loadArguments.triggeringPrincipal
|
||||
? Utils.deserializePrincipal(loadArguments.triggeringPrincipal)
|
||||
: null;
|
||||
|
||||
if (loadArguments.userContextId) {
|
||||
webNavigation.setOriginAttributesBeforeLoading({ userContextId: loadArguments.userContextId });
|
||||
@@ -211,7 +214,7 @@ ContentRestoreInternal.prototype = {
|
||||
|
||||
webNavigation.loadURIWithOptions(loadArguments.uri, loadArguments.flags,
|
||||
referrer, referrerPolicy, postData,
|
||||
null, null);
|
||||
null, null, triggeringPrincipal);
|
||||
} else if (tabData.userTypedValue && tabData.userTypedClear) {
|
||||
// If the user typed a URL into the URL bar and hit enter right before
|
||||
// we crashed, we want to start loading that page again. A non-zero
|
||||
|
||||
@@ -8,6 +8,7 @@ const { Ci, Cu, Cr } = require("chrome");
|
||||
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const Services = require("Services");
|
||||
const { NetUtil } = require("resource://gre/modules/NetUtil.jsm");
|
||||
const { Utils } = require("resource://gre/modules/sessionstore/Utils.jsm");
|
||||
|
||||
function readInputStreamToString(stream) {
|
||||
return NetUtil.readInputStreamToString(stream, stream.available());
|
||||
@@ -61,11 +62,11 @@ BrowserElementWebNavigation.prototype = {
|
||||
// No equivalent in the current BrowserElement API
|
||||
this.loadURIWithOptions(uri, flags, referrer,
|
||||
Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT,
|
||||
postData, headers, null);
|
||||
postData, headers, null, null);
|
||||
},
|
||||
|
||||
loadURIWithOptions(uri, flags, referrer, referrerPolicy, postData, headers,
|
||||
baseURI) {
|
||||
baseURI, triggeringPrincipal) {
|
||||
// No equivalent in the current BrowserElement API
|
||||
this._sendMessage("WebNavigation:LoadURI", {
|
||||
uri,
|
||||
@@ -75,6 +76,9 @@ BrowserElementWebNavigation.prototype = {
|
||||
postData: postData ? readInputStreamToString(postData) : null,
|
||||
headers: headers ? readInputStreamToString(headers) : null,
|
||||
baseURI: baseURI ? baseURI.spec : null,
|
||||
triggeringPrincipal: triggeringPrincipal
|
||||
? Utils.serializePrincipal(triggeringPrincipal)
|
||||
: null,
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -4732,7 +4732,7 @@ nsDocShell::LoadURI(const char16_t* aURI,
|
||||
{
|
||||
return LoadURIWithOptions(aURI, aLoadFlags, aReferringURI,
|
||||
mozilla::net::RP_Default, aPostStream,
|
||||
aHeaderStream, nullptr);
|
||||
aHeaderStream, nullptr, nullptr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -4742,7 +4742,8 @@ nsDocShell::LoadURIWithOptions(const char16_t* aURI,
|
||||
uint32_t aReferrerPolicy,
|
||||
nsIInputStream* aPostStream,
|
||||
nsIInputStream* aHeaderStream,
|
||||
nsIURI* aBaseURI)
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aTriggeringPrincipal)
|
||||
{
|
||||
NS_ASSERTION((aLoadFlags & 0xf) == 0, "Unexpected flags");
|
||||
|
||||
@@ -4861,6 +4862,7 @@ nsDocShell::LoadURIWithOptions(const char16_t* aURI,
|
||||
loadInfo->SetReferrerPolicy(aReferrerPolicy);
|
||||
loadInfo->SetHeadersStream(aHeaderStream);
|
||||
loadInfo->SetBaseURI(aBaseURI);
|
||||
loadInfo->SetTriggeringPrincipal(aTriggeringPrincipal);
|
||||
loadInfo->SetForceAllowDataURI(forceAllowDataURI);
|
||||
|
||||
if (fixupInfo) {
|
||||
@@ -10606,7 +10608,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
||||
}
|
||||
bool shouldLoad;
|
||||
rv = browserChrome3->ShouldLoadURI(this, uriForShouldLoadCheck, aReferrer,
|
||||
&shouldLoad);
|
||||
aTriggeringPrincipal, &shouldLoad);
|
||||
if (NS_SUCCEEDED(rv) && !shouldLoad) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ interface nsIDOMDocument;
|
||||
interface nsIInputStream;
|
||||
interface nsISHistory;
|
||||
interface nsIURI;
|
||||
interface nsIPrincipal;
|
||||
|
||||
/**
|
||||
* The nsIWebNavigation interface defines an interface for navigating the web.
|
||||
@@ -288,14 +289,20 @@ interface nsIWebNavigation : nsISupports
|
||||
* that at present this argument is only used with view-source aURIs
|
||||
* and cannot be used to resolve aURI.
|
||||
* This parameter is optional and may be null.
|
||||
* @param aTriggeringPrincipal
|
||||
* The principal that initiated the load of aURI. If omitted docShell
|
||||
* tries to create a codeBasePrincipal from aReferrer if not null. If
|
||||
* aReferrer is also null docShell peforms a load using the
|
||||
* SystemPrincipal as the triggeringPrincipal.
|
||||
*/
|
||||
void loadURIWithOptions(in wstring aURI,
|
||||
in unsigned long aLoadFlags,
|
||||
in nsIURI aReferrer,
|
||||
in unsigned long aReferrerPolicy,
|
||||
in nsIInputStream aPostData,
|
||||
in nsIInputStream aHeaders,
|
||||
in nsIURI aBaseURI);
|
||||
void loadURIWithOptions(in wstring aURI,
|
||||
in unsigned long aLoadFlags,
|
||||
in nsIURI aReferrer,
|
||||
in unsigned long aReferrerPolicy,
|
||||
in nsIInputStream aPostData,
|
||||
in nsIInputStream aHeaders,
|
||||
in nsIURI aBaseURI,
|
||||
[optional] in nsIPrincipal aTriggeringPrincipal);
|
||||
|
||||
/**
|
||||
* Tells the Object to reload the current page. There may be cases where the
|
||||
|
||||
@@ -1582,7 +1582,8 @@ nsSHistory::LoadURIWithOptions(const char16_t* aURI,
|
||||
uint32_t aReferrerPolicy,
|
||||
nsIInputStream* aPostStream,
|
||||
nsIInputStream* aExtraHeaderStream,
|
||||
nsIURI* aBaseURI)
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aTriggeringPrincipal)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -9776,9 +9776,13 @@ nsContentUtils::AttemptLargeAllocationLoad(nsIHttpChannel* aChannel)
|
||||
rv = aChannel->GetReferrer(getter_AddRefs(referrer));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal = loadInfo->TriggeringPrincipal();
|
||||
|
||||
// Actually perform the cross process load
|
||||
bool reloadSucceeded = false;
|
||||
rv = wbc3->ReloadInFreshProcess(docShell, uri, referrer, &reloadSucceeded);
|
||||
rv = wbc3->ReloadInFreshProcess(docShell, uri, referrer,
|
||||
triggeringPrincipal, &reloadSucceeded);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
return reloadSucceeded;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
interface nsIDocShell;
|
||||
interface nsIInputStream;
|
||||
interface nsIPrincipal;
|
||||
|
||||
/**
|
||||
* nsIWebBrowserChrome3 is an extension to nsIWebBrowserChrome2.
|
||||
@@ -43,10 +44,13 @@ interface nsIWebBrowserChrome3 : nsIWebBrowserChrome2
|
||||
* The URI being loaded.
|
||||
* @param aReferrer
|
||||
* The referrer of the load.
|
||||
* @param aTriggeringPrincipal
|
||||
* The principal that initiated the load of aURI.
|
||||
*/
|
||||
bool shouldLoadURI(in nsIDocShell aDocShell,
|
||||
in nsIURI aURI,
|
||||
in nsIURI aReferrer);
|
||||
in nsIURI aReferrer,
|
||||
in nsIPrincipal aTriggeringPrincipal);
|
||||
|
||||
/**
|
||||
* Attempts to load the currently loaded page into a fresh process to increase
|
||||
@@ -57,5 +61,6 @@ interface nsIWebBrowserChrome3 : nsIWebBrowserChrome2
|
||||
*/
|
||||
bool reloadInFreshProcess(in nsIDocShell aDocShell,
|
||||
in nsIURI aURI,
|
||||
in nsIURI aReferrer);
|
||||
in nsIURI aReferrer,
|
||||
in nsIPrincipal aTriggeringPrincipal);
|
||||
};
|
||||
|
||||
@@ -654,13 +654,14 @@ nsWebBrowser::LoadURIWithOptions(const char16_t* aURI, uint32_t aLoadFlags,
|
||||
uint32_t aReferrerPolicy,
|
||||
nsIInputStream* aPostDataStream,
|
||||
nsIInputStream* aExtraHeaderStream,
|
||||
nsIURI* aBaseURI)
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aTriggeringPrincipal)
|
||||
{
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
|
||||
return mDocShellAsNav->LoadURIWithOptions(
|
||||
aURI, aLoadFlags, aReferringURI, aReferrerPolicy, aPostDataStream,
|
||||
aExtraHeaderStream, aBaseURI);
|
||||
aExtraHeaderStream, aBaseURI, aTriggeringPrincipal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
@@ -390,6 +390,7 @@ NS_IMETHODIMP nsContentTreeOwner::OnBeforeLinkTraversal(const nsAString &origina
|
||||
NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURI(nsIDocShell *aDocShell,
|
||||
nsIURI *aURI,
|
||||
nsIURI *aReferrer,
|
||||
nsIPrincipal* aTriggeringPrincipal,
|
||||
bool *_retval)
|
||||
{
|
||||
NS_ENSURE_STATE(mXULWindow);
|
||||
@@ -398,7 +399,8 @@ NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURI(nsIDocShell *aDocShell,
|
||||
mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
|
||||
|
||||
if (xulBrowserWindow)
|
||||
return xulBrowserWindow->ShouldLoadURI(aDocShell, aURI, aReferrer, _retval);
|
||||
return xulBrowserWindow->ShouldLoadURI(aDocShell, aURI, aReferrer,
|
||||
aTriggeringPrincipal, _retval);
|
||||
|
||||
*_retval = true;
|
||||
return NS_OK;
|
||||
@@ -407,6 +409,7 @@ NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURI(nsIDocShell *aDocShell,
|
||||
NS_IMETHODIMP nsContentTreeOwner::ReloadInFreshProcess(nsIDocShell* aDocShell,
|
||||
nsIURI* aURI,
|
||||
nsIURI* aReferrer,
|
||||
nsIPrincipal* aTriggeringPrincipal,
|
||||
bool* aRetVal)
|
||||
{
|
||||
NS_WARNING("Cannot reload in fresh process from a nsContentTreeOwner!");
|
||||
|
||||
@@ -13,6 +13,7 @@ interface nsIDOMElement;
|
||||
interface nsIInputStream;
|
||||
interface nsIDocShell;
|
||||
interface nsITabParent;
|
||||
interface nsIPrincipal;
|
||||
interface mozIDOMWindowProxy;
|
||||
|
||||
/**
|
||||
@@ -60,10 +61,13 @@ interface nsIXULBrowserWindow : nsISupports
|
||||
* The URI being loaded.
|
||||
* @param aReferrer
|
||||
* The referrer of the load.
|
||||
* @param aTriggeringPrincipal
|
||||
* The principal that initiated the load of aURI.
|
||||
*/
|
||||
bool shouldLoadURI(in nsIDocShell aDocShell,
|
||||
in nsIURI aURI,
|
||||
in nsIURI aReferrer);
|
||||
in nsIURI aReferrer,
|
||||
in nsIPrincipal aTriggeringPrincipal);
|
||||
/**
|
||||
* Show/hide a tooltip (when the user mouses over a link, say).
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user