Bug 1945969 - part 4: simplify android implementation of RecvIsUVPAA. r=keeler
Differential Revision: https://phabricator.services.mozilla.com/D236884
This commit is contained in:
@@ -42,6 +42,8 @@ void WebAuthnTransactionParent::DisconnectTransaction() {
|
|||||||
mozilla::ipc::IPCResult WebAuthnTransactionParent::RecvRequestRegister(
|
mozilla::ipc::IPCResult WebAuthnTransactionParent::RecvRequestRegister(
|
||||||
const WebAuthnMakeCredentialInfo& aTransactionInfo,
|
const WebAuthnMakeCredentialInfo& aTransactionInfo,
|
||||||
RequestRegisterResolver&& aResolver) {
|
RequestRegisterResolver&& aResolver) {
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
if (!mWebAuthnService) {
|
if (!mWebAuthnService) {
|
||||||
mWebAuthnService = do_GetService("@mozilla.org/webauthn/service;1");
|
mWebAuthnService = do_GetService("@mozilla.org/webauthn/service;1");
|
||||||
if (!mWebAuthnService) {
|
if (!mWebAuthnService) {
|
||||||
@@ -202,6 +204,8 @@ mozilla::ipc::IPCResult WebAuthnTransactionParent::RecvRequestRegister(
|
|||||||
mozilla::ipc::IPCResult WebAuthnTransactionParent::RecvRequestSign(
|
mozilla::ipc::IPCResult WebAuthnTransactionParent::RecvRequestSign(
|
||||||
const WebAuthnGetAssertionInfo& aTransactionInfo,
|
const WebAuthnGetAssertionInfo& aTransactionInfo,
|
||||||
RequestSignResolver&& aResolver) {
|
RequestSignResolver&& aResolver) {
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
if (!mWebAuthnService) {
|
if (!mWebAuthnService) {
|
||||||
mWebAuthnService = do_GetService("@mozilla.org/webauthn/service;1");
|
mWebAuthnService = do_GetService("@mozilla.org/webauthn/service;1");
|
||||||
if (!mWebAuthnService) {
|
if (!mWebAuthnService) {
|
||||||
@@ -344,6 +348,8 @@ mozilla::ipc::IPCResult WebAuthnTransactionParent::RecvRequestSign(
|
|||||||
}
|
}
|
||||||
|
|
||||||
mozilla::ipc::IPCResult WebAuthnTransactionParent::RecvRequestCancel() {
|
mozilla::ipc::IPCResult WebAuthnTransactionParent::RecvRequestCancel() {
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
if (mTransactionId.isNothing()) {
|
if (mTransactionId.isNothing()) {
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
@@ -354,6 +360,8 @@ mozilla::ipc::IPCResult WebAuthnTransactionParent::RecvRequestCancel() {
|
|||||||
|
|
||||||
mozilla::ipc::IPCResult WebAuthnTransactionParent::RecvRequestIsUVPAA(
|
mozilla::ipc::IPCResult WebAuthnTransactionParent::RecvRequestIsUVPAA(
|
||||||
RequestIsUVPAAResolver&& aResolver) {
|
RequestIsUVPAAResolver&& aResolver) {
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
// Try the nsIWebAuthnService. If we're configured for tests we
|
// Try the nsIWebAuthnService. If we're configured for tests we
|
||||||
// will get a result. Otherwise we expect NS_ERROR_NOT_IMPLEMENTED.
|
// will get a result. Otherwise we expect NS_ERROR_NOT_IMPLEMENTED.
|
||||||
@@ -374,23 +382,16 @@ mozilla::ipc::IPCResult WebAuthnTransactionParent::RecvRequestIsUVPAA(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The GeckoView implementation of
|
// The GeckoView implementation of
|
||||||
// isUserVerifiyingPlatformAuthenticatorAvailable does not block, but we must
|
// isUserVerifiyingPlatformAuthenticatorAvailable dispatches the work to a
|
||||||
// call it on the main thread. It returns a MozPromise which we can ->Then to
|
// background thread and returns a MozPromise which we can ->Then to call
|
||||||
// call aResolver on the IPDL background thread.
|
// aResolver on the current thread.
|
||||||
//
|
|
||||||
// Bug 1550788: there is an unnecessary layer of dispatching here: ipdl ->
|
|
||||||
// main -> a background thread. Other platforms just do ipdl -> a background
|
|
||||||
// thread.
|
|
||||||
nsCOMPtr<nsISerialEventTarget> target = GetCurrentSerialEventTarget();
|
nsCOMPtr<nsISerialEventTarget> target = GetCurrentSerialEventTarget();
|
||||||
nsCOMPtr<nsIRunnable> runnable(NS_NewRunnableFunction(
|
|
||||||
__func__, [target, resolver = std::move(aResolver)]() {
|
|
||||||
auto result = java::WebAuthnTokenManager::
|
auto result = java::WebAuthnTokenManager::
|
||||||
WebAuthnIsUserVerifyingPlatformAuthenticatorAvailable();
|
WebAuthnIsUserVerifyingPlatformAuthenticatorAvailable();
|
||||||
auto geckoResult = java::GeckoResult::LocalRef(std::move(result));
|
auto geckoResult = java::GeckoResult::LocalRef(std::move(result));
|
||||||
MozPromise<bool, bool, false>::FromGeckoResult(geckoResult)
|
MozPromise<bool, bool, false>::FromGeckoResult(geckoResult)
|
||||||
->Then(
|
->Then(target, __func__,
|
||||||
target, __func__,
|
[resolver = std::move(aResolver)](
|
||||||
[resolver](
|
|
||||||
const MozPromise<bool, bool, false>::ResolveOrRejectValue&
|
const MozPromise<bool, bool, false>::ResolveOrRejectValue&
|
||||||
aValue) {
|
aValue) {
|
||||||
if (aValue.IsResolve()) {
|
if (aValue.IsResolve()) {
|
||||||
@@ -399,8 +400,6 @@ mozilla::ipc::IPCResult WebAuthnTransactionParent::RecvRequestIsUVPAA(
|
|||||||
resolver(false);
|
resolver(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}));
|
|
||||||
NS_DispatchToMainThread(runnable.forget());
|
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -433,6 +432,7 @@ mozilla::ipc::IPCResult WebAuthnTransactionParent::RecvRequestIsUVPAA(
|
|||||||
void WebAuthnTransactionParent::ActorDestroy(ActorDestroyReason aWhy) {
|
void WebAuthnTransactionParent::ActorDestroy(ActorDestroyReason aWhy) {
|
||||||
// Called either by Send__delete__() in RecvDestroyMe() above, or when
|
// Called either by Send__delete__() in RecvDestroyMe() above, or when
|
||||||
// the channel disconnects. Ensure the token manager forgets about us.
|
// the channel disconnects. Ensure the token manager forgets about us.
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
if (mTransactionId.isSome()) {
|
if (mTransactionId.isSome()) {
|
||||||
DisconnectTransaction();
|
DisconnectTransaction();
|
||||||
|
|||||||
Reference in New Issue
Block a user