Bug 1890277: part 1) Add CSP parser tests for `require-trusted-types-for`. r=tschuster
[gecko.git] / caps / SystemPrincipal.h
blob25f917ad249885eb5a3fa68b3717fb2b1b773f45
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 mozilla {
29 class SystemPrincipal final : public BasePrincipal, public nsISerializable {
30 SystemPrincipal();
32 public:
33 static already_AddRefed<SystemPrincipal> Get();
35 static PrincipalKind Kind() { return eSystemPrincipal; }
37 NS_IMETHOD_(MozExternalRefCountType) AddRef() override {
38 return nsJSPrincipals::AddRef();
40 NS_IMETHOD_(MozExternalRefCountType) Release() override {
41 return nsJSPrincipals::Release();
44 NS_DECL_NSISERIALIZABLE
45 NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
46 uint32_t GetHashValue() override;
47 NS_IMETHOD GetURI(nsIURI** aURI) override;
48 NS_IMETHOD GetDomain(nsIURI** aDomain) override;
49 NS_IMETHOD SetDomain(nsIURI* aDomain) override;
50 NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
51 NS_IMETHOD GetAddonId(nsAString& aAddonId) override;
52 NS_IMETHOD GetIsOriginPotentiallyTrustworthy(bool* aResult) override;
54 virtual nsresult GetScriptLocation(nsACString& aStr) override;
56 nsresult GetSiteIdentifier(SiteIdentifier& aSite) override {
57 aSite.Init(this);
58 return NS_OK;
61 protected:
62 friend class ::nsScriptSecurityManager;
64 virtual ~SystemPrincipal() = default;
66 static already_AddRefed<SystemPrincipal> Init();
67 static void Shutdown();
69 bool SubsumesInternal(nsIPrincipal* aOther,
70 DocumentDomainConsideration aConsideration) override {
71 return true;
74 bool MayLoadInternal(nsIURI* aURI) override { return true; }
77 } // namespace mozilla
79 #endif // mozilla_SystemPrincipal_h