Bug 1483604 - Part 2: Make all of the external consumers of nsContentUtils::StorageDisabledByAntiTracking() pass a channel if available; r=smaug

This commit is contained in:
Ehsan Akhgari 2018-08-15 18:02:48 -04:00
parent 0ef6860e9a
commit 99d839224e
3 changed files with 20 additions and 8 deletions

View File

@ -2950,6 +2950,22 @@ public:
*/
static StorageAccess StorageAllowedForPrincipal(nsIPrincipal* aPrincipal);
/*
* Returns true if this document should disable storages because of the anti-tracking feature.
*/
static bool StorageDisabledByAntiTracking(nsIDocument* aDocument,
nsIURI* aURI)
{
// Note that GetChannel() below may return null, but that's OK, since the callee
// is able to deal with a null channel argument, and if passed null, will only fail
// to notify the UI in case storage gets blocked.
return StorageDisabledByAntiTracking(aDocument->GetInnerWindow(),
aDocument->GetChannel(),
aDocument->NodePrincipal(),
aURI);
}
private:
/*
* Returns true if this window/channel/aPrincipal should disable storages
* because of the anti-tracking feature.
@ -2962,6 +2978,7 @@ public:
nsIPrincipal* aPrincipal,
nsIURI* aURI);
public:
/*
* Returns true if this window/channel is a 3rd party context.
*/

View File

@ -1106,8 +1106,7 @@ nsHTMLDocument::GetCookie(nsAString& aCookie, ErrorResult& rv)
return;
}
if (nsContentUtils::StorageDisabledByAntiTracking(GetInnerWindow(), nullptr,
NodePrincipal(), nullptr)) {
if (nsContentUtils::StorageDisabledByAntiTracking(this, nullptr)) {
return;
}
@ -1161,8 +1160,7 @@ nsHTMLDocument::SetCookie(const nsAString& aCookie, ErrorResult& rv)
return;
}
if (nsContentUtils::StorageDisabledByAntiTracking(GetInnerWindow(), nullptr,
NodePrincipal(), nullptr)) {
if (nsContentUtils::StorageDisabledByAntiTracking(this, nullptr)) {
return;
}

View File

@ -143,10 +143,7 @@ ImageCacheKey::GetSpecialCaseDocumentToken(nsIDocument* aDocument, nsIURI* aURI)
// If we must disable the storage, we want to create a unique cache key for
// this image.
if (nsContentUtils::StorageDisabledByAntiTracking(aDocument->GetInnerWindow(),
nullptr,
aDocument->NodePrincipal(),
aURI)) {
if (nsContentUtils::StorageDisabledByAntiTracking(aDocument, aURI)) {
return aDocument;
}