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_COMMON_SYSTEM_USER_TRAY_USER_H_ | 5 #ifndef ASH_COMMON_SYSTEM_USER_TRAY_USER_H_ |
6 #define ASH_COMMON_SYSTEM_USER_TRAY_USER_H_ | 6 #define ASH_COMMON_SYSTEM_USER_TRAY_USER_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/common/session/session_state_observer.h" | |
9 #include "ash/common/system/tray/system_tray_item.h" | 10 #include "ash/common/system/tray/system_tray_item.h" |
10 #include "ash/common/system/user/user_observer.h" | |
11 #include "ash/public/cpp/session_types.h" | 11 #include "ash/public/cpp/session_types.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 | 13 |
14 namespace gfx { | 14 namespace gfx { |
15 class Rect; | 15 class Rect; |
16 class Size; | 16 class Size; |
17 } | 17 } |
18 | 18 |
19 namespace views { | 19 namespace views { |
20 class Label; | 20 class Label; |
21 } | 21 } |
22 | 22 |
23 namespace ash { | 23 namespace ash { |
24 | 24 |
25 namespace tray { | 25 namespace tray { |
26 class RoundedImageView; | 26 class RoundedImageView; |
27 class UserView; | 27 class UserView; |
28 } | 28 } |
29 | 29 |
30 class ASH_EXPORT TrayUser : public SystemTrayItem, public UserObserver { | 30 class ASH_EXPORT TrayUser : public SystemTrayItem, public SessionStateObserver { |
31 public: | 31 public: |
32 // The given |index| is the user index in a multi profile scenario. Index #0 | 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 | 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 | 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. | 35 // #0) or all users be visible in the system tray. |
36 TrayUser(SystemTray* system_tray, UserIndex index); | 36 TrayUser(SystemTray* system_tray, UserIndex index); |
37 ~TrayUser() override; | 37 ~TrayUser() override; |
38 | 38 |
39 // Allows unit tests to see if the item was created. | 39 // Allows unit tests to see if the item was created. |
40 enum TestState { | 40 enum TestState { |
(...skipping 20 matching lines...) Expand all Loading... | |
61 | 61 |
62 private: | 62 private: |
63 // Overridden from SystemTrayItem. | 63 // Overridden from SystemTrayItem. |
64 views::View* CreateTrayView(LoginStatus status) override; | 64 views::View* CreateTrayView(LoginStatus status) override; |
65 views::View* CreateDefaultView(LoginStatus status) override; | 65 views::View* CreateDefaultView(LoginStatus status) override; |
66 void DestroyTrayView() override; | 66 void DestroyTrayView() override; |
67 void DestroyDefaultView() override; | 67 void DestroyDefaultView() override; |
68 void UpdateAfterLoginStatusChange(LoginStatus status) override; | 68 void UpdateAfterLoginStatusChange(LoginStatus status) override; |
69 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override; | 69 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override; |
70 | 70 |
71 // Overridden from UserObserver. | 71 // Overridden from SessionStateObserver. |
72 void OnUserUpdate() override; | 72 void ActiveUserChanged(const AccountId& account_id) override; |
73 void OnUserAddedToSession() override; | 73 void UserAddedToSession(const AccountId& account_id) override; |
74 void UserSessionUpdated(const AccountId& account_id) override; | |
74 | 75 |
75 void UpdateAvatarImage(LoginStatus status); | 76 void UpdateAvatarImage(LoginStatus status); |
76 | 77 |
77 // Updates the layout of this item. | 78 // Updates the layout of this item. |
78 void UpdateLayoutOfItem(); | 79 void UpdateLayoutOfItem(); |
79 | 80 |
81 ScopedSessionStateObserver scoped_session_observer_; | |
82 | |
80 // The user index to use. | 83 // The user index to use. |
81 UserIndex user_index_; | 84 const UserIndex user_index_; |
James Cook
2017/03/29 00:51:23
Hooray for const!
| |
82 | 85 |
83 tray::UserView* user_; | 86 tray::UserView* user_ = nullptr; |
84 | 87 |
85 // View that contains label and/or avatar. | 88 // View that contains label and/or avatar. |
86 views::View* layout_view_; | 89 views::View* layout_view_ = nullptr; |
87 tray::RoundedImageView* avatar_; | 90 tray::RoundedImageView* avatar_ = nullptr; |
88 views::Label* label_; | 91 views::Label* label_ = nullptr; |
89 | 92 |
90 DISALLOW_COPY_AND_ASSIGN(TrayUser); | 93 DISALLOW_COPY_AND_ASSIGN(TrayUser); |
91 }; | 94 }; |
92 | 95 |
93 } // namespace ash | 96 } // namespace ash |
94 | 97 |
95 #endif // ASH_COMMON_SYSTEM_USER_TRAY_USER_H_ | 98 #endif // ASH_COMMON_SYSTEM_USER_TRAY_USER_H_ |
OLD | NEW |