Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ash / system / user / user_view.h
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.
4
5 #ifndef ASH_SYSTEM_USER_USER_VIEW_H_
6 #define ASH_SYSTEM_USER_USER_VIEW_H_
7
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"
17
18 namespace gfx {
19 class Rect;
20 class Size;
21 }
22
23 namespace ash {
24
25 class PopupMessage;
26 class SystemTrayItem;
27
28 namespace tray {
29
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 {
34  public:
35   UserView(SystemTrayItem* owner,
36            ash::user::LoginStatus login,
37            MultiProfileIndex index,
38            bool for_detailed_view);
39   virtual ~UserView();
40
41   // Overridden from MouseWatcherListener:
42   virtual void MouseMovedOutOfHost() OVERRIDE;
43
44   TrayUser::TestState GetStateForTest() const;
45   gfx::Rect GetBoundsInScreenOfUserButtonForTest();
46
47  private:
48   // Overridden from views::View.
49   virtual gfx::Size GetPreferredSize() OVERRIDE;
50   virtual int GetHeightForWidth(int width) OVERRIDE;
51   virtual void Layout() OVERRIDE;
52
53   // Overridden from views::ButtonListener.
54   virtual void ButtonPressed(views::Button* sender,
55                              const ui::Event& event) OVERRIDE;
56
57   void AddLogoutButton(user::LoginStatus login);
58   void AddUserCard(user::LoginStatus login);
59
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();
63
64   MultiProfileIndex multiprofile_index_;
65   // The view of the user card.
66   views::View* user_card_view_;
67
68   // This is the owner system tray item of this view.
69   SystemTrayItem* owner_;
70
71   // True if |user_card_view_| is a |ButtonFromView| - otherwise it is only
72   // a |UserCardView|.
73   bool is_user_card_button_;
74
75   views::View* logout_button_;
76   scoped_ptr<PopupMessage> popup_message_;
77   scoped_ptr<views::Widget> add_menu_option_;
78
79   // True when the add user panel is visible but not activatable.
80   bool add_user_disabled_;
81
82   // True if this view will be used inside detailed view.
83   bool for_detailed_view_;
84
85   // The mouse watcher which takes care of out of window hover events.
86   scoped_ptr<views::MouseWatcher> mouse_watcher_;
87
88   DISALLOW_COPY_AND_ASSIGN(UserView);
89 };
90
91 }  // namespace tray
92 }  // namespace ash
93
94 #endif  // ASH_SYSTEM_USER_USER_VIEW_H_