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/layout/box_layout.h"
15 #include "ui/views/mouse_watcher.h"
16 #include "ui/views/view.h"
30 // The view of a user item in system tray bubble.
31 class UserView : public views::View,
32 public views::ButtonListener,
33 public views::MouseWatcherListener {
35 UserView(SystemTrayItem* owner,
36 ash::user::LoginStatus login,
37 MultiProfileIndex index,
38 bool for_detailed_view);
41 // Overridden from MouseWatcherListener:
42 virtual void MouseMovedOutOfHost() OVERRIDE;
44 TrayUser::TestState GetStateForTest() const;
45 gfx::Rect GetBoundsInScreenOfUserButtonForTest();
48 // Overridden from views::View.
49 virtual gfx::Size GetPreferredSize() OVERRIDE;
50 virtual int GetHeightForWidth(int width) OVERRIDE;
51 virtual void Layout() OVERRIDE;
53 // Overridden from views::ButtonListener.
54 virtual void ButtonPressed(views::Button* sender,
55 const ui::Event& event) OVERRIDE;
57 void AddLogoutButton(user::LoginStatus login);
58 void AddUserCard(user::LoginStatus login);
60 // Create the menu option to add another user. If |disabled| is set the user
61 // cannot actively click on the item.
62 void ToggleAddUserMenuOption();
64 MultiProfileIndex multiprofile_index_;
65 // The view of the user card.
66 views::View* user_card_view_;
68 // This is the owner system tray item of this view.
69 SystemTrayItem* owner_;
71 // True if |user_card_view_| is a |ButtonFromView| - otherwise it is only
73 bool is_user_card_button_;
75 views::View* logout_button_;
76 scoped_ptr<PopupMessage> popup_message_;
77 scoped_ptr<views::Widget> add_menu_option_;
79 // True when the add user panel is visible but not activatable.
80 bool add_user_disabled_;
82 // True if this view will be used inside detailed view.
83 bool for_detailed_view_;
85 // The mouse watcher which takes care of out of window hover events.
86 scoped_ptr<views::MouseWatcher> mouse_watcher_;
88 DISALLOW_COPY_AND_ASSIGN(UserView);
94 #endif // ASH_SYSTEM_USER_USER_VIEW_H_