From 60626aff92bb0167ce44dd8daca344d4676cefde Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Wed, 17 Jun 2015 00:18:16 -0400 Subject: [PATCH] Bug 1175480 - Expose the external content policy type from the load info objects; r=smaug Consumers of this type need to deal with the external content policy types. One example is HttpObserverManager.runChannelListener in WebRequest.jsm. --- dom/workers/ServiceWorkerManager.cpp | 2 +- netwerk/base/LoadInfo.cpp | 9 ++++++++- netwerk/base/nsILoadInfo.idl | 20 ++++++++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index c273079098fb..e8842831a428 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -3296,7 +3296,7 @@ public: rv = channel->GetLoadInfo(getter_AddRefs(loadInfo)); NS_ENSURE_SUCCESS(rv, rv); - mContentPolicyType = loadInfo->GetContentPolicyType(); + mContentPolicyType = loadInfo->InternalContentPolicyType(); nsCOMPtr httpChannel = do_QueryInterface(channel); if (httpChannel) { diff --git a/netwerk/base/LoadInfo.cpp b/netwerk/base/LoadInfo.cpp index 264893e1f85b..99cf63eab2e0 100644 --- a/netwerk/base/LoadInfo.cpp +++ b/netwerk/base/LoadInfo.cpp @@ -14,6 +14,7 @@ #include "nsIFrameLoader.h" #include "nsISupportsImpl.h" #include "nsISupportsUtils.h" +#include "nsContentUtils.h" namespace mozilla { @@ -172,10 +173,16 @@ LoadInfo::GetLoadingSandboxed(bool* aLoadingSandboxed) NS_IMETHODIMP LoadInfo::GetContentPolicyType(nsContentPolicyType* aResult) { - *aResult = mContentPolicyType; + *aResult = nsContentUtils::InternalContentPolicyTypeToExternal(mContentPolicyType); return NS_OK; } +nsContentPolicyType +LoadInfo::InternalContentPolicyType() +{ + return mContentPolicyType; +} + NS_IMETHODIMP LoadInfo::GetBaseURI(nsIURI** aBaseURI) { diff --git a/netwerk/base/nsILoadInfo.idl b/netwerk/base/nsILoadInfo.idl index 9025d4ae5b0c..dfd5c9177282 100644 --- a/netwerk/base/nsILoadInfo.idl +++ b/netwerk/base/nsILoadInfo.idl @@ -17,7 +17,7 @@ typedef unsigned long nsSecurityFlags; /** * An nsILoadOwner represents per-load information about who started the load. */ -[scriptable, builtinclass, uuid(dcf54f49-2d63-4c34-9da1-54df235f354c)] +[scriptable, builtinclass, uuid(f6bce897-1a4a-4664-b96b-abacd6543e95)] interface nsILoadInfo : nsISupports { /** @@ -153,8 +153,11 @@ interface nsILoadInfo : nsISupports [infallible] readonly attribute boolean loadingSandboxed; /** - * The contentPolicyType of the channel, used for security checks + * The external contentPolicyType of the channel, used for security checks * like Mixed Content Blocking and Content Security Policy. + * + * Specifically, content policy types with _INTERNAL_ in their name will + * never get returned from this attribute. */ readonly attribute nsContentPolicyType contentPolicyType; @@ -168,6 +171,19 @@ interface nsILoadInfo : nsISupports } %} + /** + * The internal contentPolicyType of the channel, used for constructing + * RequestContext values when creating a fetch event for an intercepted + * channel. + * + * This should not be used for the purposes of security checks, since + * the content policy implementations cannot be expected to deal with + * _INTERNAL_ values. Please use the contentPolicyType attribute above + * for that purpose. + */ + [noscript, notxpcom] + nsContentPolicyType internalContentPolicyType(); + /** * A base URI for use in situations where it cannot otherwise be inferred. * This attribute may be null. The value of this attribute may be