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

Unified Diff: chrome/browser/ui/ash/system_tray_delegate_chromeos.cc

Issue 627593003: Adding infrastructure for possibility of changing manager names for the supervised accounts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Weak pointers removed. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
index 2d5e39f57bd3c8e410f65eadc322c8e86da473f5..f07e9023cf36974611c60d2ed257fc7efa4f134c 100644
--- a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
@@ -70,6 +70,8 @@
#include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
#include "chrome/browser/ui/ash/user_accounts_delegate_chromeos.h"
#include "chrome/browser/ui/ash/volume_controller_chromeos.h"
@@ -308,6 +310,7 @@ SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() {
BrowserList::RemoveObserver(this);
StopObservingAppWindowRegistry();
+ StopObservingCustodianInfoChanges();
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
@@ -374,31 +377,30 @@ const base::string16 SystemTrayDelegateChromeOS::GetEnterpriseMessage() const {
}
const std::string SystemTrayDelegateChromeOS::GetSupervisedUserManager() const {
- if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED)
+ if (!IsUserSupervised())
return std::string();
- return ChromeUserManager::Get()
- ->GetSupervisedUserManager()
- ->GetManagerDisplayEmail(
- user_manager::UserManager::Get()->GetActiveUser()->email());
+ return SupervisedUserServiceFactory::GetForProfile(user_profile_)->
+ GetCustodianEmailAddress();
}
const base::string16
SystemTrayDelegateChromeOS::GetSupervisedUserManagerName() const {
- if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED)
+ if (!IsUserSupervised())
return base::string16();
- return ChromeUserManager::Get()
- ->GetSupervisedUserManager()
- ->GetManagerDisplayName(
- user_manager::UserManager::Get()->GetActiveUser()->email());
+ return base::UTF8ToUTF16(SupervisedUserServiceFactory::GetForProfile(
+ user_profile_)->GetCustodianName());
}
const base::string16 SystemTrayDelegateChromeOS::GetSupervisedUserMessage()
const {
if (!IsUserSupervised())
return base::string16();
+ std::string user_manager_name = GetSupervisedUserManager();
+ LOG_IF(WARNING, user_manager_name.empty()) <<
+ "Returning incomplete supervised user message as manager not known yet.";
return l10n_util::GetStringFUTF16(
IDS_USER_IS_SUPERVISED_BY_NOTICE,
- base::UTF8ToUTF16(GetSupervisedUserManager()));
+ base::UTF8ToUTF16(user_manager_name));
}
bool SystemTrayDelegateChromeOS::IsUserSupervised() const {
@@ -869,11 +871,17 @@ void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) {
// Stop observing the AppWindowRegistry of the current |user_profile_|.
StopObservingAppWindowRegistry();
+ // Stop observing custodian info changes of the current |user_profile_|.
+ StopObservingCustodianInfoChanges();
+
user_profile_ = profile;
// Start observing the AppWindowRegistry of the newly set |user_profile_|.
extensions::AppWindowRegistry::Get(user_profile_)->AddObserver(this);
+ // Start observing custodian info changes of the newly set |user_profile_|.
+ SupervisedUserServiceFactory::GetForProfile(profile)->AddObserver(this);
+
PrefService* prefs = profile->GetPrefs();
user_pref_registrar_.reset(new PrefChangeRegistrar);
user_pref_registrar_->Init(prefs);
@@ -917,6 +925,7 @@ void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) {
UpdateShowLogoutButtonInTray();
UpdateLogoutDialogDuration();
UpdatePerformanceTracing();
+ OnCustodianInfoChanged();
search_key_mapped_to_ =
profile->GetPrefs()->GetInteger(prefs::kLanguageRemapSearchKeyTo);
}
@@ -1021,6 +1030,16 @@ void SystemTrayDelegateChromeOS::StopObservingAppWindowRegistry() {
registry->RemoveObserver(this);
}
+void SystemTrayDelegateChromeOS::StopObservingCustodianInfoChanges() {
+ if (!user_profile_)
+ return;
+
+ SupervisedUserService* service = SupervisedUserServiceFactory::GetForProfile(
+ user_profile_);
+ if (service)
+ service->RemoveObserver(this);
+}
+
void SystemTrayDelegateChromeOS::NotifyIfLastWindowClosed() {
if (!user_profile_)
return;
@@ -1289,6 +1308,23 @@ void SystemTrayDelegateChromeOS::OnAppWindowRemoved(
NotifyIfLastWindowClosed();
}
+// Overridden from SupervisedUserServiceObserver.
+void SystemTrayDelegateChromeOS::OnCustodianInfoChanged() {
+ FOR_EACH_OBSERVER(
+ ash::CustodianInfoTrayObserver, custodian_info_changed_observers_,
+ OnCustodianInfoChanged());
+}
+
+void SystemTrayDelegateChromeOS::AddObserver(
Daniel Erat 2014/10/07 16:16:00 please move this and RemoveObserver so they match
merkulova 2014/10/08 09:19:37 Done.
+ ash::CustodianInfoTrayObserver* observer) {
+ custodian_info_changed_observers_.AddObserver(observer);
+}
+
+void SystemTrayDelegateChromeOS::RemoveObserver(
+ ash::CustodianInfoTrayObserver* observer) {
+ custodian_info_changed_observers_.RemoveObserver(observer);
+}
+
void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged(
const AccessibilityStatusEventDetails& details) {
if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN)

Powered by Google App Engine
This is Rietveld 408576698