--- a/browser/components/about/AboutRedirector.cpp +++ b/browser/components/about/AboutRedirector.cpp @@ -148,32 +148,18 @@ AboutRedirector::NewChannel(nsIURI* aURI nsresult rv; nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv); NS_ENSURE_SUCCESS(rv, 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), - 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); NS_ADDREF(*result = tempChannel); return rv; } }
--- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -971,17 +971,17 @@ nsScriptSecurityManager::CreateCodebaseP // I _think_ it's safe to not create null principals here based on aURI. // At least all the callers would do the right thing in those cases, as far // as I can tell. --bz nsCOMPtr<nsIURIWithPrincipal> uriPrinc = do_QueryInterface(aURI); if (uriPrinc) { nsCOMPtr<nsIPrincipal> principal; uriPrinc->GetPrincipal(getter_AddRefs(principal)); - if (!principal) { + if (!principal || principal == mSystemPrincipal) { return CallCreateInstance(NS_NULLPRINCIPAL_CONTRACTID, result); } principal.forget(result); return NS_OK; }
--- a/chrome/nsChromeProtocolHandler.cpp +++ b/chrome/nsChromeProtocolHandler.cpp @@ -95,17 +95,17 @@ nsChromeProtocolHandler::NewURI(const ns surl->SetMutable(false); NS_ADDREF(*result = url); return NS_OK; } NS_IMETHODIMP nsChromeProtocolHandler::NewChannel2(nsIURI* aURI, - nsILoadInfo* aLoadInfo, + nsILoadInfo* aLoadinfo, nsIChannel** aResult) { nsresult rv; NS_ENSURE_ARG_POINTER(aURI); NS_PRECONDITION(aResult, "Null out param"); #ifdef DEBUG @@ -142,32 +142,22 @@ nsChromeProtocolHandler::NewChannel2(nsI #ifdef DEBUG nsAutoCString spec; aURI->GetSpec(spec); printf("Couldn't convert chrome URL: %s\n", spec.get()); #endif 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) { nsCOMPtr<nsIFile> file; fileChan->GetFile(getter_AddRefs(file)); bool exists = false; file->Exists(&exists);
--- a/docshell/base/LoadInfo.cpp +++ b/docshell/base/LoadInfo.cpp @@ -15,33 +15,26 @@ namespace mozilla { LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal, nsINode* aLoadingContext, 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; } } LoadInfo::~LoadInfo() {
--- a/docshell/base/nsAboutRedirector.cpp +++ b/docshell/base/nsAboutRedirector.cpp @@ -80,45 +80,34 @@ static const int kRedirTotal = mozilla:: NS_IMETHODIMP nsAboutRedirector::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo, nsIChannel** result) { 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; tempChannel->SetOriginalURI(aURI); NS_ADDREF(*result = tempChannel); return rv; }
--- a/dom/base/nsHostObjectProtocolHandler.cpp +++ b/dom/base/nsHostObjectProtocolHandler.cpp @@ -480,17 +480,17 @@ nsHostObjectProtocolHandler::NewURI(cons NS_TryToSetImmutable(uri); uri.forget(aResult); return NS_OK; } NS_IMETHODIMP nsHostObjectProtocolHandler::NewChannel2(nsIURI* uri, - nsILoadInfo* aLoadInfo, + nsILoadInfo *aLoadinfo, nsIChannel** result) { *result = nullptr; nsCString spec; uri->GetSpec(spec); DataInfo* info = GetDataInfo(spec); @@ -514,36 +514,23 @@ nsHostObjectProtocolHandler::NewChannel2 #endif FileImpl* blob = static_cast<FileImpl*>(blobImpl.get()); nsCOMPtr<nsIInputStream> stream; nsresult rv = blob->GetInternalStream(getter_AddRefs(stream)); 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; blob->GetType(type); if (blob->IsFile()) { nsString filename; blob->GetName(filename);
--- a/dom/jsurl/nsJSProtocolHandler.cpp +++ b/dom/jsurl/nsJSProtocolHandler.cpp @@ -1218,21 +1218,16 @@ nsJSProtocolHandler::NewChannel2(nsIURI* channel = new nsJSChannel(); if (!channel) { return NS_ERROR_OUT_OF_MEMORY; } 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); } NS_RELEASE(channel); return rv; }
--- a/extensions/gio/nsGIOProtocolHandler.cpp +++ b/extensions/gio/nsGIOProtocolHandler.cpp @@ -1054,49 +1054,37 @@ nsGIOProtocolHandler::NewChannel2(nsIURI nsresult rv; nsAutoCString spec; rv = aURI->GetSpec(spec); if (NS_FAILED(rv)) 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); // start out assuming an unknown content-type. we'll set the content-type // to something better once we open the URI. rv = NS_NewInputStreamChannel(aResult, aURI, stream, nullPrincipal, 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; } NS_IMETHODIMP nsGIOProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **aResult) { return NewChannel2(aURI, nullptr, aResult);
--- a/image/decoders/icon/nsIconProtocolHandler.cpp +++ b/image/decoders/icon/nsIconProtocolHandler.cpp @@ -91,23 +91,16 @@ nsIconProtocolHandler::NewChannel2(nsIUR NS_ADDREF(channel); nsresult rv = channel->Init(url); if (NS_FAILED(rv)) { NS_RELEASE(channel); 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; } NS_IMETHODIMP nsIconProtocolHandler::NewChannel(nsIURI* url, nsIChannel** result) { return NewChannel2(url, nullptr, result);
--- a/modules/libjar/nsJARProtocolHandler.cpp +++ b/modules/libjar/nsJARProtocolHandler.cpp @@ -218,23 +218,16 @@ nsJARProtocolHandler::NewChannel2(nsIURI NS_ADDREF(chan); nsresult rv = chan->Init(uri); if (NS_FAILED(rv)) { NS_RELEASE(chan); 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; } NS_IMETHODIMP nsJARProtocolHandler::NewChannel(nsIURI *uri, nsIChannel **result) { return NewChannel2(uri, nullptr, result);
--- a/netwerk/base/public/nsIIOService.idl +++ b/netwerk/base/public/nsIIOService.idl @@ -62,68 +62,18 @@ interface nsIIOService : nsISupports * callers to specify whether this is a file or directory by * splitting this into newDirURI() and newActualFileURI(). */ nsIURI newFileURI(in nsIFile aFile); /** * 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, in nsIPrincipal aLoadingPrincipal, in nsIPrincipal aTriggeringPrincipal, in unsigned long aSecurityFlags, in unsigned long aContentPolicyType); @@ -131,17 +81,17 @@ interface nsIIOService : nsISupports * Creates a channel for a given URI. * * @param aURI nsIURI from which to make a channel * @return reference to the new nsIChannel object */ nsIChannel newChannelFromURI(in nsIURI aURI); /** - * Equivalent to newChannelFromURI2(newURI(...)) + * Equivalent to newChannelFromURI(newURI(...)) */ nsIChannel newChannel2(in AUTF8String aSpec, in string aOriginCharset, in nsIURI aBaseURI, in nsIDOMNode aLoadingNode, in nsIPrincipal aLoadingPrincipal, in nsIPrincipal aTriggeringPrincipal, in unsigned long aSecurityFlags,
--- a/netwerk/base/public/nsIIOService2.idl +++ b/netwerk/base/public/nsIIOService2.idl @@ -28,73 +28,22 @@ interface nsIIOService2 : nsIIOService * if there is no link, until application code runs and can turn off * this management. */ attribute boolean manageOfflineStatus; /** * 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, in unsigned long aProxyFlags, in nsIDOMNode aLoadingNode, in nsIPrincipal aLoadingPrincipal, in nsIPrincipal aTriggeringPrincipal, in unsigned long aSecurityFlags,
--- a/netwerk/base/public/nsIProxiedProtocolHandler.idl +++ b/netwerk/base/public/nsIProxiedProtocolHandler.idl @@ -22,17 +22,16 @@ interface nsIProxiedProtocolHandler : ns * @param proxyResolveFlags used if the proxy is later determined * from nsIProtocolProxyService::asyncResolve * @param proxyURI used if the proxy is later determined from * nsIProtocolProxyService::asyncResolve with this as the proxyURI name. * Generally this is the same as uri (or null which has the same * 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, in nsIURI proxyURI, in nsILoadInfo aLoadInfo); /** Create a new channel with the given proxyInfo *
--- a/netwerk/base/public/nsNetUtil.h +++ b/netwerk/base/public/nsNetUtil.h @@ -183,111 +183,47 @@ NS_NewFileURI(nsIURI* *result, nsCOMPtr<nsIIOService> grip; rv = net_EnsureIOService(&ioService, grip); if (ioService) rv = ioService->NewFileURI(spec, result); return rv; } /* -* 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, nsIIOService* aIoService = nullptr) { NS_ENSURE_ARG_POINTER(outChannel); nsCOMPtr<nsIIOService> grip; nsresult rv = net_EnsureIOService(&aIoService, grip); 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) { rv = channel->SetLoadGroup(aLoadGroup); NS_ENSURE_SUCCESS(rv, rv); } if (aCallbacks) { @@ -311,35 +247,34 @@ NS_NewChannelInternal(nsIChannel** nsCOMPtr<nsILoadInfo> loadInfo; channel->GetLoadInfo(getter_AddRefs(loadInfo)); if (loadInfo) { aSecurityFlags |= loadInfo->GetSecurityFlags(); } // 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; } channel->SetLoadInfo(loadInfo); // If we're sandboxed, make sure to clear any owner the channel // might already have. if (loadInfo->GetLoadingSandboxed()) { channel->SetOwner(nullptr); } channel.forget(outChannel); return NS_OK; } -// See NS_NewChannelInternal for usage and argument description inline nsresult NS_NewChannelInternal(nsIChannel** outChannel, nsIURI* aUri, nsILoadInfo* aLoadInfo, nsILoadGroup* aLoadGroup = nullptr, nsIInterfaceRequestor* aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, nsIIOService* aIoService = nullptr) @@ -347,161 +282,160 @@ NS_NewChannelInternal(nsIChannel** MOZ_ASSERT(aLoadInfo, "Can not create a channel without a loadInfo"); nsresult rv = NS_NewChannelInternal(outChannel, aUri, aLoadInfo->LoadingNode(), aLoadInfo->LoadingPrincipal(), 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, nsILoadGroup* aLoadGroup = nullptr, nsIInterfaceRequestor* aCallbacks = nullptr, 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, nsILoadGroup* aLoadGroup = nullptr, nsIInterfaceRequestor* aCallbacks = nullptr, 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, nsIInterfaceRequestor* aCallbacks = nullptr, 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, nsIInterfaceRequestor* aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, nsIIOService* aIoService = nullptr) { return NS_NewChannelInternal(outChannel, aUri, - nullptr, // aLoadingNode, - aLoadingPrincipal, + nullptr, // aRequestingNode, + aRequestingPrincipal, nullptr, // aTriggeringPrincipal aSecurityFlags, aContentPolicyType, + nullptr, // aBaseURI aLoadGroup, aCallbacks, aLoadFlags, aIoService); } // Use this function with CAUTION. It creates a stream that blocks when you // Read() from it and blocking the UI thread is a bad idea. If you don't want // to implement a full blown asynchronous consumer (via nsIStreamListener) look // at nsIStreamLoader instead. inline nsresult NS_OpenURIInternal(nsIInputStream** outStream, nsIURI* aUri, - nsINode* aLoadingNode, - nsIPrincipal* aLoadingPrincipal, + nsINode* aRequestingNode, + nsIPrincipal* aRequestingPrincipal, nsIPrincipal* aTriggeringPrincipal, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, nsILoadGroup* aLoadGroup = nullptr, nsIInterfaceRequestor* aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, 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, aIoService); NS_ENSURE_SUCCESS(rv, rv); nsIInputStream *stream; rv = channel->Open(&stream); @@ -512,58 +446,58 @@ NS_OpenURIInternal(nsIInputStream** channel.swap(*outChannel); } return NS_OK; } inline nsresult /* NS_OpenURIprincipal */ NS_OpenURI(nsIInputStream** outStream, nsIURI* aUri, - nsIPrincipal* aLoadingPrincipal, + nsIPrincipal* aRequestingPrincipal, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, nsILoadGroup* aLoadGroup = nullptr, nsIInterfaceRequestor* aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, nsIIOService* aIoService = nullptr, nsIChannel** outChannel = nullptr) { return NS_OpenURIInternal(outStream, aUri, - nullptr, // aLoadingNode - aLoadingPrincipal, + nullptr, // aRequestingNode + aRequestingPrincipal, nullptr, // aTriggeringPrincipal aSecurityFlags, aContentPolicyType, aLoadGroup, aCallbacks, aLoadFlags, aIoService, outChannel); } inline nsresult /* NS_OpenURIWithTriggeringPrincipalAndNode */ NS_OpenURIWithTriggeringPrincipal(nsIInputStream** outStream, nsIURI* aUri, - nsINode* aLoadingNode, + nsINode* aRequestingNode, nsIPrincipal* aTriggeringPrincipal, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, nsILoadGroup* aLoadGroup = nullptr, nsIInterfaceRequestor* aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, 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, aLoadGroup, aCallbacks, aLoadFlags, aIoService, outChannel); @@ -590,32 +524,32 @@ NS_OpenURIInternal(nsIStreamListener* NS_ENSURE_SUCCESS(rv, rv); return channel->AsyncOpen(aListener, aContext); } inline nsresult NS_OpenURIInternal(nsIStreamListener* aListener, nsISupports* aContext, nsIURI* aUri, - nsINode* aLoadingNode, - nsIPrincipal* aLoadingPrincipal, + nsINode* aRequestingNode, + nsIPrincipal* aRequestingPrincipal, nsIPrincipal* aTriggeringPrincipal, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, nsILoadGroup* aLoadGroup = nullptr, nsIInterfaceRequestor* aCallbacks = nullptr, 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) { return NS_ERROR_UNEXPECTED; } return NS_OpenURIInternal(aListener, aContext, aUri, @@ -625,29 +559,29 @@ NS_OpenURIInternal(nsIStreamListener* aLoadFlags, aIoService); } inline nsresult NS_OpenURI(nsIStreamListener* aListener, nsISupports* aContext, nsIURI* aUri, - nsIPrincipal* aLoadingPrincipal, + nsIPrincipal* aRequestingPrincipal, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, nsILoadGroup* aLoadGroup = nullptr, nsIInterfaceRequestor* aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, nsIIOService* aIoService = nullptr) { return NS_OpenURIInternal(aListener, aContext, aUri, - nullptr, // aLoadingNode - aLoadingPrincipal, + nullptr, // aRequestingNode + aRequestingPrincipal, nullptr, // aTriggeringPrincipal aSecurityFlags, aContentPolicyType, aLoadGroup, aCallbacks, aLoadFlags, aIoService); } @@ -771,25 +705,29 @@ NS_GetRealPort(nsIURI* aURI) nsAutoCString scheme; rv = aURI->GetScheme(scheme); if (NS_FAILED(rv)) return -1; 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); NS_ENSURE_SUCCESS(rv, rv); rv = isc->SetURI(aUri); NS_ENSURE_SUCCESS(rv, rv); rv = isc->SetContentStream(aStream); NS_ENSURE_SUCCESS(rv, rv); @@ -802,88 +740,67 @@ NS_NewInputStreamChannelInternal(nsIChan NS_ENSURE_SUCCESS(rv, rv); } if (!aContentCharset.IsEmpty()) { rv = channel->SetContentCharset(aContentCharset); 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); } channel.forget(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(), const nsACString& aContentCharset = EmptyCString()) { return NS_NewInputStreamChannelInternal(outChannel, aUri, aStream, aContentType, aContentCharset, - nullptr, // aLoadingNode - aLoadingPrincipal, + nullptr, // aRequestingNode + aRequestingPrincipal, nullptr, // aTriggeringPrincipal aSecurityFlags, aContentPolicyType); } inline nsresult 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, bool aIsSrcdocChannel = false, nsIURI* aBaseURI = nullptr) { nsresult rv; nsCOMPtr<nsIStringInputStream> stream; @@ -900,18 +817,18 @@ NS_NewInputStreamChannelInternal(nsIChan #endif nsCOMPtr<nsIChannel> channel; rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel), aUri, stream, aContentType, NS_LITERAL_CSTRING("UTF-8"), - aLoadingNode, - aLoadingPrincipal, + aRequestingNode, + aRequestingPrincipal, aTriggeringPrincipal, aSecurityFlags, aContentPolicyType, aBaseURI); NS_ENSURE_SUCCESS(rv, rv); if (aIsSrcdocChannel) { @@ -923,28 +840,28 @@ NS_NewInputStreamChannelInternal(nsIChan return NS_OK; } inline nsresult NS_NewInputStreamChannel(nsIChannel** outChannel, nsIURI* aUri, const nsAString& aData, const nsACString& aContentType, - nsIPrincipal* aLoadingPrincipal, + nsIPrincipal* aRequestingPrincipal, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, bool aIsSrcdocChannel = false, nsIURI* aBaseURI = nullptr) { return NS_NewInputStreamChannelInternal(outChannel, aUri, aData, aContentType, - nullptr, // aLoadingNode - aLoadingPrincipal, + nullptr, // aRequestingNode + aRequestingPrincipal, nullptr, // aTriggeringPrincipal aSecurityFlags, aContentPolicyType, aIsSrcdocChannel, aBaseURI); } inline nsresult @@ -1047,34 +964,35 @@ NS_NewStreamLoader(nsIStreamLoader } return rv; } 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, nsILoadGroup* aLoadGroup = nullptr, nsIInterfaceRequestor* aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, nsIURI* aReferrer = nullptr) { nsCOMPtr<nsIChannel> channel; nsresult rv = NS_NewChannelInternal(getter_AddRefs(channel), aUri, - aLoadingNode, - aLoadingPrincipal, + aRequestingNode, + aRequestingPrincipal, nullptr, // aTriggeringPrincipal aSecurityFlags, aContentPolicyType, + nullptr, // aBaseURI aLoadGroup, aCallbacks, aLoadFlags); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel)); if (httpChannel) { httpChannel->SetReferrer(aReferrer); @@ -1084,58 +1002,58 @@ NS_NewStreamLoaderInternal(nsIStreamLoad return channel->AsyncOpen(*outStream, aContext); } inline nsresult /* NS_NewStreamLoaderNode */ NS_NewStreamLoader(nsIStreamLoader** outStream, nsIURI* aUri, nsIStreamLoaderObserver* aObserver, - nsINode* aLoadingNode, + nsINode* aRequestingNode, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, nsISupports* aContext = nullptr, nsILoadGroup* aLoadGroup = nullptr, nsIInterfaceRequestor* aCallbacks = nullptr, 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, aLoadGroup, aCallbacks, aLoadFlags, aReferrer); } inline nsresult /* NS_NewStreamLoaderPrincipal */ NS_NewStreamLoader(nsIStreamLoader** outStream, nsIURI* aUri, nsIStreamLoaderObserver* aObserver, - nsIPrincipal* aLoadingPrincipal, + nsIPrincipal* aRequestingPrincipal, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, nsISupports* aContext = nullptr, nsILoadGroup* aLoadGroup = nullptr, nsIInterfaceRequestor* aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, nsIURI* aReferrer = nullptr) { return NS_NewStreamLoaderInternal(outStream, aUri, aObserver, - nullptr, // aLoadingNode - aLoadingPrincipal, + nullptr, // aRequestingNode + aRequestingPrincipal, aSecurityFlags, aContentPolicyType, aContext, aLoadGroup, aCallbacks, aLoadFlags, aReferrer); } @@ -1741,24 +1659,24 @@ NS_ReadInputStreamToString(nsIInputStrea return NS_ReadInputStreamToBuffer(aInputStream, &dest, aCount); } #endif 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 nullptr, // aCallbacks nsIRequest::LOAD_NORMAL, //aLoadFlags aIoService); NS_ENSURE_SUCCESS(rv, rv); @@ -1771,33 +1689,33 @@ NS_LoadPersistentPropertiesFromURI(nsIPe properties.swap(*outResult); } return rv; } inline nsresult NS_LoadPersistentPropertiesFromURISpec(nsIPersistentProperties** outResult, const nsACString& aSpec, - nsIPrincipal* aLoadingPrincipal, + nsIPrincipal* aRequestingPrincipal, nsContentPolicyType aContentPolicyType, const char* aCharset = nullptr, nsIURI* aBaseURI = nullptr, nsIIOService* aIoService = nullptr) { nsCOMPtr<nsIURI> uri; nsresult rv = NS_NewURI(getter_AddRefs(uri), aSpec, aCharset, aBaseURI, aIoService); NS_ENSURE_SUCCESS(rv, rv); return NS_LoadPersistentPropertiesFromURI(outResult, uri, - aLoadingPrincipal, + aRequestingPrincipal, aContentPolicyType, aIoService); } /** * NS_QueryNotificationCallbacks implements the canonical algorithm for * querying interfaces from a channel's notification callbacks. It first * searches the channel's notificationCallbacks attribute, and if the interface
--- a/netwerk/base/src/nsIOService.cpp +++ b/netwerk/base/src/nsIOService.cpp @@ -35,17 +35,16 @@ #include "nsPISocketTransportService.h" #include "nsAsyncRedirectVerifyHelper.h" #include "nsURLHelper.h" #include "nsPIDNSService.h" #include "nsIProtocolProxyService2.h" #include "MainThreadUtils.h" #include "nsIWidget.h" #include "nsThreadUtils.h" -#include "mozilla/LoadInfo.h" #include "mozilla/net/NeckoCommon.h" #ifdef MOZ_WIDGET_GONK #include "nsINetworkManager.h" #endif #if defined(XP_WIN) #include "nsNativeConnectionHelper.h" @@ -630,86 +629,23 @@ nsIOService::NewChannelFromURIWithProxyF if (NS_FAILED(rv)) return rv; uint32_t protoFlags; rv = handler->GetProtocolFlags(&protoFlags); 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 // seem to always implement the nsIUploadChannel2 interface, presumably // because it's a new interface. // Eventually we should remove this and simply require that http channels // implement the new interface. // See bug 529041
--- a/netwerk/protocol/about/nsAboutBlank.cpp +++ b/netwerk/protocol/about/nsAboutBlank.cpp @@ -18,38 +18,24 @@ nsAboutBlank::NewChannel(nsIURI* aURI, { NS_ENSURE_ARG_POINTER(aURI); nsCOMPtr<nsIInputStream> in; nsresult rv = NS_NewCStringInputStream(getter_AddRefs(in), EmptyCString()); 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); return rv; } NS_IMETHODIMP nsAboutBlank::GetURIFlags(nsIURI *aURI, uint32_t *result)
--- a/netwerk/protocol/about/nsAboutBloat.cpp +++ b/netwerk/protocol/about/nsAboutBloat.cpp @@ -107,38 +107,24 @@ nsAboutBloat::NewChannel(nsIURI* aURI, ::fclose(out); if (NS_FAILED(rv)) return rv; rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), file); if (NS_FAILED(rv)) return rv; } 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; return rv; } NS_IMETHODIMP nsAboutBloat::GetURIFlags(nsIURI *aURI, uint32_t *result)
--- a/netwerk/protocol/about/nsAboutCache.cpp +++ b/netwerk/protocol/about/nsAboutCache.cpp @@ -59,38 +59,24 @@ nsAboutCache::NewChannel(nsIURI* aURI, // ...and visit just the specified storage, entries will output too mStorageList.AppendElement(storageName); } // The entries header is added on encounter of the first entry 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( "<!DOCTYPE html>\n" "<html>\n" "<head>\n" " <title>Network Cache Storage Information</title>\n" " <meta charset=\"utf-8\">\n"
--- a/netwerk/protocol/about/nsAboutCacheEntry.cpp +++ b/netwerk/protocol/about/nsAboutCacheEntry.cpp @@ -94,28 +94,17 @@ nsAboutCacheEntry::NewChannel(nsIURI* ur nsIChannel** result) { NS_ENSURE_ARG_POINTER(uri); nsresult rv; 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, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_NORMAL, nsIContentPolicy::TYPE_OTHER, NS_LITERAL_CSTRING("text/html"), NS_LITERAL_CSTRING("utf-8"));
--- a/netwerk/protocol/about/nsAboutProtocolHandler.cpp +++ b/netwerk/protocol/about/nsAboutProtocolHandler.cpp @@ -137,26 +137,16 @@ nsAboutProtocolHandler::NewChannel2(nsIU // that it doesn't exist. rv = NS_ERROR_FACTORY_NOT_REGISTERED; } if (NS_SUCCEEDED(rv)) { // 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. // Note: this relies on aboutMod's newChannel implementation // having set the proper originalURI, which probably isn't ideal. if (IsSafeForUntrustedContent(aboutMod, uri)) { (*result)->SetOwner(nullptr); }
--- a/netwerk/protocol/app/AppProtocolHandler.cpp +++ b/netwerk/protocol/app/AppProtocolHandler.cpp @@ -418,30 +418,26 @@ AppProtocolHandler::NewChannel2(nsIURI* } mozilla::AutoSafeJSContext cx; JS::RootedValue jsInfo(cx); rv = appsService->GetAppInfo(NS_ConvertUTF8toUTF16(host), &jsInfo); 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; } appInfo = new mozilla::dom::AppInfo(); JSAutoCompartment ac(cx, &jsInfo.toObject()); 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); } bool noRemote = (appInfo->mIsCoreApp || XRE_GetProcessType() == GeckoProcessType_Default); @@ -455,20 +451,16 @@ AppProtocolHandler::NewChannel2(nsIURI* nsCOMPtr<nsIURI> jarURI; rv = NS_NewURI(getter_AddRefs(jarURI), jarSpec, nullptr, nullptr); NS_ENSURE_SUCCESS(rv, rv); 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); rv = channel->SetOriginalURI(aUri); NS_ENSURE_SUCCESS(rv, rv); channel.forget(aResult); return NS_OK;
--- a/netwerk/protocol/data/nsDataHandler.cpp +++ b/netwerk/protocol/data/nsDataHandler.cpp @@ -114,23 +114,16 @@ nsDataHandler::NewChannel2(nsIURI* uri, NS_ADDREF(channel); nsresult rv = channel->Init(); if (NS_FAILED(rv)) { NS_RELEASE(channel); 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; } NS_IMETHODIMP nsDataHandler::NewChannel(nsIURI* uri, nsIChannel* *result) { return NewChannel2(uri, nullptr, result);
--- a/netwerk/protocol/device/nsDeviceProtocolHandler.cpp +++ b/netwerk/protocol/device/nsDeviceProtocolHandler.cpp @@ -57,20 +57,16 @@ NS_IMETHODIMP nsDeviceProtocolHandler::NewChannel2(nsIURI* aURI, nsILoadInfo* aLoadInfo, nsIChannel** aResult) { nsRefPtr<nsDeviceChannel> channel = new nsDeviceChannel(); 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); } NS_IMETHODIMP nsDeviceProtocolHandler::NewChannel(nsIURI* aURI, nsIChannel **aResult) { return NewChannel2(aURI, nullptr, aResult); }
--- a/netwerk/protocol/file/nsFileProtocolHandler.cpp +++ b/netwerk/protocol/file/nsFileProtocolHandler.cpp @@ -187,23 +187,16 @@ nsFileProtocolHandler::NewChannel2(nsIUR NS_ADDREF(chan); nsresult rv = chan->Init(); if (NS_FAILED(rv)) { NS_RELEASE(chan); 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; } NS_IMETHODIMP nsFileProtocolHandler::NewChannel(nsIURI *uri, nsIChannel **result) { return NewChannel2(uri, nullptr, result);
--- a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp +++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp @@ -202,17 +202,17 @@ nsFtpProtocolHandler::NewURI(const nsACS return CallQueryInterface(url, result); } NS_IMETHODIMP 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 nsFtpProtocolHandler::NewChannel(nsIURI* url, nsIChannel* *result) { return NewChannel2(url, nullptr, result); } @@ -229,23 +229,17 @@ nsFtpProtocolHandler::NewProxiedChannel2 channel = new FTPChannelChild(uri); else channel = new nsFtpChannel(uri, proxyInfo); nsresult rv = channel->Init(); 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; } NS_IMETHODIMP nsFtpProtocolHandler::NewProxiedChannel(nsIURI* uri, nsIProxyInfo* proxyInfo, uint32_t proxyResolveFlags, nsIURI *proxyURI,
--- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -1720,17 +1720,17 @@ nsHttpHandler::NewChannel2(nsIURI* uri, rv = uri->SchemeIs("https", &isHttps); if (NS_FAILED(rv)) return rv; if (!isHttps) { NS_WARNING("Invalid URI scheme"); return NS_ERROR_UNEXPECTED; } } - return NewProxiedChannel2(uri, nullptr, 0, nullptr, aLoadInfo, result); + return NewProxiedChannel(uri, nullptr, 0, nullptr, result); } NS_IMETHODIMP nsHttpHandler::NewChannel(nsIURI *uri, nsIChannel **result) { return NewChannel2(uri, nullptr, result); } @@ -1788,22 +1788,16 @@ nsHttpHandler::NewProxiedChannel2(nsIURI // HACK: make sure PSM gets initialized on the main thread. net_EnsurePSMInit(); } rv = httpChannel->Init(uri, caps, proxyInfo, proxyResolveFlags, proxyURI); 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; } NS_IMETHODIMP nsHttpHandler::NewProxiedChannel(nsIURI *uri, nsIProxyInfo* givenProxyInfo, uint32_t proxyResolveFlags, @@ -2108,17 +2102,17 @@ nsHttpsHandler::NewURI(const nsACString NS_IMETHODIMP nsHttpsHandler::NewChannel2(nsIURI* aURI, nsILoadInfo* aLoadInfo, nsIChannel** _retval) { MOZ_ASSERT(gHttpHandler); if (!gHttpHandler) return NS_ERROR_UNEXPECTED; - return gHttpHandler->NewChannel2(aURI, aLoadInfo, _retval); + return gHttpHandler->NewChannel(aURI, _retval); } NS_IMETHODIMP nsHttpsHandler::NewChannel(nsIURI *aURI, nsIChannel **_retval) { return NewChannel2(aURI, nullptr, _retval); }
--- a/netwerk/protocol/res/nsResProtocolHandler.cpp +++ b/netwerk/protocol/res/nsResProtocolHandler.cpp @@ -279,37 +279,24 @@ nsResProtocolHandler::NewURI(const nsACS } NS_IMETHODIMP nsResProtocolHandler::NewChannel2(nsIURI* uri, nsILoadInfo* aLoadInfo, 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); (*result)->SetLoadFlags(loadFlags & ~nsIChannel::LOAD_REPLACE); return (*result)->SetOriginalURI(uri); } NS_IMETHODIMP
--- a/netwerk/protocol/rtsp/RtspHandler.cpp +++ b/netwerk/protocol/rtsp/RtspHandler.cpp @@ -81,20 +81,16 @@ RtspHandler::NewChannel2(nsIURI* aURI, rtspChannel = new RtspChannelChild(aURI); } else { rtspChannel = new RtspChannelParent(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; } NS_IMETHODIMP RtspHandler::NewChannel(nsIURI *aURI, nsIChannel **aResult) { return NewChannel2(aURI, nullptr, aResult);
--- a/netwerk/protocol/viewsource/nsViewSourceHandler.cpp +++ b/netwerk/protocol/viewsource/nsViewSourceHandler.cpp @@ -101,23 +101,16 @@ nsViewSourceHandler::NewChannel2(nsIURI* NS_ADDREF(channel); nsresult rv = channel->Init(uri); if (NS_FAILED(rv)) { NS_RELEASE(channel); 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; } NS_IMETHODIMP nsViewSourceHandler::NewChannel(nsIURI* uri, nsIChannel* *result) { return NewChannel2(uri, nullptr, result);
--- a/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp +++ b/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp @@ -126,22 +126,16 @@ nsWyciwygProtocolHandler::NewChannel2(ns nsWyciwygChannel *wc = new nsWyciwygChannel(); channel = wc; rv = wc->Init(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; } NS_IMETHODIMP nsWyciwygProtocolHandler::NewChannel(nsIURI* url, nsIChannel* *result) { return NewChannel2(url, nullptr, result);
--- a/toolkit/components/places/nsAnnoProtocolHandler.cpp +++ b/toolkit/components/places/nsAnnoProtocolHandler.cpp @@ -274,17 +274,17 @@ nsAnnoProtocolHandler::NewChannel2(nsIUR nsAutoCString annoName; nsresult rv = ParseAnnoURI(aURI, getter_AddRefs(annoURI), annoName); NS_ENSURE_SUCCESS(rv, rv); // Only favicon annotation are supported. if (!annoName.EqualsLiteral(FAVICON_ANNOTATION_NAME)) return NS_ERROR_INVALID_ARG; - return NewFaviconChannel(aURI, annoURI, aLoadInfo, _retval); + return NewFaviconChannel(aURI, annoURI, _retval); } NS_IMETHODIMP nsAnnoProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **_retval) { return NewChannel2(aURI, nullptr, _retval); } @@ -323,51 +323,37 @@ nsAnnoProtocolHandler::ParseAnnoURI(nsIU NS_ENSURE_SUCCESS(rv, rv); aName = Substring(path, 0, firstColon); return NS_OK; } 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. nsCOMPtr<nsIInputStream> inputStream; nsCOMPtr<nsIOutputStream> outputStream; nsresult rv = NS_NewPipe(getter_AddRefs(inputStream), getter_AddRefs(outputStream), MAX_FAVICON_SIZE, MAX_FAVICON_SIZE, true, true); NS_ENSURE_SUCCESS(rv, GetDefaultIcon(_channel)); // 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. nsCOMPtr<mozIStorageStatementCallback> callback = new faviconAsyncLoader(channel, outputStream); NS_ENSURE_TRUE(callback, GetDefaultIcon(_channel)); nsFaviconService* faviconService = nsFaviconService::GetFaviconService(); NS_ENSURE_TRUE(faviconService, GetDefaultIcon(_channel));
--- a/toolkit/components/places/nsAnnoProtocolHandler.h +++ b/toolkit/components/places/nsAnnoProtocolHandler.h @@ -36,19 +36,16 @@ protected: * method is asynchronous. * * @param aURI * The URI the channel will be created for. This is the URI that is * set as the original URI on the channel. * @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); }; #endif /* nsAnnoProtocolHandler_h___ */
--- a/uriloader/exthandler/nsExternalProtocolHandler.cpp +++ b/uriloader/exthandler/nsExternalProtocolHandler.cpp @@ -52,17 +52,16 @@ private: nsCOMPtr<nsIURI> mUrl; nsCOMPtr<nsIURI> mOriginalURI; nsresult mStatus; nsLoadFlags mLoadFlags; bool mWasOpened; nsCOMPtr<nsIInterfaceRequestor> mCallbacks; nsCOMPtr<nsILoadGroup> mLoadGroup; - nsCOMPtr<nsILoadInfo> mLoadInfo; }; NS_IMPL_ADDREF(nsExtProtocolChannel) NS_IMPL_RELEASE(nsExtProtocolChannel) NS_INTERFACE_MAP_BEGIN(nsExtProtocolChannel) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIChannel) NS_INTERFACE_MAP_ENTRY(nsIChannel) @@ -260,26 +259,24 @@ NS_IMETHODIMP nsExtProtocolChannel::GetO return NS_ERROR_NOT_IMPLEMENTED; } 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; } //////////////////////////////////////////////////////////////////////////////// // From nsIRequest //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP nsExtProtocolChannel::GetName(nsACString &result) { @@ -411,19 +408,16 @@ nsExternalProtocolHandler::NewChannel2(n if (haveExternalHandler) { nsCOMPtr<nsIChannel> channel = new nsExtProtocolChannel(); if (!channel) return NS_ERROR_OUT_OF_MEMORY; ((nsExtProtocolChannel*) channel.get())->SetURI(aURI); channel->SetOriginalURI(aURI); - // set the loadInfo on the new channel - ((nsExtProtocolChannel*) channel.get())->SetLoadInfo(aLoadInfo); - if (_retval) { *_retval = channel; NS_IF_ADDREF(*_retval); return NS_OK; } }
--- a/widget/android/nsAndroidProtocolHandler.cpp +++ b/widget/android/nsAndroidProtocolHandler.cpp @@ -165,21 +165,16 @@ nsAndroidProtocolHandler::NewURI(const n NS_IMETHODIMP nsAndroidProtocolHandler::NewChannel2(nsIURI* aURI, nsILoadInfo* aLoadInfo, nsIChannel** aResult) { 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; } NS_IMETHODIMP nsAndroidProtocolHandler::NewChannel(nsIURI* aURI, nsIChannel* *aResult) {