Source code

Revision control

Other Tools

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 mozilla_SystemPrincipal_h
10
#define mozilla_SystemPrincipal_h
11
12
#include "nsIPrincipal.h"
13
#include "nsJSPrincipals.h"
14
15
#include "mozilla/BasePrincipal.h"
16
17
#define NS_SYSTEMPRINCIPAL_CID \
18
{ \
19
0x4a6212db, 0xaccb, 0x11d3, { \
20
0xb7, 0x65, 0x0, 0x60, 0xb0, 0xb6, 0xce, 0xcb \
21
} \
22
}
23
#define NS_SYSTEMPRINCIPAL_CONTRACTID "@mozilla.org/systemprincipal;1"
24
25
namespace Json {
26
class Value;
27
}
28
29
namespace mozilla {
30
31
class SystemPrincipal final : public BasePrincipal {
32
SystemPrincipal() : BasePrincipal(eSystemPrincipal) {}
33
34
public:
35
static already_AddRefed<SystemPrincipal> Create();
36
37
static PrincipalKind Kind() { return eSystemPrincipal; }
38
39
NS_DECL_NSISERIALIZABLE
40
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
41
uint32_t GetHashValue() override;
42
NS_IMETHOD GetURI(nsIURI** aURI) override;
43
NS_IMETHOD GetDomain(nsIURI** aDomain) override;
44
NS_IMETHOD SetDomain(nsIURI* aDomain) override;
45
NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
46
NS_IMETHOD GetAddonId(nsAString& aAddonId) override;
47
NS_IMETHOD GetIsOriginPotentiallyTrustworthy(bool* aResult) override;
48
49
virtual nsresult GetScriptLocation(nsACString& aStr) override;
50
51
nsresult GetSiteIdentifier(SiteIdentifier& aSite) override {
52
aSite.Init(this);
53
return NS_OK;
54
}
55
56
protected:
57
virtual ~SystemPrincipal(void) {}
58
59
bool SubsumesInternal(nsIPrincipal* aOther,
60
DocumentDomainConsideration aConsideration) override {
61
return true;
62
}
63
64
bool MayLoadInternal(nsIURI* aURI) override { return true; }
65
};
66
67
} // namespace mozilla
68
69
#endif // mozilla_SystemPrincipal_h