Chromium Code Reviews| Index: ash/system/chromeos/supervised/tray_supervised_user.cc |
| diff --git a/ash/system/chromeos/supervised/tray_supervised_user.cc b/ash/system/chromeos/supervised/tray_supervised_user.cc |
| index 31ddb39b299836c79801a72b2a12a4854887e12e..b7eb89f2039a599eb1efc76460e42447d5e0bf10 100644 |
| --- a/ash/system/chromeos/supervised/tray_supervised_user.cc |
| +++ b/ash/system/chromeos/supervised/tray_supervised_user.cc |
| @@ -11,6 +11,7 @@ |
| #include "ash/system/tray/system_tray_notifier.h" |
| #include "ash/system/tray/tray_notification_view.h" |
| #include "ash/system/user/login_status.h" |
| +#include "base/bind.h" |
|
jennyz
2014/10/08 20:57:10
DO you need this include?
|
| #include "base/callback.h" |
| #include "base/logging.h" |
| #include "grit/ash_resources.h" |
| @@ -31,9 +32,13 @@ TraySupervisedUser::TraySupervisedUser(SystemTray* system_tray) |
| tray_view_(NULL), |
| status_(ash::user::LOGGED_IN_NONE), |
| is_user_supervised_(false) { |
| + Shell::GetInstance()->system_tray_delegate()-> |
| + AddCustodianInfoTrayObserver(this); |
| } |
| TraySupervisedUser::~TraySupervisedUser() { |
| + Shell::GetInstance()->system_tray_delegate()-> |
| + RemoveCustodianInfoTrayObserver(this); |
| } |
| void TraySupervisedUser::UpdateMessage() { |
| @@ -75,9 +80,10 @@ void TraySupervisedUser::UpdateAfterLoginStatusChange( |
| return; |
| if (is_user_supervised && |
| - status_ != ash::user::LOGGED_IN_LOCKED) { |
| - CreateOrUpdateNotification(delegate->GetSupervisedUserMessage()); |
| - } |
| + status_ != ash::user::LOGGED_IN_LOCKED && |
| + !delegate->GetSupervisedUserManager().empty()) |
| + CreateOrUpdateSupervisedWarningNotification(); |
| + |
| status_ = status; |
| is_user_supervised_ = is_user_supervised; |
| } |
| @@ -96,4 +102,20 @@ void TraySupervisedUser::CreateOrUpdateNotification( |
| message_center::MessageCenter::Get()->AddNotification(notification.Pass()); |
| } |
| +void TraySupervisedUser::CreateOrUpdateSupervisedWarningNotification() { |
| + SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
| + CreateOrUpdateNotification(delegate->GetSupervisedUserMessage()); |
| +} |
| + |
| +void TraySupervisedUser::OnCustodianInfoChanged() { |
| + SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
| + std::string manager_name = delegate->GetSupervisedUserManager(); |
| + if (!manager_name.empty()) { |
| + if (!message_center::MessageCenter::Get()->FindVisibleNotificationById( |
| + kNotificationId)) |
|
Daniel Erat
2014/10/08 14:10:46
this line should be indented four more spaces, i b
|
| + CreateOrUpdateSupervisedWarningNotification(); |
| + UpdateMessage(); |
| + } |
| +} |
| + |
| } // namespace ash |