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. 4 5 #ifndef ASH_SYSTEM_USER_TRAY_USER_H_ 6 #define ASH_SYSTEM_USER_TRAY_USER_H_ 7 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" 13 14 namespace gfx { 15 class Rect; 16 } 17 18 namespace views { 19 class ImageView; 20 class Label; 21 } 22 23 namespace ash { 24 namespace internal { 25 26 namespace tray { 27 class UserView; 28 class RoundedImageView; 29 } 30 31 class ASH_EXPORT TrayUser : public SystemTrayItem, 32 public UserObserver { 33 public: 34 // The given |multiprofile_index| is the number of the user in a multi profile 35 // scenario. Index #0 is the running user, the other indices are other 36 // logged in users (if there are any). Only index #0 will add an icon to 37 // the system tray. 38 TrayUser(SystemTray* system_tray, MultiProfileIndex index); 39 virtual ~TrayUser(); 40 41 // Allows unit tests to see if the item was created. 42 enum TestState { 43 HIDDEN, // The item is hidden. 44 SEPARATOR, // the item gets shown as a separator. 45 SHOWN, // The item gets presented to the user. 46 HOVERED, // The item is hovered and presented to the user. 47 ACTIVE, // The item was clicked and can add a user. 48 ACTIVE_BUT_DISABLED // The item was clicked anc cannot add a user. 49 }; 50 TestState GetStateForTest() const; 51 52 // Returns the bounds of the user panel in screen coordinates. 53 // Note: This only works when the panel shown. 54 gfx::Rect GetUserPanelBoundsInScreenForTest() const; 55 56 private: 57 // Overridden from SystemTrayItem. 58 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE; 59 virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE; 60 virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE; 61 virtual void DestroyTrayView() OVERRIDE; 62 virtual void DestroyDefaultView() OVERRIDE; 63 virtual void DestroyDetailedView() OVERRIDE; 64 virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE; 65 virtual void UpdateAfterShelfAlignmentChange( 66 ShelfAlignment alignment) OVERRIDE; 67 68 // Overridden from UserObserver. 69 virtual void OnUserUpdate() OVERRIDE; 70 71 void UpdateAvatarImage(user::LoginStatus status); 72 73 // The user index to use. 74 MultiProfileIndex multiprofile_index_; 75 76 tray::UserView* user_; 77 78 // View that contains label and/or avatar. 79 views::View* layout_view_; 80 tray::RoundedImageView* avatar_; 81 views::Label* label_; 82 83 // True if this element is the separator and it is shown. 84 bool separator_shown_; 85 86 DISALLOW_COPY_AND_ASSIGN(TrayUser); 87 }; 88 89 } // namespace internal 90 } // namespace ash 91 92 #endif // ASH_SYSTEM_USER_TRAY_USER_H_ 93