1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef StorageAccessPermissionRequest_h_
8 #define StorageAccessPermissionRequest_h_
10 #include "nsContentPermissionHelper.h"
11 #include "mozilla/MozPromise.h"
15 class nsPIDOMWindowInner
;
20 class StorageAccessPermissionRequest final
21 : public ContentPermissionRequestBase
{
23 NS_DECL_ISUPPORTS_INHERITED
24 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(StorageAccessPermissionRequest
,
25 ContentPermissionRequestBase
)
27 // nsIContentPermissionRequest
28 NS_IMETHOD
Cancel(void) override
;
29 NS_IMETHOD
Allow(JS::HandleValue choices
) override
;
31 using AllowCallback
= std::function
<void()>;
32 using CancelCallback
= std::function
<void()>;
34 static already_AddRefed
<StorageAccessPermissionRequest
> Create(
35 nsPIDOMWindowInner
* aWindow
, AllowCallback
&& aAllowCallback
,
36 CancelCallback
&& aCancelCallback
);
38 static already_AddRefed
<StorageAccessPermissionRequest
> Create(
39 nsPIDOMWindowInner
* aWindow
, nsIPrincipal
* aPrincipal
,
40 AllowCallback
&& aAllowCallback
, CancelCallback
&& aCancelCallback
);
42 using AutoGrantDelayPromise
= MozPromise
<bool, bool, true>;
43 RefPtr
<AutoGrantDelayPromise
> MaybeDelayAutomaticGrants();
46 StorageAccessPermissionRequest(nsPIDOMWindowInner
* aWindow
,
47 nsIPrincipal
* aNodePrincipal
,
48 AllowCallback
&& aAllowCallback
,
49 CancelCallback
&& aCancelCallback
);
50 ~StorageAccessPermissionRequest() = default;
52 unsigned CalculateSimulatedDelay();
54 AllowCallback mAllowCallback
;
55 CancelCallback mCancelCallback
;
56 nsTArray
<PermissionRequest
> mPermissionRequests
;
61 } // namespace mozilla
63 #endif // StorageAccessPermissionRequest_h_