| 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/chromeos/managed/tray_locally_managed_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_notifier.h" | 10 #include "ash/system/tray/system_tray_notifier.h" |
| 11 #include "ash/system/tray/tray_notification_view.h" | 11 #include "ash/system/tray/tray_notification_view.h" |
| 12 #include "ash/system/user/login_status.h" | 12 #include "ash/system/user/login_status.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "grit/ash_resources.h" | 15 #include "grit/ash_resources.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/message_center/message_center.h" | 17 #include "ui/message_center/message_center.h" |
| 18 #include "ui/message_center/notification.h" | 18 #include "ui/message_center/notification.h" |
| 19 #include "ui/message_center/notification_delegate.h" | 19 #include "ui/message_center/notification_delegate.h" |
| 20 | 20 |
| 21 using message_center::Notification; | 21 using message_center::Notification; |
| 22 | 22 |
| 23 namespace ash { | 23 namespace ash { |
| 24 | 24 |
| 25 const char TrayLocallyManagedUser::kNotificationId[] = | 25 const char TraySupervisedUser::kNotificationId[] = |
| 26 "chrome://user/locally-managed"; | 26 "chrome://user/locally-managed"; |
| 27 | 27 |
| 28 TrayLocallyManagedUser::TrayLocallyManagedUser(SystemTray* system_tray) | 28 TraySupervisedUser::TraySupervisedUser(SystemTray* system_tray) |
| 29 : SystemTrayItem(system_tray), | 29 : SystemTrayItem(system_tray), |
| 30 tray_view_(NULL), | 30 tray_view_(NULL), |
| 31 status_(ash::user::LOGGED_IN_NONE) { | 31 status_(ash::user::LOGGED_IN_NONE) { |
| 32 } | 32 } |
| 33 | 33 |
| 34 TrayLocallyManagedUser::~TrayLocallyManagedUser() { | 34 TraySupervisedUser::~TraySupervisedUser() { |
| 35 } | 35 } |
| 36 | 36 |
| 37 void TrayLocallyManagedUser::UpdateMessage() { | 37 void TraySupervisedUser::UpdateMessage() { |
| 38 base::string16 message = Shell::GetInstance()->system_tray_delegate()-> | 38 base::string16 message = Shell::GetInstance()->system_tray_delegate()-> |
| 39 GetLocallyManagedUserMessage(); | 39 GetSupervisedUserMessage(); |
| 40 if (tray_view_) | 40 if (tray_view_) |
| 41 tray_view_->SetMessage(message); | 41 tray_view_->SetMessage(message); |
| 42 if (message_center::MessageCenter::Get()->FindVisibleNotificationById( | 42 if (message_center::MessageCenter::Get()->FindVisibleNotificationById( |
| 43 kNotificationId)) | 43 kNotificationId)) |
| 44 CreateOrUpdateNotification(message); | 44 CreateOrUpdateNotification(message); |
| 45 } | 45 } |
| 46 | 46 |
| 47 views::View* TrayLocallyManagedUser::CreateDefaultView( | 47 views::View* TraySupervisedUser::CreateDefaultView( |
| 48 user::LoginStatus status) { | 48 user::LoginStatus status) { |
| 49 CHECK(tray_view_ == NULL); | 49 CHECK(tray_view_ == NULL); |
| 50 if (status != ash::user::LOGGED_IN_LOCALLY_MANAGED) | 50 if (status != ash::user::LOGGED_IN_SUPERVISED) |
| 51 return NULL; | 51 return NULL; |
| 52 | 52 |
| 53 tray_view_ = new LabelTrayView(this, IDR_AURA_UBER_TRAY_MANAGED_USER); | 53 tray_view_ = new LabelTrayView(this, IDR_AURA_UBER_TRAY_MANAGED_USER); |
| 54 UpdateMessage(); | 54 UpdateMessage(); |
| 55 return tray_view_; | 55 return tray_view_; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void TrayLocallyManagedUser::DestroyDefaultView() { | 58 void TraySupervisedUser::DestroyDefaultView() { |
| 59 tray_view_ = NULL; | 59 tray_view_ = NULL; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void TrayLocallyManagedUser::OnViewClicked(views::View* sender) { | 62 void TraySupervisedUser::OnViewClicked(views::View* sender) { |
| 63 Shell::GetInstance()->system_tray_delegate()->ShowLocallyManagedUserInfo(); | 63 Shell::GetInstance()->system_tray_delegate()->ShowSupervisedUserInfo(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void TrayLocallyManagedUser::UpdateAfterLoginStatusChange( | 66 void TraySupervisedUser::UpdateAfterLoginStatusChange( |
| 67 user::LoginStatus status) { | 67 user::LoginStatus status) { |
| 68 if (status == status_) | 68 if (status == status_) |
| 69 return; | 69 return; |
| 70 if (status == ash::user::LOGGED_IN_LOCALLY_MANAGED && | 70 if (status == ash::user::LOGGED_IN_SUPERVISED && |
| 71 status_ != ash::user::LOGGED_IN_LOCKED) { | 71 status_ != ash::user::LOGGED_IN_LOCKED) { |
| 72 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 72 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
| 73 CreateOrUpdateNotification(delegate->GetLocallyManagedUserMessage()); | 73 CreateOrUpdateNotification(delegate->GetSupervisedUserMessage()); |
| 74 } | 74 } |
| 75 status_ = status; | 75 status_ = status; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void TrayLocallyManagedUser::CreateOrUpdateNotification( | 78 void TraySupervisedUser::CreateOrUpdateNotification( |
| 79 const base::string16& new_message) { | 79 const base::string16& new_message) { |
| 80 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 80 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 81 scoped_ptr<Notification> notification( | 81 scoped_ptr<Notification> notification( |
| 82 message_center::Notification::CreateSystemNotification( | 82 message_center::Notification::CreateSystemNotification( |
| 83 kNotificationId, | 83 kNotificationId, |
| 84 base::string16() /* no title */, | 84 base::string16() /* no title */, |
| 85 new_message, | 85 new_message, |
| 86 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_MANAGED_USER), | 86 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_MANAGED_USER), |
| 87 system_notifier::kNotifierLocallyManagedUser, | 87 system_notifier::kNotifierSupervisedUser, |
| 88 base::Closure() /* null callback */)); | 88 base::Closure() /* null callback */)); |
| 89 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); | 89 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace ash | 92 } // namespace ash |
| OLD | NEW |