Bug 1640135 - P2: add new setter; r=timhuang

Differential Revision: https://phabricator.services.mozilla.com/D77915
This commit is contained in:
Liang-Heng Chen 2020-06-04 10:51:06 +00:00
parent edb1e5a899
commit fd2c048140
3 changed files with 22 additions and 5 deletions

View File

@ -160,6 +160,19 @@ void OriginAttributes::SetFirstPartyDomain(const bool aIsTopLevelDocument,
mFirstPartyDomain = aDomain;
}
void OriginAttributes::SetPartitionKey(nsIURI* aURI) {
// TODO: implement this function
MOZ_ASSERT(false);
}
void OriginAttributes::SetPartitionKey(const nsACString& aDomain) {
SetPartitionKey(NS_ConvertUTF8toUTF16(aDomain));
}
void OriginAttributes::SetPartitionKey(const nsAString& aDomain) {
mPartitionKey = aDomain;
}
void OriginAttributes::CreateSuffix(nsACString& aStr) const {
URLParams params;
nsAutoString value;

View File

@ -32,6 +32,10 @@ class OriginAttributes : public dom::OriginAttributesDictionary {
void SetFirstPartyDomain(const bool aIsTopLevelDocument,
const nsAString& aDomain, bool aForced = false);
void SetPartitionKey(nsIURI* aURI);
void SetPartitionKey(const nsACString& aDomain);
void SetPartitionKey(const nsAString& aDomain);
enum {
STRIP_FIRST_PARTY_DOMAIN = 0x01,
STRIP_USER_CONTEXT_ID = 0x02,

View File

@ -47,11 +47,11 @@ bool ChooseOriginAttributes(nsIChannel* aChannel, OriginAttributes& aAttrs,
}
}
nsAutoString domain;
Unused << cjs->GetFirstPartyDomain(domain);
nsAutoString partitionKey;
Unused << cjs->GetFirstPartyDomain(partitionKey);
if (!domain.IsEmpty()) {
aAttrs.SetFirstPartyDomain(false, domain, true /* aForced */);
if (!partitionKey.IsEmpty()) {
aAttrs.SetPartitionKey(partitionKey);
return true;
}
@ -71,7 +71,7 @@ bool ChooseOriginAttributes(nsIChannel* aChannel, OriginAttributes& aAttrs,
return false;
}
aAttrs.SetFirstPartyDomain(false, principalURI, true /* aForced */);
aAttrs.SetPartitionKey(principalURI);
return true;
}