Backed out 15 changesets (bug 1087442)

Backed out changeset 3f4166fb5e37 (bug 1087442)
Backed out changeset 0c9c9123a0a9 (bug 1087442)
Backed out changeset 1d85d298042d (bug 1087442)
Backed out changeset 51f3ce397d68 (bug 1087442)
Backed out changeset f3b81a623692 (bug 1087442)
Backed out changeset 472e8fa74596 (bug 1087442)
Backed out changeset 12f97df7b79c (bug 1087442)
Backed out changeset 253cde88d3c5 (bug 1087442)
Backed out changeset b44f9ebd56cb (bug 1087442)
Backed out changeset 48e412887726 (bug 1087442)
Backed out changeset a2c76343f7a9 (bug 1087442)
Backed out changeset 0b5b07cfef0e (bug 1087442)
Backed out changeset 2931c35342a4 (bug 1087442)
Backed out changeset 681ce9dcad64 (bug 1087442)
Backed out changeset 47c505856954 (bug 1087442)
This commit is contained in:
Phil Ringnalda 2014-12-11 21:58:21 -08:00
parent 059bb441c2
commit e725b6fdc2
34 changed files with 195 additions and 688 deletions

View File

@ -153,22 +153,8 @@ AboutRedirector::NewChannel(nsIURI* aURI,
for (int i = 0; i < kRedirTotal; i++) {
if (!strcmp(path.get(), kRedirMap[i].id)) {
nsCOMPtr<nsIChannel> tempChannel;
nsCOMPtr<nsIURI> tempURI;
rv = NS_NewURI(getter_AddRefs(tempURI),
nsDependentCString(kRedirMap[i].url));
NS_ENSURE_SUCCESS(rv, rv);
// Bug 1087720 (and Bug 1099296):
// Once all callsites have been updated to call NewChannel2()
// instead of NewChannel() we should have a non-null loadInfo
// consistently. Until then we have to branch on the loadInfo.
if (aLoadInfo) {
rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
tempURI,
aLoadInfo);
}
else {
rv = ioService->NewChannelFromURI(tempURI, getter_AddRefs(tempChannel));
}
rv = ioService->NewChannel(nsDependentCString(kRedirMap[i].url),
nullptr, nullptr, getter_AddRefs(tempChannel));
NS_ENSURE_SUCCESS(rv, rv);
tempChannel->SetOriginalURI(aURI);

View File

@ -976,7 +976,7 @@ nsScriptSecurityManager::CreateCodebasePrincipal(nsIURI* aURI, uint32_t aAppId,
if (uriPrinc) {
nsCOMPtr<nsIPrincipal> principal;
uriPrinc->GetPrincipal(getter_AddRefs(principal));
if (!principal) {
if (!principal || principal == mSystemPrincipal) {
return CallCreateInstance(NS_NULLPRINCIPAL_CONTRACTID, result);
}

View File

@ -100,7 +100,7 @@ nsChromeProtocolHandler::NewURI(const nsACString &aSpec,
NS_IMETHODIMP
nsChromeProtocolHandler::NewChannel2(nsIURI* aURI,
nsILoadInfo* aLoadInfo,
nsILoadInfo* aLoadinfo,
nsIChannel** aResult)
{
nsresult rv;
@ -147,22 +147,12 @@ nsChromeProtocolHandler::NewChannel2(nsIURI* aURI,
return rv;
}
// Bug 1087720 (and Bug 1099296):
// Once all callsites have been updated to call NewChannel2() instead of NewChannel()
// we should have a non-null loadInfo consistently. Until then we have to branch on the
// loadInfo.
if (aLoadInfo) {
rv = NS_NewChannelInternal(getter_AddRefs(result),
resolvedURI,
aLoadInfo);
}
else {
nsCOMPtr<nsIIOService> ioServ(do_GetIOService(&rv));
NS_ENSURE_SUCCESS(rv, rv);
rv = ioServ->NewChannelFromURI(resolvedURI, getter_AddRefs(result));
}
nsCOMPtr<nsIIOService> ioServ(do_GetIOService(&rv));
NS_ENSURE_SUCCESS(rv, rv);
rv = ioServ->NewChannelFromURI(resolvedURI, getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;
#ifdef DEBUG
nsCOMPtr<nsIFileChannel> fileChan(do_QueryInterface(result));
if (fileChan) {

View File

@ -20,23 +20,16 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsIURI* aBaseURI)
: mLoadingPrincipal(aLoadingContext ?
aLoadingContext->NodePrincipal() : aLoadingPrincipal)
: mLoadingPrincipal(aLoadingPrincipal)
, mTriggeringPrincipal(aTriggeringPrincipal ?
aTriggeringPrincipal : mLoadingPrincipal.get())
aTriggeringPrincipal : aLoadingPrincipal)
, mLoadingContext(do_GetWeakReference(aLoadingContext))
, mSecurityFlags(aSecurityFlags)
, mContentPolicyType(aContentPolicyType)
, mBaseURI(aBaseURI)
{
MOZ_ASSERT(mLoadingPrincipal);
MOZ_ASSERT(aLoadingPrincipal);
MOZ_ASSERT(mTriggeringPrincipal);
// if consumers pass both, aLoadingContext and aLoadingPrincipal
// then the loadingPrincipal must be the same as the node's principal
MOZ_ASSERT(!aLoadingContext || !aLoadingPrincipal ||
aLoadingContext->NodePrincipal() == aLoadingPrincipal);
// if the load is sandboxed, we can not also inherit the principal
if (mSecurityFlags & nsILoadInfo::SEC_SANDBOXED) {
mSecurityFlags ^= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;

View File

@ -85,35 +85,24 @@ nsAboutRedirector::NewChannel(nsIURI* aURI,
NS_ENSURE_ARG_POINTER(aURI);
NS_ASSERTION(result, "must not be null");
nsresult rv;
nsAutoCString path;
nsresult rv = NS_GetAboutModuleName(aURI, path);
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_GetAboutModuleName(aURI, path);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv))
return rv;
for (int i=0; i<kRedirTotal; i++)
{
if (!strcmp(path.get(), kRedirMap[i].id))
{
nsCOMPtr<nsIChannel> tempChannel;
nsCOMPtr<nsIURI> tempURI;
rv = NS_NewURI(getter_AddRefs(tempURI), kRedirMap[i].url);
NS_ENSURE_SUCCESS(rv, rv);
// Bug 1087720 (and Bug 1099296):
// Once all callsites have been updated to call NewChannel2()
// instead of NewChannel() we should have a non-null loadInfo
// consistently. Until then we have to branch on the loadInfo.
if (aLoadInfo) {
rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
tempURI,
aLoadInfo);
}
else {
rv = ioService->NewChannelFromURI(tempURI,
getter_AddRefs(tempChannel));
}
rv = ioService->NewChannel(nsDependentCString(kRedirMap[i].url),
nullptr, nullptr, getter_AddRefs(tempChannel));
if (NS_FAILED(rv))
return rv;

View File

@ -485,7 +485,7 @@ nsHostObjectProtocolHandler::NewURI(const nsACString& aSpec,
NS_IMETHODIMP
nsHostObjectProtocolHandler::NewChannel2(nsIURI* uri,
nsILoadInfo* aLoadInfo,
nsILoadInfo *aLoadinfo,
nsIChannel** result)
{
*result = nullptr;
@ -519,26 +519,13 @@ nsHostObjectProtocolHandler::NewChannel2(nsIURI* uri,
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIChannel> channel;
// Bug 1087720 (and Bug 1099296):
// Once all callsites have been updated to call NewChannel2() instead of NewChannel()
// we should have a non-null loadInfo consistently. Until then we have to brach on the
// loadInfo and provide default arguments to create a NewInputStreamChannel.
if (aLoadInfo) {
rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
uri,
stream,
EmptyCString(), // aContentType
EmptyCString(), // aContentCharset
aLoadInfo);
}
else {
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
uri,
stream,
info->mPrincipal,
nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
nsIContentPolicy::TYPE_OTHER);
}
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
uri,
stream,
info->mPrincipal,
nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
nsIContentPolicy::TYPE_OTHER);
NS_ENSURE_SUCCESS(rv, rv);
nsString type;

View File

@ -1223,11 +1223,6 @@ nsJSProtocolHandler::NewChannel2(nsIURI* uri,
NS_ADDREF(channel);
rv = channel->Init(uri);
// set the loadInfo on the new channel
rv = channel->SetLoadInfo(aLoadInfo);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_SUCCEEDED(rv)) {
*result = channel;
NS_ADDREF(*result);

View File

@ -1059,23 +1059,12 @@ nsGIOProtocolHandler::NewChannel2(nsIURI* aURI,
return rv;
nsRefPtr<nsGIOInputStream> stream = new nsGIOInputStream(spec);
if (!stream) {
return NS_ERROR_OUT_OF_MEMORY;
if (!stream)
{
rv = NS_ERROR_OUT_OF_MEMORY;
}
// Bug 1087720 (and Bug 1099296):
// Once all callsites have been updated to call NewChannel2() instead of NewChannel()
// we should have a non-null loadInfo consistently. Until then we have to brach on the
// loadInfo and provide default arguments to create a NewInputStreamChannel.
if (aLoadInfo) {
rv = NS_NewInputStreamChannelInternal(aResult,
aURI,
stream,
NS_LITERAL_CSTRING(UNKNOWN_CONTENT_TYPE),
EmptyCString(), // aContentCharset
aLoadInfo);
}
else {
else
{
nsCOMPtr<nsIPrincipal> nullPrincipal =
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
@ -1089,9 +1078,8 @@ nsGIOProtocolHandler::NewChannel2(nsIURI* aURI,
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
NS_LITERAL_CSTRING(UNKNOWN_CONTENT_TYPE));
}
if (NS_SUCCEEDED(rv)) {
stream->SetChannel(*aResult);
if (NS_SUCCEEDED(rv))
stream->SetChannel(*aResult);
}
return rv;
}

View File

@ -96,13 +96,6 @@ nsIconProtocolHandler::NewChannel2(nsIURI* url,
return rv;
}
// set the loadInfo on the new channel
rv = channel->SetLoadInfo(aLoadInfo);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;
}
*result = channel;
return NS_OK;
}

View File

@ -223,13 +223,6 @@ nsJARProtocolHandler::NewChannel2(nsIURI* uri,
return rv;
}
// set the loadInfo on the new channel
rv = chan->SetLoadInfo(aLoadInfo);
if (NS_FAILED(rv)) {
NS_RELEASE(chan);
return rv;
}
*result = chan;
return NS_OK;
}

View File

@ -67,58 +67,8 @@ interface nsIIOService : nsISupports
/**
* Creates a channel for a given URI.
*
* @param aURI
* nsIURI from which to make a channel
* @param aLoadingNode
* The loadingDocument of the channel.
* The element or document where the result of this request will be
* used. This is the document/element that will get access to the
* result of this request. For example for an image load, it's the
* document in which the image will be loaded. And for a CSS
* stylesheet it's the document whose rendering will be affected by
* the stylesheet.
* If possible, pass in the element which is performing the load. But
* if the load is coming from a JS API (such as XMLHttpRequest) or if
* the load might be coalesced across multiple elements (such as
* for <img>) then pass in the Document node instead.
* For loads that are not related to any document, such as loads coming
* from addons or internal browser features, use null here.
* @param aLoadingPrincipal
* The loadingPrincipal of the channel.
* The principal of the document where the result of this request will be used.
* This is generally the principal of the aLoadingNode. However for
* loads where aLoadingNode is null this argument still needs to be
* passed. For example for loads from a WebWorker, pass the principal
* of that worker. For loads from an addon or from internal browser
* features, pass the system principal.
* This principal should almost always be the system principal if
* aLoadingNode is null. The only exception to this is for loads
* from WebWorkers since they don't have any nodes to be passed as
* aLoadingNode. Please note, aLoadingPrincipal is *not* the
* principal of the resource being loaded. But rather the principal
* of the context where the resource will be used.
* @param aTriggeringPrincipal
* The triggeringPrincipal of the load.
* The triggeringPrincipal is the principal of the resource that caused
* this particular URL to be loaded.
* Most likely the triggeringPrincipal and the loadingPrincipal are
* identical, in which case the triggeringPrincipal can be left out.
* In some cases the loadingPrincipal and the triggeringPrincipal are
* different however, e.g. a stylesheet may import a subresource. In
* that case the principal of the stylesheet which contains the
* import command is the triggeringPrincipal, and the principal of
* the document whose rendering is affected is the loadingPrincipal.
* @param aSecurityFlags
* The securityFlags of the channel.
* Any of the securityflags defined in nsILoadInfo.idl
* @param aContentPolicyType
* The contentPolicyType of the channel.
* Any of the content types defined in nsIContentPolicy.idl
* @param aURI nsIURI from which to make a channel
* @return reference to the new nsIChannel object
*
* Please note, if you provide a loadingNode, then the loadingPrincipal
* must match the loadingNode->NodePrincipal(). Alternatively you can
* discard the loadingPrincipal if you provide a loadingNode.
*/
nsIChannel newChannelFromURI2(in nsIURI aURI,
in nsIDOMNode aLoadingNode,
@ -136,7 +86,7 @@ interface nsIIOService : nsISupports
nsIChannel newChannelFromURI(in nsIURI aURI);
/**
* Equivalent to newChannelFromURI2(newURI(...))
* Equivalent to newChannelFromURI(newURI(...))
*/
nsIChannel newChannel2(in AUTF8String aSpec,
in string aOriginCharset,

View File

@ -33,63 +33,12 @@ interface nsIIOService2 : nsIIOService
/**
* Creates a channel for a given URI.
*
* @param aURI
* nsIURI from which to make a channel
* @param aProxyURI
* nsIURI to use for proxy resolution. Can be null in which
* @param aURI nsIURI from which to make a channel
* @param aProxyURI nsIURI to use for proxy resolution. Can be null in which
* case aURI is used
* @param aProxyFlags flags from nsIProtocolProxyService to use
* when resolving proxies for this new channel
* @param aLoadingNode
* The loadingDocument of the channel.
* The element or document where the result of this request will be
* used. This is the document/element that will get access to the
* result of this request. For example for an image load, it's the
* document in which the image will be loaded. And for a CSS
* stylesheet it's the document whose rendering will be affected by
* the stylesheet.
* If possible, pass in the element which is performing the load. But
* if the load is coming from a JS API (such as XMLHttpRequest) or if
* the load might be coalesced across multiple elements (such as
* for <img>) then pass in the Document node instead.
* For loads that are not related to any document, such as loads coming
* from addons or internal browser features, use null here.
* @param aLoadingPrincipal
* The loadingPrincipal of the channel.
* The principal of the document where the result of this request will be used.
* This is generally the principal of the aLoadingNode. However for
* loads where aLoadingNode is null this argument still needs to be
* passed. For example for loads from a WebWorker, pass the principal
* of that worker. For loads from an addon or from internal browser
* features, pass the system principal.
* This principal should almost always be the system principal if
* aLoadingNode is null. The only exception to this is for loads
* from WebWorkers since they don't have any nodes to be passed as
* aLoadingNode. Please note, aLoadingPrincipal is *not* the
* principal of the resource being loaded. But rather the principal
* of the context where the resource will be used.
* @param aTriggeringPrincipal
* The triggeringPrincipal of the load.
* The triggeringPrincipal is the principal of the resource that caused
* this particular URL to be loaded.
* Most likely the triggeringPrincipal and the loadingPrincipal are
* identical, in which case the triggeringPrincipal can be left out.
* In some cases the loadingPrincipal and the triggeringPrincipal are
* different however, e.g. a stylesheet may import a subresource. In
* that case the principal of the stylesheet which contains the
* import command is the triggeringPrincipal, and the principal of
* the document whose rendering is affected is the loadingPrincipal.
* @param aSecurityFlags
* The securityFlags of the channel.
* Any of the securityflags defined in nsILoadInfo.idl
* @param aContentPolicyType
* The contentPolicyType of the channel.
* Any of the content types defined in nsIContentPolicy.idl
* @return reference to the new nsIChannel object
*
* Please note, if you provide a loadingNode, then the loadingPrincipal
* must match the loadingNode->NodePrincipal(). Alternatively you can
* discard the loadingPrincipal if you provide a loadingNode.
*/
nsIChannel newChannelFromURIWithProxyFlags2(in nsIURI aURI,
in nsIURI aProxyURI,

View File

@ -27,7 +27,6 @@ interface nsIProxiedProtocolHandler : nsIProtocolHandler
* effect), except in the case of websockets which wants to bootstrap
* to an http:// channel but make its proxy determination based on
* a ws:// uri.
* @param aLoadInfo used to evaluate who initated the resource request.
*/
nsIChannel newProxiedChannel2(in nsIURI uri, in nsIProxyInfo proxyInfo,
in unsigned long proxyResolveFlags,

View File

@ -188,80 +188,24 @@ NS_NewFileURI(nsIURI* *result,
}
/*
* How to create a new Channel, using NS_NewChannel,
* NS_NewChannelWithTriggeringPrincipal, NS_OpenURI,
* NS_NewInputStreamChannel, NS_NewChannelInternal
* and it's variations:
*
* @param aURI
* nsIURI from which to make a channel
* @param aLoadingNode
* The loadingDocument of the channel.
* The element or document where the result of this request will be
* used. This is the document/element that will get access to the
* result of this request. For example for an image load, it's the
* document in which the image will be loaded. And for a CSS
* stylesheet it's the document whose rendering will be affected by
* the stylesheet.
* If possible, pass in the element which is performing the load. But
* if the load is coming from a JS API (such as XMLHttpRequest) or if
* the load might be coalesced across multiple elements (such as
* for <img>) then pass in the Document node instead.
* For loads that are not related to any document, such as loads coming
* from addons or internal browser features, use null here.
* @param aLoadingPrincipal
* The loadingPrincipal of the channel.
* The principal of the document where the result of this request will be used.
* This is generally the principal of the aLoadingNode. However for
* loads where aLoadingNode is null this argument still needs to be
* passed. For example for loads from a WebWorker, pass the principal
* of that worker. For loads from an addon or from internal browser
* features, pass the system principal.
* This principal should almost always be the system principal if
* aLoadingNode is null. The only exception to this is for loads
* from WebWorkers since they don't have any nodes to be passed as
* aLoadingNode. Please note, aLoadingPrincipal is *not* the
* principal of the resource being loaded. But rather the principal
* of the context where the resource will be used.
* @param aTriggeringPrincipal
* The triggeringPrincipal of the load.
* The triggeringPrincipal is the principal of the resource that caused
* this particular URL to be loaded.
* Most likely the triggeringPrincipal and the loadingPrincipal are
* identical, in which case the triggeringPrincipal can be left out.
* In some cases the loadingPrincipal and the triggeringPrincipal are
* different however, e.g. a stylesheet may import a subresource. In
* that case the principal of the stylesheet which contains the
* import command is the triggeringPrincipal, and the principal of
* the document whose rendering is affected is the loadingPrincipal.
* @param aSecurityFlags
* The securityFlags of the channel.
* Any of the securityflags defined in nsILoadInfo.idl
* @param aContentPolicyType
* The contentPolicyType of the channel.
* Any of the content types defined in nsIContentPolicy.idl
*
* Please note, if you provide a loadingNode, then the loadingPrincipal
* must match the loadingNode->NodePrincipal(). Alternatively you can
* discard the loadingPrincipal if you provide a loadingNode.
*
* What specific API function to use:
* * If possible try to call NS_NewChannel() providing a loading *nsINode*
* * If no loading *nsINode* is avaialable, call NS_NewChannel() providing
* a loading *nsIPrincipal*.
* * Call NS_NewChannelWithTriggeringPrincipal() if the loading principal
* and the Node's principal have to be different (see above).
* * Call NS_NewChannelInternal() providing aLoadInfo object in cases where
* you already have loadInfo object, e.g in case of a channel redirect.
*/
* How to create a new Channel using NS_NewChannel:
* 1) Please try to call NS_NewChannel providing a requesting *nsINode*
* 2) If no requesting nsINode is available,
* call NS_NewChannel providing a requesting *nsIPrincipal*.
* 3) Call NS_NewChannelInternal *only* if requesting Principal and
* the Node's Principal have to be different.
* >> Most likely this is not the case! <<
* Needs special approval!
*/
inline nsresult
NS_NewChannelInternal(nsIChannel** outChannel,
nsIURI* aUri,
nsINode* aLoadingNode,
nsIPrincipal* aLoadingPrincipal,
nsINode* aRequestingNode,
nsIPrincipal* aRequestingPrincipal,
nsIPrincipal* aTriggeringPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsIURI* aBaseURI = nullptr,
nsILoadGroup* aLoadGroup = nullptr,
nsIInterfaceRequestor* aCallbacks = nullptr,
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
@ -274,15 +218,7 @@ NS_NewChannelInternal(nsIChannel** outChannel,
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIChannel> channel;
rv = aIoService->NewChannelFromURI2(
aUri,
aLoadingNode ?
aLoadingNode->AsDOMNode() : nullptr,
aLoadingPrincipal,
aTriggeringPrincipal,
aSecurityFlags,
aContentPolicyType,
getter_AddRefs(channel));
rv = aIoService->NewChannelFromURI(aUri, getter_AddRefs(channel));
NS_ENSURE_SUCCESS(rv, rv);
if (aLoadGroup) {
@ -316,9 +252,9 @@ NS_NewChannelInternal(nsIChannel** outChannel,
// create a new Loadinfo with the potentially updated securityFlags
loadInfo =
new mozilla::LoadInfo(aLoadingPrincipal, aTriggeringPrincipal,
aLoadingNode, aSecurityFlags,
aContentPolicyType);
new mozilla::LoadInfo(aRequestingPrincipal, aTriggeringPrincipal,
aRequestingNode, aSecurityFlags,
aContentPolicyType, aBaseURI);
if (!loadInfo) {
return NS_ERROR_UNEXPECTED;
}
@ -334,7 +270,6 @@ NS_NewChannelInternal(nsIChannel** outChannel,
return NS_OK;
}
// See NS_NewChannelInternal for usage and argument description
inline nsresult
NS_NewChannelInternal(nsIChannel** outChannel,
nsIURI* aUri,
@ -352,22 +287,19 @@ NS_NewChannelInternal(nsIChannel** outChannel,
aLoadInfo->TriggeringPrincipal(),
aLoadInfo->GetSecurityFlags(),
aLoadInfo->GetContentPolicyType(),
aLoadInfo->BaseURI(),
aLoadGroup,
aCallbacks,
aLoadFlags,
aIoService);
NS_ENSURE_SUCCESS(rv, rv);
// Please note that we still call SetLoadInfo on the channel because
// we want the same instance of the loadInfo to be set on the channel.
(*outChannel)->SetLoadInfo(aLoadInfo);
return NS_OK;
}
// See NS_NewChannelInternal for usage and argument description
inline nsresult /*NS_NewChannelWithNodeAndTriggeringPrincipal */
NS_NewChannelWithTriggeringPrincipal(nsIChannel** outChannel,
nsIURI* aUri,
nsINode* aLoadingNode,
nsINode* aRequestingNode,
nsIPrincipal* aTriggeringPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
@ -376,26 +308,26 @@ NS_NewChannelWithTriggeringPrincipal(nsIChannel** outChannel,
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
nsIIOService* aIoService = nullptr)
{
MOZ_ASSERT(aLoadingNode);
MOZ_ASSERT(aRequestingNode);
NS_ASSERTION(aTriggeringPrincipal, "Can not create channel without a triggering Principal!");
return NS_NewChannelInternal(outChannel,
aUri,
aLoadingNode,
aLoadingNode->NodePrincipal(),
aRequestingNode,
aRequestingNode->NodePrincipal(),
aTriggeringPrincipal,
aSecurityFlags,
aContentPolicyType,
nullptr, // aBaseURI
aLoadGroup,
aCallbacks,
aLoadFlags,
aIoService);
}
// See NS_NewChannelInternal for usage and argument description
inline nsresult /*NS_NewChannelWithPrincipalAndTriggeringPrincipal */
NS_NewChannelWithTriggeringPrincipal(nsIChannel** outChannel,
nsIURI* aUri,
nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aRequestingPrincipal,
nsIPrincipal* aTriggeringPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
@ -404,25 +336,25 @@ NS_NewChannelWithTriggeringPrincipal(nsIChannel** outChannel,
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
nsIIOService* aIoService = nullptr)
{
NS_ASSERTION(aLoadingPrincipal, "Can not create channel without a loading Principal!");
NS_ASSERTION(aRequestingPrincipal, "Can not create channel without a requesting Principal!");
return NS_NewChannelInternal(outChannel,
aUri,
nullptr, // aLoadingNode
aLoadingPrincipal,
nullptr, // aRequestingNode
aRequestingPrincipal,
aTriggeringPrincipal,
aSecurityFlags,
aContentPolicyType,
nullptr, // aBaseURI
aLoadGroup,
aCallbacks,
aLoadFlags,
aIoService);
}
// See NS_NewChannelInternal for usage and argument description
inline nsresult /* NS_NewChannelNode */
NS_NewChannel(nsIChannel** outChannel,
nsIURI* aUri,
nsINode* aLoadingNode,
nsINode* aRequestingNode,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsILoadGroup* aLoadGroup = nullptr,
@ -430,25 +362,25 @@ NS_NewChannel(nsIChannel** outChannel,
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
nsIIOService* aIoService = nullptr)
{
NS_ASSERTION(aLoadingNode, "Can not create channel without a loading Node!");
NS_ASSERTION(aRequestingNode, "Can not create channel without a requesting Node!");
return NS_NewChannelInternal(outChannel,
aUri,
aLoadingNode,
aLoadingNode->NodePrincipal(),
aRequestingNode,
aRequestingNode->NodePrincipal(),
nullptr, // aTriggeringPrincipal
aSecurityFlags,
aContentPolicyType,
nullptr, // aBaseURI
aLoadGroup,
aCallbacks,
aLoadFlags,
aIoService);
}
// See NS_NewChannelInternal for usage and argument description
inline nsresult /* NS_NewChannelPrincipal */
NS_NewChannel(nsIChannel** outChannel,
nsIURI* aUri,
nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aRequestingPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsILoadGroup* aLoadGroup = nullptr,
@ -458,11 +390,12 @@ NS_NewChannel(nsIChannel** outChannel,
{
return NS_NewChannelInternal(outChannel,
aUri,
nullptr, // aLoadingNode,
aLoadingPrincipal,
nullptr, // aRequestingNode,
aRequestingPrincipal,
nullptr, // aTriggeringPrincipal
aSecurityFlags,
aContentPolicyType,
nullptr, // aBaseURI
aLoadGroup,
aCallbacks,
aLoadFlags,
@ -476,8 +409,8 @@ NS_NewChannel(nsIChannel** outChannel,
inline nsresult
NS_OpenURIInternal(nsIInputStream** outStream,
nsIURI* aUri,
nsINode* aLoadingNode,
nsIPrincipal* aLoadingPrincipal,
nsINode* aRequestingNode,
nsIPrincipal* aRequestingPrincipal,
nsIPrincipal* aTriggeringPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
@ -487,16 +420,17 @@ NS_OpenURIInternal(nsIInputStream** outStream,
nsIIOService* aIoService = nullptr, // pass in nsIIOService to optimize callers
nsIChannel** outChannel = nullptr)
{
NS_ASSERTION(aLoadingPrincipal, "Can not create channel without a loading Principal!");
NS_ASSERTION(aRequestingPrincipal, "Can not create channel without a requesting Principal!");
nsCOMPtr<nsIChannel> channel;
nsresult rv = NS_NewChannelInternal(getter_AddRefs(channel),
aUri,
aLoadingNode,
aLoadingPrincipal,
aRequestingNode,
aRequestingPrincipal,
aTriggeringPrincipal,
aSecurityFlags,
aContentPolicyType,
nullptr, // aBaseURI
aLoadGroup,
aCallbacks,
aLoadFlags,
@ -517,7 +451,7 @@ NS_OpenURIInternal(nsIInputStream** outStream,
inline nsresult /* NS_OpenURIprincipal */
NS_OpenURI(nsIInputStream** outStream,
nsIURI* aUri,
nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aRequestingPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsILoadGroup* aLoadGroup = nullptr,
@ -528,8 +462,8 @@ NS_OpenURI(nsIInputStream** outStream,
{
return NS_OpenURIInternal(outStream,
aUri,
nullptr, // aLoadingNode
aLoadingPrincipal,
nullptr, // aRequestingNode
aRequestingPrincipal,
nullptr, // aTriggeringPrincipal
aSecurityFlags,
aContentPolicyType,
@ -543,7 +477,7 @@ NS_OpenURI(nsIInputStream** outStream,
inline nsresult /* NS_OpenURIWithTriggeringPrincipalAndNode */
NS_OpenURIWithTriggeringPrincipal(nsIInputStream** outStream,
nsIURI* aUri,
nsINode* aLoadingNode,
nsINode* aRequestingNode,
nsIPrincipal* aTriggeringPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
@ -553,12 +487,12 @@ NS_OpenURIWithTriggeringPrincipal(nsIInputStream** outStream,
nsIIOService* aIoService = nullptr,
nsIChannel** outChannel = nullptr)
{
MOZ_ASSERT(aLoadingNode);
MOZ_ASSERT(aRequestingNode);
NS_ASSERTION(aTriggeringPrincipal, "Can not open uri without a triggering Principal!");
return NS_OpenURIInternal(outStream,
aUri,
aLoadingNode,
aLoadingNode->NodePrincipal(),
aRequestingNode,
aRequestingNode->NodePrincipal(),
aTriggeringPrincipal,
aSecurityFlags,
aContentPolicyType,
@ -595,8 +529,8 @@ inline nsresult
NS_OpenURIInternal(nsIStreamListener* aListener,
nsISupports* aContext,
nsIURI* aUri,
nsINode* aLoadingNode,
nsIPrincipal* aLoadingPrincipal,
nsINode* aRequestingNode,
nsIPrincipal* aRequestingPrincipal,
nsIPrincipal* aTriggeringPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
@ -605,12 +539,12 @@ NS_OpenURIInternal(nsIStreamListener* aListener,
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
nsIIOService* aIoService = nullptr)
{
NS_ASSERTION(aLoadingPrincipal, "Can not create channel without a loading Principal!");
NS_ASSERTION(aRequestingPrincipal, "Can not create channel without a requesting Principal!");
nsCOMPtr<nsILoadInfo> loadInfo =
new mozilla::LoadInfo(aLoadingPrincipal,
new mozilla::LoadInfo(aRequestingPrincipal,
aTriggeringPrincipal,
aLoadingNode,
aRequestingNode,
aSecurityFlags,
aContentPolicyType);
if (!loadInfo) {
@ -630,7 +564,7 @@ inline nsresult
NS_OpenURI(nsIStreamListener* aListener,
nsISupports* aContext,
nsIURI* aUri,
nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aRequestingPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsILoadGroup* aLoadGroup = nullptr,
@ -641,8 +575,8 @@ NS_OpenURI(nsIStreamListener* aListener,
return NS_OpenURIInternal(aListener,
aContext,
aUri,
nullptr, // aLoadingNode
aLoadingPrincipal,
nullptr, // aRequestingNode
aRequestingPrincipal,
nullptr, // aTriggeringPrincipal
aSecurityFlags,
aContentPolicyType,
@ -776,15 +710,19 @@ NS_GetRealPort(nsIURI* aURI)
return NS_GetDefaultPort(scheme.get());
}
inline nsresult /* NS_NewInputStreamChannelWithLoadInfo */
inline nsresult
NS_NewInputStreamChannelInternal(nsIChannel** outChannel,
nsIURI* aUri,
nsIInputStream* aStream,
const nsACString& aContentType,
const nsACString& aContentCharset,
nsILoadInfo* aLoadInfo)
nsINode* aRequestingNode,
nsIPrincipal* aRequestingPrincipal,
nsIPrincipal* aTriggeringPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsIURI* aBaseURI = nullptr)
{
MOZ_ASSERT(aLoadInfo, "can not create channel without a loadinfo");
nsresult rv;
nsCOMPtr<nsIInputStreamChannel> isc =
do_CreateInstance(NS_INPUTSTREAMCHANNEL_CONTRACTID, &rv);
@ -807,11 +745,21 @@ NS_NewInputStreamChannelInternal(nsIChannel** outChannel,
NS_ENSURE_SUCCESS(rv, rv);
}
channel->SetLoadInfo(aLoadInfo);
nsCOMPtr<nsILoadInfo> loadInfo =
new mozilla::LoadInfo(aRequestingPrincipal,
aTriggeringPrincipal,
aRequestingNode,
aSecurityFlags,
aContentPolicyType,
aBaseURI);
if (!loadInfo) {
return NS_ERROR_UNEXPECTED;
}
channel->SetLoadInfo(loadInfo);
// If we're sandboxed, make sure to clear any owner the channel
// might already have.
if (aLoadInfo->GetLoadingSandboxed()) {
if (loadInfo->GetLoadingSandboxed()) {
channel->SetOwner(nullptr);
}
@ -819,42 +767,11 @@ NS_NewInputStreamChannelInternal(nsIChannel** outChannel,
return NS_OK;
}
inline nsresult
NS_NewInputStreamChannelInternal(nsIChannel** outChannel,
nsIURI* aUri,
nsIInputStream* aStream,
const nsACString& aContentType,
const nsACString& aContentCharset,
nsINode* aLoadingNode,
nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aTriggeringPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsIURI* aBaseURI = nullptr)
{
nsCOMPtr<nsILoadInfo> loadInfo =
new mozilla::LoadInfo(aLoadingPrincipal,
aTriggeringPrincipal,
aLoadingNode,
aSecurityFlags,
aContentPolicyType,
aBaseURI);
if (!loadInfo) {
return NS_ERROR_UNEXPECTED;
}
return NS_NewInputStreamChannelInternal(outChannel,
aUri,
aStream,
aContentType,
aContentCharset,
loadInfo);
}
inline nsresult /* NS_NewInputStreamChannelPrincipal */
NS_NewInputStreamChannel(nsIChannel** outChannel,
nsIURI* aUri,
nsIInputStream* aStream,
nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aRequestingPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
const nsACString& aContentType = EmptyCString(),
@ -865,8 +782,8 @@ NS_NewInputStreamChannel(nsIChannel** outChannel,
aStream,
aContentType,
aContentCharset,
nullptr, // aLoadingNode
aLoadingPrincipal,
nullptr, // aRequestingNode
aRequestingPrincipal,
nullptr, // aTriggeringPrincipal
aSecurityFlags,
aContentPolicyType);
@ -877,8 +794,8 @@ NS_NewInputStreamChannelInternal(nsIChannel** outChannel,
nsIURI* aUri,
const nsAString& aData,
const nsACString& aContentType,
nsINode* aLoadingNode,
nsIPrincipal* aLoadingPrincipal,
nsINode* aRequestingNode,
nsIPrincipal* aRequestingPrincipal,
nsIPrincipal* aTriggeringPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
@ -905,8 +822,8 @@ NS_NewInputStreamChannelInternal(nsIChannel** outChannel,
stream,
aContentType,
NS_LITERAL_CSTRING("UTF-8"),
aLoadingNode,
aLoadingPrincipal,
aRequestingNode,
aRequestingPrincipal,
aTriggeringPrincipal,
aSecurityFlags,
aContentPolicyType,
@ -928,7 +845,7 @@ NS_NewInputStreamChannel(nsIChannel** outChannel,
nsIURI* aUri,
const nsAString& aData,
const nsACString& aContentType,
nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aRequestingPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
bool aIsSrcdocChannel = false,
@ -938,8 +855,8 @@ NS_NewInputStreamChannel(nsIChannel** outChannel,
aUri,
aData,
aContentType,
nullptr, // aLoadingNode
aLoadingPrincipal,
nullptr, // aRequestingNode
aRequestingPrincipal,
nullptr, // aTriggeringPrincipal
aSecurityFlags,
aContentPolicyType,
@ -1052,8 +969,8 @@ inline nsresult
NS_NewStreamLoaderInternal(nsIStreamLoader** outStream,
nsIURI* aUri,
nsIStreamLoaderObserver* aObserver,
nsINode* aLoadingNode,
nsIPrincipal* aLoadingPrincipal,
nsINode* aRequestingNode,
nsIPrincipal* aRequestingPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsISupports* aContext = nullptr,
@ -1065,11 +982,12 @@ NS_NewStreamLoaderInternal(nsIStreamLoader** outStream,
nsCOMPtr<nsIChannel> channel;
nsresult rv = NS_NewChannelInternal(getter_AddRefs(channel),
aUri,
aLoadingNode,
aLoadingPrincipal,
aRequestingNode,
aRequestingPrincipal,
nullptr, // aTriggeringPrincipal
aSecurityFlags,
aContentPolicyType,
nullptr, // aBaseURI
aLoadGroup,
aCallbacks,
aLoadFlags);
@ -1089,7 +1007,7 @@ inline nsresult /* NS_NewStreamLoaderNode */
NS_NewStreamLoader(nsIStreamLoader** outStream,
nsIURI* aUri,
nsIStreamLoaderObserver* aObserver,
nsINode* aLoadingNode,
nsINode* aRequestingNode,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsISupports* aContext = nullptr,
@ -1098,12 +1016,12 @@ NS_NewStreamLoader(nsIStreamLoader** outStream,
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
nsIURI* aReferrer = nullptr)
{
NS_ASSERTION(aLoadingNode, "Can not create stream loader without a loading Node!");
NS_ASSERTION(aRequestingNode, "Can not create stream loader without a requesting Node!");
return NS_NewStreamLoaderInternal(outStream,
aUri,
aObserver,
aLoadingNode,
aLoadingNode->NodePrincipal(),
aRequestingNode,
aRequestingNode->NodePrincipal(),
aSecurityFlags,
aContentPolicyType,
aContext,
@ -1117,7 +1035,7 @@ inline nsresult /* NS_NewStreamLoaderPrincipal */
NS_NewStreamLoader(nsIStreamLoader** outStream,
nsIURI* aUri,
nsIStreamLoaderObserver* aObserver,
nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aRequestingPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsISupports* aContext = nullptr,
@ -1129,8 +1047,8 @@ NS_NewStreamLoader(nsIStreamLoader** outStream,
return NS_NewStreamLoaderInternal(outStream,
aUri,
aObserver,
nullptr, // aLoadingNode
aLoadingPrincipal,
nullptr, // aRequestingNode
aRequestingPrincipal,
aSecurityFlags,
aContentPolicyType,
aContext,
@ -1746,14 +1664,14 @@ NS_ReadInputStreamToString(nsIInputStream *aInputStream,
inline nsresult
NS_LoadPersistentPropertiesFromURI(nsIPersistentProperties** outResult,
nsIURI* aUri,
nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aRequestingPrincipal,
nsContentPolicyType aContentPolicyType,
nsIIOService* aIoService = nullptr)
{
nsCOMPtr<nsIInputStream> in;
nsresult rv = NS_OpenURI(getter_AddRefs(in),
aUri,
aLoadingPrincipal,
aRequestingPrincipal,
nsILoadInfo::SEC_NORMAL,
aContentPolicyType,
nullptr, // aLoadGroup
@ -1776,7 +1694,7 @@ NS_LoadPersistentPropertiesFromURI(nsIPersistentProperties** outResult,
inline nsresult
NS_LoadPersistentPropertiesFromURISpec(nsIPersistentProperties** outResult,
const nsACString& aSpec,
nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aRequestingPrincipal,
nsContentPolicyType aContentPolicyType,
const char* aCharset = nullptr,
nsIURI* aBaseURI = nullptr,
@ -1792,7 +1710,7 @@ NS_LoadPersistentPropertiesFromURISpec(nsIPersistentProperties** outResult,
return NS_LoadPersistentPropertiesFromURI(outResult,
uri,
aLoadingPrincipal,
aRequestingPrincipal,
aContentPolicyType,
aIoService);
}

View File

@ -40,7 +40,6 @@
#include "MainThreadUtils.h"
#include "nsIWidget.h"
#include "nsThreadUtils.h"
#include "mozilla/LoadInfo.h"
#include "mozilla/net/NeckoCommon.h"
#ifdef MOZ_WIDGET_GONK
@ -635,76 +634,13 @@ nsIOService::NewChannelFromURIWithProxyFlags2(nsIURI* aURI,
if (NS_FAILED(rv))
return rv;
// Ideally we are creating new channels by calling NewChannel2 (NewProxiedChannel2).
// Keep in mind that Addons can implement their own Protocolhandlers, hence
// NewChannel2() might *not* be implemented.
// We do not want to break those addons, therefore we first try to create a channel
// calling NewChannel2(); if that fails we fall back to creating a channel by calling
// NewChannel();
nsCOMPtr<nsILoadInfo> loadInfo;
// Unfortunately not all callsites (see Bug 1087720, and 1099296) have been updated
// yet to call NewChannel2() instead of NewChannel(), hence those callsites do not
// provide the necessary loadinfo arguments yet.
// Since creating a new loadInfo requires 'aLoadingPrincipal' or 'aLoadingNode' we
// can branch on those arguments as an interim solution.
//
// BUG 1087720: Once that bug lands, we should have a loadInfo for all callers of
// NewChannelFromURIWithProxyFlags2() and should remove the *if* before creating a
// a new loadinfo.
if (aLoadingNode || aLoadingPrincipal) {
nsCOMPtr<nsINode> loadingNode(do_QueryInterface(aLoadingNode));
loadInfo = new mozilla::LoadInfo(aLoadingPrincipal,
aTriggeringPrincipal,
loadingNode,
aSecurityFlags,
aContentPolicyType);
if (!loadInfo) {
return NS_ERROR_UNEXPECTED;
}
}
bool newChannel2Succeeded = true;
nsCOMPtr<nsIProxiedProtocolHandler> pph = do_QueryInterface(handler);
if (pph) {
rv = pph->NewProxiedChannel2(aURI, nullptr, aProxyFlags, aProxyURI,
loadInfo, result);
// if calling NewProxiedChannel2() fails we try to fall back to
// creating a new proxied channel by calling NewProxiedChannel().
if (NS_FAILED(rv)) {
newChannel2Succeeded = false;
rv = pph->NewProxiedChannel(aURI, nullptr, aProxyFlags, aProxyURI,
result);
}
}
else {
rv = handler->NewChannel2(aURI, loadInfo, result);
// if calling newChannel2() fails we try to fall back to
// creating a new channel by calling NewChannel().
if (NS_FAILED(rv)) {
newChannel2Succeeded = false;
rv = handler->NewChannel(aURI, result);
}
}
NS_ENSURE_SUCCESS(rv, rv);
if ((aLoadingNode || aLoadingPrincipal) && newChannel2Succeeded) {
// Make sure that all the individual protocolhandlers attach
// a loadInfo within it's implementation of ::newChannel2().
// Once Bug 1087720 lands, we should remove the surrounding
// if-clause here and always assert that we indeed have a
// loadinfo on the newly created channel.
nsCOMPtr<nsILoadInfo> loadInfo;
(*result)->GetLoadInfo(getter_AddRefs(loadInfo));
MOZ_ASSERT(loadInfo);
// If we're sandboxed, make sure to clear any owner the channel
// might already have.
if (loadInfo->GetLoadingSandboxed()) {
(*result)->SetOwner(nullptr);
}
}
if (pph)
rv = pph->NewProxiedChannel(aURI, nullptr, aProxyFlags, aProxyURI, result);
else
rv = handler->NewChannel(aURI, result);
if (NS_FAILED(rv))
return rv;
// Some extensions override the http protocol handler and provide their own
// implementation. The channels returned from that implementation doesn't

View File

@ -23,28 +23,14 @@ nsAboutBlank::NewChannel(nsIURI* aURI,
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
// Bug 1087720 (and Bug 1099296):
// Once all callsites have been updated to call NewChannel2()
// instead of NewChannel() we should have a non-null loadInfo
// consistently. Until then we have to branch on the loadInfo.
if (aLoadInfo) {
rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
aURI,
in,
NS_LITERAL_CSTRING("text/html"),
NS_LITERAL_CSTRING("utf-8"),
aLoadInfo);
}
else {
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
aURI,
in,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
NS_LITERAL_CSTRING("text/html"),
NS_LITERAL_CSTRING("utf-8"));
}
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
aURI,
in,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
NS_LITERAL_CSTRING("text/html"),
NS_LITERAL_CSTRING("utf-8"));
if (NS_FAILED(rv)) return rv;
channel.forget(result);

View File

@ -112,28 +112,14 @@ nsAboutBloat::NewChannel(nsIURI* aURI,
}
nsIChannel* channel = nullptr;
// Bug 1087720 (and Bug 1099296):
// Once all callsites have been updated to call NewChannel2()
// instead of NewChannel() we should have a non-null loadInfo
// consistently. Until then we have to branch on the loadInfo.
if (aLoadInfo) {
rv = NS_NewInputStreamChannelInternal(&channel,
aURI,
inStr,
NS_LITERAL_CSTRING("text/plain"),
NS_LITERAL_CSTRING("utf-8"),
aLoadInfo);
}
else {
rv = NS_NewInputStreamChannel(&channel,
aURI,
inStr,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
NS_LITERAL_CSTRING("text/plain"),
NS_LITERAL_CSTRING("utf-8"));
}
rv = NS_NewInputStreamChannel(&channel,
aURI,
inStr,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
NS_LITERAL_CSTRING("text/plain"),
NS_LITERAL_CSTRING("utf-8"));
if (NS_FAILED(rv)) return rv;
*result = channel;

View File

@ -64,28 +64,14 @@ nsAboutCache::NewChannel(nsIURI* aURI,
mEntriesHeaderAdded = false;
nsCOMPtr<nsIChannel> channel;
// Bug 1087720 (and Bug 1099296):
// Once all callsites have been updated to call NewChannel2()
// instead of NewChannel() we should have a non-null loadInfo
// consistently. Until then we have to branch on the loadInfo.
if (aLoadInfo) {
rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
aURI,
inputStream,
NS_LITERAL_CSTRING("text/html"),
NS_LITERAL_CSTRING("utf-8"),
aLoadInfo);
}
else {
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
aURI,
inputStream,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
NS_LITERAL_CSTRING("text/html"),
NS_LITERAL_CSTRING("utf-8"));
}
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
aURI,
inputStream,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
NS_LITERAL_CSTRING("text/html"),
NS_LITERAL_CSTRING("utf-8"));
if (NS_FAILED(rv)) return rv;
mBuffer.AssignLiteral(

View File

@ -99,18 +99,7 @@ nsAboutCacheEntry::NewChannel(nsIURI* uri,
nsCOMPtr<nsIInputStream> stream;
rv = GetContentStream(uri, getter_AddRefs(stream));
if (NS_FAILED(rv)) return rv;
// Bug 1087720 (and Bug 1099296):
// Once all callsites have been updated to call NewChannel2()
// instead of NewChannel() we should have a non-null loadInfo
// consistently. Until then we have to branch on the loadInfo.
if (aLoadInfo) {
return NS_NewInputStreamChannelInternal(result,
uri,
stream,
NS_LITERAL_CSTRING("text/html"),
NS_LITERAL_CSTRING("utf-8"),
aLoadInfo);
}
return NS_NewInputStreamChannel(result,
uri,
stream,

View File

@ -142,16 +142,6 @@ nsAboutProtocolHandler::NewChannel2(nsIURI* uri,
// The standard return case:
rv = aboutMod->NewChannel(uri, aLoadInfo, result);
if (NS_SUCCEEDED(rv)) {
// Not all implementations of nsIAboutModule::NewChannel()
// set the LoadInfo on the newly created channel yet, as
// an interim solution we set the LoadInfo here if not
// available on the channel. Bug 1087720
nsCOMPtr<nsILoadInfo> loadInfo;
(*result)->GetLoadInfo(getter_AddRefs(loadInfo));
if (!loadInfo) {
(*result)->SetLoadInfo(aLoadInfo);
}
// If this URI is safe for untrusted content, enforce that its
// principal be based on the channel's originalURI by setting the
// owner to null.

View File

@ -423,9 +423,7 @@ AppProtocolHandler::NewChannel2(nsIURI* aUri,
if (NS_FAILED(rv) || !jsInfo.isObject()) {
// Return a DummyChannel.
printf_stderr("!! Creating a dummy channel for %s (no appInfo)\n", host.get());
nsRefPtr<nsIChannel> dummyChannel = new DummyChannel();
dummyChannel->SetLoadInfo(aLoadInfo);
dummyChannel.forget(aResult);
NS_IF_ADDREF(*aResult = new DummyChannel());
return NS_OK;
}
@ -434,9 +432,7 @@ AppProtocolHandler::NewChannel2(nsIURI* aUri,
if (!appInfo->Init(cx, jsInfo) || appInfo->mPath.IsEmpty()) {
// Return a DummyChannel.
printf_stderr("!! Creating a dummy channel for %s (invalid appInfo)\n", host.get());
nsRefPtr<nsIChannel> dummyChannel = new DummyChannel();
dummyChannel->SetLoadInfo(aLoadInfo);
dummyChannel.forget(aResult);
NS_IF_ADDREF(*aResult = new DummyChannel());
return NS_OK;
}
mAppInfoCache.Put(host, appInfo);
@ -460,10 +456,6 @@ AppProtocolHandler::NewChannel2(nsIURI* aUri,
rv = channel->Init(jarURI);
NS_ENSURE_SUCCESS(rv, rv);
// set the loadInfo on the new channel
rv = channel->SetLoadInfo(aLoadInfo);
NS_ENSURE_SUCCESS(rv, rv);
rv = channel->SetAppURI(aUri);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -119,13 +119,6 @@ nsDataHandler::NewChannel2(nsIURI* uri,
return rv;
}
// set the loadInfo on the new channel
rv = channel->SetLoadInfo(aLoadInfo);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;
}
*result = channel;
return NS_OK;
}

View File

@ -62,10 +62,6 @@ nsDeviceProtocolHandler::NewChannel2(nsIURI* aURI,
nsresult rv = channel->Init(aURI);
NS_ENSURE_SUCCESS(rv, rv);
// set the loadInfo on the new channel
rv = channel->SetLoadInfo(aLoadInfo);
NS_ENSURE_SUCCESS(rv, rv);
return CallQueryInterface(channel, aResult);
}

View File

@ -192,13 +192,6 @@ nsFileProtocolHandler::NewChannel2(nsIURI* uri,
return rv;
}
// set the loadInfo on the new channel
rv = chan->SetLoadInfo(aLoadInfo);
if (NS_FAILED(rv)) {
NS_RELEASE(chan);
return rv;
}
*result = chan;
return NS_OK;
}

View File

@ -207,7 +207,7 @@ nsFtpProtocolHandler::NewChannel2(nsIURI* url,
nsILoadInfo* aLoadInfo,
nsIChannel** result)
{
return NewProxiedChannel2(url, nullptr, 0, nullptr, aLoadInfo, result);
return NewProxiedChannel(url, nullptr, 0, nullptr, result);
}
NS_IMETHODIMP
@ -234,13 +234,7 @@ nsFtpProtocolHandler::NewProxiedChannel2(nsIURI* uri, nsIProxyInfo* proxyInfo,
if (NS_FAILED(rv)) {
return rv;
}
// set the loadInfo on the new channel
rv = channel->SetLoadInfo(aLoadInfo);
if (NS_FAILED(rv)) {
return rv;
}
channel.forget(result);
return rv;
}

View File

@ -1725,7 +1725,7 @@ nsHttpHandler::NewChannel2(nsIURI* uri,
}
}
return NewProxiedChannel2(uri, nullptr, 0, nullptr, aLoadInfo, result);
return NewProxiedChannel(uri, nullptr, 0, nullptr, result);
}
NS_IMETHODIMP
@ -1793,12 +1793,6 @@ nsHttpHandler::NewProxiedChannel2(nsIURI *uri,
if (NS_FAILED(rv))
return rv;
// set the loadInfo on the new channel
rv = httpChannel->SetLoadInfo(aLoadInfo);
if (NS_FAILED(rv)) {
return rv;
}
httpChannel.forget(result);
return NS_OK;
}
@ -2113,7 +2107,7 @@ nsHttpsHandler::NewChannel2(nsIURI* aURI,
MOZ_ASSERT(gHttpHandler);
if (!gHttpHandler)
return NS_ERROR_UNEXPECTED;
return gHttpHandler->NewChannel2(aURI, aLoadInfo, _retval);
return gHttpHandler->NewChannel(aURI, _retval);
}
NS_IMETHODIMP

View File

@ -284,27 +284,14 @@ nsResProtocolHandler::NewChannel2(nsIURI* uri,
nsIChannel** result)
{
NS_ENSURE_ARG_POINTER(uri);
nsresult rv;
nsAutoCString spec;
nsresult rv = ResolveURI(uri, spec);
NS_ENSURE_SUCCESS(rv, rv);
// Bug 1087720 (and Bug 1099296):
// Once all callsites have been updated to call NewChannel2() instead of NewChannel()
// we should have a non-null loadInfo consistently. Until then we have to branch on the
// loadInfo.
nsCOMPtr<nsIURI> newURI;
rv = NS_NewURI(getter_AddRefs(newURI), spec);
NS_ENSURE_SUCCESS(rv, rv);
rv = ResolveURI(uri, spec);
if (NS_FAILED(rv)) return rv;
if (aLoadInfo) {
rv = NS_NewChannelInternal(result,
newURI,
aLoadInfo);
}
else {
rv = mIOService->NewChannelFromURI(newURI, result);
}
NS_ENSURE_SUCCESS(rv, rv);
rv = mIOService->NewChannel(spec, nullptr, nullptr, result);
if (NS_FAILED(rv)) return rv;
nsLoadFlags loadFlags = 0;
(*result)->GetLoadFlags(&loadFlags);

View File

@ -86,10 +86,6 @@ RtspHandler::NewChannel2(nsIURI* aURI,
rv = rtspChannel->Init();
NS_ENSURE_SUCCESS(rv, rv);
// set the loadInfo on the new channel
rv = rtspChannel->SetLoadInfo(aLoadInfo);
NS_ENSURE_SUCCESS(rv, rv);
rtspChannel.forget(aResult);
return NS_OK;
}

View File

@ -106,13 +106,6 @@ nsViewSourceHandler::NewChannel2(nsIURI* uri,
return rv;
}
// set the loadInfo on the new channel
rv = channel->SetLoadInfo(aLoadInfo);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;
}
*result = static_cast<nsIViewSourceChannel*>(channel);
return NS_OK;
}

View File

@ -131,12 +131,6 @@ nsWyciwygProtocolHandler::NewChannel2(nsIURI* url,
if (NS_FAILED(rv))
return rv;
// set the loadInfo on the new channel
rv = channel->SetLoadInfo(aLoadInfo);
if (NS_FAILED(rv)) {
return rv;
}
channel.forget(result);
return NS_OK;
}

View File

@ -279,7 +279,7 @@ nsAnnoProtocolHandler::NewChannel2(nsIURI* aURI,
if (!annoName.EqualsLiteral(FAVICON_ANNOTATION_NAME))
return NS_ERROR_INVALID_ARG;
return NewFaviconChannel(aURI, annoURI, aLoadInfo, _retval);
return NewFaviconChannel(aURI, annoURI, _retval);
}
NS_IMETHODIMP
@ -328,7 +328,7 @@ nsAnnoProtocolHandler::ParseAnnoURI(nsIURI* aURI,
nsresult
nsAnnoProtocolHandler::NewFaviconChannel(nsIURI *aURI, nsIURI *aAnnotationURI,
nsILoadInfo* aLoadInfo, nsIChannel **_channel)
nsIChannel **_channel)
{
// Create our pipe. This will give us our input stream and output stream
// that will be written to when we get data from the database.
@ -343,26 +343,12 @@ nsAnnoProtocolHandler::NewFaviconChannel(nsIURI *aURI, nsIURI *aAnnotationURI,
// Create our channel. We'll call SetContentType with the right type when
// we know what it actually is.
nsCOMPtr<nsIChannel> channel;
// Bug 1087720 (and Bug 1099296):
// Once all callsites have been updated to call NewChannel2() instead of NewChannel()
// we should have a non-null loadInfo consistently. Until then we have to brach on the
// loadInfo and provide default arguments to create a NewInputStreamChannel.
if (aLoadInfo) {
rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
aURI,
inputStream,
EmptyCString(), // aContentType
EmptyCString(), // aContentCharset
aLoadInfo);
}
else {
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
aURI,
inputStream,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER);
}
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
aURI,
inputStream,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER);
NS_ENSURE_SUCCESS(rv, GetDefaultIcon(_channel));
// Now we go ahead and get our data asynchronously for the favicon.

View File

@ -41,13 +41,10 @@ protected:
* @param aAnnotationURI
* The URI that holds the data needed to get the favicon from the
* database.
* @param aLoadInfo
* The loadinfo that requested the resource load.
* @returns (via _channel) the channel that will obtain the favicon data.
*/
nsresult NewFaviconChannel(nsIURI *aURI,
nsIURI *aAnnotationURI,
nsILoadInfo *aLoadInfo,
nsIChannel **_channel);
};

View File

@ -57,7 +57,6 @@ private:
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCOMPtr<nsILoadInfo> mLoadInfo;
};
NS_IMPL_ADDREF(nsExtProtocolChannel)
@ -265,16 +264,14 @@ NS_IMETHODIMP nsExtProtocolChannel::SetOwner(nsISupports * aPrincipal)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsExtProtocolChannel::GetLoadInfo(nsILoadInfo **aLoadInfo)
NS_IMETHODIMP nsExtProtocolChannel::GetLoadInfo(nsILoadInfo * *aLoadInfo)
{
NS_IF_ADDREF(*aLoadInfo = mLoadInfo);
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsExtProtocolChannel::SetLoadInfo(nsILoadInfo *aLoadInfo)
NS_IMETHODIMP nsExtProtocolChannel::SetLoadInfo(nsILoadInfo * aLoadInfo)
{
mLoadInfo = aLoadInfo;
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
}
////////////////////////////////////////////////////////////////////////////////
@ -416,9 +413,6 @@ nsExternalProtocolHandler::NewChannel2(nsIURI* aURI,
((nsExtProtocolChannel*) channel.get())->SetURI(aURI);
channel->SetOriginalURI(aURI);
// set the loadInfo on the new channel
((nsExtProtocolChannel*) channel.get())->SetLoadInfo(aLoadInfo);
if (_retval)
{
*_retval = channel;

View File

@ -170,11 +170,6 @@ nsAndroidProtocolHandler::NewChannel2(nsIURI* aURI,
nsCOMPtr<nsIChannel> channel = AndroidChannel::CreateChannel(aURI);
if (!channel)
return NS_ERROR_FAILURE;
// set the loadInfo on the new channel
nsresult rv = channel->SetLoadInfo(aLoadInfo);
NS_ENSURE_SUCCESS(rv, rv);
NS_ADDREF(*aResult = channel);
return NS_OK;
}