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 using AutoGrantDelayPromise
= MozPromise
<bool, bool, true>;
39 RefPtr
<AutoGrantDelayPromise
> MaybeDelayAutomaticGrants();
42 StorageAccessPermissionRequest(nsPIDOMWindowInner
* aWindow
,
43 nsIPrincipal
* aNodePrincipal
,
44 AllowCallback
&& aAllowCallback
,
45 CancelCallback
&& aCancelCallback
);
46 ~StorageAccessPermissionRequest() = default;
48 unsigned CalculateSimulatedDelay();
50 AllowCallback mAllowCallback
;
51 CancelCallback mCancelCallback
;
52 nsTArray
<PermissionRequest
> mPermissionRequests
;
57 } // namespace mozilla
59 #endif // StorageAccessPermissionRequest_h_