зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1319773 - Part 1: Add a SubsumesConsideringDomainIgnoringFPD in BasePrincipal. r=baku
--HG-- extra : rebase_source : db853a600e666cd11a140153536427c1f4e5882c
This commit is contained in:
Родитель
79a4687d13
Коммит
3e5d172c95
|
@ -388,6 +388,24 @@ BasePrincipal::SubsumesConsideringDomain(nsIPrincipal *aOther, bool *aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::SubsumesConsideringDomainIgnoringFPD(nsIPrincipal *aOther,
|
||||
bool *aResult)
|
||||
{
|
||||
NS_ENSURE_TRUE(aOther, NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (Kind() == eCodebasePrincipal &&
|
||||
!dom::ChromeUtils::IsOriginAttributesEqualIgnoringFPD(
|
||||
OriginAttributesRef(), aOther->OriginAttributesRef())) {
|
||||
*aResult = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aResult = SubsumesInternal(aOther, ConsiderDocumentDomain);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::CheckMayLoad(nsIURI* aURI, bool aReport, bool aAllowIfInheritsPrincipal)
|
||||
{
|
||||
|
|
|
@ -210,6 +210,7 @@ public:
|
|||
NS_IMETHOD EqualsConsideringDomain(nsIPrincipal* other, bool* _retval) final;
|
||||
NS_IMETHOD Subsumes(nsIPrincipal* other, bool* _retval) final;
|
||||
NS_IMETHOD SubsumesConsideringDomain(nsIPrincipal* other, bool* _retval) final;
|
||||
NS_IMETHOD SubsumesConsideringDomainIgnoringFPD(nsIPrincipal* other, bool* _retval) final;
|
||||
NS_IMETHOD CheckMayLoad(nsIURI* uri, bool report, bool allowIfInheritsPrincipal) final;
|
||||
NS_IMETHOD GetCsp(nsIContentSecurityPolicy** aCsp) override;
|
||||
NS_IMETHOD EnsureCSP(nsIDOMDocument* aDocument, nsIContentSecurityPolicy** aCSP) override;
|
||||
|
|
|
@ -94,6 +94,12 @@ interface nsIPrincipal : nsISerializable
|
|||
*/
|
||||
boolean subsumesConsideringDomain(in nsIPrincipal other);
|
||||
|
||||
/**
|
||||
* Same as the subsumesConsideringDomain(), but ignores the first party
|
||||
* domain in its originAttributes.
|
||||
*/
|
||||
boolean subsumesConsideringDomainIgnoringFPD(in nsIPrincipal other);
|
||||
|
||||
%{C++
|
||||
inline bool Subsumes(nsIPrincipal* aOther) {
|
||||
bool subsumes = false;
|
||||
|
@ -104,6 +110,11 @@ interface nsIPrincipal : nsISerializable
|
|||
bool subsumes = false;
|
||||
return NS_SUCCEEDED(SubsumesConsideringDomain(aOther, &subsumes)) && subsumes;
|
||||
}
|
||||
|
||||
inline bool SubsumesConsideringDomainIgnoringFPD(nsIPrincipal* aOther) {
|
||||
bool subsumes = false;
|
||||
return NS_SUCCEEDED(SubsumesConsideringDomainIgnoringFPD(aOther, &subsumes)) && subsumes;
|
||||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
|
|
|
@ -199,5 +199,16 @@ ChromeUtils::IsOriginAttributesEqualIgnoringAddonId(const dom::OriginAttributesD
|
|||
aA.mPrivateBrowsingId == aB.mPrivateBrowsingId;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
ChromeUtils::IsOriginAttributesEqualIgnoringFPD(const dom::OriginAttributesDictionary& aA,
|
||||
const dom::OriginAttributesDictionary& aB)
|
||||
{
|
||||
return aA.mAddonId == aB.mAddonId &&
|
||||
aA.mAppId == aB.mAppId &&
|
||||
aA.mInIsolatedMozBrowser == aB.mInIsolatedMozBrowser &&
|
||||
aA.mUserContextId == aB.mUserContextId &&
|
||||
aA.mPrivateBrowsingId == aB.mPrivateBrowsingId;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -95,6 +95,10 @@ public:
|
|||
static bool
|
||||
IsOriginAttributesEqualIgnoringAddonId(const dom::OriginAttributesDictionary& aA,
|
||||
const dom::OriginAttributesDictionary& aB);
|
||||
|
||||
static bool
|
||||
IsOriginAttributesEqualIgnoringFPD(const dom::OriginAttributesDictionary& aA,
|
||||
const dom::OriginAttributesDictionary& aB);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
Загрузка…
Ссылка в новой задаче