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

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: Daniel's comments addressed. 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 44856326681b1967365d114fdaa143bbe76b4ff1..f1f32f7d1b5ac8fb72a877a6e854f194cb366e44 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/system_tray_delegate_utils.h"
#include "chrome/browser/ui/ash/user_accounts_delegate_chromeos.h"
@@ -309,6 +311,7 @@ SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() {
BrowserList::RemoveObserver(this);
StopObservingAppWindowRegistry();
+ StopObservingCustodianInfoChanges();
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
@@ -375,31 +378,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 {
@@ -859,6 +861,16 @@ SystemTrayDelegateChromeOS::GetUserAccountsDelegate(
return accounts_delegates_.get(user_id);
}
+void SystemTrayDelegateChromeOS::AddCustodianInfoTrayObserver(
+ ash::CustodianInfoTrayObserver* observer) {
+ custodian_info_changed_observers_.AddObserver(observer);
+}
+
+void SystemTrayDelegateChromeOS::RemoveCustodianInfoTrayObserver(
+ ash::CustodianInfoTrayObserver* observer) {
+ custodian_info_changed_observers_.RemoveObserver(observer);
+}
+
ash::SystemTray* SystemTrayDelegateChromeOS::GetPrimarySystemTray() {
return ash::Shell::GetInstance()->GetPrimarySystemTray();
}
@@ -871,11 +883,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);
@@ -919,6 +937,7 @@ void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) {
UpdateShowLogoutButtonInTray();
UpdateLogoutDialogDuration();
UpdatePerformanceTracing();
+ OnCustodianInfoChanged();
search_key_mapped_to_ =
profile->GetPrefs()->GetInteger(prefs::kLanguageRemapSearchKeyTo);
}
@@ -1023,6 +1042,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;
@@ -1271,6 +1300,13 @@ void SystemTrayDelegateChromeOS::OnAppWindowRemoved(
NotifyIfLastWindowClosed();
}
+// Overridden from SupervisedUserServiceObserver.
Daniel Erat 2014/10/08 14:10:46 don't need to fix it here, but chrome typically do
+void SystemTrayDelegateChromeOS::OnCustodianInfoChanged() {
+ FOR_EACH_OBSERVER(
+ ash::CustodianInfoTrayObserver, custodian_info_changed_observers_,
+ OnCustodianInfoChanged());
+}
+
void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged(
const AccessibilityStatusEventDetails& details) {
if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN)

Powered by Google App Engine
This is Rietveld 408576698