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