in_session_auth_dialog_controller_impl.cc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  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. #include "ash/in_session_auth/in_session_auth_dialog_controller_impl.h"
  5. #include "ash/components/login/auth/auth_performer.h"
  6. #include "ash/in_session_auth/authentication_dialog.h"
  7. #include "ash/session/session_controller_impl.h"
  8. #include "ash/shell.h"
  9. #include "chromeos/ash/components/dbus/userdataauth/userdataauth_client.h"
  10. namespace ash {
  11. void InSessionAuthDialogControllerImpl::ShowAuthDialog(
  12. Reason reason,
  13. OnAuthComplete on_auth_complete) {
  14. auto account_id = Shell::Get()->session_controller()->GetActiveAccountId();
  15. DCHECK(account_id.is_valid());
  16. DCHECK_NE(auth_token_provider_, nullptr);
  17. // We don't manage the lifetime of `AuthenticationDialog` here.
  18. // `AuthenticatonDialog` is-a View and it is instead owned by it's widget,
  19. // which would properly delete it when the widget is closed.
  20. (new AuthenticationDialog(
  21. std::move(on_auth_complete), auth_token_provider_,
  22. std::make_unique<AuthPerformer>(UserDataAuthClient::Get()), account_id))
  23. ->Show();
  24. }
  25. void InSessionAuthDialogControllerImpl::SetTokenProvider(
  26. InSessionAuthTokenProvider* auth_token_provider) {
  27. auth_token_provider_ = auth_token_provider;
  28. }
  29. } // namespace ash