Roll src/third_party/WebKit b4168eb:6c137a7 (svn 202006:202008)
[chromium-blink-merge.git] / ash / system / user / user_view.h
blob2c42f1d5593592a3163d095cbd04389ecf57a693
1 // Copyright 2014 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.
5 #ifndef ASH_SYSTEM_USER_USER_VIEW_H_
6 #define ASH_SYSTEM_USER_USER_VIEW_H_
8 #include "ash/session/session_state_delegate.h"
9 #include "ash/system/tray/tray_constants.h"
10 #include "ash/system/user/login_status.h"
11 #include "ash/system/user/tray_user.h"
12 #include "base/macros.h"
13 #include "ui/views/controls/button/button.h"
14 #include "ui/views/focus/focus_manager.h"
15 #include "ui/views/layout/box_layout.h"
16 #include "ui/views/mouse_watcher.h"
17 #include "ui/views/view.h"
19 namespace gfx {
20 class Rect;
21 class Size;
24 namespace views {
25 class FocusManager;
28 namespace ash {
30 class PopupMessage;
31 class SystemTrayItem;
33 namespace tray {
35 // The view of a user item in system tray bubble.
36 class UserView : public views::View,
37 public views::ButtonListener,
38 public views::MouseWatcherListener,
39 public views::FocusChangeListener {
40 public:
41 UserView(SystemTrayItem* owner,
42 ash::user::LoginStatus login,
43 MultiProfileIndex index,
44 bool for_detailed_view);
45 ~UserView() override;
47 // Overridden from MouseWatcherListener:
48 void MouseMovedOutOfHost() override;
50 TrayUser::TestState GetStateForTest() const;
51 gfx::Rect GetBoundsInScreenOfUserButtonForTest();
53 views::View* user_card_view_for_test() const { return user_card_view_; }
55 private:
56 // Overridden from views::View.
57 gfx::Size GetPreferredSize() const override;
58 int GetHeightForWidth(int width) const override;
59 void Layout() override;
61 // Overridden from views::ButtonListener.
62 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
64 // Overridden from views::FocusChangeListener:
65 void OnWillChangeFocus(View* focused_before, View* focused_now) override;
66 void OnDidChangeFocus(View* focused_before, View* focused_now) override;
68 void AddLogoutButton(user::LoginStatus login);
69 void AddUserCard(user::LoginStatus login);
71 // Create the menu option to add another user. If |disabled| is set the user
72 // cannot actively click on the item.
73 void ToggleAddUserMenuOption();
75 // Removes the add user menu option.
76 void RemoveAddUserMenuOption();
78 MultiProfileIndex multiprofile_index_;
79 // The view of the user card.
80 views::View* user_card_view_;
82 // This is the owner system tray item of this view.
83 SystemTrayItem* owner_;
85 // True if |user_card_view_| is a |ButtonFromView| - otherwise it is only
86 // a |UserCardView|.
87 bool is_user_card_button_;
89 views::View* logout_button_;
90 scoped_ptr<PopupMessage> popup_message_;
91 scoped_ptr<views::Widget> add_menu_option_;
93 // False when the add user panel is visible but not activatable.
94 bool add_user_enabled_;
96 // True if this view will be used inside detailed view.
97 bool for_detailed_view_;
99 // The mouse watcher which takes care of out of window hover events.
100 scoped_ptr<views::MouseWatcher> mouse_watcher_;
102 // The focus manager which we use to detect focus changes.
103 views::FocusManager* focus_manager_;
105 DISALLOW_COPY_AND_ASSIGN(UserView);
108 } // namespace tray
109 } // namespace ash
111 #endif // ASH_SYSTEM_USER_USER_VIEW_H_