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