зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1724376 - Part 6: Implement StorageAccess::AsyncStorageDisabledByAntiTracking(). r=dimi,pbz
Differential Revision: https://phabricator.services.mozilla.com/D123808
This commit is contained in:
Родитель
0bfb4abf4a
Коммит
674bf908ac
|
@ -382,6 +382,27 @@ bool StorageDisabledByAntiTracking(dom::Document* aDocument, nsIURI* aURI,
|
|||
aDocument->NodePrincipal(), aURI, aRejectedReason);
|
||||
}
|
||||
|
||||
RefPtr<AsyncStorageDisabledByAntiTrackingPromise>
|
||||
AsyncStorageDisabledByAntiTracking(dom::BrowsingContext* aContext,
|
||||
nsIPrincipal* aPrincipal) {
|
||||
MOZ_ASSERT(aContext);
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
|
||||
return ContentBlocking::AsyncShouldAllowAccessFor(aContext, aPrincipal)
|
||||
->Then(
|
||||
GetCurrentSerialEventTarget(), __func__,
|
||||
[](const ContentBlocking::AsyncShouldAllowAccessForPromise::
|
||||
ResolveOrRejectValue&& aValue) {
|
||||
if (aValue.IsResolve()) {
|
||||
return AsyncStorageDisabledByAntiTrackingPromise::CreateAndReject(
|
||||
aValue.ResolveValue(), __func__);
|
||||
}
|
||||
|
||||
return AsyncStorageDisabledByAntiTrackingPromise::CreateAndResolve(
|
||||
aValue.RejectValue(), __func__);
|
||||
});
|
||||
}
|
||||
|
||||
bool ShouldPartitionStorage(StorageAccess aAccess) {
|
||||
return aAccess == StorageAccess::ePartitionTrackersOrDeny ||
|
||||
aAccess == StorageAccess::ePartitionForeignOrDeny;
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
#include "mozilla/dom/BrowsingContext.h"
|
||||
|
||||
class nsIChannel;
|
||||
class nsICookieJarSettings;
|
||||
class nsIPrincipal;
|
||||
|
@ -105,6 +110,17 @@ bool StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
|
|||
bool StorageDisabledByAntiTracking(dom::Document* aDocument, nsIURI* aURI,
|
||||
uint32_t& aRejectedReason);
|
||||
|
||||
/*
|
||||
* Returns true if the principal in the browsing context should disable storages
|
||||
* because of the anti-tracking feature. Note that this has to be async because
|
||||
* the aPrincipal is a cross-origin principal.
|
||||
*/
|
||||
using AsyncStorageDisabledByAntiTrackingPromise =
|
||||
MozPromise<uint32_t, nsresult, true>;
|
||||
[[nodiscard]] RefPtr<AsyncStorageDisabledByAntiTrackingPromise>
|
||||
AsyncStorageDisabledByAntiTracking(dom::BrowsingContext* aContext,
|
||||
nsIPrincipal* aPrincipal);
|
||||
|
||||
bool ShouldPartitionStorage(StorageAccess aAccess);
|
||||
|
||||
bool ShouldPartitionStorage(uint32_t aRejectedReason);
|
||||
|
|
Загрузка…
Ссылка в новой задаче