Bug 1175480 - Expose the external content policy type from the load info objects; r=smaug
☠☠ backed out by f1f1a9a1c46a ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 17 Jun 2015 00:18:16 -0400
changeset 280233 b2c472fe14ca2f9e778a27743dd4a4c9f7207320
parent 280232 b40af190753c5fe1298b2e4ea03b99fdc4b5d42e
child 280234 439e1f841ea21057a20887f0efabf4e40c670604
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1175480
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
netwerk/base/LoadInfo.cpp
netwerk/base/nsILoadInfo.idl
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -3195,17 +3195,17 @@ public:
     uint32_t loadFlags;
     rv = channel->GetLoadFlags(&loadFlags);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsILoadInfo> loadInfo;
     rv = channel->GetLoadInfo(getter_AddRefs(loadInfo));
     NS_ENSURE_SUCCESS(rv, rv);
 
-    mContentPolicyType = loadInfo->GetContentPolicyType();
+    mContentPolicyType = loadInfo->InternalContentPolicyType();
 
     nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
     if (httpChannel) {
       rv = httpChannel->GetRequestMethod(mMethod);
       NS_ENSURE_SUCCESS(rv, rv);
 
       nsCOMPtr<nsIHttpChannelInternal> internalChannel = do_QueryInterface(httpChannel);
       NS_ENSURE_TRUE(internalChannel, NS_ERROR_NOT_AVAILABLE);
--- a/netwerk/base/LoadInfo.cpp
+++ b/netwerk/base/LoadInfo.cpp
@@ -9,16 +9,17 @@
 #include "mozilla/Assertions.h"
 #include "nsFrameLoader.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIFrameLoader.h"
 #include "nsISupportsImpl.h"
 #include "nsISupportsUtils.h"
+#include "nsContentUtils.h"
 
 namespace mozilla {
 
 LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
                    nsIPrincipal* aTriggeringPrincipal,
                    nsINode* aLoadingContext,
                    nsSecurityFlags aSecurityFlags,
                    nsContentPolicyType aContentPolicyType,
@@ -167,20 +168,26 @@ LoadInfo::GetLoadingSandboxed(bool* aLoa
 {
   *aLoadingSandboxed = (mSecurityFlags & nsILoadInfo::SEC_SANDBOXED);
   return NS_OK;
 }
 
 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)
 {
   *aBaseURI = mBaseURI;
   NS_IF_ADDREF(*aBaseURI);
   return NS_OK;
 }
 
--- a/netwerk/base/nsILoadInfo.idl
+++ b/netwerk/base/nsILoadInfo.idl
@@ -12,17 +12,17 @@ interface nsINode;
 interface nsIPrincipal;
 interface nsIURI;
 
 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
 {
   /**
    * No special security flags:
    */
   const unsigned long SEC_NORMAL = 0;
 
   /**
@@ -148,32 +148,48 @@ interface nsILoadInfo : nsISupports
   /**
    * If loadingSandboxed is true, the data coming from the channel is
    * being loaded sandboxed, so it should have a nonce origin and
    * hence should use a NullPrincipal.
    */
   [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;
 
 %{ C++
   inline nsContentPolicyType GetContentPolicyType()
   {
     nsContentPolicyType result;
     mozilla::DebugOnly<nsresult> rv = GetContentPolicyType(&result);
     MOZ_ASSERT(NS_SUCCEEDED(rv));
     return result;
   }
 %}
 
   /**
+   * 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
    * ignored if the base URI can be inferred by the channel's URI.
    */
   readonly attribute nsIURI baseURI;
 
   /**
    * A C++-friendly version of baseURI.