2015-05-20 20:21:09 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "ImageCacheKey.h"
|
|
|
|
|
2020-01-20 19:18:20 +03:00
|
|
|
#include <utility>
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
|
2021-08-11 13:37:18 +03:00
|
|
|
#include "mozilla/AntiTrackingUtils.h"
|
2022-06-08 22:07:37 +03:00
|
|
|
#include "mozilla/ContentBlocking.h"
|
2019-05-02 15:27:07 +03:00
|
|
|
#include "mozilla/HashFunctions.h"
|
2019-05-27 17:06:49 +03:00
|
|
|
#include "mozilla/StorageAccess.h"
|
2020-05-21 14:28:14 +03:00
|
|
|
#include "mozilla/StoragePrincipalHelper.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "mozilla/Unused.h"
|
|
|
|
#include "mozilla/dom/Document.h"
|
2016-12-01 17:12:42 +03:00
|
|
|
#include "mozilla/dom/File.h"
|
2018-01-27 00:08:59 +03:00
|
|
|
#include "mozilla/dom/ServiceWorkerManager.h"
|
2020-05-21 14:28:14 +03:00
|
|
|
#include "mozilla/StaticPrefs_privacy.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "nsContentUtils.h"
|
2019-05-02 15:27:07 +03:00
|
|
|
#include "nsHashKeys.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "nsLayoutUtils.h"
|
2015-10-27 21:12:46 +03:00
|
|
|
#include "nsPrintfCString.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "nsString.h"
|
2015-05-20 20:21:09 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
using namespace dom;
|
|
|
|
|
|
|
|
namespace image {
|
|
|
|
|
2016-08-04 21:22:00 +03:00
|
|
|
ImageCacheKey::ImageCacheKey(nsIURI* aURI, const OriginAttributes& aAttrs,
|
2019-02-22 17:25:04 +03:00
|
|
|
Document* aDocument)
|
2018-06-06 03:42:56 +03:00
|
|
|
: mURI(aURI),
|
2016-08-04 21:22:00 +03:00
|
|
|
mOriginAttributes(aAttrs),
|
2020-04-13 23:50:19 +03:00
|
|
|
mControlledDocument(GetSpecialCaseDocumentToken(aDocument)),
|
2020-05-21 14:28:14 +03:00
|
|
|
mIsolationKey(GetIsolationKey(aDocument, aURI)),
|
2022-03-29 00:04:47 +03:00
|
|
|
mIsChrome(false) {
|
2020-09-23 01:02:42 +03:00
|
|
|
if (mURI->SchemeIs("chrome")) {
|
2018-06-06 03:42:56 +03:00
|
|
|
mIsChrome = true;
|
2015-05-21 04:49:53 +03:00
|
|
|
}
|
2015-05-20 20:21:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ImageCacheKey::ImageCacheKey(const ImageCacheKey& aOther)
|
2015-05-20 20:21:11 +03:00
|
|
|
: mURI(aOther.mURI),
|
2016-08-04 21:22:00 +03:00
|
|
|
mOriginAttributes(aOther.mOriginAttributes),
|
2015-10-27 21:12:46 +03:00
|
|
|
mControlledDocument(aOther.mControlledDocument),
|
2020-05-21 14:28:14 +03:00
|
|
|
mIsolationKey(aOther.mIsolationKey),
|
2015-05-20 20:21:09 +03:00
|
|
|
mHash(aOther.mHash),
|
2022-03-29 00:04:47 +03:00
|
|
|
mIsChrome(aOther.mIsChrome) {}
|
2015-05-20 20:21:09 +03:00
|
|
|
|
|
|
|
ImageCacheKey::ImageCacheKey(ImageCacheKey&& aOther)
|
2018-05-30 22:15:35 +03:00
|
|
|
: mURI(std::move(aOther.mURI)),
|
2016-08-04 21:22:00 +03:00
|
|
|
mOriginAttributes(aOther.mOriginAttributes),
|
2015-10-27 21:12:46 +03:00
|
|
|
mControlledDocument(aOther.mControlledDocument),
|
2020-05-21 14:28:14 +03:00
|
|
|
mIsolationKey(aOther.mIsolationKey),
|
2015-05-20 20:21:09 +03:00
|
|
|
mHash(aOther.mHash),
|
2022-03-29 00:04:47 +03:00
|
|
|
mIsChrome(aOther.mIsChrome) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-05-20 20:21:09 +03:00
|
|
|
bool ImageCacheKey::operator==(const ImageCacheKey& aOther) const {
|
2015-10-27 21:12:46 +03:00
|
|
|
// Don't share the image cache between a controlled document and anything
|
|
|
|
// else.
|
|
|
|
if (mControlledDocument != aOther.mControlledDocument) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-05-02 15:27:07 +03:00
|
|
|
// Don't share the image cache between two top-level documents of different
|
|
|
|
// base domains.
|
2020-05-21 14:28:14 +03:00
|
|
|
if (!mIsolationKey.Equals(aOther.mIsolationKey,
|
2020-05-27 21:11:12 +03:00
|
|
|
nsCaseInsensitiveCStringComparator)) {
|
2019-05-02 15:27:07 +03:00
|
|
|
return false;
|
|
|
|
}
|
2016-08-04 21:22:00 +03:00
|
|
|
// The origin attributes always have to match.
|
|
|
|
if (mOriginAttributes != aOther.mOriginAttributes) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-05-21 04:49:53 +03:00
|
|
|
|
|
|
|
// For non-blob URIs, compare the URIs.
|
2018-06-06 03:42:56 +03:00
|
|
|
bool equals = false;
|
|
|
|
nsresult rv = mURI->Equals(aOther.mURI, &equals);
|
|
|
|
return NS_SUCCEEDED(rv) && equals;
|
2015-05-20 20:21:09 +03:00
|
|
|
}
|
|
|
|
|
2019-02-22 17:25:04 +03:00
|
|
|
void ImageCacheKey::EnsureHash() const {
|
|
|
|
MOZ_ASSERT(mHash.isNothing());
|
|
|
|
PLDHashNumber hash = 0;
|
|
|
|
|
|
|
|
// Since we frequently call Hash() several times in a row on the same
|
|
|
|
// ImageCacheKey, as an optimization we compute our hash once and store it.
|
|
|
|
|
|
|
|
nsPrintfCString ptr("%p", mControlledDocument);
|
|
|
|
nsAutoCString suffix;
|
|
|
|
mOriginAttributes.CreateSuffix(suffix);
|
|
|
|
|
2020-09-23 01:02:42 +03:00
|
|
|
nsAutoCString spec;
|
|
|
|
Unused << mURI->GetSpec(spec);
|
|
|
|
hash = HashString(spec);
|
2019-02-22 17:25:04 +03:00
|
|
|
|
2020-05-21 14:28:14 +03:00
|
|
|
hash = AddToHash(hash, HashString(suffix), HashString(mIsolationKey),
|
2022-03-29 00:04:47 +03:00
|
|
|
HashString(ptr));
|
2019-02-22 17:25:04 +03:00
|
|
|
mHash.emplace(hash);
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:58 +03:00
|
|
|
/* static */
|
2020-04-13 23:50:19 +03:00
|
|
|
void* ImageCacheKey::GetSpecialCaseDocumentToken(Document* aDocument) {
|
2018-08-16 23:44:37 +03:00
|
|
|
// Cookie-averse documents can never have storage granted to them. Since they
|
|
|
|
// may not have inner windows, they would require special handling below, so
|
|
|
|
// just bail out early here.
|
|
|
|
if (!aDocument || aDocument->IsCookieAverse()) {
|
2018-07-13 13:02:19 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-06-20 20:38:22 +03:00
|
|
|
// For controlled documents, we cast the pointer into a void* to avoid
|
|
|
|
// dereferencing it (since we only use it for comparisons).
|
2015-10-27 21:12:46 +03:00
|
|
|
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
2018-07-13 13:02:19 +03:00
|
|
|
if (swm && aDocument->GetController().isSome()) {
|
|
|
|
return aDocument;
|
|
|
|
}
|
|
|
|
|
2019-05-02 15:27:07 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
2020-05-21 14:28:14 +03:00
|
|
|
nsCString ImageCacheKey::GetIsolationKey(Document* aDocument, nsIURI* aURI) {
|
2019-05-02 15:27:07 +03:00
|
|
|
if (!aDocument || !aDocument->GetInnerWindow()) {
|
2020-09-23 18:17:15 +03:00
|
|
|
return ""_ns;
|
2019-05-02 15:27:07 +03:00
|
|
|
}
|
|
|
|
|
2020-05-21 14:28:12 +03:00
|
|
|
// Network-state isolation
|
|
|
|
if (StaticPrefs::privacy_partition_network_state()) {
|
|
|
|
OriginAttributes oa;
|
|
|
|
StoragePrincipalHelper::GetOriginAttributesForNetworkState(aDocument, oa);
|
|
|
|
|
|
|
|
nsAutoCString suffix;
|
|
|
|
oa.CreateSuffix(suffix);
|
|
|
|
|
|
|
|
return std::move(suffix);
|
|
|
|
}
|
|
|
|
|
2018-08-16 23:44:37 +03:00
|
|
|
// If the window is 3rd party resource, let's see if first-party storage
|
|
|
|
// access is granted for this image.
|
2021-08-11 13:37:18 +03:00
|
|
|
if (AntiTrackingUtils::IsThirdPartyWindow(aDocument->GetInnerWindow(),
|
|
|
|
nullptr)) {
|
2020-12-16 19:45:18 +03:00
|
|
|
uint32_t rejectedReason = 0;
|
|
|
|
Unused << rejectedReason;
|
|
|
|
return StorageDisabledByAntiTracking(aDocument, aURI, rejectedReason)
|
2019-05-02 15:27:07 +03:00
|
|
|
? aDocument->GetBaseDomain()
|
2020-09-23 18:17:15 +03:00
|
|
|
: ""_ns;
|
2015-10-27 21:12:46 +03:00
|
|
|
}
|
2018-06-20 20:38:22 +03:00
|
|
|
|
2018-07-13 13:02:19 +03:00
|
|
|
// Another scenario is if this image is a 3rd party resource loaded by a
|
|
|
|
// first party context. In this case, we should check if the nsIChannel has
|
|
|
|
// been marked as tracking resource, but we don't have the channel yet at
|
|
|
|
// this point. The best approach here is to be conservative: if we are sure
|
2019-05-02 15:27:07 +03:00
|
|
|
// that the permission is granted, let's return 0. Otherwise, let's make a
|
|
|
|
// unique image cache per the top-level document eTLD+1.
|
2022-06-08 22:07:37 +03:00
|
|
|
if (!ContentBlocking::ApproximateAllowAccessForWithoutChannel(
|
|
|
|
aDocument->GetInnerWindow(), aURI)) {
|
2020-10-22 15:57:11 +03:00
|
|
|
// If we are here, the image is a 3rd-party resource loaded by a first-party
|
|
|
|
// context. We can just use the document's base domain as the key because it
|
|
|
|
// should be the same as the top-level document's base domain.
|
|
|
|
return aDocument
|
|
|
|
->GetBaseDomain(); // because we don't have anything better!
|
2018-06-20 20:38:22 +03:00
|
|
|
}
|
|
|
|
|
2020-09-23 18:17:15 +03:00
|
|
|
return ""_ns;
|
2015-05-20 20:21:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|