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.
This commit is contained in:
Ehsan Akhgari 2015-06-17 00:18:16 -04:00
parent b4745b397a
commit 60626aff92
3 changed files with 27 additions and 4 deletions

View File

@ -3296,7 +3296,7 @@ public:
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) {

View File

@ -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)
{

View File

@ -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