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

Unified Diff: ash/system/chromeos/supervised/tray_supervised_user.cc

Issue 627593003: Adding infrastructure for possibility of changing manager names for the supervised accounts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Default system tray extended for proper tests support. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
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..aa47fcfd7997969f9526ced8bf2035644d294b43 100644
--- a/ash/system/chromeos/supervised/tray_supervised_user.cc
+++ b/ash/system/chromeos/supervised/tray_supervised_user.cc
@@ -31,9 +31,16 @@ 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() {
+ // We need the check as on shell destruction delegate is destroyed first.
+ SystemTrayDelegate* system_tray_delegate =
+ Shell::GetInstance()->system_tray_delegate();
+ if (system_tray_delegate)
+ system_tray_delegate->RemoveCustodianInfoTrayObserver(this);
}
void TraySupervisedUser::UpdateMessage() {
@@ -75,9 +82,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 +104,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))
+ CreateOrUpdateSupervisedWarningNotification();
+ UpdateMessage();
+ }
+}
+
} // namespace ash
« no previous file with comments | « ash/system/chromeos/supervised/tray_supervised_user.h ('k') | ash/system/tray/default_system_tray_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698