| OLD | NEW |
| (Empty) |
| 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/public/cpp/session_types.h" | |
| 10 #include "ash/system/tray/system_tray_item.h" | |
| 11 #include "ash/system/user/user_observer.h" | |
| 12 #include "base/macros.h" | |
| 13 | |
| 14 namespace gfx { | |
| 15 class Rect; | |
| 16 class Size; | |
| 17 } | |
| 18 | |
| 19 namespace views { | |
| 20 class Label; | |
| 21 } | |
| 22 | |
| 23 namespace ash { | |
| 24 | |
| 25 namespace tray { | |
| 26 class RoundedImageView; | |
| 27 class UserView; | |
| 28 } | |
| 29 | |
| 30 class ASH_EXPORT TrayUser : public SystemTrayItem, public UserObserver { | |
| 31 public: | |
| 32 // The given |index| is the user index in a multi profile scenario. Index #0 | |
| 33 // is the active user, the other indices are other logged in users (if there | |
| 34 // are any). Depending on the multi user mode, there will be either one (index | |
| 35 // #0) or all users be visible in the system tray. | |
| 36 TrayUser(SystemTray* system_tray, UserIndex index); | |
| 37 ~TrayUser() override; | |
| 38 | |
| 39 // Allows unit tests to see if the item was created. | |
| 40 enum TestState { | |
| 41 HIDDEN, // The item is hidden. | |
| 42 SHOWN, // The item gets presented to the user. | |
| 43 HOVERED, // The item is hovered and presented to the user. | |
| 44 ACTIVE, // The item was clicked and can add a user. | |
| 45 ACTIVE_BUT_DISABLED // The item was clicked anc cannot add a user. | |
| 46 }; | |
| 47 TestState GetStateForTest() const; | |
| 48 | |
| 49 // Returns the size of layout_view_. | |
| 50 gfx::Size GetLayoutSizeForTest() 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 // Update the TrayUser as if the current LoginStatus is |status|. | |
| 57 void UpdateAfterLoginStatusChangeForTest(LoginStatus status); | |
| 58 | |
| 59 // Use for access inside of tests. | |
| 60 tray::UserView* user_view_for_test() const { return user_; } | |
| 61 | |
| 62 private: | |
| 63 // Overridden from SystemTrayItem. | |
| 64 views::View* CreateTrayView(LoginStatus status) override; | |
| 65 views::View* CreateDefaultView(LoginStatus status) override; | |
| 66 void DestroyTrayView() override; | |
| 67 void DestroyDefaultView() override; | |
| 68 void UpdateAfterLoginStatusChange(LoginStatus status) override; | |
| 69 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override; | |
| 70 | |
| 71 // Overridden from UserObserver. | |
| 72 void OnUserUpdate() override; | |
| 73 void OnUserAddedToSession() override; | |
| 74 | |
| 75 void UpdateAvatarImage(LoginStatus status); | |
| 76 | |
| 77 // Updates the layout of this item. | |
| 78 void UpdateLayoutOfItem(); | |
| 79 | |
| 80 // The user index to use. | |
| 81 UserIndex user_index_; | |
| 82 | |
| 83 tray::UserView* user_; | |
| 84 | |
| 85 // View that contains label and/or avatar. | |
| 86 views::View* layout_view_; | |
| 87 tray::RoundedImageView* avatar_; | |
| 88 views::Label* label_; | |
| 89 | |
| 90 DISALLOW_COPY_AND_ASSIGN(TrayUser); | |
| 91 }; | |
| 92 | |
| 93 } // namespace ash | |
| 94 | |
| 95 #endif // ASH_SYSTEM_USER_TRAY_USER_H_ | |
| OLD | NEW |