tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SystemPrincipal.h (2249B)


      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  {0x4a6212db, 0xaccb, 0x11d3, {0xb7, 0x65, 0x0, 0x60, 0xb0, 0xb6, 0xce, 0xcb}}
     19 #define NS_SYSTEMPRINCIPAL_CONTRACTID "@mozilla.org/systemprincipal;1"
     20 
     21 class nsScriptSecurityManager;
     22 
     23 namespace mozilla {
     24 
     25 class SystemPrincipal final : public BasePrincipal, public nsISerializable {
     26  SystemPrincipal();
     27 
     28 public:
     29  static already_AddRefed<SystemPrincipal> Get();
     30 
     31  static PrincipalKind Kind() { return eSystemPrincipal; }
     32 
     33  NS_IMETHOD_(MozExternalRefCountType) AddRef() override {
     34    return nsJSPrincipals::AddRef();
     35  };
     36  NS_IMETHOD_(MozExternalRefCountType) Release() override {
     37    return nsJSPrincipals::Release();
     38  };
     39 
     40  NS_DECL_NSISERIALIZABLE
     41  NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) 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  friend class ::nsScriptSecurityManager;
     58 
     59  virtual ~SystemPrincipal() = default;
     60 
     61  static already_AddRefed<SystemPrincipal> Init();
     62  static void Shutdown();
     63 
     64  bool SubsumesInternal(nsIPrincipal* aOther,
     65                        DocumentDomainConsideration aConsideration) override {
     66    return true;
     67  }
     68 
     69  bool MayLoadInternal(nsIURI* aURI) override { return true; }
     70 };
     71 
     72 }  // namespace mozilla
     73 
     74 #endif  // mozilla_SystemPrincipal_h