Bug 1731988 - Part 2: Support eForeignPartitionedPrincipal for StoragePrincipalHelper::GetOriginAttributes(). r=dimi

Differential Revision: https://phabricator.services.mozilla.com/D127436
This commit is contained in:
Tim Huang 2021-10-06 14:56:59 +00:00
Родитель 0d2eb797fd
Коммит c3ea5f426d
1 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -238,6 +238,8 @@ bool StoragePrincipalHelper::GetOriginAttributes(
}
aAttributes.SyncAttributesWithPrivateBrowsing(isPrivate);
nsCOMPtr<nsICookieJarSettings> cjs;
switch (aPrincipalType) {
case eRegularPrincipal:
break;
@ -249,6 +251,18 @@ bool StoragePrincipalHelper::GetOriginAttributes(
case ePartitionedPrincipal:
ChooseOriginAttributes(aChannel, aAttributes, true);
break;
case eForeignPartitionedPrincipal:
Unused << loadInfo->GetCookieJarSettings(getter_AddRefs(cjs));
// We only support foreign partitioned principal when dFPI is enabled.
// Otherwise, we will use the regular principal.
if (cjs->GetCookieBehavior() ==
nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN &&
loadInfo->GetIsThirdPartyContextToTopWindow()) {
ChooseOriginAttributes(aChannel, aAttributes, true);
}
break;
}
return true;