OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_SYSTEM_USER_TRAY_USER_H_ | 5 #ifndef ASH_SYSTEM_USER_TRAY_USER_H_ |
6 #define ASH_SYSTEM_USER_TRAY_USER_H_ | 6 #define ASH_SYSTEM_USER_TRAY_USER_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/session/session_state_delegate.h" | 9 #include "ash/session/session_state_delegate.h" |
10 #include "ash/system/tray/system_tray_item.h" | 10 #include "ash/system/tray/system_tray_item.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 class ASH_EXPORT TrayUser : public SystemTrayItem, | 31 class ASH_EXPORT TrayUser : public SystemTrayItem, |
32 public UserObserver { | 32 public UserObserver { |
33 public: | 33 public: |
34 // The given |multiprofile_index| is the user number in a multi profile | 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 | 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 | 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. | 37 // be either one (index #0) or all users be visible in the system tray. |
38 TrayUser(SystemTray* system_tray, MultiProfileIndex index); | 38 TrayUser(SystemTray* system_tray, MultiProfileIndex index); |
39 virtual ~TrayUser(); | 39 ~TrayUser() override; |
40 | 40 |
41 // Allows unit tests to see if the item was created. | 41 // Allows unit tests to see if the item was created. |
42 enum TestState { | 42 enum TestState { |
43 HIDDEN, // The item is hidden. | 43 HIDDEN, // The item is hidden. |
44 SHOWN, // The item gets presented to the user. | 44 SHOWN, // The item gets presented to the user. |
45 HOVERED, // The item is hovered and 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. | 46 ACTIVE, // The item was clicked and can add a user. |
47 ACTIVE_BUT_DISABLED // The item was clicked anc cannot add a user. | 47 ACTIVE_BUT_DISABLED // The item was clicked anc cannot add a user. |
48 }; | 48 }; |
49 TestState GetStateForTest() const; | 49 TestState GetStateForTest() const; |
50 | 50 |
51 // Returns the size of layout_view_. | 51 // Returns the size of layout_view_. |
52 gfx::Size GetLayoutSizeForTest() const; | 52 gfx::Size GetLayoutSizeForTest() const; |
53 | 53 |
54 // Returns the bounds of the user panel in screen coordinates. | 54 // Returns the bounds of the user panel in screen coordinates. |
55 // Note: This only works when the panel shown. | 55 // Note: This only works when the panel shown. |
56 gfx::Rect GetUserPanelBoundsInScreenForTest() const; | 56 gfx::Rect GetUserPanelBoundsInScreenForTest() const; |
57 | 57 |
58 // Update the TrayUser as if the current LoginStatus is |status|. | 58 // Update the TrayUser as if the current LoginStatus is |status|. |
59 void UpdateAfterLoginStatusChangeForTest(user::LoginStatus status); | 59 void UpdateAfterLoginStatusChangeForTest(user::LoginStatus status); |
60 | 60 |
61 | 61 |
62 private: | 62 private: |
63 // Overridden from SystemTrayItem. | 63 // Overridden from SystemTrayItem. |
64 virtual views::View* CreateTrayView(user::LoginStatus status) override; | 64 views::View* CreateTrayView(user::LoginStatus status) override; |
65 virtual views::View* CreateDefaultView(user::LoginStatus status) override; | 65 views::View* CreateDefaultView(user::LoginStatus status) override; |
66 virtual views::View* CreateDetailedView(user::LoginStatus status) override; | 66 views::View* CreateDetailedView(user::LoginStatus status) override; |
67 virtual void DestroyTrayView() override; | 67 void DestroyTrayView() override; |
68 virtual void DestroyDefaultView() override; | 68 void DestroyDefaultView() override; |
69 virtual void DestroyDetailedView() override; | 69 void DestroyDetailedView() override; |
70 virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) override; | 70 void UpdateAfterLoginStatusChange(user::LoginStatus status) override; |
71 virtual void UpdateAfterShelfAlignmentChange( | 71 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override; |
72 ShelfAlignment alignment) override; | |
73 | 72 |
74 // Overridden from UserObserver. | 73 // Overridden from UserObserver. |
75 virtual void OnUserUpdate() override; | 74 void OnUserUpdate() override; |
76 virtual void OnUserAddedToSession() override; | 75 void OnUserAddedToSession() override; |
77 | 76 |
78 void UpdateAvatarImage(user::LoginStatus status); | 77 void UpdateAvatarImage(user::LoginStatus status); |
79 | 78 |
80 // Get the user index which should be used for the tray icon of this item. | 79 // Get the user index which should be used for the tray icon of this item. |
81 MultiProfileIndex GetTrayIndex(); | 80 MultiProfileIndex GetTrayIndex(); |
82 | 81 |
83 // Updates the layout of this item. | 82 // Updates the layout of this item. |
84 void UpdateLayoutOfItem(); | 83 void UpdateLayoutOfItem(); |
85 | 84 |
86 // The user index to use. | 85 // The user index to use. |
87 MultiProfileIndex multiprofile_index_; | 86 MultiProfileIndex multiprofile_index_; |
88 | 87 |
89 tray::UserView* user_; | 88 tray::UserView* user_; |
90 | 89 |
91 // View that contains label and/or avatar. | 90 // View that contains label and/or avatar. |
92 views::View* layout_view_; | 91 views::View* layout_view_; |
93 tray::RoundedImageView* avatar_; | 92 tray::RoundedImageView* avatar_; |
94 views::Label* label_; | 93 views::Label* label_; |
95 | 94 |
96 DISALLOW_COPY_AND_ASSIGN(TrayUser); | 95 DISALLOW_COPY_AND_ASSIGN(TrayUser); |
97 }; | 96 }; |
98 | 97 |
99 } // namespace ash | 98 } // namespace ash |
100 | 99 |
101 #endif // ASH_SYSTEM_USER_TRAY_USER_H_ | 100 #endif // ASH_SYSTEM_USER_TRAY_USER_H_ |
OLD | NEW |