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
|
|
|
|
2015-05-11 14:36:56 -07:00
|
|
|
#include "mozilla/BasePrincipal.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsIURI;
|
|
|
|
|
|
|
|
#define NS_NULLPRINCIPAL_CID \
|
2015-07-28 14:32:00 -07:00
|
|
|
{ 0xbd066e5f, 0x146f, 0x4472, \
|
|
|
|
{ 0x83, 0x31, 0x7b, 0xfd, 0x05, 0xb1, 0xed, 0x90 } }
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_NULLPRINCIPAL_CONTRACTID "@mozilla.org/nullprincipal;1"
|
|
|
|
|
|
|
|
#define NS_NULLPRINCIPAL_SCHEME "moz-nullprincipal"
|
|
|
|
|
2015-05-11 14:36:56 -07:00
|
|
|
class nsNullPrincipal final : public mozilla::BasePrincipal
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2015-03-31 10:11:00 -07:00
|
|
|
// This should only be used by deserialization, and the factory constructor.
|
|
|
|
// Other consumers should use the Create and CreateWithInheritedAttributes
|
|
|
|
// methods.
|
2015-05-11 13:16:36 -07:00
|
|
|
nsNullPrincipal() {}
|
2015-02-24 12:54:40 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSISERIALIZABLE
|
2015-05-11 14:36:56 -07:00
|
|
|
|
2015-05-11 13:16:36 -07:00
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
2015-05-11 14:36:56 -07:00
|
|
|
NS_IMETHOD GetHashValue(uint32_t* aHashValue) override;
|
|
|
|
NS_IMETHOD GetURI(nsIURI** aURI) override;
|
|
|
|
NS_IMETHOD GetDomain(nsIURI** aDomain) override;
|
|
|
|
NS_IMETHOD SetDomain(nsIURI* aDomain) override;
|
|
|
|
NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
|
2015-05-14 16:50:44 -07:00
|
|
|
nsresult GetOriginInternal(nsACString& aOrigin) override;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2015-03-31 10:11:00 -07:00
|
|
|
// Returns null on failure.
|
2014-07-29 08:47:52 -07:00
|
|
|
static already_AddRefed<nsNullPrincipal> CreateWithInheritedAttributes(nsIPrincipal *aInheritFrom);
|
|
|
|
|
2015-03-31 10:11:00 -07:00
|
|
|
// Returns null on failure.
|
|
|
|
static already_AddRefed<nsNullPrincipal>
|
2015-05-15 13:43:11 -07:00
|
|
|
Create(const mozilla::OriginAttributes& aOriginAttributes = mozilla::OriginAttributes());
|
2015-03-31 10:11:00 -07:00
|
|
|
|
2015-05-15 13:43:11 -07:00
|
|
|
nsresult Init(const mozilla::OriginAttributes& aOriginAttributes = mozilla::OriginAttributes());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void GetScriptLocation(nsACString &aStr) override;
|
2012-03-09 01:48:50 -08:00
|
|
|
|
2015-10-23 17:58:21 -07:00
|
|
|
PrincipalKind Kind() override { return eNullPrincipal; }
|
|
|
|
|
2012-03-09 01:48:50 -08:00
|
|
|
protected:
|
2015-05-11 13:16:36 -07:00
|
|
|
virtual ~nsNullPrincipal() {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2015-05-14 11:15:56 -07:00
|
|
|
bool SubsumesInternal(nsIPrincipal* aOther, DocumentDomainConsideration aConsideration) override
|
|
|
|
{
|
|
|
|
return aOther == this;
|
|
|
|
}
|
|
|
|
|
2015-09-30 20:03:36 -07:00
|
|
|
bool MayLoadInternal(nsIURI* aURI) override;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIURI> mURI;
|
2013-11-22 15:12:00 -08:00
|
|
|
nsCOMPtr<nsIContentSecurityPolicy> mCSP;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsNullPrincipal_h__
|