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_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"
29 class RoundedImageView;
32 class ASH_EXPORT TrayUser : public SystemTrayItem,
35 // The given |multiprofile_index| is the user number in a multi profile
36 // scenario. Index #0 is the running user, the other indices are other logged
37 // in users (if there are any). Depending on the multi user mode, there will
38 // be either one (index #0) or all users be visible in the system tray.
39 TrayUser(SystemTray* system_tray, MultiProfileIndex index);
42 // Allows unit tests to see if the item was created.
44 HIDDEN, // The item is hidden.
45 SEPARATOR, // the item gets shown as a separator.
46 SHOWN, // The item gets presented to the user.
47 HOVERED, // The item is hovered and presented to the user.
48 ACTIVE, // The item was clicked and can add a user.
49 ACTIVE_BUT_DISABLED // The item was clicked anc cannot add a user.
51 TestState GetStateForTest() const;
53 // Checks if a drag and drop operation would be able to land a window on this
55 bool CanDropWindowHereToTransferToUser(const gfx::Point& point_in_screen);
57 // Try to re-parent the |window| to a new owner. Returns true if the window
59 bool TransferWindowToUser(aura::Window* window);
61 // Returns the bounds of the user panel in screen coordinates.
62 // Note: This only works when the panel shown.
63 gfx::Rect GetUserPanelBoundsInScreenForTest() const;
66 // Overridden from SystemTrayItem.
67 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE;
68 virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE;
69 virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE;
70 virtual void DestroyTrayView() OVERRIDE;
71 virtual void DestroyDefaultView() OVERRIDE;
72 virtual void DestroyDetailedView() OVERRIDE;
73 virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE;
74 virtual void UpdateAfterShelfAlignmentChange(
75 ShelfAlignment alignment) OVERRIDE;
77 // Overridden from UserObserver.
78 virtual void OnUserUpdate() OVERRIDE;
79 virtual void OnUserAddedToSession() OVERRIDE;
81 void UpdateAvatarImage(user::LoginStatus status);
83 // Get the user index which should be used for the tray icon of this item.
84 MultiProfileIndex GetTrayIndex();
86 // Return the radius for the tray item to use.
87 int GetTrayItemRadius();
89 // Updates the layout of this item.
90 void UpdateLayoutOfItem();
92 // The user index to use.
93 MultiProfileIndex multiprofile_index_;
95 tray::UserView* user_;
97 // View that contains label and/or avatar.
98 views::View* layout_view_;
99 tray::RoundedImageView* avatar_;
100 views::Label* label_;
102 // True if this element is the separator and it is shown.
103 bool separator_shown_;
105 DISALLOW_COPY_AND_ASSIGN(TrayUser);
108 } // namespace internal
111 #endif // ASH_SYSTEM_USER_TRAY_USER_H_