mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1087442 - Attach LoadInfo inside each individual ProtocolHandler - netwerk/ changes (r=sworkman,sicking)
This commit is contained in:
parent
ba9a8c86be
commit
7d8deee972
@ -27,6 +27,7 @@ interface nsIProxiedProtocolHandler : nsIProtocolHandler
|
|||||||
* effect), except in the case of websockets which wants to bootstrap
|
* effect), except in the case of websockets which wants to bootstrap
|
||||||
* to an http:// channel but make its proxy determination based on
|
* to an http:// channel but make its proxy determination based on
|
||||||
* a ws:// uri.
|
* a ws:// uri.
|
||||||
|
* @param aLoadInfo used to evaluate who initated the resource request.
|
||||||
*/
|
*/
|
||||||
nsIChannel newProxiedChannel2(in nsIURI uri, in nsIProxyInfo proxyInfo,
|
nsIChannel newProxiedChannel2(in nsIURI uri, in nsIProxyInfo proxyInfo,
|
||||||
in unsigned long proxyResolveFlags,
|
in unsigned long proxyResolveFlags,
|
||||||
|
@ -23,14 +23,28 @@ nsAboutBlank::NewChannel(nsIURI* aURI,
|
|||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
nsCOMPtr<nsIChannel> channel;
|
nsCOMPtr<nsIChannel> channel;
|
||||||
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
|
// Bug 1087720 (and Bug 1099296):
|
||||||
aURI,
|
// Once all callsites have been updated to call NewChannel2()
|
||||||
in,
|
// instead of NewChannel() we should have a non-null loadInfo
|
||||||
nsContentUtils::GetSystemPrincipal(),
|
// consistently. Until then we have to branch on the loadInfo.
|
||||||
nsILoadInfo::SEC_NORMAL,
|
if (aLoadInfo) {
|
||||||
nsIContentPolicy::TYPE_OTHER,
|
rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
|
||||||
NS_LITERAL_CSTRING("text/html"),
|
aURI,
|
||||||
NS_LITERAL_CSTRING("utf-8"));
|
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"));
|
||||||
|
}
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
channel.forget(result);
|
channel.forget(result);
|
||||||
|
@ -112,14 +112,28 @@ nsAboutBloat::NewChannel(nsIURI* aURI,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsIChannel* channel = nullptr;
|
nsIChannel* channel = nullptr;
|
||||||
rv = NS_NewInputStreamChannel(&channel,
|
// Bug 1087720 (and Bug 1099296):
|
||||||
aURI,
|
// Once all callsites have been updated to call NewChannel2()
|
||||||
inStr,
|
// instead of NewChannel() we should have a non-null loadInfo
|
||||||
nsContentUtils::GetSystemPrincipal(),
|
// consistently. Until then we have to branch on the loadInfo.
|
||||||
nsILoadInfo::SEC_NORMAL,
|
if (aLoadInfo) {
|
||||||
nsIContentPolicy::TYPE_OTHER,
|
rv = NS_NewInputStreamChannelInternal(&channel,
|
||||||
NS_LITERAL_CSTRING("text/plain"),
|
aURI,
|
||||||
NS_LITERAL_CSTRING("utf-8"));
|
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"));
|
||||||
|
}
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
*result = channel;
|
*result = channel;
|
||||||
|
@ -64,14 +64,28 @@ nsAboutCache::NewChannel(nsIURI* aURI,
|
|||||||
mEntriesHeaderAdded = false;
|
mEntriesHeaderAdded = false;
|
||||||
|
|
||||||
nsCOMPtr<nsIChannel> channel;
|
nsCOMPtr<nsIChannel> channel;
|
||||||
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
|
// Bug 1087720 (and Bug 1099296):
|
||||||
aURI,
|
// Once all callsites have been updated to call NewChannel2()
|
||||||
inputStream,
|
// instead of NewChannel() we should have a non-null loadInfo
|
||||||
nsContentUtils::GetSystemPrincipal(),
|
// consistently. Until then we have to branch on the loadInfo.
|
||||||
nsILoadInfo::SEC_NORMAL,
|
if (aLoadInfo) {
|
||||||
nsIContentPolicy::TYPE_OTHER,
|
rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
|
||||||
NS_LITERAL_CSTRING("text/html"),
|
aURI,
|
||||||
NS_LITERAL_CSTRING("utf-8"));
|
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"));
|
||||||
|
}
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
mBuffer.AssignLiteral(
|
mBuffer.AssignLiteral(
|
||||||
|
@ -99,7 +99,18 @@ nsAboutCacheEntry::NewChannel(nsIURI* uri,
|
|||||||
nsCOMPtr<nsIInputStream> stream;
|
nsCOMPtr<nsIInputStream> stream;
|
||||||
rv = GetContentStream(uri, getter_AddRefs(stream));
|
rv = GetContentStream(uri, getter_AddRefs(stream));
|
||||||
if (NS_FAILED(rv)) return rv;
|
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,
|
return NS_NewInputStreamChannel(result,
|
||||||
uri,
|
uri,
|
||||||
stream,
|
stream,
|
||||||
|
@ -142,6 +142,16 @@ nsAboutProtocolHandler::NewChannel2(nsIURI* uri,
|
|||||||
// The standard return case:
|
// The standard return case:
|
||||||
rv = aboutMod->NewChannel(uri, aLoadInfo, result);
|
rv = aboutMod->NewChannel(uri, aLoadInfo, result);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
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
|
// If this URI is safe for untrusted content, enforce that its
|
||||||
// principal be based on the channel's originalURI by setting the
|
// principal be based on the channel's originalURI by setting the
|
||||||
// owner to null.
|
// owner to null.
|
||||||
|
@ -423,7 +423,9 @@ AppProtocolHandler::NewChannel2(nsIURI* aUri,
|
|||||||
if (NS_FAILED(rv) || !jsInfo.isObject()) {
|
if (NS_FAILED(rv) || !jsInfo.isObject()) {
|
||||||
// Return a DummyChannel.
|
// Return a DummyChannel.
|
||||||
printf_stderr("!! Creating a dummy channel for %s (no appInfo)\n", host.get());
|
printf_stderr("!! Creating a dummy channel for %s (no appInfo)\n", host.get());
|
||||||
NS_IF_ADDREF(*aResult = new DummyChannel());
|
nsRefPtr<nsIChannel> dummyChannel = new DummyChannel();
|
||||||
|
dummyChannel->SetLoadInfo(aLoadInfo);
|
||||||
|
dummyChannel.forget(aResult);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +434,9 @@ AppProtocolHandler::NewChannel2(nsIURI* aUri,
|
|||||||
if (!appInfo->Init(cx, jsInfo) || appInfo->mPath.IsEmpty()) {
|
if (!appInfo->Init(cx, jsInfo) || appInfo->mPath.IsEmpty()) {
|
||||||
// Return a DummyChannel.
|
// Return a DummyChannel.
|
||||||
printf_stderr("!! Creating a dummy channel for %s (invalid appInfo)\n", host.get());
|
printf_stderr("!! Creating a dummy channel for %s (invalid appInfo)\n", host.get());
|
||||||
NS_IF_ADDREF(*aResult = new DummyChannel());
|
nsRefPtr<nsIChannel> dummyChannel = new DummyChannel();
|
||||||
|
dummyChannel->SetLoadInfo(aLoadInfo);
|
||||||
|
dummyChannel.forget(aResult);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
mAppInfoCache.Put(host, appInfo);
|
mAppInfoCache.Put(host, appInfo);
|
||||||
@ -456,6 +460,10 @@ AppProtocolHandler::NewChannel2(nsIURI* aUri,
|
|||||||
rv = channel->Init(jarURI);
|
rv = channel->Init(jarURI);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
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);
|
rv = channel->SetAppURI(aUri);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
@ -119,6 +119,13 @@ nsDataHandler::NewChannel2(nsIURI* uri,
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the loadInfo on the new channel
|
||||||
|
rv = channel->SetLoadInfo(aLoadInfo);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
NS_RELEASE(channel);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
*result = channel;
|
*result = channel;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,10 @@ nsDeviceProtocolHandler::NewChannel2(nsIURI* aURI,
|
|||||||
nsresult rv = channel->Init(aURI);
|
nsresult rv = channel->Init(aURI);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
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);
|
return CallQueryInterface(channel, aResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,6 +192,13 @@ nsFileProtocolHandler::NewChannel2(nsIURI* uri,
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the loadInfo on the new channel
|
||||||
|
rv = chan->SetLoadInfo(aLoadInfo);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
NS_RELEASE(chan);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
*result = chan;
|
*result = chan;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ nsFtpProtocolHandler::NewChannel2(nsIURI* url,
|
|||||||
nsILoadInfo* aLoadInfo,
|
nsILoadInfo* aLoadInfo,
|
||||||
nsIChannel** result)
|
nsIChannel** result)
|
||||||
{
|
{
|
||||||
return NewProxiedChannel(url, nullptr, 0, nullptr, result);
|
return NewProxiedChannel2(url, nullptr, 0, nullptr, aLoadInfo, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@ -234,7 +234,13 @@ nsFtpProtocolHandler::NewProxiedChannel2(nsIURI* uri, nsIProxyInfo* proxyInfo,
|
|||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the loadInfo on the new channel
|
||||||
|
rv = channel->SetLoadInfo(aLoadInfo);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
channel.forget(result);
|
channel.forget(result);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1725,7 +1725,7 @@ nsHttpHandler::NewChannel2(nsIURI* uri,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewProxiedChannel(uri, nullptr, 0, nullptr, result);
|
return NewProxiedChannel2(uri, nullptr, 0, nullptr, aLoadInfo, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@ -1793,6 +1793,12 @@ nsHttpHandler::NewProxiedChannel2(nsIURI *uri,
|
|||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
// set the loadInfo on the new channel
|
||||||
|
rv = httpChannel->SetLoadInfo(aLoadInfo);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
httpChannel.forget(result);
|
httpChannel.forget(result);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -2107,7 +2113,7 @@ nsHttpsHandler::NewChannel2(nsIURI* aURI,
|
|||||||
MOZ_ASSERT(gHttpHandler);
|
MOZ_ASSERT(gHttpHandler);
|
||||||
if (!gHttpHandler)
|
if (!gHttpHandler)
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
return gHttpHandler->NewChannel(aURI, _retval);
|
return gHttpHandler->NewChannel2(aURI, aLoadInfo, _retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -284,14 +284,27 @@ nsResProtocolHandler::NewChannel2(nsIURI* uri,
|
|||||||
nsIChannel** result)
|
nsIChannel** result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(uri);
|
NS_ENSURE_ARG_POINTER(uri);
|
||||||
nsresult rv;
|
|
||||||
nsAutoCString spec;
|
nsAutoCString spec;
|
||||||
|
nsresult rv = ResolveURI(uri, spec);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = ResolveURI(uri, spec);
|
// Bug 1087720 (and Bug 1099296):
|
||||||
if (NS_FAILED(rv)) return rv;
|
// 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 = mIOService->NewChannel(spec, nullptr, nullptr, result);
|
if (aLoadInfo) {
|
||||||
if (NS_FAILED(rv)) return rv;
|
rv = NS_NewChannelInternal(result,
|
||||||
|
newURI,
|
||||||
|
aLoadInfo);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rv = mIOService->NewChannelFromURI(newURI, result);
|
||||||
|
}
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsLoadFlags loadFlags = 0;
|
nsLoadFlags loadFlags = 0;
|
||||||
(*result)->GetLoadFlags(&loadFlags);
|
(*result)->GetLoadFlags(&loadFlags);
|
||||||
|
@ -86,6 +86,10 @@ RtspHandler::NewChannel2(nsIURI* aURI,
|
|||||||
rv = rtspChannel->Init();
|
rv = rtspChannel->Init();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
// set the loadInfo on the new channel
|
||||||
|
rv = rtspChannel->SetLoadInfo(aLoadInfo);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rtspChannel.forget(aResult);
|
rtspChannel.forget(aResult);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,13 @@ nsViewSourceHandler::NewChannel2(nsIURI* uri,
|
|||||||
return rv;
|
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);
|
*result = static_cast<nsIViewSourceChannel*>(channel);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,12 @@ nsWyciwygProtocolHandler::NewChannel2(nsIURI* url,
|
|||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
// set the loadInfo on the new channel
|
||||||
|
rv = channel->SetLoadInfo(aLoadInfo);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
channel.forget(result);
|
channel.forget(result);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user