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:
Andrea Marchesini
2020-05-21 11:28:12 +00:00
parent 3c40eac6ec
commit 183edecd6a
2 changed files with 26 additions and 1 deletions

View File

@@ -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(),