1 // Copyright (c) 2012 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_TRAY_USER_H_
6 #define ASH_SYSTEM_USER_TRAY_USER_H_
8 #include "ash/ash_export.h"
9 #include "ash/session/session_state_delegate.h"
10 #include "ash/system/tray/system_tray_item.h"
11 #include "ash/system/user/user_observer.h"
12 #include "base/compiler_specific.h"
27 class RoundedImageView
;
31 class ASH_EXPORT TrayUser
: public SystemTrayItem
,
34 // The given |multiprofile_index| is the user number in a multi profile
35 // scenario. Index #0 is the running user, the other indices are other logged
36 // in users (if there are any). Depending on the multi user mode, there will
37 // be either one (index #0) or all users be visible in the system tray.
38 TrayUser(SystemTray
* system_tray
, MultiProfileIndex index
);
41 // Allows unit tests to see if the item was created.
43 HIDDEN
, // The item is hidden.
44 SHOWN
, // The item gets presented to the user.
45 HOVERED
, // The item is hovered and presented to the user.
46 ACTIVE
, // The item was clicked and can add a user.
47 ACTIVE_BUT_DISABLED
// The item was clicked anc cannot add a user.
49 TestState
GetStateForTest() const;
51 // Returns the size of layout_view_.
52 gfx::Size
GetLayoutSizeForTest() const;
54 // Returns the bounds of the user panel in screen coordinates.
55 // Note: This only works when the panel shown.
56 gfx::Rect
GetUserPanelBoundsInScreenForTest() const;
58 // Update the TrayUser as if the current LoginStatus is |status|.
59 void UpdateAfterLoginStatusChangeForTest(user::LoginStatus status
);
61 // Use for access inside of tests.
62 tray::UserView
* user_view_for_test() const { return user_
; }
65 // Overridden from SystemTrayItem.
66 views::View
* CreateTrayView(user::LoginStatus status
) override
;
67 views::View
* CreateDefaultView(user::LoginStatus status
) override
;
68 views::View
* CreateDetailedView(user::LoginStatus status
) override
;
69 void DestroyTrayView() override
;
70 void DestroyDefaultView() override
;
71 void DestroyDetailedView() override
;
72 void UpdateAfterLoginStatusChange(user::LoginStatus status
) override
;
73 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment
) override
;
75 // Overridden from UserObserver.
76 void OnUserUpdate() override
;
77 void OnUserAddedToSession() override
;
79 void UpdateAvatarImage(user::LoginStatus status
);
81 // Updates the layout of this item.
82 void UpdateLayoutOfItem();
84 // The user index to use.
85 MultiProfileIndex multiprofile_index_
;
87 tray::UserView
* user_
;
89 // View that contains label and/or avatar.
90 views::View
* layout_view_
;
91 tray::RoundedImageView
* avatar_
;
94 DISALLOW_COPY_AND_ASSIGN(TrayUser
);
99 #endif // ASH_SYSTEM_USER_TRAY_USER_H_