mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 18:47:53 +00:00
Bug 1213150 - Part 1: Add a nsContentUtils::IsNonSubresourceRequest helper; r=jdm
This commit is contained in:
parent
40faae43d4
commit
fbd4c8c55b
@ -14070,18 +14070,13 @@ nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool isNavigation = false;
|
||||
nsresult rv = aChannel->GetIsNavigation(&isNavigation);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsContentPolicyType loadType;
|
||||
rv = aChannel->GetInternalContentPolicyType(&loadType);
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsresult rv = aChannel->GetChannel(getter_AddRefs(channel));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
|
||||
bool isSubresourceLoad = !isNavigation &&
|
||||
!nsContentUtils::IsWorkerLoad(loadType);
|
||||
bool isSubresourceLoad = !nsContentUtils::IsNonSubresourceRequest(channel);
|
||||
if (isSubresourceLoad) {
|
||||
doc = GetDocument();
|
||||
if (!doc) {
|
||||
|
@ -8101,10 +8101,21 @@ nsContentUtils::PushEnabled(JSContext* aCx, JSObject* aObj)
|
||||
|
||||
// static
|
||||
bool
|
||||
nsContentUtils::IsWorkerLoad(nsContentPolicyType aType)
|
||||
nsContentUtils::IsNonSubresourceRequest(nsIChannel* aChannel)
|
||||
{
|
||||
return aType == nsIContentPolicy::TYPE_INTERNAL_WORKER ||
|
||||
aType == nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER;
|
||||
nsLoadFlags loadFlags = 0;
|
||||
aChannel->GetLoadFlags(&loadFlags);
|
||||
if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
|
||||
if (!loadInfo) {
|
||||
return false;
|
||||
}
|
||||
nsContentPolicyType type = loadInfo->InternalContentPolicyType();
|
||||
return type == nsIContentPolicy::TYPE_INTERNAL_WORKER ||
|
||||
type == nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER;
|
||||
}
|
||||
|
||||
// static, public
|
||||
|
@ -2522,7 +2522,7 @@ public:
|
||||
|
||||
static bool PushEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
static bool IsWorkerLoad(nsContentPolicyType aLoadType);
|
||||
static bool IsNonSubresourceRequest(nsIChannel* aChannel);
|
||||
|
||||
// The order of these entries matters, as we use std::min for total ordering
|
||||
// of permissions. Private Browsing is considered to be more limiting
|
||||
|
Loading…
Reference in New Issue
Block a user