2006-04-03 00:58:26 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2006-04-03 00:58:26 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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"
|
2014-07-29 19:47:52 +04:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2006-04-03 00:58:26 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2013-11-23 03:12:00 +04:00
|
|
|
#include "nsIContentSecurityPolicy.h"
|
2006-04-03 00:58:26 +04:00
|
|
|
|
2015-05-12 00:36:56 +03:00
|
|
|
#include "mozilla/BasePrincipal.h"
|
|
|
|
|
2006-04-03 00:58:26 +04:00
|
|
|
class nsIURI;
|
|
|
|
|
|
|
|
#define NS_NULLPRINCIPAL_CID \
|
2015-07-29 00:32:00 +03:00
|
|
|
{ 0xbd066e5f, 0x146f, 0x4472, \
|
|
|
|
{ 0x83, 0x31, 0x7b, 0xfd, 0x05, 0xb1, 0xed, 0x90 } }
|
2006-04-03 00:58:26 +04:00
|
|
|
#define NS_NULLPRINCIPAL_CONTRACTID "@mozilla.org/nullprincipal;1"
|
|
|
|
|
|
|
|
#define NS_NULLPRINCIPAL_SCHEME "moz-nullprincipal"
|
|
|
|
|
2015-05-12 00:36:56 +03:00
|
|
|
class nsNullPrincipal final : public mozilla::BasePrincipal
|
2006-04-03 00:58:26 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-03-31 20:11:00 +03:00
|
|
|
// This should only be used by deserialization, and the factory constructor.
|
|
|
|
// Other consumers should use the Create and CreateWithInheritedAttributes
|
|
|
|
// methods.
|
2015-05-11 23:16:36 +03:00
|
|
|
nsNullPrincipal() {}
|
2015-02-24 23:54:40 +03:00
|
|
|
|
2006-04-03 00:58:26 +04:00
|
|
|
NS_DECL_NSISERIALIZABLE
|
2015-05-12 00:36:56 +03:00
|
|
|
|
2015-05-11 23:16:36 +03:00
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
2015-05-12 00:36:56 +03:00
|
|
|
NS_IMETHOD GetHashValue(uint32_t* aHashValue) 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;
|
2015-05-15 02:50:44 +03:00
|
|
|
nsresult GetOriginInternal(nsACString& aOrigin) override;
|
2006-04-03 00:58:26 +04:00
|
|
|
|
2015-03-31 20:11:00 +03:00
|
|
|
// Returns null on failure.
|
2014-07-29 19:47:52 +04:00
|
|
|
static already_AddRefed<nsNullPrincipal> CreateWithInheritedAttributes(nsIPrincipal *aInheritFrom);
|
|
|
|
|
2015-03-31 20:11:00 +03:00
|
|
|
// Returns null on failure.
|
|
|
|
static already_AddRefed<nsNullPrincipal>
|
2015-11-03 04:50:54 +03:00
|
|
|
Create(const mozilla::PrincipalOriginAttributes& aOriginAttributes = mozilla::PrincipalOriginAttributes());
|
2015-03-31 20:11:00 +03:00
|
|
|
|
2015-11-03 04:50:54 +03:00
|
|
|
nsresult Init(const mozilla::PrincipalOriginAttributes& aOriginAttributes = mozilla::PrincipalOriginAttributes());
|
2006-04-03 00:58:26 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void GetScriptLocation(nsACString &aStr) override;
|
2012-03-09 13:48:50 +04:00
|
|
|
|
2015-10-24 03:58:21 +03:00
|
|
|
PrincipalKind Kind() override { return eNullPrincipal; }
|
|
|
|
|
2012-03-09 13:48:50 +04:00
|
|
|
protected:
|
2015-05-11 23:16:36 +03:00
|
|
|
virtual ~nsNullPrincipal() {}
|
2006-04-03 00:58:26 +04:00
|
|
|
|
2015-05-14 21:15:56 +03:00
|
|
|
bool SubsumesInternal(nsIPrincipal* aOther, DocumentDomainConsideration aConsideration) override
|
|
|
|
{
|
|
|
|
return aOther == this;
|
|
|
|
}
|
|
|
|
|
2015-10-01 06:03:36 +03:00
|
|
|
bool MayLoadInternal(nsIURI* aURI) override;
|
|
|
|
|
2006-04-03 00:58:26 +04:00
|
|
|
nsCOMPtr<nsIURI> mURI;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsNullPrincipal_h__
|