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"
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
{
41 UserView(SystemTrayItem
* owner
,
42 ash::user::LoginStatus login
,
43 MultiProfileIndex index
,
44 bool for_detailed_view
);
47 // Overridden from MouseWatcherListener:
48 void MouseMovedOutOfHost() override
;
50 TrayUser::TestState
GetStateForTest() const;
51 gfx::Rect
GetBoundsInScreenOfUserButtonForTest();
54 // Overridden from views::View.
55 gfx::Size
GetPreferredSize() const override
;
56 int GetHeightForWidth(int width
) const override
;
57 void Layout() override
;
59 // Overridden from views::ButtonListener.
60 void ButtonPressed(views::Button
* sender
, const ui::Event
& event
) override
;
62 // Overridden from views::FocusChangeListener:
63 void OnWillChangeFocus(View
* focused_before
, View
* focused_now
) override
;
64 void OnDidChangeFocus(View
* focused_before
, View
* focused_now
) override
;
66 void AddLogoutButton(user::LoginStatus login
);
67 void AddUserCard(user::LoginStatus login
);
69 // Create the menu option to add another user. If |disabled| is set the user
70 // cannot actively click on the item.
71 void ToggleAddUserMenuOption();
73 // Removes the add user menu option.
74 void RemoveAddUserMenuOption();
76 MultiProfileIndex multiprofile_index_
;
77 // The view of the user card.
78 views::View
* user_card_view_
;
80 // This is the owner system tray item of this view.
81 SystemTrayItem
* owner_
;
83 // True if |user_card_view_| is a |ButtonFromView| - otherwise it is only
85 bool is_user_card_button_
;
87 views::View
* logout_button_
;
88 scoped_ptr
<PopupMessage
> popup_message_
;
89 scoped_ptr
<views::Widget
> add_menu_option_
;
91 // False when the add user panel is visible but not activatable.
92 bool add_user_enabled_
;
94 // True if this view will be used inside detailed view.
95 bool for_detailed_view_
;
97 // The mouse watcher which takes care of out of window hover events.
98 scoped_ptr
<views::MouseWatcher
> mouse_watcher_
;
100 // The focus manager which we use to detect focus changes.
101 views::FocusManager
* focus_manager_
;
103 DISALLOW_COPY_AND_ASSIGN(UserView
);
109 #endif // ASH_SYSTEM_USER_USER_VIEW_H_