1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /* The privileged system principal. */
9 #include "SystemPrincipal.h"
11 #include "nsReadableUtils.h"
14 #include "nsIClassInfoImpl.h"
17 using namespace mozilla
;
19 NS_IMPL_CLASSINFO(SystemPrincipal
, nullptr,
20 nsIClassInfo::SINGLETON
| nsIClassInfo::MAIN_THREAD_ONLY
,
21 NS_SYSTEMPRINCIPAL_CID
)
22 NS_IMPL_QUERY_INTERFACE_CI(SystemPrincipal
, nsIPrincipal
, nsISerializable
)
23 NS_IMPL_CI_INTERFACE_GETTER(SystemPrincipal
, nsIPrincipal
, nsISerializable
)
25 static constexpr nsLiteralCString kSystemPrincipalSpec
=
26 "[System Principal]"_ns
;
28 SystemPrincipal::SystemPrincipal()
29 : BasePrincipal(eSystemPrincipal
, kSystemPrincipalSpec
,
30 OriginAttributes()) {}
32 already_AddRefed
<SystemPrincipal
> SystemPrincipal::Create() {
33 RefPtr
<SystemPrincipal
> sp
= new SystemPrincipal();
37 nsresult
SystemPrincipal::GetScriptLocation(nsACString
& aStr
) {
38 aStr
.Assign(kSystemPrincipalSpec
);
42 ///////////////////////////////////////
43 // Methods implementing nsIPrincipal //
44 ///////////////////////////////////////
46 uint32_t SystemPrincipal::GetHashValue() { return NS_PTR_TO_INT32(this); }
49 SystemPrincipal::GetURI(nsIURI
** aURI
) {
55 SystemPrincipal::GetIsOriginPotentiallyTrustworthy(bool* aResult
) {
61 SystemPrincipal::GetDomain(nsIURI
** aDomain
) {
67 SystemPrincipal::SetDomain(nsIURI
* aDomain
) { return NS_OK
; }
70 SystemPrincipal::GetBaseDomain(nsACString
& aBaseDomain
) {
71 // No base domain for chrome.
76 SystemPrincipal::GetAddonId(nsAString
& aAddonId
) {
81 //////////////////////////////////////////
82 // Methods implementing nsISerializable //
83 //////////////////////////////////////////
86 SystemPrincipal::Read(nsIObjectInputStream
* aStream
) {
87 // no-op: CID is sufficient to identify the mSystemPrincipal singleton
92 SystemPrincipal::Write(nsIObjectOutputStream
* aStream
) {
93 // Read is used still for legacy principals
94 MOZ_RELEASE_ASSERT(false, "Old style serialization is removed");