1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 mozilla_dom_WebAuthnManagerBase_h
8 #define mozilla_dom_WebAuthnManagerBase_h
10 #include "nsIDOMEventListener.h"
11 #include "nsCycleCollectionParticipant.h"
15 * A base class used by WebAuthn and U2F implementations, providing shared
16 * functionality and requiring an interface used by the IPC child actors.
19 class nsPIDOMWindowInner
;
21 namespace mozilla::dom
{
23 class WebAuthnTransactionChild
;
24 class WebAuthnMakeCredentialResult
;
25 class WebAuthnGetAssertionResult
;
27 class WebAuthnManagerBase
: public nsIDOMEventListener
{
29 NS_DECL_NSIDOMEVENTLISTENER
31 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
32 NS_DECL_CYCLE_COLLECTION_CLASS(WebAuthnManagerBase
)
34 explicit WebAuthnManagerBase(nsPIDOMWindowInner
* aParent
);
37 virtual void FinishMakeCredential(
38 const uint64_t& aTransactionId
,
39 const WebAuthnMakeCredentialResult
& aResult
) = 0;
42 virtual void FinishGetAssertion(
43 const uint64_t& aTransactionId
,
44 const WebAuthnGetAssertionResult
& aResult
) = 0;
47 virtual void RequestAborted(const uint64_t& aTransactionId
,
48 const nsresult
& aError
) = 0;
50 void ActorDestroyed();
53 MOZ_CAN_RUN_SCRIPT
virtual ~WebAuthnManagerBase();
55 // Needed by HandleEvent() to track visibilty changes.
56 MOZ_CAN_RUN_SCRIPT
virtual void HandleVisibilityChange() = 0;
58 // Visibility event handling.
59 void ListenForVisibilityEvents();
60 void StopListeningForVisibilityEvents();
62 bool MaybeCreateBackgroundActor();
65 nsCOMPtr
<nsPIDOMWindowInner
> mParent
;
67 // IPC Channel to the parent process.
68 RefPtr
<WebAuthnTransactionChild
> mChild
;
71 } // namespace mozilla::dom
73 #endif // mozilla_dom_WebAuthnManagerBase_h