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 #define SYSTEM_PRINCIPAL_SPEC "[System Principal]"
27 already_AddRefed
<SystemPrincipal
> SystemPrincipal::Create() {
28 RefPtr
<SystemPrincipal
> sp
= new SystemPrincipal();
29 sp
->FinishInit(NS_LITERAL_CSTRING(SYSTEM_PRINCIPAL_SPEC
), OriginAttributes());
33 nsresult
SystemPrincipal::GetScriptLocation(nsACString
& aStr
) {
34 aStr
.AssignLiteral(SYSTEM_PRINCIPAL_SPEC
);
38 ///////////////////////////////////////
39 // Methods implementing nsIPrincipal //
40 ///////////////////////////////////////
42 uint32_t SystemPrincipal::GetHashValue() { return NS_PTR_TO_INT32(this); }
45 SystemPrincipal::GetURI(nsIURI
** aURI
) {
51 SystemPrincipal::GetIsOriginPotentiallyTrustworthy(bool* aResult
) {
57 SystemPrincipal::GetDomain(nsIURI
** aDomain
) {
63 SystemPrincipal::SetDomain(nsIURI
* aDomain
) { return NS_OK
; }
66 SystemPrincipal::GetBaseDomain(nsACString
& aBaseDomain
) {
67 // No base domain for chrome.
72 SystemPrincipal::GetAddonId(nsAString
& aAddonId
) {
77 //////////////////////////////////////////
78 // Methods implementing nsISerializable //
79 //////////////////////////////////////////
82 SystemPrincipal::Read(nsIObjectInputStream
* aStream
) {
83 // no-op: CID is sufficient to identify the mSystemPrincipal singleton
88 SystemPrincipal::Write(nsIObjectOutputStream
* aStream
) {
89 // Read is used still for legacy principals
90 MOZ_RELEASE_ASSERT(false, "Old style serialization is removed");