forked from mirrors/gecko-dev
Bug 1461921 - Block storage access for third-parties on the tracking protection list - part 6 - Image cache, r=aosmond
This commit is contained in:
parent
5b9437cad2
commit
c42c9f66ed
2 changed files with 20 additions and 6 deletions
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "mozilla/HashFunctions.h"
|
||||
#include "mozilla/Move.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/dom/BlobURLProtocolHandler.h"
|
||||
|
|
@ -42,7 +43,7 @@ ImageCacheKey::ImageCacheKey(nsIURI* aURI,
|
|||
nsresult& aRv)
|
||||
: mURI(aURI)
|
||||
, mOriginAttributes(aAttrs)
|
||||
, mControlledDocument(GetControlledDocumentToken(aDocument))
|
||||
, mControlledDocument(GetSpecialCaseDocumentToken(aDocument, aURI))
|
||||
, mHash(0)
|
||||
, mIsChrome(false)
|
||||
{
|
||||
|
|
@ -125,11 +126,10 @@ ImageCacheKey::SchemeIs(const char* aScheme)
|
|||
}
|
||||
|
||||
/* static */ void*
|
||||
ImageCacheKey::GetControlledDocumentToken(nsIDocument* aDocument)
|
||||
ImageCacheKey::GetSpecialCaseDocumentToken(nsIDocument* aDocument, nsIURI* aURI)
|
||||
{
|
||||
// For non-controlled documents, we just return null. For controlled
|
||||
// documents, we cast the pointer into a void* to avoid dereferencing
|
||||
// it (since we only use it for comparisons), and return it.
|
||||
// For controlled documents, we cast the pointer into a void* to avoid
|
||||
// dereferencing it (since we only use it for comparisons).
|
||||
void* pointer = nullptr;
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
if (aDocument && swm) {
|
||||
|
|
@ -138,6 +138,16 @@ ImageCacheKey::GetControlledDocumentToken(nsIDocument* aDocument)
|
|||
pointer = aDocument;
|
||||
}
|
||||
}
|
||||
|
||||
// If this document has been marked as tracker, let's use its address to make
|
||||
// a unique cache key.
|
||||
if (!pointer && aDocument &&
|
||||
nsContentUtils::StorageDisabledByAntiTracking(nullptr,
|
||||
aDocument->GetChannel(),
|
||||
aURI)) {
|
||||
pointer = aDocument;
|
||||
}
|
||||
|
||||
return pointer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,11 @@ public:
|
|||
|
||||
private:
|
||||
bool SchemeIs(const char* aScheme);
|
||||
static void* GetControlledDocumentToken(nsIDocument* aDocument);
|
||||
|
||||
// For ServiceWorker and for anti-tracking we need to use the document as
|
||||
// token for the key. All those exceptions are handled by this method.
|
||||
static void* GetSpecialCaseDocumentToken(nsIDocument* aDocument,
|
||||
nsIURI* aURI);
|
||||
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
Maybe<uint64_t> mBlobSerial;
|
||||
|
|
|
|||
Loading…
Reference in a new issue