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

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

Issue 10200006: ash: Refresh the tray items, instead of recreating them, when login status changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/system/user/tray_user.h ('k') | no next file » | 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/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray_delegate.h" 8 #include "ash/system/tray/system_tray_delegate.h"
9 #include "ash/system/tray/tray_constants.h" 9 #include "ash/system/tray/tray_constants.h"
10 #include "ash/system/tray/tray_item_view.h" 10 #include "ash/system/tray/tray_item_view.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } // namespace tray 255 } // namespace tray
256 256
257 TrayUser::TrayUser() { 257 TrayUser::TrayUser() {
258 } 258 }
259 259
260 TrayUser::~TrayUser() { 260 TrayUser::~TrayUser() {
261 } 261 }
262 262
263 views::View* TrayUser::CreateTrayView(user::LoginStatus status) { 263 views::View* TrayUser::CreateTrayView(user::LoginStatus status) {
264 avatar_.reset(new tray::RoundedImageView(kTrayRoundedBorderRadius)); 264 avatar_.reset(new tray::RoundedImageView(kTrayRoundedBorderRadius));
265 if (status != user::LOGGED_IN_NONE && status != user::LOGGED_IN_KIOSK &&
266 status != user::LOGGED_IN_GUEST) {
267 avatar_->SetImage(
268 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(),
269 gfx::Size(kUserIconSize, kUserIconSize));
270 } else {
271 avatar_->SetVisible(false);
272 }
273 avatar_->set_border(views::Border::CreateEmptyBorder(0, 6, 0, 0)); 265 avatar_->set_border(views::Border::CreateEmptyBorder(0, 6, 0, 0));
266 UpdateAfterLoginStatusChange(status);
274 return avatar_.get(); 267 return avatar_.get();
275 } 268 }
276 269
277 views::View* TrayUser::CreateDefaultView(user::LoginStatus status) { 270 views::View* TrayUser::CreateDefaultView(user::LoginStatus status) {
278 if (status == user::LOGGED_IN_NONE) 271 if (status == user::LOGGED_IN_NONE)
279 return NULL; 272 return NULL;
280 273
281 user_.reset(new tray::UserView(status)); 274 user_.reset(new tray::UserView(status));
282 return user_.get(); 275 return user_.get();
283 } 276 }
284 277
285 views::View* TrayUser::CreateDetailedView(user::LoginStatus status) { 278 views::View* TrayUser::CreateDetailedView(user::LoginStatus status) {
286 return NULL; 279 return NULL;
287 } 280 }
288 281
289 void TrayUser::DestroyTrayView() { 282 void TrayUser::DestroyTrayView() {
290 avatar_.reset(); 283 avatar_.reset();
291 } 284 }
292 285
293 void TrayUser::DestroyDefaultView() { 286 void TrayUser::DestroyDefaultView() {
294 user_.reset(); 287 user_.reset();
295 } 288 }
296 289
297 void TrayUser::DestroyDetailedView() { 290 void TrayUser::DestroyDetailedView() {
298 } 291 }
299 292
293 void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) {
294 if (status != user::LOGGED_IN_NONE && status != user::LOGGED_IN_KIOSK &&
295 status != user::LOGGED_IN_GUEST) {
296 avatar_->SetImage(
297 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(),
298 gfx::Size(kUserIconSize, kUserIconSize));
299 avatar_->SetVisible(true);
300 } else {
301 avatar_->SetVisible(false);
302 }
303 }
304
300 void TrayUser::OnUserUpdate() { 305 void TrayUser::OnUserUpdate() {
301 avatar_->SetImage( 306 avatar_->SetImage(
302 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(), 307 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(),
303 gfx::Size(kUserIconSize, kUserIconSize)); 308 gfx::Size(kUserIconSize, kUserIconSize));
304 } 309 }
305 310
306 } // namespace internal 311 } // namespace internal
307 } // namespace ash 312 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/user/tray_user.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698