2017-02-22 12:01:43 +03:00
|
|
|
/* -*- 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/. */
|
|
|
|
|
2017-03-22 13:38:17 +03:00
|
|
|
#ifndef ExpandedPrincipal_h
|
|
|
|
#define ExpandedPrincipal_h
|
2017-02-22 12:01:43 +03:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsJSPrincipals.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsNetUtil.h"
|
|
|
|
#include "mozilla/BasePrincipal.h"
|
|
|
|
|
2017-03-22 13:38:17 +03:00
|
|
|
class ExpandedPrincipal : public nsIExpandedPrincipal
|
|
|
|
, public mozilla::BasePrincipal
|
2017-02-22 12:01:43 +03:00
|
|
|
{
|
2017-02-25 01:02:24 +03:00
|
|
|
public:
|
2017-03-22 13:38:17 +03:00
|
|
|
static already_AddRefed<ExpandedPrincipal>
|
2017-02-25 01:02:24 +03:00
|
|
|
Create(nsTArray<nsCOMPtr<nsIPrincipal>>& aWhiteList,
|
|
|
|
const mozilla::OriginAttributes& aAttrs);
|
|
|
|
|
2017-04-16 23:32:42 +03:00
|
|
|
static PrincipalKind Kind() { return eExpandedPrincipal; }
|
|
|
|
|
2018-05-24 09:43:14 +03:00
|
|
|
// For use from the XPCOM factory constructor only. Do not ever use this
|
|
|
|
// constructor by hand!
|
|
|
|
ExpandedPrincipal();
|
|
|
|
|
2017-02-22 12:01:43 +03:00
|
|
|
NS_DECL_NSIEXPANDEDPRINCIPAL
|
|
|
|
NS_DECL_NSISERIALIZABLE
|
2017-03-22 13:38:17 +03:00
|
|
|
|
2017-02-22 12:01:43 +03:00
|
|
|
NS_IMETHOD_(MozExternalRefCountType) AddRef() override { return nsJSPrincipals::AddRef(); };
|
|
|
|
NS_IMETHOD_(MozExternalRefCountType) Release() override { return nsJSPrincipals::Release(); };
|
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
|
|
|
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;
|
2016-11-06 08:38:17 +03:00
|
|
|
NS_IMETHOD GetAddonId(nsAString& aAddonId) override;
|
2017-10-03 01:05:19 +03:00
|
|
|
virtual bool AddonHasPermission(const nsAtom* aPerm) override;
|
2017-02-22 12:01:43 +03:00
|
|
|
virtual nsresult GetScriptLocation(nsACString &aStr) override;
|
|
|
|
|
2018-04-04 17:54:26 +03:00
|
|
|
bool AddonAllowsLoad(nsIURI* aURI, bool aExplicit = false);
|
|
|
|
|
2017-11-03 05:56:27 +03:00
|
|
|
// Returns the principal to inherit when this principal requests the given
|
|
|
|
// URL. See BasePrincipal::PrincipalToInherit.
|
2017-11-23 01:20:26 +03:00
|
|
|
nsIPrincipal* PrincipalToInherit(nsIURI* aRequestedURI = nullptr);
|
2017-11-03 05:56:27 +03:00
|
|
|
|
2018-09-11 12:01:14 +03:00
|
|
|
nsresult GetSiteIdentifier(mozilla::SiteIdentifier& aSite) override;
|
|
|
|
|
2017-02-22 12:01:43 +03:00
|
|
|
protected:
|
2017-03-29 09:21:03 +03:00
|
|
|
explicit ExpandedPrincipal(nsTArray<nsCOMPtr<nsIPrincipal>> &aWhiteList);
|
|
|
|
|
2017-03-22 13:38:17 +03:00
|
|
|
virtual ~ExpandedPrincipal();
|
|
|
|
|
|
|
|
bool SubsumesInternal(nsIPrincipal* aOther,
|
|
|
|
DocumentDomainConsideration aConsideration) override;
|
2017-02-22 12:01:43 +03:00
|
|
|
|
|
|
|
bool MayLoadInternal(nsIURI* aURI) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsTArray< nsCOMPtr<nsIPrincipal> > mPrincipals;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define NS_EXPANDEDPRINCIPAL_CONTRACTID "@mozilla.org/expandedprincipal;1"
|
|
|
|
#define NS_EXPANDEDPRINCIPAL_CID \
|
|
|
|
{ 0xe8ee88b0, 0x5571, 0x4086, \
|
|
|
|
{ 0xa4, 0x5b, 0x39, 0xa7, 0x16, 0x90, 0x6b, 0xdb } }
|
|
|
|
|
2017-03-22 13:38:17 +03:00
|
|
|
#endif // ExpandedPrincipal_h
|