Bug 1750871 - run mochitest-remote on fission everywhere. r=releng-reviewers,aki
[gecko.git] / dom / base / StorageAccessPermissionRequest.h
blob73fc69ff42315f5adce1d66fe905f8bf77be93d9
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"
13 #include <functional>
15 class nsPIDOMWindowInner;
17 namespace mozilla {
18 namespace dom {
20 class StorageAccessPermissionRequest final
21 : public ContentPermissionRequestBase {
22 public:
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();
45 private:
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;
57 bool mCallbackCalled;
60 } // namespace dom
61 } // namespace mozilla
63 #endif // StorageAccessPermissionRequest_h_