webauthn_dialog_controller.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_PUBLIC_CPP_WEBAUTHN_DIALOG_CONTROLLER_H_
  5. #define ASH_PUBLIC_CPP_WEBAUTHN_DIALOG_CONTROLLER_H_
  6. #include "ash/public/cpp/ash_public_export.h"
  7. #include "ash/public/cpp/in_session_auth_dialog_client.h"
  8. namespace aura {
  9. class Window;
  10. }
  11. namespace ash {
  12. // WebAuthNDialogController manages the webauthn auth dialog.
  13. class ASH_PUBLIC_EXPORT WebAuthNDialogController {
  14. public:
  15. // Callback for authentication checks. |success| true/false if auth
  16. // succeeded/failed, and |can_use_pin| indicates whether PIN can still be used
  17. // (not locked out) after the previous authentication.
  18. using OnAuthenticateCallback =
  19. base::OnceCallback<void(bool success, bool can_use_pin)>;
  20. // Callback for overall authentication flow result.
  21. using FinishCallback = base::OnceCallback<void(bool success)>;
  22. // Return the singleton instance.
  23. static WebAuthNDialogController* Get();
  24. // Sets the client that will handle authentication.
  25. virtual void SetClient(InSessionAuthDialogClient* client) = 0;
  26. // Displays the authentication dialog for the website/app name in |app_id|.
  27. virtual void ShowAuthenticationDialog(aura::Window* source_window,
  28. const std::string& origin_name,
  29. FinishCallback finish_callback) = 0;
  30. // Destroys the authentication dialog.
  31. virtual void DestroyAuthenticationDialog() = 0;
  32. // Takes a password or PIN and sends it to InSessionAuthDialogClient to
  33. // authenticate. The InSessionAuthDialogClient should already know the current
  34. // session's active user, so the user account is not provided here.
  35. virtual void AuthenticateUserWithPasswordOrPin(
  36. const std::string& password,
  37. bool authenticated_by_pin,
  38. OnAuthenticateCallback callback) = 0;
  39. // Requests ChromeOS to report fingerprint scan result through |callback|.
  40. virtual void AuthenticateUserWithFingerprint(
  41. base::OnceCallback<void(bool, FingerprintState)> callback) = 0;
  42. // Opens a help article in Chrome.
  43. virtual void OpenInSessionAuthHelpPage() = 0;
  44. // Cancels all operations and destroys the dialog.
  45. virtual void Cancel() = 0;
  46. // Checks whether there's at least one authentication method.
  47. virtual void CheckAvailability(
  48. FinishCallback on_availability_checked) const = 0;
  49. protected:
  50. WebAuthNDialogController();
  51. virtual ~WebAuthNDialogController();
  52. };
  53. } // namespace ash
  54. #endif // ASH_PUBLIC_CPP_WEBAUTHN_DIALOG_CONTROLLER_H_