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

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

Issue 2615663002: Fix MediaClient::RequestCaptureState(). (Closed)
Patch Set: ash Created 3 years, 11 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
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/common/system/user/tray_user.h" 5 #include "ash/common/system/user/tray_user.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/session/session_controller.h"
8 #include "ash/common/session/session_state_delegate.h" 9 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/shelf/wm_shelf_util.h" 10 #include "ash/common/shelf/wm_shelf_util.h"
10 #include "ash/common/system/tray/system_tray.h" 11 #include "ash/common/system/tray/system_tray.h"
11 #include "ash/common/system/tray/system_tray_delegate.h" 12 #include "ash/common/system/tray/system_tray_delegate.h"
12 #include "ash/common/system/tray/system_tray_notifier.h" 13 #include "ash/common/system/tray/system_tray_notifier.h"
13 #include "ash/common/system/tray/tray_constants.h" 14 #include "ash/common/system/tray/tray_constants.h"
14 #include "ash/common/system/tray/tray_item_view.h" 15 #include "ash/common/system/tray/tray_item_view.h"
15 #include "ash/common/system/tray/tray_utils.h" 16 #include "ash/common/system/tray/tray_utils.h"
16 #include "ash/common/system/user/rounded_image_view.h" 17 #include "ash/common/system/user/rounded_image_view.h"
17 #include "ash/common/system/user/user_view.h" 18 #include "ash/common/system/user/user_view.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 CHECK(layout_view_ == nullptr); 75 CHECK(layout_view_ == nullptr);
75 76
76 layout_view_ = new views::View; 77 layout_view_ = new views::View;
77 UpdateAfterLoginStatusChange(status); 78 UpdateAfterLoginStatusChange(status);
78 return layout_view_; 79 return layout_view_;
79 } 80 }
80 81
81 views::View* TrayUser::CreateDefaultView(LoginStatus status) { 82 views::View* TrayUser::CreateDefaultView(LoginStatus status) {
82 if (status == LoginStatus::NOT_LOGGED_IN) 83 if (status == LoginStatus::NOT_LOGGED_IN)
83 return nullptr; 84 return nullptr;
84 const SessionStateDelegate* session_state_delegate = 85 const SessionController* session_controller =
85 WmShell::Get()->GetSessionStateDelegate(); 86 WmShell::Get()->session_controller();
xiyuan 2017/01/09 21:21:47 I have an incomplete CL (replace SessionStateDeleg
86 87
87 // If the screen is locked or a system modal dialog box is shown, show only 88 // If the screen is locked or a system modal dialog box is shown, show only
88 // the currently active user. 89 // the currently active user.
89 if (user_index_ && (session_state_delegate->IsUserSessionBlocked() || 90 if (user_index_ && (session_controller->IsUserSessionBlocked() ||
90 WmShell::Get()->IsSystemModalWindowOpen())) 91 WmShell::Get()->IsSystemModalWindowOpen()))
91 return nullptr; 92 return nullptr;
92 93
93 CHECK(user_ == nullptr); 94 CHECK(user_ == nullptr);
94 95
95 int logged_in_users = session_state_delegate->NumberOfLoggedInUsers();
96
97 // Do not show more UserView's then there are logged in users. 96 // Do not show more UserView's then there are logged in users.
98 if (user_index_ >= logged_in_users) 97 if (user_index_ >= session_controller->NumberOfLoggedInUsers())
99 return nullptr; 98 return nullptr;
100 99
101 user_ = new tray::UserView(this, status, user_index_); 100 user_ = new tray::UserView(this, status, user_index_);
102 return user_; 101 return user_;
103 } 102 }
104 103
105 void TrayUser::DestroyTrayView() { 104 void TrayUser::DestroyTrayView() {
106 layout_view_ = nullptr; 105 layout_view_ = nullptr;
107 avatar_ = nullptr; 106 avatar_ = nullptr;
108 label_ = nullptr; 107 label_ = nullptr;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 views::BoxLayout::kVertical, 0, 0, kUserLabelToIconPadding)); 218 views::BoxLayout::kVertical, 0, 0, kUserLabelToIconPadding));
220 } 219 }
221 } 220 }
222 221
223 void TrayUser::OnUserUpdate() { 222 void TrayUser::OnUserUpdate() {
224 UpdateAvatarImage( 223 UpdateAvatarImage(
225 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()); 224 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus());
226 } 225 }
227 226
228 void TrayUser::OnUserAddedToSession() { 227 void TrayUser::OnUserAddedToSession() {
229 SessionStateDelegate* session_state_delegate =
230 WmShell::Get()->GetSessionStateDelegate();
231 // Only create views for user items which are logged in. 228 // Only create views for user items which are logged in.
232 if (user_index_ >= session_state_delegate->NumberOfLoggedInUsers()) 229 if (user_index_ >=
230 WmShell::Get()->session_controller()->NumberOfLoggedInUsers()) {
James Cook 2017/01/09 21:07:19 nit: line wrapping might be better here and below
riajiang 2017/01/09 23:46:50 Done.
233 return; 231 return;
232 }
234 233
235 // Enforce a layout change that newly added items become visible. 234 // Enforce a layout change that newly added items become visible.
236 UpdateLayoutOfItem(); 235 UpdateLayoutOfItem();
237 236
238 // Update the user item. 237 // Update the user item.
239 UpdateAvatarImage( 238 UpdateAvatarImage(
240 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()); 239 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus());
241 } 240 }
242 241
243 void TrayUser::UpdateAvatarImage(LoginStatus status) { 242 void TrayUser::UpdateAvatarImage(LoginStatus status) {
244 SessionStateDelegate* session_state_delegate = 243 SessionStateDelegate* session_state_delegate =
245 WmShell::Get()->GetSessionStateDelegate(); 244 WmShell::Get()->GetSessionStateDelegate();
246 if (!avatar_ || 245 if (!avatar_ ||
247 user_index_ >= session_state_delegate->NumberOfLoggedInUsers()) 246 user_index_ >=
247 WmShell::Get()->session_controller()->NumberOfLoggedInUsers()) {
248 return; 248 return;
249 }
249 250
250 const user_manager::UserInfo* user_info = 251 const user_manager::UserInfo* user_info =
251 session_state_delegate->GetUserInfo(user_index_); 252 session_state_delegate->GetUserInfo(user_index_);
252 CHECK(user_info); 253 CHECK(user_info);
253 avatar_->SetImage(user_info->GetImage(), 254 avatar_->SetImage(user_info->GetImage(),
254 gfx::Size(kTrayItemSize, kTrayItemSize)); 255 gfx::Size(kTrayItemSize, kTrayItemSize));
255 256
256 // Unit tests might come here with no images for some users. 257 // Unit tests might come here with no images for some users.
257 if (avatar_->size().IsEmpty()) 258 if (avatar_->size().IsEmpty())
258 avatar_->SetSize(gfx::Size(kTrayItemSize, kTrayItemSize)); 259 avatar_->SetSize(gfx::Size(kTrayItemSize, kTrayItemSize));
259 } 260 }
260 261
261 void TrayUser::UpdateLayoutOfItem() { 262 void TrayUser::UpdateLayoutOfItem() {
262 UpdateAfterShelfAlignmentChange(system_tray()->shelf_alignment()); 263 UpdateAfterShelfAlignmentChange(system_tray()->shelf_alignment());
263 } 264 }
264 265
265 } // namespace ash 266 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698