/src/mozilla-central/caps/ExpandedPrincipal.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; 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 | | |
6 | | #ifndef ExpandedPrincipal_h |
7 | | #define ExpandedPrincipal_h |
8 | | |
9 | | #include "nsCOMPtr.h" |
10 | | #include "nsJSPrincipals.h" |
11 | | #include "nsTArray.h" |
12 | | #include "nsNetUtil.h" |
13 | | #include "mozilla/BasePrincipal.h" |
14 | | |
15 | | class ExpandedPrincipal : public nsIExpandedPrincipal |
16 | | , public mozilla::BasePrincipal |
17 | | { |
18 | | public: |
19 | | static already_AddRefed<ExpandedPrincipal> |
20 | | Create(nsTArray<nsCOMPtr<nsIPrincipal>>& aWhiteList, |
21 | | const mozilla::OriginAttributes& aAttrs); |
22 | | |
23 | 3 | static PrincipalKind Kind() { return eExpandedPrincipal; } |
24 | | |
25 | | // For use from the XPCOM factory constructor only. Do not ever use this |
26 | | // constructor by hand! |
27 | | ExpandedPrincipal(); |
28 | | |
29 | | NS_DECL_NSIEXPANDEDPRINCIPAL |
30 | | NS_DECL_NSISERIALIZABLE |
31 | | |
32 | 0 | NS_IMETHOD_(MozExternalRefCountType) AddRef() override { return nsJSPrincipals::AddRef(); }; |
33 | 0 | NS_IMETHOD_(MozExternalRefCountType) Release() override { return nsJSPrincipals::Release(); }; |
34 | | NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override; |
35 | | NS_IMETHOD GetHashValue(uint32_t* aHashValue) override; |
36 | | NS_IMETHOD GetURI(nsIURI** aURI) override; |
37 | | NS_IMETHOD GetDomain(nsIURI** aDomain) override; |
38 | | NS_IMETHOD SetDomain(nsIURI* aDomain) override; |
39 | | NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override; |
40 | | NS_IMETHOD GetAddonId(nsAString& aAddonId) override; |
41 | | virtual bool AddonHasPermission(const nsAtom* aPerm) override; |
42 | | virtual nsresult GetScriptLocation(nsACString &aStr) override; |
43 | | |
44 | | bool AddonAllowsLoad(nsIURI* aURI, bool aExplicit = false); |
45 | | |
46 | | // Returns the principal to inherit when this principal requests the given |
47 | | // URL. See BasePrincipal::PrincipalToInherit. |
48 | | nsIPrincipal* PrincipalToInherit(nsIURI* aRequestedURI = nullptr); |
49 | | |
50 | | nsresult GetSiteIdentifier(mozilla::SiteIdentifier& aSite) override; |
51 | | |
52 | | protected: |
53 | | explicit ExpandedPrincipal(nsTArray<nsCOMPtr<nsIPrincipal>> &aWhiteList); |
54 | | |
55 | | virtual ~ExpandedPrincipal(); |
56 | | |
57 | | bool SubsumesInternal(nsIPrincipal* aOther, |
58 | | DocumentDomainConsideration aConsideration) override; |
59 | | |
60 | | bool MayLoadInternal(nsIURI* aURI) override; |
61 | | |
62 | | private: |
63 | | nsTArray< nsCOMPtr<nsIPrincipal> > mPrincipals; |
64 | | }; |
65 | | |
66 | | #define NS_EXPANDEDPRINCIPAL_CONTRACTID "@mozilla.org/expandedprincipal;1" |
67 | | #define NS_EXPANDEDPRINCIPAL_CID \ |
68 | | { 0xe8ee88b0, 0x5571, 0x4086, \ |
69 | | { 0xa4, 0x5b, 0x39, 0xa7, 0x16, 0x90, 0x6b, 0xdb } } |
70 | | |
71 | | #endif // ExpandedPrincipal_h |