in_session_auth_dialog.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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_IN_SESSION_AUTH_IN_SESSION_AUTH_DIALOG_H_
  5. #define ASH_IN_SESSION_AUTH_IN_SESSION_AUTH_DIALOG_H_
  6. #include <memory>
  7. #include "ash/ash_export.h"
  8. #include "ash/in_session_auth/auth_dialog_contents_view.h"
  9. namespace aura {
  10. class Window;
  11. }
  12. namespace views {
  13. class Widget;
  14. }
  15. namespace ash {
  16. // InSessionAuthDialog gets instantiated on every request to show
  17. // an authentication dialog, and gets destroyed when the request is
  18. // completed.
  19. class InSessionAuthDialog {
  20. public:
  21. InSessionAuthDialog(
  22. uint32_t auth_methods,
  23. aura::Window* parent_window,
  24. const std::string& origin_name,
  25. const AuthDialogContentsView::AuthMethodsMetadata& auth_metadata,
  26. const UserAvatar& avatar);
  27. InSessionAuthDialog(const InSessionAuthDialog&) = delete;
  28. InSessionAuthDialog& operator=(const InSessionAuthDialog&) = delete;
  29. ~InSessionAuthDialog();
  30. views::Widget* widget() { return widget_.get(); }
  31. bool is_shown() const { return !!widget_; }
  32. uint32_t GetAuthMethods() const;
  33. private:
  34. // The dialog widget. Owned by this class so that we can close the widget
  35. // when auth completes.
  36. std::unique_ptr<views::Widget> widget_;
  37. // Pointer to the contents view. Used to query and update the set of available
  38. // auth methods.
  39. const uint32_t auth_methods_;
  40. };
  41. } // namespace ash
  42. #endif // ASH_IN_SESSION_AUTH_IN_SESSION_AUTH_DIALOG_H_