Bug 1863873 - Block ability to perform audio decoding outside of Utility on release...
[gecko.git] / dom / webauthn / WebAuthnService.h
blob4a9d91d3c1082ab512287befb40ae5d84fa8e42d
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_dom_WebAuthnService_h_
6 #define mozilla_dom_WebAuthnService_h_
8 #include "nsIWebAuthnService.h"
9 #include "AuthrsBridge_ffi.h"
11 #ifdef MOZ_WIDGET_ANDROID
12 # include "AndroidWebAuthnService.h"
13 #endif
15 #ifdef XP_MACOSX
16 # include "MacOSWebAuthnService.h"
17 #endif
19 #ifdef XP_WIN
20 # include "WinWebAuthnService.h"
21 #endif
23 namespace mozilla::dom {
25 already_AddRefed<nsIWebAuthnService> NewWebAuthnService();
27 class WebAuthnService final : public nsIWebAuthnService {
28 public:
29 NS_DECL_THREADSAFE_ISUPPORTS
30 NS_DECL_NSIWEBAUTHNSERVICE
32 WebAuthnService() {
33 Unused << authrs_service_constructor(getter_AddRefs(mAuthrsService));
34 #if defined(XP_WIN)
35 if (WinWebAuthnService::AreWebAuthNApisAvailable()) {
36 mPlatformService = new WinWebAuthnService();
37 } else {
38 mPlatformService = mAuthrsService;
40 #elif defined(MOZ_WIDGET_ANDROID)
41 mPlatformService = new AndroidWebAuthnService();
42 #elif defined(XP_MACOSX)
43 if (__builtin_available(macos 13.3, *)) {
44 mPlatformService = NewMacOSWebAuthnServiceIfAvailable();
46 if (!mPlatformService) {
47 mPlatformService = mAuthrsService;
49 #else
50 mPlatformService = mAuthrsService;
51 #endif
54 private:
55 ~WebAuthnService() = default;
57 nsIWebAuthnService* DefaultService() {
58 if (StaticPrefs::security_webauth_webauthn_enable_softtoken()) {
59 return mAuthrsService;
61 return mPlatformService;
64 nsIWebAuthnService* AuthrsService() { return mAuthrsService; }
66 nsCOMPtr<nsIWebAuthnService> mAuthrsService;
67 nsCOMPtr<nsIWebAuthnService> mPlatformService;
70 } // namespace mozilla::dom
72 #endif // mozilla_dom_WebAuthnService_h_