1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* The privileged system principal. */
9 #ifndef mozilla_SystemPrincipal_h
10 #define mozilla_SystemPrincipal_h
12 #include "nsIPrincipal.h"
13 #include "nsJSPrincipals.h"
15 #include "mozilla/BasePrincipal.h"
17 #define NS_SYSTEMPRINCIPAL_CID \
19 0x4a6212db, 0xaccb, 0x11d3, { \
20 0xb7, 0x65, 0x0, 0x60, 0xb0, 0xb6, 0xce, 0xcb \
23 #define NS_SYSTEMPRINCIPAL_CONTRACTID "@mozilla.org/systemprincipal;1"
31 class SystemPrincipal final
: public BasePrincipal
, public nsISerializable
{
35 static already_AddRefed
<SystemPrincipal
> Create();
37 static PrincipalKind
Kind() { return eSystemPrincipal
; }
39 NS_IMETHOD_(MozExternalRefCountType
) AddRef() override
{
40 return nsJSPrincipals::AddRef();
42 NS_IMETHOD_(MozExternalRefCountType
) Release() override
{
43 return nsJSPrincipals::Release();
46 NS_DECL_NSISERIALIZABLE
47 NS_IMETHOD
QueryInterface(REFNSIID aIID
, void** aInstancePtr
) override
;
48 uint32_t GetHashValue() override
;
49 NS_IMETHOD
GetURI(nsIURI
** aURI
) override
;
50 NS_IMETHOD
GetDomain(nsIURI
** aDomain
) override
;
51 NS_IMETHOD
SetDomain(nsIURI
* aDomain
) override
;
52 NS_IMETHOD
GetBaseDomain(nsACString
& aBaseDomain
) override
;
53 NS_IMETHOD
GetAddonId(nsAString
& aAddonId
) override
;
54 NS_IMETHOD
GetIsOriginPotentiallyTrustworthy(bool* aResult
) override
;
56 virtual nsresult
GetScriptLocation(nsACString
& aStr
) override
;
58 nsresult
GetSiteIdentifier(SiteIdentifier
& aSite
) override
{
64 virtual ~SystemPrincipal() = default;
66 bool SubsumesInternal(nsIPrincipal
* aOther
,
67 DocumentDomainConsideration aConsideration
) override
{
71 bool MayLoadInternal(nsIURI
* aURI
) override
{ return true; }
74 } // namespace mozilla
76 #endif // mozilla_SystemPrincipal_h