nsSystemPrincipal.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* -*- Mode: C++; tab-width: 8; 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/. */
  5. /* The privileged system principal. */
  6. #ifndef nsSystemPrincipal_h__
  7. #define nsSystemPrincipal_h__
  8. #include "nsIPrincipal.h"
  9. #include "nsJSPrincipals.h"
  10. #include "mozilla/BasePrincipal.h"
  11. #define NS_SYSTEMPRINCIPAL_CID \
  12. { 0x4a6212db, 0xaccb, 0x11d3, \
  13. { 0xb7, 0x65, 0x0, 0x60, 0xb0, 0xb6, 0xce, 0xcb }}
  14. #define NS_SYSTEMPRINCIPAL_CONTRACTID "@mozilla.org/systemprincipal;1"
  15. class nsSystemPrincipal final : public mozilla::BasePrincipal
  16. {
  17. public:
  18. NS_DECL_NSISERIALIZABLE
  19. NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
  20. NS_IMETHOD GetHashValue(uint32_t* aHashValue) override;
  21. NS_IMETHOD GetURI(nsIURI** aURI) override;
  22. NS_IMETHOD GetDomain(nsIURI** aDomain) override;
  23. NS_IMETHOD SetDomain(nsIURI* aDomain) override;
  24. NS_IMETHOD GetCsp(nsIContentSecurityPolicy** aCsp) override;
  25. NS_IMETHOD SetCsp(nsIContentSecurityPolicy* aCsp) override;
  26. NS_IMETHOD EnsureCSP(nsIDOMDocument* aDocument, nsIContentSecurityPolicy** aCSP) override;
  27. NS_IMETHOD GetPreloadCsp(nsIContentSecurityPolicy** aPreloadCSP) override;
  28. NS_IMETHOD EnsurePreloadCSP(nsIDOMDocument* aDocument, nsIContentSecurityPolicy** aCSP) override;
  29. NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
  30. nsresult GetOriginInternal(nsACString& aOrigin) override;
  31. nsSystemPrincipal() {}
  32. virtual nsresult GetScriptLocation(nsACString &aStr) override;
  33. protected:
  34. virtual ~nsSystemPrincipal(void) {}
  35. bool SubsumesInternal(nsIPrincipal *aOther, DocumentDomainConsideration aConsideration) override
  36. {
  37. return true;
  38. }
  39. bool MayLoadInternal(nsIURI* aURI) override
  40. {
  41. return true;
  42. }
  43. PrincipalKind Kind() override { return eSystemPrincipal; }
  44. };
  45. #endif // nsSystemPrincipal_h__