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

Side by Side Diff: chrome/browser/ui/ash/system_tray_delegate_chromeos.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 | « chrome/browser/ui/ash/system_tray_delegate_chromeos.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 void OnAcceptMultiprofilesIntro(bool no_show_again) { 106 void OnAcceptMultiprofilesIntro(bool no_show_again) {
107 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); 107 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
108 prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again); 108 prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again);
109 UserAddingScreen::Get()->Start(); 109 UserAddingScreen::Get()->Start();
110 } 110 }
111 111
112 bool IsSessionInSecondaryLoginScreen() { 112 bool IsSessionInSecondaryLoginScreen() {
113 return session_manager::SessionManager::Get()->IsInSecondaryLoginScreen(); 113 return session_manager::SessionManager::Get()->IsInSecondaryLoginScreen();
114 } 114 }
115 115
116 bool IsUserSupervised() {
117 user_manager::User* user = user_manager::UserManager::Get()->GetActiveUser();
118 return user && user->IsSupervised();
119 }
120
116 } // namespace 121 } // namespace
117 122
118 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() 123 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS()
119 : networking_config_delegate_( 124 : networking_config_delegate_(
120 base::MakeUnique<NetworkingConfigDelegateChromeos>()) { 125 base::MakeUnique<NetworkingConfigDelegateChromeos>()) {
121 // Register notifications on construction so that events such as 126 // Register notifications on construction so that events such as
122 // PROFILE_CREATED do not get missed if they happen before Initialize(). 127 // PROFILE_CREATED do not get missed if they happen before Initialize().
123 registrar_.reset(new content::NotificationRegistrar); 128 registrar_.reset(new content::NotificationRegistrar);
124 if (GetUserLoginStatus() == ash::LoginStatus::NOT_LOGGED_IN) { 129 if (GetUserLoginStatus() == ash::LoginStatus::NOT_LOGGED_IN) {
125 registrar_->Add(this, 130 registrar_->Add(this,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 if (!IsUserSupervised()) 232 if (!IsUserSupervised())
228 return base::string16(); 233 return base::string16();
229 return base::UTF8ToUTF16(SupervisedUserServiceFactory::GetForProfile( 234 return base::UTF8ToUTF16(SupervisedUserServiceFactory::GetForProfile(
230 user_profile_)->GetCustodianName()); 235 user_profile_)->GetCustodianName());
231 } 236 }
232 237
233 base::string16 SystemTrayDelegateChromeOS::GetSupervisedUserMessage() 238 base::string16 SystemTrayDelegateChromeOS::GetSupervisedUserMessage()
234 const { 239 const {
235 if (!IsUserSupervised()) 240 if (!IsUserSupervised())
236 return base::string16(); 241 return base::string16();
237 if (IsUserChild()) 242 if (user_manager::UserManager::Get()->IsLoggedInAsChildUser())
238 return GetChildUserMessage(); 243 return GetChildUserMessage();
239 return GetLegacySupervisedUserMessage(); 244 return GetLegacySupervisedUserMessage();
240 } 245 }
241 246
242 bool SystemTrayDelegateChromeOS::IsUserSupervised() const {
243 user_manager::User* user = user_manager::UserManager::Get()->GetActiveUser();
244 return user && user->IsSupervised();
245 }
246
247 bool SystemTrayDelegateChromeOS::IsUserChild() const {
248 return user_manager::UserManager::Get()->IsLoggedInAsChildUser();
249 }
250
251 void SystemTrayDelegateChromeOS::ShowEnterpriseInfo() { 247 void SystemTrayDelegateChromeOS::ShowEnterpriseInfo() {
252 // TODO(mash): Refactor out SessionStateDelegate and move to SystemTrayClient. 248 // TODO(mash): Refactor out SessionStateDelegate and move to SystemTrayClient.
253 ash::LoginStatus status = GetUserLoginStatus(); 249 ash::LoginStatus status = GetUserLoginStatus();
254 if (status == ash::LoginStatus::NOT_LOGGED_IN || 250 if (status == ash::LoginStatus::NOT_LOGGED_IN ||
255 status == ash::LoginStatus::LOCKED || IsSessionInSecondaryLoginScreen()) { 251 status == ash::LoginStatus::LOCKED || IsSessionInSecondaryLoginScreen()) {
256 scoped_refptr<chromeos::HelpAppLauncher> help_app( 252 scoped_refptr<chromeos::HelpAppLauncher> help_app(
257 new chromeos::HelpAppLauncher(nullptr /* parent_window */)); 253 new chromeos::HelpAppLauncher(nullptr /* parent_window */));
258 help_app->ShowHelpTopic(chromeos::HelpAppLauncher::HELP_ENTERPRISE); 254 help_app->ShowHelpTopic(chromeos::HelpAppLauncher::HELP_ENTERPRISE);
259 } else { 255 } else {
260 chrome::ScopedTabbedBrowserDisplayer displayer( 256 chrome::ScopedTabbedBrowserDisplayer displayer(
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 SystemTrayDelegateChromeOS::GetLegacySupervisedUserMessage() const { 684 SystemTrayDelegateChromeOS::GetLegacySupervisedUserMessage() const {
689 std::string user_manager_name = GetSupervisedUserManager(); 685 std::string user_manager_name = GetSupervisedUserManager();
690 return l10n_util::GetStringFUTF16( 686 return l10n_util::GetStringFUTF16(
691 IDS_USER_IS_SUPERVISED_BY_NOTICE, 687 IDS_USER_IS_SUPERVISED_BY_NOTICE,
692 base::UTF8ToUTF16(user_manager_name)); 688 base::UTF8ToUTF16(user_manager_name));
693 } 689 }
694 690
695 const base::string16 691 const base::string16
696 SystemTrayDelegateChromeOS::GetChildUserMessage() const { 692 SystemTrayDelegateChromeOS::GetChildUserMessage() const {
697 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) 693 #if BUILDFLAG(ENABLE_SUPERVISED_USERS)
694 // TODO(jamescook): If supervised users are always enabled on Chrome OS then
695 // these ifdefs can be removed.
698 SupervisedUserService* service = 696 SupervisedUserService* service =
699 SupervisedUserServiceFactory::GetForProfile(user_profile_); 697 SupervisedUserServiceFactory::GetForProfile(user_profile_);
700 base::string16 first_custodian = 698 base::string16 first_custodian =
701 base::UTF8ToUTF16(service->GetCustodianEmailAddress()); 699 base::UTF8ToUTF16(service->GetCustodianEmailAddress());
702 base::string16 second_custodian = 700 base::string16 second_custodian =
703 base::UTF8ToUTF16(service->GetSecondCustodianEmailAddress()); 701 base::UTF8ToUTF16(service->GetSecondCustodianEmailAddress());
704 LOG_IF(WARNING, first_custodian.empty()) << 702 LOG_IF(WARNING, first_custodian.empty()) <<
705 "Returning incomplete child user message as manager not known yet."; 703 "Returning incomplete child user message as manager not known yet.";
706 if (second_custodian.empty()) { 704 if (second_custodian.empty()) {
707 return l10n_util::GetStringFUTF16( 705 return l10n_util::GetStringFUTF16(
708 IDS_CHILD_USER_IS_MANAGED_BY_ONE_PARENT_NOTICE, first_custodian); 706 IDS_CHILD_USER_IS_MANAGED_BY_ONE_PARENT_NOTICE, first_custodian);
709 } else { 707 } else {
710 return l10n_util::GetStringFUTF16( 708 return l10n_util::GetStringFUTF16(
711 IDS_CHILD_USER_IS_MANAGED_BY_TWO_PARENTS_NOTICE, 709 IDS_CHILD_USER_IS_MANAGED_BY_TWO_PARENTS_NOTICE,
712 first_custodian, 710 first_custodian,
713 second_custodian); 711 second_custodian);
714 } 712 }
715 #endif 713 #endif
716 714
717 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " 715 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while "
718 << "ENABLE_SUPERVISED_USERS undefined."; 716 << "ENABLE_SUPERVISED_USERS undefined.";
719 return base::string16(); 717 return base::string16();
720 } 718 }
721 719
722 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 720 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
723 return new SystemTrayDelegateChromeOS(); 721 return new SystemTrayDelegateChromeOS();
724 } 722 }
725 723
726 } // namespace chromeos 724 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/system_tray_delegate_chromeos.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698