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
6d6fa71cc0
commit
c5658b66eb
@ -27,6 +27,7 @@ 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,
|
||||
|
@ -23,14 +23,28 @@ nsAboutBlank::NewChannel(nsIURI* aURI,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
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"));
|
||||
// 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"));
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
channel.forget(result);
|
||||
|
@ -112,14 +112,28 @@ nsAboutBloat::NewChannel(nsIURI* aURI,
|
||||
}
|
||||
|
||||
nsIChannel* channel = nullptr;
|
||||
rv = NS_NewInputStreamChannel(&channel,
|
||||
aURI,
|
||||
inStr,
|
||||
nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_NORMAL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
NS_LITERAL_CSTRING("text/plain"),
|
||||
NS_LITERAL_CSTRING("utf-8"));
|
||||
// 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"));
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = channel;
|
||||
|
@ -64,14 +64,28 @@ nsAboutCache::NewChannel(nsIURI* aURI,
|
||||
mEntriesHeaderAdded = false;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
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"));
|
||||
// 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"));
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mBuffer.AssignLiteral(
|
||||
|
@ -99,7 +99,18 @@ 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,
|
||||
|
@ -142,6 +142,16 @@ 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.
|
||||
|
@ -423,7 +423,9 @@ 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());
|
||||
NS_IF_ADDREF(*aResult = new DummyChannel());
|
||||
nsRefPtr<nsIChannel> dummyChannel = new DummyChannel();
|
||||
dummyChannel->SetLoadInfo(aLoadInfo);
|
||||
dummyChannel.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -432,7 +434,9 @@ 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());
|
||||
NS_IF_ADDREF(*aResult = new DummyChannel());
|
||||
nsRefPtr<nsIChannel> dummyChannel = new DummyChannel();
|
||||
dummyChannel->SetLoadInfo(aLoadInfo);
|
||||
dummyChannel.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
mAppInfoCache.Put(host, appInfo);
|
||||
@ -456,6 +460,10 @@ 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);
|
||||
|
||||
|
@ -119,6 +119,13 @@ 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;
|
||||
}
|
||||
|
@ -62,6 +62,10 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -192,6 +192,13 @@ 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;
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ nsFtpProtocolHandler::NewChannel2(nsIURI* url,
|
||||
nsILoadInfo* aLoadInfo,
|
||||
nsIChannel** result)
|
||||
{
|
||||
return NewProxiedChannel(url, nullptr, 0, nullptr, result);
|
||||
return NewProxiedChannel2(url, nullptr, 0, nullptr, aLoadInfo, result);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -235,6 +235,12 @@ nsFtpProtocolHandler::NewProxiedChannel2(nsIURI* uri, nsIProxyInfo* proxyInfo,
|
||||
return rv;
|
||||
}
|
||||
|
||||
// set the loadInfo on the new channel
|
||||
rv = channel->SetLoadInfo(aLoadInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
channel.forget(result);
|
||||
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
|
||||
@ -1793,6 +1793,12 @@ 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;
|
||||
}
|
||||
@ -2107,7 +2113,7 @@ nsHttpsHandler::NewChannel2(nsIURI* aURI,
|
||||
MOZ_ASSERT(gHttpHandler);
|
||||
if (!gHttpHandler)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
return gHttpHandler->NewChannel(aURI, _retval);
|
||||
return gHttpHandler->NewChannel2(aURI, aLoadInfo, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -284,14 +284,27 @@ 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);
|
||||
|
||||
rv = ResolveURI(uri, spec);
|
||||
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.
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
rv = NS_NewURI(getter_AddRefs(newURI), spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mIOService->NewChannel(spec, nullptr, nullptr, result);
|
||||
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);
|
||||
|
||||
nsLoadFlags loadFlags = 0;
|
||||
(*result)->GetLoadFlags(&loadFlags);
|
||||
|
@ -86,6 +86,10 @@ 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;
|
||||
}
|
||||
|
@ -106,6 +106,13 @@ 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;
|
||||
}
|
||||
|
@ -131,6 +131,12 @@ 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user