mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1297687 - Part 2: Allow specifying an OriginAttribute when creating an expanded principal; r=bholley
This commit is contained in:
parent
6b65aceec2
commit
5404c2dc93
@ -674,7 +674,7 @@ struct OriginComparator
|
||||
}
|
||||
};
|
||||
|
||||
nsExpandedPrincipal::nsExpandedPrincipal(nsTArray<nsCOMPtr <nsIPrincipal> > &aWhiteList)
|
||||
nsExpandedPrincipal::nsExpandedPrincipal(nsTArray<nsCOMPtr<nsIPrincipal>> &aWhiteList)
|
||||
{
|
||||
// We force the principals to be sorted by origin so that nsExpandedPrincipal
|
||||
// origins can have a canonical form.
|
||||
@ -684,6 +684,13 @@ nsExpandedPrincipal::nsExpandedPrincipal(nsTArray<nsCOMPtr <nsIPrincipal> > &aWh
|
||||
}
|
||||
}
|
||||
|
||||
nsExpandedPrincipal::nsExpandedPrincipal(nsTArray<nsCOMPtr<nsIPrincipal>> &aWhiteList,
|
||||
const PrincipalOriginAttributes& aAttrs)
|
||||
: nsExpandedPrincipal(aWhiteList)
|
||||
{
|
||||
mOriginAttributes = aAttrs;
|
||||
}
|
||||
|
||||
nsExpandedPrincipal::~nsExpandedPrincipal()
|
||||
{ }
|
||||
|
||||
|
@ -67,7 +67,9 @@ protected:
|
||||
class nsExpandedPrincipal : public nsIExpandedPrincipal, public mozilla::BasePrincipal
|
||||
{
|
||||
public:
|
||||
explicit nsExpandedPrincipal(nsTArray< nsCOMPtr<nsIPrincipal> > &aWhiteList);
|
||||
nsExpandedPrincipal(nsTArray<nsCOMPtr<nsIPrincipal>> &aWhiteList,
|
||||
const mozilla::PrincipalOriginAttributes& aAttrs);
|
||||
explicit nsExpandedPrincipal(nsTArray<nsCOMPtr<nsIPrincipal>> &aWhiteList);
|
||||
|
||||
NS_DECL_NSIEXPANDEDPRINCIPAL
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
|
@ -93,7 +93,7 @@ PrincipalInfoToPrincipal(const PrincipalInfo& aPrincipalInfo,
|
||||
case PrincipalInfo::TExpandedPrincipalInfo: {
|
||||
const ExpandedPrincipalInfo& info = aPrincipalInfo.get_ExpandedPrincipalInfo();
|
||||
|
||||
nsTArray< nsCOMPtr<nsIPrincipal> > whitelist;
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>> whitelist;
|
||||
nsCOMPtr<nsIPrincipal> wlPrincipal;
|
||||
|
||||
for (uint32_t i = 0; i < info.whitelist().Length(); i++) {
|
||||
@ -105,7 +105,7 @@ PrincipalInfoToPrincipal(const PrincipalInfo& aPrincipalInfo,
|
||||
whitelist.AppendElement(wlPrincipal);
|
||||
}
|
||||
|
||||
RefPtr<nsExpandedPrincipal> expandedPrincipal = new nsExpandedPrincipal(whitelist);
|
||||
RefPtr<nsExpandedPrincipal> expandedPrincipal = new nsExpandedPrincipal(whitelist, info.attrs());
|
||||
if (!expandedPrincipal) {
|
||||
NS_WARNING("could not instantiate expanded principal");
|
||||
return nullptr;
|
||||
@ -173,7 +173,9 @@ PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
|
||||
whitelistInfo.AppendElement(info);
|
||||
}
|
||||
|
||||
*aPrincipalInfo = ExpandedPrincipalInfo(Move(whitelistInfo));
|
||||
*aPrincipalInfo =
|
||||
ExpandedPrincipalInfo(BasePrincipal::Cast(aPrincipal)->OriginAttributesRef(),
|
||||
Move(whitelistInfo));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ struct NullPrincipalInfo
|
||||
|
||||
struct ExpandedPrincipalInfo
|
||||
{
|
||||
PrincipalOriginAttributes attrs;
|
||||
PrincipalInfo[] whitelist;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user