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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/system/chromeos/label_tray_view.h" | 10 #include "ash/system/chromeos/label_tray_view.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 using message_center::Notification; | 24 using message_center::Notification; |
25 | 25 |
26 namespace ash { | 26 namespace ash { |
27 | 27 |
28 const char TraySupervisedUser::kNotificationId[] = | 28 const char TraySupervisedUser::kNotificationId[] = |
29 "chrome://user/locally-managed"; | 29 "chrome://user/locally-managed"; |
30 | 30 |
31 TraySupervisedUser::TraySupervisedUser(SystemTray* system_tray) | 31 TraySupervisedUser::TraySupervisedUser(SystemTray* system_tray) |
32 : SystemTrayItem(system_tray), | 32 : SystemTrayItem(system_tray), |
33 tray_view_(NULL), | 33 tray_view_(NULL), |
34 status_(ash::user::LOGGED_IN_NONE), | 34 status_(LoginStatus::NOT_LOGGED_IN), |
35 is_user_supervised_(false) { | 35 is_user_supervised_(false) { |
36 Shell::GetInstance()->system_tray_delegate()-> | 36 Shell::GetInstance()->system_tray_delegate()-> |
37 AddCustodianInfoTrayObserver(this); | 37 AddCustodianInfoTrayObserver(this); |
38 } | 38 } |
39 | 39 |
40 TraySupervisedUser::~TraySupervisedUser() { | 40 TraySupervisedUser::~TraySupervisedUser() { |
41 // We need the check as on shell destruction delegate is destroyed first. | 41 // We need the check as on shell destruction delegate is destroyed first. |
42 SystemTrayDelegate* system_tray_delegate = | 42 SystemTrayDelegate* system_tray_delegate = |
43 Shell::GetInstance()->system_tray_delegate(); | 43 Shell::GetInstance()->system_tray_delegate(); |
44 if (system_tray_delegate) | 44 if (system_tray_delegate) |
45 system_tray_delegate->RemoveCustodianInfoTrayObserver(this); | 45 system_tray_delegate->RemoveCustodianInfoTrayObserver(this); |
46 } | 46 } |
47 | 47 |
48 void TraySupervisedUser::UpdateMessage() { | 48 void TraySupervisedUser::UpdateMessage() { |
49 base::string16 message = Shell::GetInstance()->system_tray_delegate()-> | 49 base::string16 message = Shell::GetInstance()->system_tray_delegate()-> |
50 GetSupervisedUserMessage(); | 50 GetSupervisedUserMessage(); |
51 if (tray_view_) | 51 if (tray_view_) |
52 tray_view_->SetMessage(message); | 52 tray_view_->SetMessage(message); |
53 if (message_center::MessageCenter::Get()->FindVisibleNotificationById( | 53 if (message_center::MessageCenter::Get()->FindVisibleNotificationById( |
54 kNotificationId)) | 54 kNotificationId)) |
55 CreateOrUpdateNotification(message); | 55 CreateOrUpdateNotification(message); |
56 } | 56 } |
57 | 57 |
58 views::View* TraySupervisedUser::CreateDefaultView( | 58 views::View* TraySupervisedUser::CreateDefaultView(LoginStatus status) { |
59 user::LoginStatus status) { | |
60 CHECK(tray_view_ == NULL); | 59 CHECK(tray_view_ == NULL); |
61 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 60 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
62 if (!delegate->IsUserSupervised()) | 61 if (!delegate->IsUserSupervised()) |
63 return NULL; | 62 return NULL; |
64 | 63 |
65 tray_view_ = new LabelTrayView(this, GetSupervisedUserIconId()); | 64 tray_view_ = new LabelTrayView(this, GetSupervisedUserIconId()); |
66 UpdateMessage(); | 65 UpdateMessage(); |
67 return tray_view_; | 66 return tray_view_; |
68 } | 67 } |
69 | 68 |
70 void TraySupervisedUser::DestroyDefaultView() { | 69 void TraySupervisedUser::DestroyDefaultView() { |
71 tray_view_ = NULL; | 70 tray_view_ = NULL; |
72 } | 71 } |
73 | 72 |
74 void TraySupervisedUser::OnViewClicked(views::View* sender) { | 73 void TraySupervisedUser::OnViewClicked(views::View* sender) { |
75 Shell::GetInstance()->system_tray_delegate()->ShowSupervisedUserInfo(); | 74 Shell::GetInstance()->system_tray_delegate()->ShowSupervisedUserInfo(); |
76 } | 75 } |
77 | 76 |
78 void TraySupervisedUser::UpdateAfterLoginStatusChange( | 77 void TraySupervisedUser::UpdateAfterLoginStatusChange(LoginStatus status) { |
79 user::LoginStatus status) { | |
80 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 78 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
81 | 79 |
82 bool is_user_supervised = delegate->IsUserSupervised(); | 80 bool is_user_supervised = delegate->IsUserSupervised(); |
83 if (status == status_ && is_user_supervised == is_user_supervised_) | 81 if (status == status_ && is_user_supervised == is_user_supervised_) |
84 return; | 82 return; |
85 | 83 |
86 if (is_user_supervised && | 84 if (is_user_supervised && !delegate->IsUserChild() && |
87 !delegate->IsUserChild() && | 85 status_ != LoginStatus::LOCKED && |
88 status_ != ash::user::LOGGED_IN_LOCKED && | |
89 !delegate->GetSupervisedUserManager().empty()) | 86 !delegate->GetSupervisedUserManager().empty()) |
90 CreateOrUpdateSupervisedWarningNotification(); | 87 CreateOrUpdateSupervisedWarningNotification(); |
91 | 88 |
92 status_ = status; | 89 status_ = status; |
93 is_user_supervised_ = is_user_supervised; | 90 is_user_supervised_ = is_user_supervised; |
94 } | 91 } |
95 | 92 |
96 void TraySupervisedUser::CreateOrUpdateNotification( | 93 void TraySupervisedUser::CreateOrUpdateNotification( |
97 const base::string16& new_message) { | 94 const base::string16& new_message) { |
98 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 95 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
(...skipping 30 matching lines...) Expand all Loading... |
129 | 126 |
130 // Not intended to be used for non-supervised users. | 127 // Not intended to be used for non-supervised users. |
131 CHECK(delegate->IsUserSupervised()); | 128 CHECK(delegate->IsUserSupervised()); |
132 | 129 |
133 if (delegate->IsUserChild()) | 130 if (delegate->IsUserChild()) |
134 return IDR_AURA_UBER_TRAY_CHILD_USER; | 131 return IDR_AURA_UBER_TRAY_CHILD_USER; |
135 return IDR_AURA_UBER_TRAY_SUPERVISED_USER; | 132 return IDR_AURA_UBER_TRAY_SUPERVISED_USER; |
136 } | 133 } |
137 | 134 |
138 } // namespace ash | 135 } // namespace ash |
OLD | NEW |