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

Side by Side Diff: ash/system/user/tray_user.cc

Issue 2829813002: cros: Move IsUserSupervised and IsUserChild off SystemTrayDelegate (Closed)
Patch Set: review comments 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/system/tray/system_tray_delegate.cc ('k') | ash/system/user/user_card_view.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 #include "ash/system/user/tray_user.h" 5 #include "ash/system/user/tray_user.h"
6 6
7 #include "ash/session/session_controller.h" 7 #include "ash/session/session_controller.h"
8 #include "ash/shelf/wm_shelf_util.h" 8 #include "ash/shelf/wm_shelf_util.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_port.h" 10 #include "ash/shell_port.h"
11 #include "ash/strings/grit/ash_strings.h" 11 #include "ash/strings/grit/ash_strings.h"
12 #include "ash/system/tray/system_tray.h" 12 #include "ash/system/tray/system_tray.h"
13 #include "ash/system/tray/system_tray_delegate.h"
14 #include "ash/system/tray/tray_constants.h" 13 #include "ash/system/tray/tray_constants.h"
15 #include "ash/system/tray/tray_item_view.h" 14 #include "ash/system/tray/tray_item_view.h"
16 #include "ash/system/tray/tray_utils.h" 15 #include "ash/system/tray/tray_utils.h"
17 #include "ash/system/user/rounded_image_view.h" 16 #include "ash/system/user/rounded_image_view.h"
18 #include "ash/system/user/user_view.h" 17 #include "ash/system/user/user_view.h"
19 #include "base/logging.h" 18 #include "base/logging.h"
20 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
21 #include "components/signin/core/account_id/account_id.h" 20 #include "components/signin/core/account_id/account_id.h"
22 #include "components/user_manager/user_info.h" 21 #include "components/user_manager/user_info.h"
23 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 104 }
106 105
107 void TrayUser::UpdateAfterLoginStatusChange(LoginStatus status) { 106 void TrayUser::UpdateAfterLoginStatusChange(LoginStatus status) {
108 // Only the active user is represented in the tray. 107 // Only the active user is represented in the tray.
109 if (!layout_view_) 108 if (!layout_view_)
110 return; 109 return;
111 if (user_index_ > 0) 110 if (user_index_ > 0)
112 return; 111 return;
113 bool need_label = false; 112 bool need_label = false;
114 bool need_avatar = false; 113 bool need_avatar = false;
115 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); 114 SessionController* session = Shell::Get()->session_controller();
116 if (delegate->IsUserSupervised()) 115 if (session->IsUserSupervised())
117 need_label = true; 116 need_label = true;
118 switch (status) { 117 switch (status) {
119 case LoginStatus::LOCKED: 118 case LoginStatus::LOCKED:
120 case LoginStatus::USER: 119 case LoginStatus::USER:
121 case LoginStatus::OWNER: 120 case LoginStatus::OWNER:
122 case LoginStatus::PUBLIC: 121 case LoginStatus::PUBLIC:
123 need_avatar = true; 122 need_avatar = true;
124 break; 123 break;
125 case LoginStatus::SUPERVISED: 124 case LoginStatus::SUPERVISED:
126 need_avatar = true; 125 need_avatar = true;
(...skipping 23 matching lines...) Expand all
150 if (need_avatar) { 149 if (need_avatar) {
151 avatar_ = new tray::RoundedImageView(kTrayRoundedBorderRadius); 150 avatar_ = new tray::RoundedImageView(kTrayRoundedBorderRadius);
152 avatar_->SetPaintToLayer(); 151 avatar_->SetPaintToLayer();
153 avatar_->layer()->SetFillsBoundsOpaquely(false); 152 avatar_->layer()->SetFillsBoundsOpaquely(false);
154 layout_view_->AddChildView(avatar_); 153 layout_view_->AddChildView(avatar_);
155 } else { 154 } else {
156 avatar_ = nullptr; 155 avatar_ = nullptr;
157 } 156 }
158 } 157 }
159 158
160 if (delegate->IsUserSupervised()) { 159 if (session->IsUserSupervised()) {
161 label_->SetText( 160 label_->SetText(
162 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL)); 161 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL));
163 } else if (status == LoginStatus::GUEST) { 162 } else if (status == LoginStatus::GUEST) {
164 label_->SetText(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL)); 163 label_->SetText(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL));
165 } 164 }
166 165
167 UpdateAvatarImage(status); 166 UpdateAvatarImage(status);
168 167
169 // Update layout after setting label_ and avatar_ with new login status. 168 // Update layout after setting label_ and avatar_ with new login status.
170 UpdateLayoutOfItem(); 169 UpdateLayoutOfItem();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // Unit tests might come here with no images for some users. 246 // Unit tests might come here with no images for some users.
248 if (avatar_->size().IsEmpty()) 247 if (avatar_->size().IsEmpty())
249 avatar_->SetSize(gfx::Size(kTrayItemSize, kTrayItemSize)); 248 avatar_->SetSize(gfx::Size(kTrayItemSize, kTrayItemSize));
250 } 249 }
251 250
252 void TrayUser::UpdateLayoutOfItem() { 251 void TrayUser::UpdateLayoutOfItem() {
253 UpdateAfterShelfAlignmentChange(system_tray()->shelf_alignment()); 252 UpdateAfterShelfAlignmentChange(system_tray()->shelf_alignment());
254 } 253 }
255 254
256 } // namespace ash 255 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray_delegate.cc ('k') | ash/system/user/user_card_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698