Bug 1708422: part 20) Const-qualify some variables in `mozInlineSpellChecker::SpellCh...
[gecko.git] / caps / SystemPrincipal.cpp
blob615e977f1f52e1725e66ec6adc8037ab19ddd063
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. */
8 #include "nscore.h"
9 #include "SystemPrincipal.h"
10 #include "nsCOMPtr.h"
11 #include "nsReadableUtils.h"
12 #include "nsCRT.h"
13 #include "nsString.h"
14 #include "nsIClassInfoImpl.h"
15 #include "pratom.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();
34 return sp.forget();
37 nsresult SystemPrincipal::GetScriptLocation(nsACString& aStr) {
38 aStr.Assign(kSystemPrincipalSpec);
39 return NS_OK;
42 ///////////////////////////////////////
43 // Methods implementing nsIPrincipal //
44 ///////////////////////////////////////
46 uint32_t SystemPrincipal::GetHashValue() { return NS_PTR_TO_INT32(this); }
48 NS_IMETHODIMP
49 SystemPrincipal::GetURI(nsIURI** aURI) {
50 *aURI = nullptr;
51 return NS_OK;
54 NS_IMETHODIMP
55 SystemPrincipal::GetIsOriginPotentiallyTrustworthy(bool* aResult) {
56 *aResult = true;
57 return NS_OK;
60 NS_IMETHODIMP
61 SystemPrincipal::GetDomain(nsIURI** aDomain) {
62 *aDomain = nullptr;
63 return NS_OK;
66 NS_IMETHODIMP
67 SystemPrincipal::SetDomain(nsIURI* aDomain) { return NS_OK; }
69 NS_IMETHODIMP
70 SystemPrincipal::GetBaseDomain(nsACString& aBaseDomain) {
71 // No base domain for chrome.
72 return NS_OK;
75 NS_IMETHODIMP
76 SystemPrincipal::GetAddonId(nsAString& aAddonId) {
77 aAddonId.Truncate();
78 return NS_OK;
81 //////////////////////////////////////////
82 // Methods implementing nsISerializable //
83 //////////////////////////////////////////
85 NS_IMETHODIMP
86 SystemPrincipal::Read(nsIObjectInputStream* aStream) {
87 // no-op: CID is sufficient to identify the mSystemPrincipal singleton
88 return NS_OK;
91 NS_IMETHODIMP
92 SystemPrincipal::Write(nsIObjectOutputStream* aStream) {
93 // Read is used still for legacy principals
94 MOZ_RELEASE_ASSERT(false, "Old style serialization is removed");
95 return NS_OK;