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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/supervised/tray_supervised_user.h" 5 #include "ash/system/chromeos/supervised/tray_supervised_user.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/chromeos/label_tray_view.h" 8 #include "ash/system/chromeos/label_tray_view.h"
9 #include "ash/system/system_notifier.h" 9 #include "ash/system/system_notifier.h"
10 #include "ash/system/tray/system_tray_delegate.h" 10 #include "ash/system/tray/system_tray_delegate.h"
(...skipping 13 matching lines...) Expand all
24 namespace ash { 24 namespace ash {
25 25
26 const char TraySupervisedUser::kNotificationId[] = 26 const char TraySupervisedUser::kNotificationId[] =
27 "chrome://user/locally-managed"; 27 "chrome://user/locally-managed";
28 28
29 TraySupervisedUser::TraySupervisedUser(SystemTray* system_tray) 29 TraySupervisedUser::TraySupervisedUser(SystemTray* system_tray)
30 : SystemTrayItem(system_tray), 30 : SystemTrayItem(system_tray),
31 tray_view_(NULL), 31 tray_view_(NULL),
32 status_(ash::user::LOGGED_IN_NONE), 32 status_(ash::user::LOGGED_IN_NONE),
33 is_user_supervised_(false) { 33 is_user_supervised_(false) {
34 Shell::GetInstance()->system_tray_delegate()->
35 AddCustodianInfoTrayObserver(this);
34 } 36 }
35 37
36 TraySupervisedUser::~TraySupervisedUser() { 38 TraySupervisedUser::~TraySupervisedUser() {
39 // We need the check as on shell destruction delegate is destroyed first.
40 SystemTrayDelegate* system_tray_delegate =
41 Shell::GetInstance()->system_tray_delegate();
42 if (system_tray_delegate)
43 system_tray_delegate->RemoveCustodianInfoTrayObserver(this);
37 } 44 }
38 45
39 void TraySupervisedUser::UpdateMessage() { 46 void TraySupervisedUser::UpdateMessage() {
40 base::string16 message = Shell::GetInstance()->system_tray_delegate()-> 47 base::string16 message = Shell::GetInstance()->system_tray_delegate()->
41 GetSupervisedUserMessage(); 48 GetSupervisedUserMessage();
42 if (tray_view_) 49 if (tray_view_)
43 tray_view_->SetMessage(message); 50 tray_view_->SetMessage(message);
44 if (message_center::MessageCenter::Get()->FindVisibleNotificationById( 51 if (message_center::MessageCenter::Get()->FindVisibleNotificationById(
45 kNotificationId)) 52 kNotificationId))
46 CreateOrUpdateNotification(message); 53 CreateOrUpdateNotification(message);
(...skipping 21 matching lines...) Expand all
68 75
69 void TraySupervisedUser::UpdateAfterLoginStatusChange( 76 void TraySupervisedUser::UpdateAfterLoginStatusChange(
70 user::LoginStatus status) { 77 user::LoginStatus status) {
71 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); 78 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
72 79
73 bool is_user_supervised = delegate->IsUserSupervised(); 80 bool is_user_supervised = delegate->IsUserSupervised();
74 if (status == status_ && is_user_supervised == is_user_supervised_) 81 if (status == status_ && is_user_supervised == is_user_supervised_)
75 return; 82 return;
76 83
77 if (is_user_supervised && 84 if (is_user_supervised &&
78 status_ != ash::user::LOGGED_IN_LOCKED) { 85 status_ != ash::user::LOGGED_IN_LOCKED &&
79 CreateOrUpdateNotification(delegate->GetSupervisedUserMessage()); 86 !delegate->GetSupervisedUserManager().empty())
80 } 87 CreateOrUpdateSupervisedWarningNotification();
88
81 status_ = status; 89 status_ = status;
82 is_user_supervised_ = is_user_supervised; 90 is_user_supervised_ = is_user_supervised;
83 } 91 }
84 92
85 void TraySupervisedUser::CreateOrUpdateNotification( 93 void TraySupervisedUser::CreateOrUpdateNotification(
86 const base::string16& new_message) { 94 const base::string16& new_message) {
87 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 95 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
88 scoped_ptr<Notification> notification( 96 scoped_ptr<Notification> notification(
89 message_center::Notification::CreateSystemNotification( 97 message_center::Notification::CreateSystemNotification(
90 kNotificationId, 98 kNotificationId,
91 base::string16() /* no title */, 99 base::string16() /* no title */,
92 new_message, 100 new_message,
93 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SUPERVISED_USER), 101 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SUPERVISED_USER),
94 system_notifier::kNotifierSupervisedUser, 102 system_notifier::kNotifierSupervisedUser,
95 base::Closure() /* null callback */)); 103 base::Closure() /* null callback */));
96 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); 104 message_center::MessageCenter::Get()->AddNotification(notification.Pass());
97 } 105 }
98 106
107 void TraySupervisedUser::CreateOrUpdateSupervisedWarningNotification() {
108 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
109 CreateOrUpdateNotification(delegate->GetSupervisedUserMessage());
110 }
111
112 void TraySupervisedUser::OnCustodianInfoChanged() {
113 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
114 std::string manager_name = delegate->GetSupervisedUserManager();
115 if (!manager_name.empty()) {
116 if (!message_center::MessageCenter::Get()->FindVisibleNotificationById(
117 kNotificationId))
118 CreateOrUpdateSupervisedWarningNotification();
119 UpdateMessage();
120 }
121 }
122
99 } // namespace ash 123 } // namespace ash
OLDNEW
« 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