diff --git a/dom/credentialmanagement/CredentialsContainer.cpp b/dom/credentialmanagement/CredentialsContainer.cpp index d3b88b20324e..5d0fa5ed29b2 100644 --- a/dom/credentialmanagement/CredentialsContainer.cpp +++ b/dom/credentialmanagement/CredentialsContainer.cpp @@ -14,7 +14,7 @@ #include "mozilla/dom/Promise-inl.h" #include "mozilla/StaticPrefs_dom.h" #include "mozilla/StaticPrefs_security.h" -#include "mozilla/dom/WebAuthnManager.h" +#include "mozilla/dom/WebAuthnHandler.h" #include "mozilla/dom/WindowGlobalChild.h" #include "mozilla/dom/WindowContext.h" #include "nsContentUtils.h" @@ -24,7 +24,8 @@ namespace mozilla::dom { -NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CredentialsContainer, mParent, mManager) +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CredentialsContainer, mParent, + mWebAuthnHandler) NS_IMPL_CYCLE_COLLECTING_ADDREF(CredentialsContainer) NS_IMPL_CYCLE_COLLECTING_RELEASE(CredentialsContainer) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CredentialsContainer) @@ -133,19 +134,19 @@ CredentialsContainer::CredentialsContainer(nsPIDOMWindowInner* aParent) CredentialsContainer::~CredentialsContainer() = default; -void CredentialsContainer::EnsureWebAuthnManager() { +void CredentialsContainer::EnsureWebAuthnHandler() { MOZ_ASSERT(NS_IsMainThread()); - if (!mManager) { - mManager = new WebAuthnManager(mParent); + if (!mWebAuthnHandler) { + mWebAuthnHandler = new WebAuthnHandler(mParent); } } -already_AddRefed CredentialsContainer::GetWebAuthnManager() { +already_AddRefed CredentialsContainer::GetWebAuthnHandler() { MOZ_ASSERT(NS_IsMainThread()); - EnsureWebAuthnManager(); - RefPtr ref = mManager; + EnsureWebAuthnHandler(); + RefPtr ref = mWebAuthnHandler; return ref.forget(); } @@ -191,9 +192,10 @@ already_AddRefed CredentialsContainer::Get( return promise.forget(); } - EnsureWebAuthnManager(); - return mManager->GetAssertion(aOptions.mPublicKey.Value(), - conditionallyMediated, aOptions.mSignal, aRv); + EnsureWebAuthnHandler(); + return mWebAuthnHandler->GetAssertion(aOptions.mPublicKey.Value(), + conditionallyMediated, + aOptions.mSignal, aRv); } if (aOptions.mIdentity.WasPassed() && @@ -265,9 +267,9 @@ already_AddRefed CredentialsContainer::Create( return CreateAndRejectWithNotAllowed(mParent, aRv); } - EnsureWebAuthnManager(); - return mManager->MakeCredential(aOptions.mPublicKey.Value(), - aOptions.mSignal, aRv); + EnsureWebAuthnHandler(); + return mWebAuthnHandler->MakeCredential(aOptions.mPublicKey.Value(), + aOptions.mSignal, aRv); } if (aOptions.mIdentity.WasPassed() && @@ -304,8 +306,8 @@ already_AddRefed CredentialsContainer::Store( return CreateAndRejectWithNotAllowed(mParent, aRv); } - EnsureWebAuthnManager(); - return mManager->Store(aCredential, aRv); + EnsureWebAuthnHandler(); + return mWebAuthnHandler->Store(aCredential, aRv); } if (type.EqualsLiteral("identity") && diff --git a/dom/credentialmanagement/CredentialsContainer.h b/dom/credentialmanagement/CredentialsContainer.h index 1c4c53bd9d01..cdb0e6cc188e 100644 --- a/dom/credentialmanagement/CredentialsContainer.h +++ b/dom/credentialmanagement/CredentialsContainer.h @@ -11,7 +11,7 @@ namespace mozilla::dom { -class WebAuthnManager; +class WebAuthnHandler; class CredentialsContainer final : public nsISupports, public nsWrapperCache { public: @@ -22,7 +22,7 @@ class CredentialsContainer final : public nsISupports, public nsWrapperCache { nsPIDOMWindowInner* GetParentObject() const { return mParent; } - already_AddRefed GetWebAuthnManager(); + already_AddRefed GetWebAuthnHandler(); virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aGivenProto) override; @@ -41,10 +41,10 @@ class CredentialsContainer final : public nsISupports, public nsWrapperCache { private: ~CredentialsContainer(); - void EnsureWebAuthnManager(); + void EnsureWebAuthnHandler(); nsCOMPtr mParent; - RefPtr mManager; + RefPtr mWebAuthnHandler; bool mActiveIdentityRequest; }; diff --git a/dom/webauthn/PublicKeyCredential.cpp b/dom/webauthn/PublicKeyCredential.cpp index 25645f9fec71..f5b6dab89f37 100644 --- a/dom/webauthn/PublicKeyCredential.cpp +++ b/dom/webauthn/PublicKeyCredential.cpp @@ -15,7 +15,7 @@ #include "mozilla/dom/Promise.h" #include "mozilla/dom/PublicKeyCredential.h" #include "mozilla/dom/WebAuthenticationBinding.h" -#include "mozilla/dom/WebAuthnManager.h" +#include "mozilla/dom/WebAuthnHandler.h" #include "nsCycleCollectionParticipant.h" #ifdef MOZ_WIDGET_ANDROID @@ -121,9 +121,9 @@ PublicKeyCredential::IsUserVerifyingPlatformAuthenticatorAvailable( return nullptr; } - RefPtr manager = - window->Navigator()->Credentials()->GetWebAuthnManager(); - return manager->IsUVPAA(aGlobal, aError); + RefPtr handler = + window->Navigator()->Credentials()->GetWebAuthnHandler(); + return handler->IsUVPAA(aGlobal, aError); } /* static */ diff --git a/dom/webauthn/WebAuthnManager.cpp b/dom/webauthn/WebAuthnHandler.cpp similarity index 97% rename from dom/webauthn/WebAuthnManager.cpp rename to dom/webauthn/WebAuthnHandler.cpp index 262437a6f37a..c65b7a1f66c1 100644 --- a/dom/webauthn/WebAuthnManager.cpp +++ b/dom/webauthn/WebAuthnHandler.cpp @@ -19,7 +19,7 @@ #include "mozilla/dom/AuthenticatorAttestationResponse.h" #include "mozilla/dom/PublicKeyCredential.h" #include "mozilla/dom/PWebAuthnTransaction.h" -#include "mozilla/dom/WebAuthnManager.h" +#include "mozilla/dom/WebAuthnHandler.h" #include "mozilla/dom/WebAuthnTransactionChild.h" #include "mozilla/dom/WebAuthnUtil.h" #include "mozilla/dom/WindowGlobalChild.h" @@ -39,17 +39,17 @@ namespace mozilla::dom { **********************************************************************/ namespace { -static mozilla::LazyLogModule gWebAuthnManagerLog("webauthnmanager"); +static mozilla::LazyLogModule gWebAuthnHandlerLog("webauthnhandler"); } -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebAuthnManager) +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebAuthnHandler) NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_END -NS_IMPL_CYCLE_COLLECTION(WebAuthnManager, mWindow, mTransaction) +NS_IMPL_CYCLE_COLLECTION(WebAuthnHandler, mWindow, mTransaction) -NS_IMPL_CYCLE_COLLECTING_ADDREF(WebAuthnManager) -NS_IMPL_CYCLE_COLLECTING_RELEASE(WebAuthnManager) +NS_IMPL_CYCLE_COLLECTING_ADDREF(WebAuthnHandler) +NS_IMPL_CYCLE_COLLECTING_RELEASE(WebAuthnHandler) /*********************************************************************** * Utility Functions @@ -135,7 +135,7 @@ nsresult GetOrigin(nsPIDOMWindowInner* aParent, // 4.1.1.3 If callerOrigin is an opaque origin, reject promise with a // DOMException whose name is "NotAllowedError", and terminate this // algorithm - MOZ_LOG(gWebAuthnManagerLog, LogLevel::Debug, + MOZ_LOG(gWebAuthnHandlerLog, LogLevel::Debug, ("Rejecting due to opaque origin")); return NS_ERROR_DOM_NOT_ALLOWED_ERR; } @@ -200,10 +200,10 @@ nsresult RelaxSameOrigin(nsPIDOMWindowInner* aParent, } /*********************************************************************** - * WebAuthnManager Implementation + * WebAuthnHandler Implementation **********************************************************************/ -WebAuthnManager::~WebAuthnManager() { +WebAuthnHandler::~WebAuthnHandler() { MOZ_ASSERT(NS_IsMainThread()); if (mActor) { if (mTransaction.isSome()) { @@ -213,7 +213,7 @@ WebAuthnManager::~WebAuthnManager() { } } -bool WebAuthnManager::MaybeCreateActor() { +bool WebAuthnHandler::MaybeCreateActor() { MOZ_ASSERT(NS_IsMainThread()); if (mActor) { @@ -229,17 +229,17 @@ bool WebAuthnManager::MaybeCreateActor() { } mActor = actor; - mActor->SetManager(this); + mActor->SetHandler(this); return true; } -void WebAuthnManager::ActorDestroyed() { +void WebAuthnHandler::ActorDestroyed() { MOZ_ASSERT(NS_IsMainThread()); mActor = nullptr; } -already_AddRefed WebAuthnManager::MakeCredential( +already_AddRefed WebAuthnHandler::MakeCredential( const PublicKeyCredentialCreationOptions& aOptions, const Optional>& aSignal, ErrorResult& aError) { MOZ_ASSERT(NS_IsMainThread()); @@ -545,7 +545,7 @@ already_AddRefed WebAuthnManager::MakeCredential( const size_t MAX_ALLOWED_CREDENTIALS = 20; -already_AddRefed WebAuthnManager::GetAssertion( +already_AddRefed WebAuthnHandler::GetAssertion( const PublicKeyCredentialRequestOptions& aOptions, const bool aConditionallyMediated, const Optional>& aSignal, ErrorResult& aError) { @@ -803,7 +803,7 @@ already_AddRefed WebAuthnManager::GetAssertion( return promise.forget(); } -already_AddRefed WebAuthnManager::Store(const Credential& aCredential, +already_AddRefed WebAuthnHandler::Store(const Credential& aCredential, ErrorResult& aError) { MOZ_ASSERT(NS_IsMainThread()); @@ -823,7 +823,7 @@ already_AddRefed WebAuthnManager::Store(const Credential& aCredential, return promise.forget(); } -already_AddRefed WebAuthnManager::IsUVPAA(GlobalObject& aGlobal, +already_AddRefed WebAuthnHandler::IsUVPAA(GlobalObject& aGlobal, ErrorResult& aError) { RefPtr promise = Promise::Create(xpc::CurrentNativeGlobal(aGlobal.Context()), aError); @@ -849,7 +849,7 @@ already_AddRefed WebAuthnManager::IsUVPAA(GlobalObject& aGlobal, return promise.forget(); } -void WebAuthnManager::FinishMakeCredential( +void WebAuthnHandler::FinishMakeCredential( const WebAuthnMakeCredentialResult& aResult) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(mTransaction.isSome()); @@ -928,7 +928,7 @@ void WebAuthnManager::FinishMakeCredential( ResolveTransaction(credential); } -void WebAuthnManager::FinishGetAssertion( +void WebAuthnHandler::FinishGetAssertion( const WebAuthnGetAssertionResult& aResult) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(mTransaction.isSome()); @@ -1003,7 +1003,7 @@ void WebAuthnManager::FinishGetAssertion( ResolveTransaction(credential); } -void WebAuthnManager::RunAbortAlgorithm() { +void WebAuthnHandler::RunAbortAlgorithm() { if (NS_WARN_IF(mTransaction.isNothing())) { return; } @@ -1021,7 +1021,7 @@ void WebAuthnManager::RunAbortAlgorithm() { CancelTransaction(reason); } -void WebAuthnManager::ResolveTransaction( +void WebAuthnHandler::ResolveTransaction( const RefPtr& aCredential) { MOZ_ASSERT(mTransaction.isSome()); @@ -1040,7 +1040,7 @@ void WebAuthnManager::ResolveTransaction( } template -void WebAuthnManager::RejectTransaction(const T& aReason) { +void WebAuthnHandler::RejectTransaction(const T& aReason) { MOZ_ASSERT(mTransaction.isSome()); switch (mTransaction.ref().mType) { diff --git a/dom/webauthn/WebAuthnManager.h b/dom/webauthn/WebAuthnHandler.h similarity index 82% rename from dom/webauthn/WebAuthnManager.h rename to dom/webauthn/WebAuthnHandler.h index e46b7cde199d..720db30ef827 100644 --- a/dom/webauthn/WebAuthnManager.h +++ b/dom/webauthn/WebAuthnHandler.h @@ -4,8 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef mozilla_dom_WebAuthnManager_h -#define mozilla_dom_WebAuthnManager_h +#ifndef mozilla_dom_WebAuthnHandler_h +#define mozilla_dom_WebAuthnHandler_h #include "mozilla/Maybe.h" #include "mozilla/MozPromise.h" @@ -17,15 +17,15 @@ #include "mozilla/dom/WebAuthnTransactionChild.h" /* - * Content process manager for the WebAuthn protocol. Created on calls to the - * WebAuthentication DOM object, this manager handles establishing IPC channels - * for WebAuthn transactions, as well as keeping track of JS Promise objects - * representing transactions in flight. + * Content process handler for the WebAuthn protocol. Created on calls to the + * WebAuthentication DOM object, this is responsible for establishing IPC + * channels for WebAuthn transactions as well as keeping track of JS Promise + * objects representing transactions in flight. * * The WebAuthn spec (https://www.w3.org/TR/webauthn/) allows for two different * types of transactions: registration and signing. When either of these is * requested via the DOM API, the following steps are executed in the - * WebAuthnManager: + * WebAuthnHandler: * * - Validation of the request. Return a failed promise to js if request does * not have correct parameters. @@ -34,15 +34,12 @@ * another transaction is already running in this content process, cancel it. * Return a pending promise to js. * - * - Send transaction information to parent process (by running the Start* - * functions of WebAuthnManager). Assuming another transaction is currently in - * flight in another content process, parent will handle canceling it. + * - Send transaction information to parent process. * * - On return of successful transaction information from parent process, turn * information into DOM object format required by spec, and resolve promise - * (by running the Finish* functions of WebAuthnManager). On cancellation - * request from parent, reject promise with corresponding error code. Either - * outcome will also close the IPC channel. + * (by running the Finish* functions of WebAuthnHandler). On cancellation + * request from parent, reject promise with corresponding error code. * */ @@ -68,7 +65,7 @@ class WebAuthnTransaction { // These holders are used to track the transaction once it has been dispatched // to the parent process. Once ->Track()'d, they must either be disconnected - // (through a call to WebAuthnManager::CancelTransaction) or completed + // (through a call to WebAuthnHandler::CancelTransaction) or completed // (through a response on the IPC channel) before this WebAuthnTransaction is // destroyed. MozPromiseRequestHolder @@ -77,12 +74,12 @@ class WebAuthnTransaction { mSignHolder; }; -class WebAuthnManager final : public AbortFollower { +class WebAuthnHandler final : public AbortFollower { public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS(WebAuthnManager) + NS_DECL_CYCLE_COLLECTION_CLASS(WebAuthnHandler) - explicit WebAuthnManager(nsPIDOMWindowInner* aWindow) : mWindow(aWindow) { + explicit WebAuthnHandler(nsPIDOMWindowInner* aWindow) : mWindow(aWindow) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aWindow); } @@ -107,7 +104,7 @@ class WebAuthnManager final : public AbortFollower { void RunAbortAlgorithm() override; private: - virtual ~WebAuthnManager(); + virtual ~WebAuthnHandler(); bool MaybeCreateActor(); @@ -159,4 +156,4 @@ inline void ImplCycleCollectionUnlink(WebAuthnTransaction& aTransaction) { } // namespace mozilla::dom -#endif // mozilla_dom_WebAuthnManager_h +#endif // mozilla_dom_WebAuthnHandler_h diff --git a/dom/webauthn/WebAuthnTransactionChild.cpp b/dom/webauthn/WebAuthnTransactionChild.cpp index 0d66ef6e8d6e..7f0d14ff5ecc 100644 --- a/dom/webauthn/WebAuthnTransactionChild.cpp +++ b/dom/webauthn/WebAuthnTransactionChild.cpp @@ -4,21 +4,21 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "mozilla/dom/WebAuthnManager.h" +#include "mozilla/dom/WebAuthnHandler.h" #include "mozilla/dom/WebAuthnTransactionChild.h" namespace mozilla::dom { -void WebAuthnTransactionChild::SetManager(WebAuthnManager* aManager) { - mManager = aManager; +void WebAuthnTransactionChild::SetHandler(WebAuthnHandler* aHandler) { + mHandler = aHandler; } void WebAuthnTransactionChild::ActorDestroy(ActorDestroyReason why) { // Called by either a __delete__ message from the parent, or when the // channel disconnects. Clear out the child actor reference to be sure. - if (mManager) { - mManager->ActorDestroyed(); - mManager = nullptr; + if (mHandler) { + mHandler->ActorDestroyed(); + mHandler = nullptr; } } diff --git a/dom/webauthn/WebAuthnTransactionChild.h b/dom/webauthn/WebAuthnTransactionChild.h index f38c449a98b8..4d0463e89b39 100644 --- a/dom/webauthn/WebAuthnTransactionChild.h +++ b/dom/webauthn/WebAuthnTransactionChild.h @@ -12,13 +12,13 @@ /* * Child process IPC implementation for WebAuthn API. Receives results of * WebAuthn transactions from the parent process, and sends them to the - * WebAuthnManager either cancel the transaction, or be formatted and relayed to + * WebAuthnHandler either cancel the transaction, or be formatted and relayed to * content. */ namespace mozilla::dom { -class WebAuthnManager; +class WebAuthnHandler; class WebAuthnTransactionChild final : public PWebAuthnTransactionChild { public: @@ -28,13 +28,12 @@ class WebAuthnTransactionChild final : public PWebAuthnTransactionChild { void ActorDestroy(ActorDestroyReason why) override; - void SetManager(WebAuthnManager* aMananger); + void SetHandler(WebAuthnHandler* aMananger); private: ~WebAuthnTransactionChild() = default; - // Nulled by ~WebAuthnManager() when disconnecting. - WebAuthnManager* mManager; + WebAuthnHandler* mHandler; }; } // namespace mozilla::dom diff --git a/dom/webauthn/WebAuthnUtil.h b/dom/webauthn/WebAuthnUtil.h index 4c5841b34751..6394a4e03381 100644 --- a/dom/webauthn/WebAuthnUtil.h +++ b/dom/webauthn/WebAuthnUtil.h @@ -7,10 +7,6 @@ #ifndef mozilla_dom_WebAuthnUtil_h #define mozilla_dom_WebAuthnUtil_h -/* - * Utility functions used by both WebAuthnManager and U2FTokenManager. - */ - #include "mozilla/dom/WebAuthenticationBinding.h" #include "ipc/IPCMessageUtils.h" diff --git a/dom/webauthn/WinWebAuthnService.cpp b/dom/webauthn/WinWebAuthnService.cpp index 56dfa8c19a38..a516dbee888b 100644 --- a/dom/webauthn/WinWebAuthnService.cpp +++ b/dom/webauthn/WinWebAuthnService.cpp @@ -406,7 +406,7 @@ WinWebAuthnService::MakeCredential(uint64_t aTransactionId, winRequireResidentKey = FALSE; winPreferResidentKey = FALSE; } else { - // WebAuthnManager::MakeCredential is supposed to assign one of the + // WebAuthnHandler::MakeCredential is supposed to assign one of the // above values, so this shouldn't happen. MOZ_ASSERT_UNREACHABLE(); aPromise->Reject(NS_ERROR_DOM_UNKNOWN_ERR); diff --git a/dom/webauthn/moz.build b/dom/webauthn/moz.build index 7b1b54a55216..b83f5444f8de 100644 --- a/dom/webauthn/moz.build +++ b/dom/webauthn/moz.build @@ -28,7 +28,7 @@ EXPORTS.mozilla.dom += [ "AuthenticatorAttestationResponse.h", "AuthenticatorResponse.h", "PublicKeyCredential.h", - "WebAuthnManager.h", + "WebAuthnHandler.h", "WebAuthnPromiseHolder.h", "WebAuthnTransactionChild.h", "WebAuthnTransactionParent.h", @@ -43,7 +43,7 @@ UNIFIED_SOURCES += [ "PublicKeyCredential.cpp", "WebAuthnArgs.cpp", "WebAuthnAutoFillEntry.cpp", - "WebAuthnManager.cpp", + "WebAuthnHandler.cpp", "WebAuthnPromiseHolder.cpp", "WebAuthnResult.cpp", "WebAuthnService.cpp",