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

Side by Side Diff: ash/system/supervised/tray_supervised_user.cc

Issue 2829813002: cros: Move IsUserSupervised and IsUserChild off SystemTrayDelegate (Closed)
Patch Set: review comments Created 3 years, 8 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
« no previous file with comments | « ash/shelf/wm_shelf.cc ('k') | ash/system/supervised/tray_supervised_user_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/supervised/tray_supervised_user.h" 5 #include "ash/system/supervised/tray_supervised_user.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/login_status.h" 9 #include "ash/login_status.h"
10 #include "ash/resources/vector_icons/vector_icons.h" 10 #include "ash/resources/vector_icons/vector_icons.h"
11 #include "ash/session/session_controller.h"
11 #include "ash/shell.h" 12 #include "ash/shell.h"
12 #include "ash/system/system_notifier.h" 13 #include "ash/system/system_notifier.h"
13 #include "ash/system/tray/label_tray_view.h" 14 #include "ash/system/tray/label_tray_view.h"
14 #include "ash/system/tray/system_tray_delegate.h" 15 #include "ash/system/tray/system_tray_delegate.h"
15 #include "ash/system/tray/tray_constants.h" 16 #include "ash/system/tray/tray_constants.h"
16 #include "base/callback.h" 17 #include "base/callback.h"
17 #include "base/logging.h" 18 #include "base/logging.h"
18 #include "ui/gfx/paint_vector_icon.h" 19 #include "ui/gfx/paint_vector_icon.h"
19 #include "ui/message_center/message_center.h" 20 #include "ui/message_center/message_center.h"
20 #include "ui/message_center/notification.h" 21 #include "ui/message_center/notification.h"
(...skipping 27 matching lines...) Expand all
48 Shell::Get()->system_tray_delegate()->GetSupervisedUserMessage(); 49 Shell::Get()->system_tray_delegate()->GetSupervisedUserMessage();
49 if (tray_view_) 50 if (tray_view_)
50 tray_view_->SetMessage(message); 51 tray_view_->SetMessage(message);
51 if (message_center::MessageCenter::Get()->FindVisibleNotificationById( 52 if (message_center::MessageCenter::Get()->FindVisibleNotificationById(
52 kNotificationId)) 53 kNotificationId))
53 CreateOrUpdateNotification(message); 54 CreateOrUpdateNotification(message);
54 } 55 }
55 56
56 views::View* TraySupervisedUser::CreateDefaultView(LoginStatus status) { 57 views::View* TraySupervisedUser::CreateDefaultView(LoginStatus status) {
57 DCHECK(!tray_view_); 58 DCHECK(!tray_view_);
58 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); 59 if (!Shell::Get()->session_controller()->IsUserSupervised())
59 if (!delegate->IsUserSupervised())
60 return nullptr; 60 return nullptr;
61 61
62 tray_view_ = new LabelTrayView(this, GetSupervisedUserIcon()); 62 tray_view_ = new LabelTrayView(this, GetSupervisedUserIcon());
63 UpdateMessage(); 63 UpdateMessage();
64 return tray_view_; 64 return tray_view_;
65 } 65 }
66 66
67 void TraySupervisedUser::DestroyDefaultView() { 67 void TraySupervisedUser::DestroyDefaultView() {
68 tray_view_ = nullptr; 68 tray_view_ = nullptr;
69 } 69 }
70 70
71 void TraySupervisedUser::OnViewClicked(views::View* sender) { 71 void TraySupervisedUser::OnViewClicked(views::View* sender) {
72 // TODO(antrim): Find out what should we show in this case. 72 // TODO(antrim): Find out what should we show in this case.
73 } 73 }
74 74
75 void TraySupervisedUser::UpdateAfterLoginStatusChange(LoginStatus status) { 75 void TraySupervisedUser::UpdateAfterLoginStatusChange(LoginStatus status) {
76 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); 76 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate();
77 SessionController* session = Shell::Get()->session_controller();
77 78
78 bool is_user_supervised = delegate->IsUserSupervised(); 79 const bool is_user_supervised = session->IsUserSupervised();
79 if (status == status_ && is_user_supervised == is_user_supervised_) 80 if (status == status_ && is_user_supervised == is_user_supervised_)
80 return; 81 return;
81 82
82 if (is_user_supervised && !delegate->IsUserChild() && 83 if (is_user_supervised && !session->IsUserChild() &&
83 status_ != LoginStatus::LOCKED && 84 status_ != LoginStatus::LOCKED &&
84 !delegate->GetSupervisedUserManager().empty()) { 85 !delegate->GetSupervisedUserManager().empty()) {
85 CreateOrUpdateSupervisedWarningNotification(); 86 CreateOrUpdateSupervisedWarningNotification();
86 } 87 }
87 88
88 status_ = status; 89 status_ = status;
89 is_user_supervised_ = is_user_supervised; 90 is_user_supervised_ = is_user_supervised;
90 } 91 }
91 92
92 void TraySupervisedUser::CreateOrUpdateNotification( 93 void TraySupervisedUser::CreateOrUpdateNotification(
(...skipping 11 matching lines...) Expand all
104 105
105 void TraySupervisedUser::CreateOrUpdateSupervisedWarningNotification() { 106 void TraySupervisedUser::CreateOrUpdateSupervisedWarningNotification() {
106 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); 107 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate();
107 CreateOrUpdateNotification(delegate->GetSupervisedUserMessage()); 108 CreateOrUpdateNotification(delegate->GetSupervisedUserMessage());
108 } 109 }
109 110
110 void TraySupervisedUser::OnCustodianInfoChanged() { 111 void TraySupervisedUser::OnCustodianInfoChanged() {
111 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); 112 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate();
112 std::string manager_name = delegate->GetSupervisedUserManager(); 113 std::string manager_name = delegate->GetSupervisedUserManager();
113 if (!manager_name.empty()) { 114 if (!manager_name.empty()) {
114 if (!delegate->IsUserChild() && 115 if (!Shell::Get()->session_controller()->IsUserChild() &&
115 !message_center::MessageCenter::Get()->FindVisibleNotificationById( 116 !message_center::MessageCenter::Get()->FindVisibleNotificationById(
116 kNotificationId)) { 117 kNotificationId)) {
117 CreateOrUpdateSupervisedWarningNotification(); 118 CreateOrUpdateSupervisedWarningNotification();
118 } 119 }
119 UpdateMessage(); 120 UpdateMessage();
120 } 121 }
121 } 122 }
122 123
123 const gfx::VectorIcon& TraySupervisedUser::GetSupervisedUserIcon() const { 124 const gfx::VectorIcon& TraySupervisedUser::GetSupervisedUserIcon() const {
124 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); 125 // Not intended to be used for non-supervised users.
126 DCHECK(Shell::Get()->session_controller()->IsUserSupervised());
125 127
126 // Not intended to be used for non-supervised users. 128 if (Shell::Get()->session_controller()->IsUserChild())
127 DCHECK(delegate->IsUserSupervised());
128
129 if (delegate->IsUserChild())
130 return kSystemMenuChildUserIcon; 129 return kSystemMenuChildUserIcon;
131 return kSystemMenuSupervisedUserIcon; 130 return kSystemMenuSupervisedUserIcon;
132 } 131 }
133 132
134 } // namespace ash 133 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/wm_shelf.cc ('k') | ash/system/supervised/tray_supervised_user_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698