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 11 matching lines...) Expand all Loading... | |
| 22 using message_center::Notification; | 22 using message_center::Notification; |
| 23 | 23 |
| 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 } | 34 } |
| 34 | 35 |
| 35 TraySupervisedUser::~TraySupervisedUser() { | 36 TraySupervisedUser::~TraySupervisedUser() { |
| 36 } | 37 } |
| 37 | 38 |
| 38 void TraySupervisedUser::UpdateMessage() { | 39 void TraySupervisedUser::UpdateMessage() { |
| 39 base::string16 message = Shell::GetInstance()->system_tray_delegate()-> | 40 base::string16 message = Shell::GetInstance()->system_tray_delegate()-> |
| 40 GetSupervisedUserMessage(); | 41 GetSupervisedUserMessage(); |
| 41 if (tray_view_) | 42 if (tray_view_) |
| 42 tray_view_->SetMessage(message); | 43 tray_view_->SetMessage(message); |
| 43 if (message_center::MessageCenter::Get()->FindVisibleNotificationById( | 44 if (message_center::MessageCenter::Get()->FindVisibleNotificationById( |
| 44 kNotificationId)) | 45 kNotificationId)) |
| 45 CreateOrUpdateNotification(message); | 46 CreateOrUpdateNotification(message); |
| 46 } | 47 } |
| 47 | 48 |
| 48 views::View* TraySupervisedUser::CreateDefaultView( | 49 views::View* TraySupervisedUser::CreateDefaultView( |
| 49 user::LoginStatus status) { | 50 user::LoginStatus status) { |
| 50 CHECK(tray_view_ == NULL); | 51 CHECK(tray_view_ == NULL); |
| 51 if (status != ash::user::LOGGED_IN_SUPERVISED) | 52 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
| 53 if (!(status != ash::user::LOGGED_IN_SUPERVISED || | |
|
Marc Treib
2014/09/15 08:16:21
Should this be "==" instead of "!="?
merkulova
2014/09/18 08:51:29
Done.
| |
| 54 delegate->IsUserSupervised())) | |
| 52 return NULL; | 55 return NULL; |
| 53 | 56 |
| 54 tray_view_ = new LabelTrayView(this, IDR_AURA_UBER_TRAY_SUPERVISED_USER); | 57 tray_view_ = new LabelTrayView(this, IDR_AURA_UBER_TRAY_SUPERVISED_USER); |
| 55 UpdateMessage(); | 58 UpdateMessage(); |
| 56 return tray_view_; | 59 return tray_view_; |
| 57 } | 60 } |
| 58 | 61 |
| 59 void TraySupervisedUser::DestroyDefaultView() { | 62 void TraySupervisedUser::DestroyDefaultView() { |
| 60 tray_view_ = NULL; | 63 tray_view_ = NULL; |
| 61 } | 64 } |
| 62 | 65 |
| 63 void TraySupervisedUser::OnViewClicked(views::View* sender) { | 66 void TraySupervisedUser::OnViewClicked(views::View* sender) { |
| 64 Shell::GetInstance()->system_tray_delegate()->ShowSupervisedUserInfo(); | 67 Shell::GetInstance()->system_tray_delegate()->ShowSupervisedUserInfo(); |
| 65 } | 68 } |
| 66 | 69 |
| 67 void TraySupervisedUser::UpdateAfterLoginStatusChange( | 70 void TraySupervisedUser::UpdateAfterLoginStatusChange( |
| 68 user::LoginStatus status) { | 71 user::LoginStatus status) { |
| 69 if (status == status_) | 72 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
| 73 | |
| 74 bool is_user_supervised = status == ash::user::LOGGED_IN_SUPERVISED || | |
| 75 delegate->IsUserSupervised(); | |
| 76 if (status == status_ && is_user_supervised == is_user_supervised_) | |
| 70 return; | 77 return; |
| 71 if (status == ash::user::LOGGED_IN_SUPERVISED && | 78 |
| 79 if (is_user_supervised && | |
| 72 status_ != ash::user::LOGGED_IN_LOCKED) { | 80 status_ != ash::user::LOGGED_IN_LOCKED) { |
| 73 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | |
| 74 CreateOrUpdateNotification(delegate->GetSupervisedUserMessage()); | 81 CreateOrUpdateNotification(delegate->GetSupervisedUserMessage()); |
| 75 } | 82 } |
| 76 status_ = status; | 83 status_ = status; |
| 84 is_user_supervised_ = is_user_supervised; | |
| 77 } | 85 } |
| 78 | 86 |
| 79 void TraySupervisedUser::CreateOrUpdateNotification( | 87 void TraySupervisedUser::CreateOrUpdateNotification( |
| 80 const base::string16& new_message) { | 88 const base::string16& new_message) { |
| 81 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 89 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 82 scoped_ptr<Notification> notification( | 90 scoped_ptr<Notification> notification( |
| 83 message_center::Notification::CreateSystemNotification( | 91 message_center::Notification::CreateSystemNotification( |
| 84 kNotificationId, | 92 kNotificationId, |
| 85 base::string16() /* no title */, | 93 base::string16() /* no title */, |
| 86 new_message, | 94 new_message, |
| 87 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SUPERVISED_USER), | 95 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SUPERVISED_USER), |
| 88 system_notifier::kNotifierSupervisedUser, | 96 system_notifier::kNotifierSupervisedUser, |
| 89 base::Closure() /* null callback */)); | 97 base::Closure() /* null callback */)); |
| 90 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); | 98 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); |
| 91 } | 99 } |
| 92 | 100 |
| 93 } // namespace ash | 101 } // namespace ash |
| OLD | NEW |