2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the principal that has no rights and can't be accessed by
|
|
|
|
* anything other than itself and chrome; null principals are not
|
|
|
|
* same-origin with anything but themselves.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsNullPrincipal_h__
|
|
|
|
#define nsNullPrincipal_h__
|
|
|
|
|
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsJSPrincipals.h"
|
2014-07-29 08:47:52 -07:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
2013-11-22 15:12:00 -08:00
|
|
|
#include "nsIContentSecurityPolicy.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsIURI;
|
|
|
|
|
|
|
|
#define NS_NULLPRINCIPAL_CID \
|
2014-07-29 08:47:52 -07:00
|
|
|
{ 0xa0bd8b42, 0xf6bf, 0x4fb9, \
|
|
|
|
{ 0x93, 0x42, 0x90, 0xbf, 0xc9, 0xb7, 0xa1, 0xab } }
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_NULLPRINCIPAL_CONTRACTID "@mozilla.org/nullprincipal;1"
|
|
|
|
|
|
|
|
#define NS_NULLPRINCIPAL_SCHEME "moz-nullprincipal"
|
|
|
|
|
2014-08-05 10:33:55 -07:00
|
|
|
class nsNullPrincipal MOZ_FINAL : public nsJSPrincipals
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsNullPrincipal();
|
|
|
|
|
2012-03-09 01:48:50 -08:00
|
|
|
// Our refcount is managed by nsJSPrincipals. Use this macro to avoid an
|
2007-03-22 10:30:00 -07:00
|
|
|
// extra refcount member.
|
|
|
|
|
|
|
|
// FIXME: bug 327245 -- I sorta wish there were a clean way to share the
|
2012-03-09 01:48:50 -08:00
|
|
|
// nsJSPrincipals munging code between the various principal classes without
|
2007-03-22 10:30:00 -07:00
|
|
|
// giving up the NS_DECL_NSIPRINCIPAL goodness.
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIPRINCIPAL
|
|
|
|
NS_DECL_NSISERIALIZABLE
|
|
|
|
|
2014-07-29 08:47:52 -07:00
|
|
|
static already_AddRefed<nsNullPrincipal> CreateWithInheritedAttributes(nsIPrincipal *aInheritFrom);
|
|
|
|
|
2014-07-29 08:47:52 -07:00
|
|
|
nsresult Init(uint32_t aAppId = nsIScriptSecurityManager::NO_APP_ID,
|
|
|
|
bool aInMozBrowser = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-09 01:48:50 -08:00
|
|
|
virtual void GetScriptLocation(nsACString &aStr) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
virtual void dumpImpl() MOZ_OVERRIDE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~nsNullPrincipal();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> mURI;
|
2013-11-22 15:12:00 -08:00
|
|
|
nsCOMPtr<nsIContentSecurityPolicy> mCSP;
|
2014-07-29 08:47:52 -07:00
|
|
|
uint32_t mAppId;
|
|
|
|
bool mInMozBrowser;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsNullPrincipal_h__
|