Skip to content

Commit

Permalink
Revert "Cherry-pick dfd64c8. rdar://123659147"
Browse files Browse the repository at this point in the history
This reverts commit ecc7415.

Identifier: 272448.581@safari-7618.1.15.11-branch
  • Loading branch information
MyahCobbs committed Feb 28, 2024
1 parent ecc7415 commit 6c38570
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,24 +299,13 @@ static inline ASAuthorizationPublicKeyCredentialLargeBlobSupportRequirement toAS
return requests;
}

WeakPtr<WebAuthenticatorCoordinatorProxy>& WebAuthenticatorCoordinatorProxy::activeConditionalMediationProxy()
void WebAuthenticatorCoordinatorProxy::pauseConditionalAssertion()
{
static MainThreadNeverDestroyed<WeakPtr<WebAuthenticatorCoordinatorProxy>> proxy;
return proxy.get();
}

void WebAuthenticatorCoordinatorProxy::pauseConditionalAssertion(CompletionHandler<void()>&& completionHandler)
{
if (m_paused) {
completionHandler();
if (m_paused)
return;
}
m_paused = true;
if (m_isConditionalAssertion)
m_cancelHandler = WTFMove(completionHandler);
[m_controller cancel];
} else
completionHandler();
}

void WebAuthenticatorCoordinatorProxy::unpauseConditionalAssertion()
Expand All @@ -329,19 +318,6 @@ static inline ASAuthorizationPublicKeyCredentialLargeBlobSupportRequirement toAS
m_paused = false;
}

void WebAuthenticatorCoordinatorProxy::makeActiveConditionalAssertion()
{
if (auto& activeProxy = activeConditionalMediationProxy()) {
if (activeProxy == this)
return;
activeProxy->pauseConditionalAssertion([weakThis = WeakPtr { *this }] () {
if (!weakThis)
return;
weakThis->unpauseConditionalAssertion();
});
}
}

#endif // HAVE(WEB_AUTHN_AS_MODERN)

void WebAuthenticatorCoordinatorProxy::performRequest(WebAuthenticationRequestData &&requestData, RequestCompletionHandler &&handler)
Expand All @@ -363,8 +339,6 @@ static inline ASAuthorizationPublicKeyCredentialLargeBlobSupportRequirement toAS
handler(WebCore::AuthenticatorResponseData { }, AuthenticatorAttachment::Platform, { ExceptionCode::NotAllowedError, @"" });
return;
}
if (m_isConditionalMediation)
activeConditionalMediationProxy() = *this;
m_controller = WTFMove(controller);
m_completionHandler = WTFMove(handler);
m_delegate = adoptNS([[_WKASDelegate alloc] initWithPage:WTFMove(requestData.page) completionHandler:makeBlockPtr([weakThis = WeakPtr { *this }](ASAuthorization *auth, NSError *error) mutable {
Expand Down Expand Up @@ -411,17 +385,11 @@ static inline ASAuthorizationPublicKeyCredentialLargeBlobSupportRequirement toAS
response.userHandle = toArrayBuffer(credential.get().userID);
response.clientDataJSON = toArrayBuffer(credential.get().rawClientDataJSON);
}
if (weakThis) {
if (activeConditionalMediationProxy() == weakThis)
activeConditionalMediationProxy() = nullptr;
if (auto cancelHandler = WTFMove(weakThis->m_cancelHandler))
cancelHandler();
if (!weakThis->m_paused) {
weakThis->m_completionHandler(response, attachment, exceptionData);
weakThis->m_delegate.clear();
weakThis->m_controller.clear();
weakThis->m_isConditionalAssertion = false;
}
if (!weakThis->m_paused) {
weakThis->m_completionHandler(response, attachment, exceptionData);
weakThis->m_delegate.clear();
weakThis->m_controller.clear();
weakThis->m_isConditionalAssertion = false;
}
});
}).get()]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ class WebAuthenticatorCoordinatorProxy : public IPC::MessageReceiver {
~WebAuthenticatorCoordinatorProxy();

#if HAVE(WEB_AUTHN_AS_MODERN)
static WeakPtr<WebAuthenticatorCoordinatorProxy>& activeConditionalMediationProxy();
void pauseConditionalAssertion(CompletionHandler<void()>&&);
void pauseConditionalAssertion();
void unpauseConditionalAssertion();
void makeActiveConditionalAssertion();
#endif

private:
Expand Down Expand Up @@ -126,7 +124,6 @@ class WebAuthenticatorCoordinatorProxy : public IPC::MessageReceiver {

RetainPtr<ASCAuthorizationRemotePresenter> m_presenter;
RetainPtr<ASCAgentProxy> m_proxy;
CompletionHandler<void()> m_cancelHandler;
#endif // HAVE(UNIFIED_ASC_AUTH_UI)
};

Expand Down
4 changes: 3 additions & 1 deletion Source/WebKit/UIProcess/WebPageProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2725,7 +2725,9 @@ void WebPageProxy::dispatchActivityStateChange()
#if ENABLE(WEB_AUTHN) && HAVE(WEB_AUTHN_AS_MODERN)
if ((changed & ActivityState::WindowIsActive) && m_credentialsMessenger) {
if (pageClient().isViewWindowActive())
m_credentialsMessenger->makeActiveConditionalAssertion();
m_credentialsMessenger->unpauseConditionalAssertion();
else
m_credentialsMessenger->pauseConditionalAssertion();
}
#endif

Expand Down

0 comments on commit 6c38570

Please sign in to comment.