Line data Source code
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/. */
6 :
7 : /* The privileged system principal. */
8 :
9 : #ifndef SystemPrincipal_h
10 : #define SystemPrincipal_h
11 :
12 : #include "nsIPrincipal.h"
13 : #include "nsJSPrincipals.h"
14 :
15 : #include "mozilla/BasePrincipal.h"
16 :
17 : #define NS_SYSTEMPRINCIPAL_CID \
18 : { 0x4a6212db, 0xaccb, 0x11d3, \
19 : { 0xb7, 0x65, 0x0, 0x60, 0xb0, 0xb6, 0xce, 0xcb }}
20 : #define NS_SYSTEMPRINCIPAL_CONTRACTID "@mozilla.org/systemprincipal;1"
21 :
22 :
23 : class SystemPrincipal final : public mozilla::BasePrincipal
24 : {
25 3 : SystemPrincipal()
26 3 : : BasePrincipal(eSystemPrincipal)
27 : {
28 3 : }
29 :
30 : public:
31 : static already_AddRefed<SystemPrincipal> Create();
32 :
33 : NS_DECL_NSISERIALIZABLE
34 : NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
35 : NS_IMETHOD GetHashValue(uint32_t* aHashValue) override;
36 : NS_IMETHOD GetURI(nsIURI** aURI) override;
37 : NS_IMETHOD GetDomain(nsIURI** aDomain) override;
38 : NS_IMETHOD SetDomain(nsIURI* aDomain) override;
39 : NS_IMETHOD GetCsp(nsIContentSecurityPolicy** aCsp) override;
40 : NS_IMETHOD SetCsp(nsIContentSecurityPolicy* aCsp) override;
41 : NS_IMETHOD EnsureCSP(nsIDOMDocument* aDocument, nsIContentSecurityPolicy** aCSP) override;
42 : NS_IMETHOD GetPreloadCsp(nsIContentSecurityPolicy** aPreloadCSP) override;
43 : NS_IMETHOD EnsurePreloadCSP(nsIDOMDocument* aDocument, nsIContentSecurityPolicy** aCSP) override;
44 : NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
45 : NS_IMETHOD GetAddonId(nsAString& aAddonId) override;
46 :
47 : virtual nsresult GetScriptLocation(nsACString &aStr) override;
48 :
49 : protected:
50 0 : virtual ~SystemPrincipal(void) {}
51 :
52 1260 : bool SubsumesInternal(nsIPrincipal *aOther,
53 : DocumentDomainConsideration aConsideration) override
54 : {
55 1260 : return true;
56 : }
57 :
58 43 : bool MayLoadInternal(nsIURI* aURI) override
59 : {
60 43 : return true;
61 : }
62 : };
63 :
64 : #endif // SystemPrincipal_h
|