Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: ash/common/system/user/tray_user.h

Issue 2780963002: ash: Fix system tray avatar not updated regression (Closed)
Patch Set: resized_ -> resized_image_ Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/common/system/user/rounded_image_view.cc ('k') | ash/common/system/user/tray_user.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
51 51
52 // Returns the bounds of the user panel in screen coordinates. 52 // Returns the bounds of the user panel in screen coordinates.
53 // Note: This only works when the panel shown. 53 // Note: This only works when the panel shown.
54 gfx::Rect GetUserPanelBoundsInScreenForTest() const; 54 gfx::Rect GetUserPanelBoundsInScreenForTest() const;
55 55
56 // Update the TrayUser as if the current LoginStatus is |status|. 56 // Update the TrayUser as if the current LoginStatus is |status|.
57 void UpdateAfterLoginStatusChangeForTest(LoginStatus status); 57 void UpdateAfterLoginStatusChangeForTest(LoginStatus status);
58 58
59 // Use for access inside of tests. 59 // Use for access inside of tests.
60 tray::UserView* user_view_for_test() const { return user_; } 60 tray::UserView* user_view_for_test() const { return user_; }
61 tray::RoundedImageView* avatar_view_for_test() const { return avatar_; }
61 62
62 private: 63 private:
63 // Overridden from SystemTrayItem. 64 // Overridden from SystemTrayItem.
64 views::View* CreateTrayView(LoginStatus status) override; 65 views::View* CreateTrayView(LoginStatus status) override;
65 views::View* CreateDefaultView(LoginStatus status) override; 66 views::View* CreateDefaultView(LoginStatus status) override;
66 void DestroyTrayView() override; 67 void DestroyTrayView() override;
67 void DestroyDefaultView() override; 68 void DestroyDefaultView() override;
68 void UpdateAfterLoginStatusChange(LoginStatus status) override; 69 void UpdateAfterLoginStatusChange(LoginStatus status) override;
69 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override; 70 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override;
70 71
71 // Overridden from UserObserver. 72 // Overridden from SessionStateObserver.
72 void OnUserUpdate() override; 73 void ActiveUserChanged(const AccountId& account_id) override;
73 void OnUserAddedToSession() override; 74 void UserAddedToSession(const AccountId& account_id) override;
75 void UserSessionUpdated(const AccountId& account_id) override;
74 76
75 void UpdateAvatarImage(LoginStatus status); 77 void UpdateAvatarImage(LoginStatus status);
76 78
77 // Updates the layout of this item. 79 // Updates the layout of this item.
78 void UpdateLayoutOfItem(); 80 void UpdateLayoutOfItem();
79 81
82 ScopedSessionStateObserver scoped_session_observer_;
83
80 // The user index to use. 84 // The user index to use.
81 UserIndex user_index_; 85 const UserIndex user_index_;
82 86
83 tray::UserView* user_; 87 tray::UserView* user_ = nullptr;
84 88
85 // View that contains label and/or avatar. 89 // View that contains label and/or avatar.
86 views::View* layout_view_; 90 views::View* layout_view_ = nullptr;
87 tray::RoundedImageView* avatar_; 91 tray::RoundedImageView* avatar_ = nullptr;
88 views::Label* label_; 92 views::Label* label_ = nullptr;
89 93
90 DISALLOW_COPY_AND_ASSIGN(TrayUser); 94 DISALLOW_COPY_AND_ASSIGN(TrayUser);
91 }; 95 };
92 96
93 } // namespace ash 97 } // namespace ash
94 98
95 #endif // ASH_COMMON_SYSTEM_USER_TRAY_USER_H_ 99 #endif // ASH_COMMON_SYSTEM_USER_TRAY_USER_H_
OLDNEW
« no previous file with comments | « ash/common/system/user/rounded_image_view.cc ('k') | ash/common/system/user/tray_user.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698