mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1639807 - Isolate image cache per first-party when privacy.partition.network_state is set to true - part 2 - Implementation, r=timhuang
Differential Revision: https://phabricator.services.mozilla.com/D76283
This commit is contained in:
parent
55807d2b15
commit
fd1027ec66
@ -170,6 +170,17 @@ nsCString ImageCacheKey::GetIsolationKey(Document* aDocument, nsIURI* aURI) {
|
||||
return EmptyCString();
|
||||
}
|
||||
|
||||
// Network-state isolation
|
||||
if (StaticPrefs::privacy_partition_network_state()) {
|
||||
OriginAttributes oa;
|
||||
StoragePrincipalHelper::GetOriginAttributesForNetworkState(aDocument, oa);
|
||||
|
||||
nsAutoCString suffix;
|
||||
oa.CreateSuffix(suffix);
|
||||
|
||||
return std::move(suffix);
|
||||
}
|
||||
|
||||
// If the window is 3rd party resource, let's see if first-party storage
|
||||
// access is granted for this image.
|
||||
if (nsContentUtils::IsThirdPartyWindowOrChannel(aDocument->GetInnerWindow(),
|
||||
|
@ -277,8 +277,22 @@ bool StoragePrincipalHelper::GetOriginAttributesForNetworkState(
|
||||
// static
|
||||
void StoragePrincipalHelper::GetOriginAttributesForNetworkState(
|
||||
Document* aDocument, OriginAttributes& aAttributes) {
|
||||
aAttributes = aDocument->NodePrincipal()->OriginAttributesRef();
|
||||
|
||||
if (!StaticPrefs::privacy_partition_network_state()) {
|
||||
aAttributes = aDocument->NodePrincipal()->OriginAttributesRef();
|
||||
return;
|
||||
}
|
||||
|
||||
// This part is required because the intrisicStoragePrincipal is not always
|
||||
// partitioned. This should probably change. TODO - bug 1639833.
|
||||
nsCOMPtr<nsICookieJarSettings> cjs = aDocument->CookieJarSettings();
|
||||
MOZ_ASSERT(cjs);
|
||||
|
||||
nsAutoString domain;
|
||||
Unused << cjs->GetFirstPartyDomain(domain);
|
||||
|
||||
if (!domain.IsEmpty()) {
|
||||
aAttributes.SetFirstPartyDomain(false, domain, true /* aForced */);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user