From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- caps/nsNullPrincipal.h | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 caps/nsNullPrincipal.h (limited to 'caps/nsNullPrincipal.h') diff --git a/caps/nsNullPrincipal.h b/caps/nsNullPrincipal.h new file mode 100644 index 000000000..b29474773 --- /dev/null +++ b/caps/nsNullPrincipal.h @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * This is the principal that has no rights and can't be accessed by + * anything other than itself and chrome; null principals are not + * same-origin with anything but themselves. + */ + +#ifndef nsNullPrincipal_h__ +#define nsNullPrincipal_h__ + +#include "nsIPrincipal.h" +#include "nsJSPrincipals.h" +#include "nsIScriptSecurityManager.h" +#include "nsCOMPtr.h" +#include "nsIContentSecurityPolicy.h" + +#include "mozilla/BasePrincipal.h" + +class nsIDocShell; +class nsIURI; + +#define NS_NULLPRINCIPAL_CID \ +{ 0xbd066e5f, 0x146f, 0x4472, \ + { 0x83, 0x31, 0x7b, 0xfd, 0x05, 0xb1, 0xed, 0x90 } } +#define NS_NULLPRINCIPAL_CONTRACTID "@mozilla.org/nullprincipal;1" + +#define NS_NULLPRINCIPAL_SCHEME "moz-nullprincipal" + +class nsNullPrincipal final : public mozilla::BasePrincipal +{ +public: + // This should only be used by deserialization, and the factory constructor. + // Other consumers should use the Create and CreateWithInheritedAttributes + // methods. + nsNullPrincipal() {} + + NS_DECL_NSISERIALIZABLE + + NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override; + NS_IMETHOD GetHashValue(uint32_t* aHashValue) override; + NS_IMETHOD SetCsp(nsIContentSecurityPolicy* aCsp) override; + NS_IMETHOD GetURI(nsIURI** aURI) override; + NS_IMETHOD GetDomain(nsIURI** aDomain) override; + NS_IMETHOD SetDomain(nsIURI* aDomain) override; + NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override; + nsresult GetOriginInternal(nsACString& aOrigin) override; + + static already_AddRefed CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom); + + static already_AddRefed CreateWithInheritedAttributes(nsIDocShell* aDocShell); + + static already_AddRefed + Create(const mozilla::PrincipalOriginAttributes& aOriginAttributes = mozilla::PrincipalOriginAttributes()); + + nsresult Init(const mozilla::PrincipalOriginAttributes& aOriginAttributes = mozilla::PrincipalOriginAttributes()); + + virtual nsresult GetScriptLocation(nsACString &aStr) override; + + PrincipalKind Kind() override { return eNullPrincipal; } + + protected: + virtual ~nsNullPrincipal() {} + + bool SubsumesInternal(nsIPrincipal* aOther, DocumentDomainConsideration aConsideration) override + { + return aOther == this; + } + + bool MayLoadInternal(nsIURI* aURI) override; + + nsCOMPtr mURI; +}; + +#endif // nsNullPrincipal_h__ -- cgit v1.2.3