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

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

Issue 10918215: Refresh Guest session UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 8 years, 3 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') | chrome/app/theme/default_100_percent/guest_icon.png » ('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/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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 244
245 views::Button* signout_; 245 views::Button* signout_;
246 246
247 DISALLOW_COPY_AND_ASSIGN(UserView); 247 DISALLOW_COPY_AND_ASSIGN(UserView);
248 }; 248 };
249 249
250 } // namespace tray 250 } // namespace tray
251 251
252 TrayUser::TrayUser() 252 TrayUser::TrayUser()
253 : user_(NULL), 253 : user_(NULL),
254 avatar_(NULL) { 254 avatar_(NULL),
255 label_(NULL) {
255 } 256 }
256 257
257 TrayUser::~TrayUser() { 258 TrayUser::~TrayUser() {
258 } 259 }
259 260
260 views::View* TrayUser::CreateTrayView(user::LoginStatus status) { 261 views::View* TrayUser::CreateTrayView(user::LoginStatus status) {
261 CHECK(avatar_ == NULL); 262 CHECK(avatar_ == NULL);
262 avatar_ = new tray::RoundedImageView(kTrayRoundedBorderRadius); 263 CHECK(label_ == NULL);
264 if (status == user::LOGGED_IN_GUEST) {
265 label_ = new views::Label;
266 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
267 label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_GUEST_LABEL));
268 SetupLabelForTray(label_);
269 } else {
270 avatar_ = new tray::RoundedImageView(kTrayRoundedBorderRadius);
271 }
263 UpdateAfterLoginStatusChange(status); 272 UpdateAfterLoginStatusChange(status);
264 return avatar_; 273 return avatar_ ? static_cast<views::View*>(avatar_)
274 : static_cast<views::View*>(label_);
sadrul 2012/09/13 17:11:32 Do you need the cast here?
Dmitry Polukhin 2012/09/13 17:24:16 Unfortunately, yes. Without these casts compiler r
265 } 275 }
266 276
267 views::View* TrayUser::CreateDefaultView(user::LoginStatus status) { 277 views::View* TrayUser::CreateDefaultView(user::LoginStatus status) {
268 if (status == user::LOGGED_IN_NONE) 278 if (status == user::LOGGED_IN_NONE)
269 return NULL; 279 return NULL;
270 280
271 CHECK(user_ == NULL); 281 CHECK(user_ == NULL);
272 user_ = new tray::UserView(status); 282 user_ = new tray::UserView(status);
273 return user_; 283 return user_;
274 } 284 }
275 285
276 views::View* TrayUser::CreateDetailedView(user::LoginStatus status) { 286 views::View* TrayUser::CreateDetailedView(user::LoginStatus status) {
277 return NULL; 287 return NULL;
278 } 288 }
279 289
280 void TrayUser::DestroyTrayView() { 290 void TrayUser::DestroyTrayView() {
281 avatar_ = NULL; 291 avatar_ = NULL;
292 label_ = NULL;
282 } 293 }
283 294
284 void TrayUser::DestroyDefaultView() { 295 void TrayUser::DestroyDefaultView() {
285 user_ = NULL; 296 user_ = NULL;
286 } 297 }
287 298
288 void TrayUser::DestroyDetailedView() { 299 void TrayUser::DestroyDetailedView() {
289 } 300 }
290 301
291 void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) { 302 void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) {
292 if (status != user::LOGGED_IN_NONE && status != user::LOGGED_IN_KIOSK && 303 switch (status) {
293 status != user::LOGGED_IN_GUEST) { 304 case user::LOGGED_IN_LOCKED:
294 avatar_->SetImage( 305 case user::LOGGED_IN_USER:
295 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(), 306 case user::LOGGED_IN_OWNER:
296 gfx::Size(kUserIconSize, kUserIconSize)); 307 avatar_->SetImage(
297 avatar_->SetVisible(true); 308 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(),
298 } else { 309 gfx::Size(kUserIconSize, kUserIconSize));
299 avatar_->SetVisible(false); 310 avatar_->SetVisible(true);
311 break;
312
313 case user::LOGGED_IN_GUEST:
314 label_->SetVisible(true);
315 break;
316
317 case user::LOGGED_IN_KIOSK:
318 case user::LOGGED_IN_NONE:
319 avatar_->SetVisible(false);
320 break;
300 } 321 }
301 } 322 }
302 323
303 void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { 324 void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
304 SetTrayImageItemBorder(avatar_, alignment); 325 if (avatar_) {
326 SetTrayImageItemBorder(avatar_, alignment);
327 } else {
328 if (alignment == SHELF_ALIGNMENT_BOTTOM) {
329 label_->set_border(views::Border::CreateEmptyBorder(
330 0, kTrayLabelItemHorizontalPaddingBottomAlignment,
331 0, kTrayLabelItemHorizontalPaddingBottomAlignment));
332 } else {
333 label_->set_border(views::Border::CreateEmptyBorder(
334 kTrayLabelItemVerticalPaddingVeriticalAlignment,
335 kTrayLabelItemHorizontalPaddingBottomAlignment,
336 kTrayLabelItemVerticalPaddingVeriticalAlignment,
337 kTrayLabelItemHorizontalPaddingBottomAlignment));
338 }
339 }
305 } 340 }
306 341
307 void TrayUser::OnUserUpdate() { 342 void TrayUser::OnUserUpdate() {
308 avatar_->SetImage( 343 avatar_->SetImage(
309 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(), 344 ash::Shell::GetInstance()->tray_delegate()->GetUserImage(),
310 gfx::Size(kUserIconSize, kUserIconSize)); 345 gfx::Size(kUserIconSize, kUserIconSize));
311 } 346 }
312 347
313 } // namespace internal 348 } // namespace internal
314 } // namespace ash 349 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/user/tray_user.h ('k') | chrome/app/theme/default_100_percent/guest_icon.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698