user_chooser_view.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright 2018 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_SYSTEM_UNIFIED_USER_CHOOSER_VIEW_H_
  5. #define ASH_SYSTEM_UNIFIED_USER_CHOOSER_VIEW_H_
  6. #include "ash/media/media_controller_impl.h"
  7. #include "ui/views/controls/button/button.h"
  8. #include "ui/views/view.h"
  9. namespace views {
  10. class ImageView;
  11. class Label;
  12. } // namespace views
  13. namespace ash {
  14. class UserChooserDetailedViewController;
  15. // Circular image view with user's icon of |user_index|.
  16. views::View* CreateUserAvatarView(int user_index);
  17. // Get accessibility string for |user_index|.
  18. std::u16string GetUserItemAccessibleString(int user_index);
  19. // A button item of a switchable user.
  20. class UserItemButton : public views::Button {
  21. public:
  22. UserItemButton(PressedCallback callback,
  23. UserChooserDetailedViewController* controller,
  24. int user_index,
  25. ax::mojom::Role role,
  26. bool has_close_button);
  27. UserItemButton(const UserItemButton&) = delete;
  28. UserItemButton& operator=(const UserItemButton&) = delete;
  29. ~UserItemButton() override = default;
  30. void SetCaptureState(MediaCaptureState capture_states);
  31. // views::Button:
  32. std::u16string GetTooltipText(const gfx::Point& p) const override;
  33. void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
  34. private:
  35. const int user_index_;
  36. views::ImageView* const capture_icon_;
  37. views::Label* const name_;
  38. views::Label* const email_;
  39. };
  40. // A detailed view of user chooser.
  41. class UserChooserView : public views::View, public MediaCaptureObserver {
  42. public:
  43. explicit UserChooserView(UserChooserDetailedViewController* controller);
  44. UserChooserView(const UserChooserView&) = delete;
  45. UserChooserView& operator=(const UserChooserView&) = delete;
  46. ~UserChooserView() override;
  47. // MediaCaptureObserver:
  48. void OnMediaCaptureChanged(const base::flat_map<AccountId, MediaCaptureState>&
  49. capture_states) override;
  50. // views::View:
  51. const char* GetClassName() const override;
  52. private:
  53. std::vector<UserItemButton*> user_item_buttons_;
  54. };
  55. } // namespace ash
  56. #endif // ASH_SYSTEM_UNIFIED_USER_CHOOSER_VIEW_H_