Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 CreateOrUpdateNotification(message); | 53 CreateOrUpdateNotification(message); |
| 54 } | 54 } |
| 55 | 55 |
| 56 views::View* TraySupervisedUser::CreateDefaultView( | 56 views::View* TraySupervisedUser::CreateDefaultView( |
| 57 user::LoginStatus status) { | 57 user::LoginStatus status) { |
| 58 CHECK(tray_view_ == NULL); | 58 CHECK(tray_view_ == NULL); |
| 59 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 59 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
| 60 if (!delegate->IsUserSupervised()) | 60 if (!delegate->IsUserSupervised()) |
| 61 return NULL; | 61 return NULL; |
| 62 | 62 |
| 63 tray_view_ = new LabelTrayView(this, IDR_AURA_UBER_TRAY_SUPERVISED_USER); | 63 tray_view_ = new LabelTrayView(this, GetSupervisedUserIconId()); |
| 64 UpdateMessage(); | 64 UpdateMessage(); |
| 65 return tray_view_; | 65 return tray_view_; |
| 66 } | 66 } |
| 67 | 67 |
| 68 void TraySupervisedUser::DestroyDefaultView() { | 68 void TraySupervisedUser::DestroyDefaultView() { |
| 69 tray_view_ = NULL; | 69 tray_view_ = NULL; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void TraySupervisedUser::OnViewClicked(views::View* sender) { | 72 void TraySupervisedUser::OnViewClicked(views::View* sender) { |
| 73 Shell::GetInstance()->system_tray_delegate()->ShowSupervisedUserInfo(); | 73 Shell::GetInstance()->system_tray_delegate()->ShowSupervisedUserInfo(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 89 | 89 |
| 90 status_ = status; | 90 status_ = status; |
| 91 is_user_supervised_ = is_user_supervised; | 91 is_user_supervised_ = is_user_supervised; |
| 92 } | 92 } |
| 93 | 93 |
| 94 void TraySupervisedUser::CreateOrUpdateNotification( | 94 void TraySupervisedUser::CreateOrUpdateNotification( |
| 95 const base::string16& new_message) { | 95 const base::string16& new_message) { |
| 96 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 96 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 97 scoped_ptr<Notification> notification( | 97 scoped_ptr<Notification> notification( |
| 98 message_center::Notification::CreateSystemNotification( | 98 message_center::Notification::CreateSystemNotification( |
| 99 kNotificationId, | 99 kNotificationId, base::string16() /* no title */, new_message, |
| 100 base::string16() /* no title */, | 100 bundle.GetImageNamed(GetSupervisedUserIconId()), |
| 101 new_message, | |
| 102 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SUPERVISED_USER), | |
| 103 system_notifier::kNotifierSupervisedUser, | 101 system_notifier::kNotifierSupervisedUser, |
| 104 base::Closure() /* null callback */)); | 102 base::Closure() /* null callback */)); |
| 105 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); | 103 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); |
| 106 } | 104 } |
| 107 | 105 |
| 108 void TraySupervisedUser::CreateOrUpdateSupervisedWarningNotification() { | 106 void TraySupervisedUser::CreateOrUpdateSupervisedWarningNotification() { |
| 109 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 107 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
| 110 CreateOrUpdateNotification(delegate->GetSupervisedUserMessage()); | 108 CreateOrUpdateNotification(delegate->GetSupervisedUserMessage()); |
| 111 } | 109 } |
| 112 | 110 |
| 113 void TraySupervisedUser::OnCustodianInfoChanged() { | 111 void TraySupervisedUser::OnCustodianInfoChanged() { |
| 114 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 112 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
| 115 std::string manager_name = delegate->GetSupervisedUserManager(); | 113 std::string manager_name = delegate->GetSupervisedUserManager(); |
| 116 if (!manager_name.empty()) { | 114 if (!manager_name.empty()) { |
| 117 if (!delegate->IsUserChild() && | 115 if (!delegate->IsUserChild() && |
| 118 !message_center::MessageCenter::Get()->FindVisibleNotificationById( | 116 !message_center::MessageCenter::Get()->FindVisibleNotificationById( |
| 119 kNotificationId)) { | 117 kNotificationId)) { |
| 120 CreateOrUpdateSupervisedWarningNotification(); | 118 CreateOrUpdateSupervisedWarningNotification(); |
| 121 } | 119 } |
| 122 UpdateMessage(); | 120 UpdateMessage(); |
| 123 } | 121 } |
| 124 } | 122 } |
| 125 | 123 |
| 124 int TraySupervisedUser::GetSupervisedUserIconId() { | |
|
oshima
2015/01/27 10:36:47
can this be const?
merkulova
2015/01/27 16:39:47
Done.
| |
| 125 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | |
| 126 | |
| 127 if (delegate->IsUserChild()) | |
| 128 return IDR_AURA_UBER_TRAY_CHILD_USER; | |
| 129 else if (delegate->IsUserSupervised()) | |
| 130 return IDR_AURA_UBER_TRAY_SUPERVISED_USER; | |
| 131 return -1; | |
| 132 } | |
| 133 | |
| 126 } // namespace ash | 134 } // namespace ash |
| OLD | NEW |