in_session_auth_dialog_controller.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2022 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_IN_SESSION_AUTH_DIALOG_CONTROLLER_H_
  5. #define ASH_PUBLIC_CPP_IN_SESSION_AUTH_DIALOG_CONTROLLER_H_
  6. #include "ash/public/cpp/ash_public_export.h"
  7. #include "ash/public/cpp/in_session_auth_dialog_client.h"
  8. #include "ash/public/cpp/in_session_auth_token_provider.h"
  9. #include "base/unguessable_token.h"
  10. #include "third_party/abseil-cpp/absl/types/optional.h"
  11. namespace ash {
  12. // InSessionAuthDialogController manages the in session auth dialog.
  13. class ASH_PUBLIC_EXPORT InSessionAuthDialogController {
  14. public:
  15. enum Reason {
  16. kAccessPasswordManager,
  17. kModifyAuthFactors,
  18. kModifyAuthFactorsMultidevice
  19. };
  20. // Callback passed from clients of the dialog
  21. // `success`: Whether or not the authentication was successful.
  22. // `token`: If the authentication was successful, a token is returned from
  23. // backends
  24. // that can be passed to further sensitive operations (such as those in
  25. // quickUnlockPrivate).
  26. // `timeout`: The length of time for which the token is valid.
  27. using OnAuthComplete =
  28. base::OnceCallback<void(bool success,
  29. const base::UnguessableToken& token,
  30. base::TimeDelta timeout)>;
  31. InSessionAuthDialogController() = default;
  32. virtual ~InSessionAuthDialogController() = default;
  33. // Summons a native UI dialog that authenticates the user, providing a
  34. // token, timeout and status in return.
  35. // `reason`: Indicates security context.
  36. virtual void ShowAuthDialog(Reason reason,
  37. OnAuthComplete on_auth_complete) = 0;
  38. // Must be called with a non null auth_token_provider prior to calling
  39. // `ShowAuthDialog`.
  40. // Injects a specific implementation of `InSessionAuthTokenProvider`
  41. // for generating an `AuthToken` after successful authentication.
  42. virtual void SetTokenProvider(
  43. InSessionAuthTokenProvider* auth_token_provider) = 0;
  44. };
  45. } // namespace ash
  46. #endif // ASH_PUBLIC_CPP_IN_SESSION_AUTH_DIALOG_CONTROLLER_H_