Bug 1861709 replace AudioCallbackDriver::ThreadRunning() assertions that mean to...
[gecko.git] / caps / SystemPrincipal.h
blob7b89d7ddff5741bf85646b9d07c3aba20cce8704
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 \
18 { \
19 0x4a6212db, 0xaccb, 0x11d3, { \
20 0xb7, 0x65, 0x0, 0x60, 0xb0, 0xb6, 0xce, 0xcb \
21 } \
23 #define NS_SYSTEMPRINCIPAL_CONTRACTID "@mozilla.org/systemprincipal;1"
25 class nsScriptSecurityManager;
27 namespace Json {
28 class Value;
31 namespace mozilla {
33 class SystemPrincipal final : public BasePrincipal, public nsISerializable {
34 SystemPrincipal();
36 public:
37 static already_AddRefed<SystemPrincipal> Get();
39 static PrincipalKind Kind() { return eSystemPrincipal; }
41 NS_IMETHOD_(MozExternalRefCountType) AddRef() override {
42 return nsJSPrincipals::AddRef();
44 NS_IMETHOD_(MozExternalRefCountType) Release() override {
45 return nsJSPrincipals::Release();
48 NS_DECL_NSISERIALIZABLE
49 NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
50 uint32_t GetHashValue() override;
51 NS_IMETHOD GetURI(nsIURI** aURI) override;
52 NS_IMETHOD GetDomain(nsIURI** aDomain) override;
53 NS_IMETHOD SetDomain(nsIURI* aDomain) override;
54 NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
55 NS_IMETHOD GetAddonId(nsAString& aAddonId) override;
56 NS_IMETHOD GetIsOriginPotentiallyTrustworthy(bool* aResult) override;
58 virtual nsresult GetScriptLocation(nsACString& aStr) override;
60 nsresult GetSiteIdentifier(SiteIdentifier& aSite) override {
61 aSite.Init(this);
62 return NS_OK;
65 protected:
66 friend class ::nsScriptSecurityManager;
68 virtual ~SystemPrincipal() = default;
70 static already_AddRefed<SystemPrincipal> Init();
71 static void Shutdown();
73 bool SubsumesInternal(nsIPrincipal* aOther,
74 DocumentDomainConsideration aConsideration) override {
75 return true;
78 bool MayLoadInternal(nsIURI* aURI) override { return true; }
81 } // namespace mozilla
83 #endif // mozilla_SystemPrincipal_h