| OLD | NEW |
| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <climits> | 8 #include <climits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 void AddLoggedInPublicModeUserCardContent(SystemTrayItem* owner); | 266 void AddLoggedInPublicModeUserCardContent(SystemTrayItem* owner); |
| 267 | 267 |
| 268 // Create the menu option to add another user. If |disabled| is set the user | 268 // Create the menu option to add another user. If |disabled| is set the user |
| 269 // cannot actively click on the item. | 269 // cannot actively click on the item. |
| 270 void ToggleAddUserMenuOption(); | 270 void ToggleAddUserMenuOption(); |
| 271 | 271 |
| 272 MultiProfileIndex multiprofile_index_; | 272 MultiProfileIndex multiprofile_index_; |
| 273 // The view of the user card. | 273 // The view of the user card. |
| 274 views::View* user_card_view_; | 274 views::View* user_card_view_; |
| 275 | 275 |
| 276 // This is the owner system tray item of this view. |
| 277 SystemTrayItem* owner_; |
| 278 |
| 276 // True if |user_card_view_| is a |UserView| - otherwise it is only a | 279 // True if |user_card_view_| is a |UserView| - otherwise it is only a |
| 277 // |views::View|. | 280 // |views::View|. |
| 278 bool is_user_card_; | 281 bool is_user_card_; |
| 279 views::View* logout_button_; | 282 views::View* logout_button_; |
| 280 scoped_ptr<ash::PopupMessage> popup_message_; | 283 scoped_ptr<ash::PopupMessage> popup_message_; |
| 281 scoped_ptr<views::Widget> add_menu_option_; | 284 scoped_ptr<views::Widget> add_menu_option_; |
| 282 | 285 |
| 283 // True when the add user panel is visible but not activatable. | 286 // True when the add user panel is visible but not activatable. |
| 284 bool add_user_visible_but_disabled_; | 287 bool add_user_visible_but_disabled_; |
| 285 | 288 |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 set_border(views::Border::CreateSolidSidedBorder(width, width, width, 1, | 591 set_border(views::Border::CreateSolidSidedBorder(width, width, width, 1, |
| 589 kBorderColor)); | 592 kBorderColor)); |
| 590 SchedulePaint(); | 593 SchedulePaint(); |
| 591 } | 594 } |
| 592 | 595 |
| 593 UserView::UserView(SystemTrayItem* owner, | 596 UserView::UserView(SystemTrayItem* owner, |
| 594 ash::user::LoginStatus login, | 597 ash::user::LoginStatus login, |
| 595 MultiProfileIndex index) | 598 MultiProfileIndex index) |
| 596 : multiprofile_index_(index), | 599 : multiprofile_index_(index), |
| 597 user_card_view_(NULL), | 600 user_card_view_(NULL), |
| 601 owner_(owner), |
| 598 is_user_card_(false), | 602 is_user_card_(false), |
| 599 logout_button_(NULL), | 603 logout_button_(NULL), |
| 600 add_user_visible_but_disabled_(false) { | 604 add_user_visible_but_disabled_(false) { |
| 601 CHECK_NE(ash::user::LOGGED_IN_NONE, login); | 605 CHECK_NE(ash::user::LOGGED_IN_NONE, login); |
| 602 if (!index) { | 606 if (!index) { |
| 603 // Only the logged in user will have a background. All other users will have | 607 // Only the logged in user will have a background. All other users will have |
| 604 // to allow the TrayPopupContainer highlighting the menu line. | 608 // to allow the TrayPopupContainer highlighting the menu line. |
| 605 set_background(views::Background::CreateSolidBackground( | 609 set_background(views::Background::CreateSolidBackground( |
| 606 login == ash::user::LOGGED_IN_PUBLIC ? kPublicAccountBackgroundColor : | 610 login == ash::user::LOGGED_IN_PUBLIC ? kPublicAccountBackgroundColor : |
| 607 kBackgroundColor)); | 611 kBackgroundColor)); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 if (sender == logout_button_) { | 707 if (sender == logout_button_) { |
| 704 ash::Shell::GetInstance()->system_tray_delegate()->SignOut(); | 708 ash::Shell::GetInstance()->system_tray_delegate()->SignOut(); |
| 705 } else if (sender == user_card_view_ && | 709 } else if (sender == user_card_view_ && |
| 706 ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) { | 710 ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) { |
| 707 if (!multiprofile_index_) { | 711 if (!multiprofile_index_) { |
| 708 ToggleAddUserMenuOption(); | 712 ToggleAddUserMenuOption(); |
| 709 } else { | 713 } else { |
| 710 ash::SessionStateDelegate* delegate = | 714 ash::SessionStateDelegate* delegate = |
| 711 ash::Shell::GetInstance()->session_state_delegate(); | 715 ash::Shell::GetInstance()->session_state_delegate(); |
| 712 delegate->SwitchActiveUser(delegate->GetUserEmail(multiprofile_index_)); | 716 delegate->SwitchActiveUser(delegate->GetUserEmail(multiprofile_index_)); |
| 717 // Since the user list is about to change the system menu should get |
| 718 // closed. |
| 719 owner_->system_tray()->CloseSystemBubble(); |
| 713 } | 720 } |
| 714 } else if (add_menu_option_.get() && | 721 } else if (add_menu_option_.get() && |
| 715 sender == add_menu_option_->GetContentsView()) { | 722 sender == add_menu_option_->GetContentsView()) { |
| 716 // Let the user add another account to the session. | 723 // Let the user add another account to the session. |
| 717 ash::Shell::GetInstance()->system_tray_delegate()->ShowUserLogin(); | 724 ash::Shell::GetInstance()->system_tray_delegate()->ShowUserLogin(); |
| 718 } else { | 725 } else { |
| 719 NOTREACHED(); | 726 NOTREACHED(); |
| 720 } | 727 } |
| 721 } | 728 } |
| 722 | 729 |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 if (avatar_) { | 1220 if (avatar_) { |
| 1214 avatar_->SetImage( | 1221 avatar_->SetImage( |
| 1215 ash::Shell::GetInstance()->session_state_delegate()->GetUserImage( | 1222 ash::Shell::GetInstance()->session_state_delegate()->GetUserImage( |
| 1216 multiprofile_index_), | 1223 multiprofile_index_), |
| 1217 gfx::Size(kUserIconSize, kUserIconSize)); | 1224 gfx::Size(kUserIconSize, kUserIconSize)); |
| 1218 } | 1225 } |
| 1219 } | 1226 } |
| 1220 | 1227 |
| 1221 } // namespace internal | 1228 } // namespace internal |
| 1222 } // namespace ash | 1229 } // namespace ash |
| OLD | NEW |