forked from mirrors/gecko-dev
Bug 1858494 - Return permission action rather than boolean when fetching the storage access permission from the parent process - r=timhuang,anti-tracking-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D190722
This commit is contained in:
parent
d9dc6c946f
commit
094d813e4c
7 changed files with 30 additions and 24 deletions
|
|
@ -17372,22 +17372,26 @@ Document::CreatePermissionGrantPromise(
|
|||
p = new StorageAccessAPIHelper::StorageAccessPermissionGrantPromise::
|
||||
Private(__func__);
|
||||
|
||||
RefPtr<PWindowGlobalChild::HasStorageAccessPermissionPromise> promise;
|
||||
RefPtr<PWindowGlobalChild::GetStorageAccessPermissionPromise> promise;
|
||||
// Test the permission
|
||||
MOZ_ASSERT(XRE_IsContentProcess());
|
||||
|
||||
WindowGlobalChild* wgc = inner->GetWindowGlobalChild();
|
||||
MOZ_ASSERT(wgc);
|
||||
|
||||
promise = wgc->SendHasStorageAccessPermission();
|
||||
promise = wgc->SendGetStorageAccessPermission();
|
||||
MOZ_ASSERT(promise);
|
||||
promise->Then(
|
||||
GetCurrentSerialEventTarget(), __func__,
|
||||
[self, p, inner, principal, aHasUserInteraction,
|
||||
aRequireUserInteraction, aTopLevelBaseDomain,
|
||||
aFrameOnly](bool aGranted) {
|
||||
if (aGranted) {
|
||||
p->Resolve(true, __func__);
|
||||
aFrameOnly](uint32_t aAction) {
|
||||
if (aAction == nsIPermissionManager::ALLOW_ACTION) {
|
||||
p->Resolve(StorageAccessAPIHelper::eAllow, __func__);
|
||||
return;
|
||||
}
|
||||
if (aAction == nsIPermissionManager::DENY_ACTION) {
|
||||
p->Reject(false, __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ parent:
|
|||
async DiscoverIdentityCredentialFromExternalSource(IdentityCredentialRequestOptions aOptions)
|
||||
returns (IPCIdentityCredential? identityCredential);
|
||||
|
||||
async HasStorageAccessPermission() returns(bool granted);
|
||||
async GetStorageAccessPermission() returns(uint32_t permission_action);
|
||||
|
||||
|
||||
async SetCookies(nsCString baseDomain,
|
||||
|
|
|
|||
|
|
@ -1396,21 +1396,21 @@ IPCResult WindowGlobalParent::RecvDiscoverIdentityCredentialFromExternalSource(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
IPCResult WindowGlobalParent::RecvHasStorageAccessPermission(
|
||||
HasStorageAccessPermissionResolver&& aResolve) {
|
||||
IPCResult WindowGlobalParent::RecvGetStorageAccessPermission(
|
||||
GetStorageAccessPermissionResolver&& aResolve) {
|
||||
WindowGlobalParent* top = TopWindowContext();
|
||||
if (!top) {
|
||||
return IPC_FAIL_NO_REASON(this);
|
||||
}
|
||||
nsIPrincipal* topPrincipal = top->DocumentPrincipal();
|
||||
nsIPrincipal* principal = DocumentPrincipal();
|
||||
bool result;
|
||||
uint32_t result;
|
||||
nsresult rv = AntiTrackingUtils::TestStoragePermissionInParent(
|
||||
topPrincipal, principal, &result);
|
||||
NS_ENSURE_SUCCESS(
|
||||
rv, IPC_FAIL(
|
||||
this,
|
||||
"Storage Access Permission: Failed to test storage permission."));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aResolve(nsIPermissionManager::UNKNOWN_ACTION);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
aResolve(result);
|
||||
return IPC_OK();
|
||||
|
|
|
|||
|
|
@ -310,8 +310,8 @@ class WindowGlobalParent final : public WindowContext,
|
|||
const IdentityCredentialRequestOptions& aOptions,
|
||||
const DiscoverIdentityCredentialFromExternalSourceResolver& aResolver);
|
||||
|
||||
mozilla::ipc::IPCResult RecvHasStorageAccessPermission(
|
||||
HasStorageAccessPermissionResolver&& aResolve);
|
||||
mozilla::ipc::IPCResult RecvGetStorageAccessPermission(
|
||||
GetStorageAccessPermissionResolver&& aResolve);
|
||||
|
||||
mozilla::ipc::IPCResult RecvSetCookies(
|
||||
const nsCString& aBaseDomain, const OriginAttributes& aOriginAttributes,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "mozilla/dom/FeaturePolicyUtils.h"
|
||||
#include "mozilla/dom/PermissionStatus.h"
|
||||
#include "mozilla/dom/PermissionStatusBinding.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
|
|
@ -57,12 +58,13 @@ StorageAccessPermissionStatus::UpdateState() {
|
|||
}
|
||||
|
||||
RefPtr<StorageAccessPermissionStatus> self(this);
|
||||
return wgc->SendHasStorageAccessPermission()->Then(
|
||||
return wgc->SendGetStorageAccessPermission()->Then(
|
||||
GetMainThreadSerialEventTarget(), __func__,
|
||||
[self](bool aGranted) {
|
||||
if (aGranted) {
|
||||
[self](uint32_t aAction) {
|
||||
if (aAction == nsIPermissionManager::ALLOW_ACTION) {
|
||||
self->mState = PermissionState::Granted;
|
||||
} else {
|
||||
// We never reveal PermissionState::Denied here
|
||||
self->mState = PermissionState::Prompt;
|
||||
}
|
||||
return SimplePromise::CreateAndResolve(NS_OK, __func__);
|
||||
|
|
|
|||
|
|
@ -386,9 +386,9 @@ bool AntiTrackingUtils::CheckStoragePermission(nsIPrincipal* aPrincipal,
|
|||
|
||||
/* static */
|
||||
nsresult AntiTrackingUtils::TestStoragePermissionInParent(
|
||||
nsIPrincipal* aTopPrincipal, nsIPrincipal* aPrincipal, bool* aResult) {
|
||||
nsIPrincipal* aTopPrincipal, nsIPrincipal* aPrincipal, uint32_t* aResult) {
|
||||
NS_ENSURE_ARG(aResult);
|
||||
*aResult = false;
|
||||
*aResult = nsIPermissionManager::UNKNOWN_ACTION;
|
||||
NS_ENSURE_ARG(aTopPrincipal);
|
||||
NS_ENSURE_ARG(aPrincipal);
|
||||
|
||||
|
|
@ -413,8 +413,8 @@ nsresult AntiTrackingUtils::TestStoragePermissionInParent(
|
|||
aTopPrincipal, requestPermissionKey, &access);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (access == nsIPermissionManager::ALLOW_ACTION) {
|
||||
*aResult = true;
|
||||
if (access != nsIPermissionManager::UNKNOWN_ACTION) {
|
||||
*aResult = access;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
@ -423,7 +423,7 @@ nsresult AntiTrackingUtils::TestStoragePermissionInParent(
|
|||
aTopPrincipal, requestFramePermissionKey, &frameAccess);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aResult = frameAccess == nsIPermissionManager::ALLOW_ACTION;
|
||||
*aResult = frameAccess;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class AntiTrackingUtils final {
|
|||
// with secondary key for embedee aPrincipal.
|
||||
static nsresult TestStoragePermissionInParent(nsIPrincipal* aTopPrincipal,
|
||||
nsIPrincipal* aPrincipal,
|
||||
bool* aResult);
|
||||
uint32_t* aResult);
|
||||
|
||||
// Returns the storage permission state for the given channel. And this is
|
||||
// meant to be called in the parent process. This only reflects the fact that
|
||||
|
|
|
|||
Loading…
Reference in a new issue