зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1214122 - Check if addon ProtocolHandler actually provide nsHttpChannel. r=sicking r=mayhemer
This commit is contained in:
Родитель
dfbd8ea546
Коммит
0f390c8344
|
@ -9,7 +9,7 @@
|
||||||
* behavior for the channel's IsPending(), forcing 'true' to be returned.
|
* behavior for the channel's IsPending(), forcing 'true' to be returned.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
[scriptable, uuid(225ab092-1554-423a-9492-606f6db3b4fb)]
|
[noscript, uuid(2ac3e1ca-049f-44c3-a519-f0681f51e9b1)]
|
||||||
interface nsIForcePendingChannel : nsISupports
|
interface nsIForcePendingChannel : nsISupports
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -759,8 +759,11 @@ nsIOService::NewChannelFromURIWithProxyFlagsInternal(nsIURI* aURI,
|
||||||
rv = pph->NewProxiedChannel(aURI, nullptr, aProxyFlags, aProxyURI,
|
rv = pph->NewProxiedChannel(aURI, nullptr, aProxyFlags, aProxyURI,
|
||||||
getter_AddRefs(channel));
|
getter_AddRefs(channel));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
// we have to wrap that channel
|
|
||||||
channel = new nsSecCheckWrapChannel(channel, aLoadInfo);
|
// The protocol handler does not implement NewProxiedChannel2, so
|
||||||
|
// maybe we need to wrap the channel (see comment in MaybeWrap
|
||||||
|
// function).
|
||||||
|
channel = nsSecCheckWrapChannel::MaybeWrap(channel, aLoadInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -770,8 +773,10 @@ nsIOService::NewChannelFromURIWithProxyFlagsInternal(nsIURI* aURI,
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
rv = handler->NewChannel(aURI, getter_AddRefs(channel));
|
rv = handler->NewChannel(aURI, getter_AddRefs(channel));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
// we have to wrap that channel
|
// The protocol handler does not implement NewChannel2, so
|
||||||
channel = new nsSecCheckWrapChannel(channel, aLoadInfo);
|
// maybe we need to wrap the channel (see comment in MaybeWrap
|
||||||
|
// function).
|
||||||
|
channel = nsSecCheckWrapChannel::MaybeWrap(channel, aLoadInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "nsContentSecurityManager.h"
|
#include "nsContentSecurityManager.h"
|
||||||
#include "nsSecCheckWrapChannel.h"
|
#include "nsSecCheckWrapChannel.h"
|
||||||
#include "nsHttpChannel.h"
|
#include "nsIForcePendingChannel.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
|
||||||
static PRLogModuleInfo*
|
static PRLogModuleInfo*
|
||||||
|
@ -84,6 +84,31 @@ nsSecCheckWrapChannel::nsSecCheckWrapChannel(nsIChannel* aChannel,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
already_AddRefed<nsIChannel>
|
||||||
|
nsSecCheckWrapChannel::MaybeWrap(nsIChannel* aChannel, nsILoadInfo* aLoadInfo)
|
||||||
|
{
|
||||||
|
// Maybe a custom protocol handler actually returns a gecko
|
||||||
|
// http/ftpChannel - To check this we will check whether the channel
|
||||||
|
// implements a gecko non-scriptable interface e.g. nsIForcePendingChannel.
|
||||||
|
nsCOMPtr<nsIForcePendingChannel> isGeckoChannel = do_QueryInterface(aChannel);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIChannel> channel = aChannel;
|
||||||
|
if (isGeckoChannel) {
|
||||||
|
// If it is a gecko channel (ftp or http) we do not need to wrap it.
|
||||||
|
channel->SetLoadInfo(aLoadInfo);
|
||||||
|
} else {
|
||||||
|
nsCOMPtr<nsIHttpChannel> httpChannel =
|
||||||
|
do_QueryInterface(aChannel);
|
||||||
|
// we can only wrap http channel.
|
||||||
|
if (httpChannel) {
|
||||||
|
// we have to wrap that channel
|
||||||
|
channel = new nsSecCheckWrapChannel(aChannel, aLoadInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return channel.forget();
|
||||||
|
}
|
||||||
|
|
||||||
nsSecCheckWrapChannel::~nsSecCheckWrapChannel()
|
nsSecCheckWrapChannel::~nsSecCheckWrapChannel()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,8 @@ public:
|
||||||
NS_IMETHOD Open2(nsIInputStream** aStream);
|
NS_IMETHOD Open2(nsIInputStream** aStream);
|
||||||
|
|
||||||
nsSecCheckWrapChannel(nsIChannel* aChannel, nsILoadInfo* aLoadInfo);
|
nsSecCheckWrapChannel(nsIChannel* aChannel, nsILoadInfo* aLoadInfo);
|
||||||
|
static already_AddRefed<nsIChannel> MaybeWrap(nsIChannel* aChannel,
|
||||||
|
nsILoadInfo* aLoadInfo);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~nsSecCheckWrapChannel();
|
virtual ~nsSecCheckWrapChannel();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче