Source code

Revision control

Other Tools

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/. */
6
7
#ifndef mozilla_dom_WebAuthnManagerBase_h
8
#define mozilla_dom_WebAuthnManagerBase_h
9
10
#include "nsIDOMEventListener.h"
11
12
/*
13
* A base class used by WebAuthn and U2F implementations, providing shared
14
* functionality and requiring an interface used by the IPC child actors.
15
*/
16
17
namespace mozilla {
18
namespace dom {
19
20
class WebAuthnTransactionChild;
21
class WebAuthnMakeCredentialResult;
22
class WebAuthnGetAssertionResult;
23
24
class WebAuthnManagerBase : public nsIDOMEventListener {
25
public:
26
NS_DECL_NSIDOMEVENTLISTENER
27
28
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
29
NS_DECL_CYCLE_COLLECTION_CLASS(WebAuthnManagerBase)
30
31
explicit WebAuthnManagerBase(nsPIDOMWindowInner* aParent);
32
33
MOZ_CAN_RUN_SCRIPT
34
virtual void FinishMakeCredential(
35
const uint64_t& aTransactionId,
36
const WebAuthnMakeCredentialResult& aResult) = 0;
37
38
MOZ_CAN_RUN_SCRIPT
39
virtual void FinishGetAssertion(
40
const uint64_t& aTransactionId,
41
const WebAuthnGetAssertionResult& aResult) = 0;
42
43
MOZ_CAN_RUN_SCRIPT
44
virtual void RequestAborted(const uint64_t& aTransactionId,
45
const nsresult& aError) = 0;
46
47
void ActorDestroyed();
48
49
protected:
50
MOZ_CAN_RUN_SCRIPT virtual ~WebAuthnManagerBase();
51
52
// Needed by HandleEvent() to track visibilty changes.
53
MOZ_CAN_RUN_SCRIPT virtual void HandleVisibilityChange() = 0;
54
55
// Visibility event handling.
56
void ListenForVisibilityEvents();
57
void StopListeningForVisibilityEvents();
58
59
bool MaybeCreateBackgroundActor();
60
61
// The parent window.
62
nsCOMPtr<nsPIDOMWindowInner> mParent;
63
64
// IPC Channel to the parent process.
65
RefPtr<WebAuthnTransactionChild> mChild;
66
};
67
68
} // namespace dom
69
} // namespace mozilla
70
71
#endif // mozilla_dom_WebAuthnManagerBase_h