AuthenticatorTransportService.cpp [plain text]
#include "config.h"
#include "AuthenticatorTransportService.h"
#if ENABLE(WEB_AUTHN)
#include "HidService.h"
#include "LocalService.h"
#include "MockHidService.h"
#include "MockLocalService.h"
#include <wtf/RunLoop.h>
namespace WebKit {
UniqueRef<AuthenticatorTransportService> AuthenticatorTransportService::create(WebCore::AuthenticatorTransport transport, Observer& observer)
{
switch (transport) {
case WebCore::AuthenticatorTransport::Internal:
return makeUniqueRef<LocalService>(observer);
#if PLATFORM(MAC)
case WebCore::AuthenticatorTransport::Usb:
return makeUniqueRef<HidService>(observer);
#endif
default:
ASSERT_NOT_REACHED();
return makeUniqueRef<LocalService>(observer);
}
}
UniqueRef<AuthenticatorTransportService> AuthenticatorTransportService::createMock(WebCore::AuthenticatorTransport transport, Observer& observer, const MockWebAuthenticationConfiguration& configuration)
{
switch (transport) {
case WebCore::AuthenticatorTransport::Internal:
return makeUniqueRef<MockLocalService>(observer, configuration);
#if PLATFORM(MAC)
case WebCore::AuthenticatorTransport::Usb:
return makeUniqueRef<MockHidService>(observer, configuration);
#endif
default:
ASSERT_NOT_REACHED();
return makeUniqueRef<MockLocalService>(observer, configuration);
}
}
AuthenticatorTransportService::AuthenticatorTransportService(Observer& observer)
: m_observer(makeWeakPtr(observer))
{
}
void AuthenticatorTransportService::startDiscovery()
{
RunLoop::main().dispatch([weakThis = makeWeakPtr(*this)] {
if (!weakThis)
return;
weakThis->startDiscoveryInternal();
});
}
}
#endif // ENABLE(WEB_AUTHN)