Commit 270ffc01 authored by merkulova's avatar merkulova Committed by Commit bot

Adding infrastructure for possibility of changing manager names for the supervised accounts.

CL https://chromereviews.googleplex.com/90457013/ for pre-checks.

BUG=419007

Review URL: https://codereview.chromium.org/627593003

Cr-Commit-Position: refs/heads/master@{#299296}
parent a456ad3f
...@@ -343,6 +343,7 @@ ...@@ -343,6 +343,7 @@
'system/chromeos/session/tray_session_length_limit.h', 'system/chromeos/session/tray_session_length_limit.h',
'system/chromeos/settings/tray_settings.cc', 'system/chromeos/settings/tray_settings.cc',
'system/chromeos/settings/tray_settings.h', 'system/chromeos/settings/tray_settings.h',
'system/chromeos/supervised/custodian_info_tray_observer.h',
'system/chromeos/supervised/tray_supervised_user.cc', 'system/chromeos/supervised/tray_supervised_user.cc',
'system/chromeos/supervised/tray_supervised_user.h', 'system/chromeos/supervised/tray_supervised_user.h',
'system/chromeos/system_clock_observer.cc', 'system/chromeos/system_clock_observer.cc',
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_CHROMEOS_SUPERVISED_CUSTODIAN_INFO_TRAY_OBSERVER_H_
#define ASH_SYSTEM_CHROMEOS_SUPERVISED_CUSTODIAN_INFO_TRAY_OBSERVER_H_
namespace ash {
// Used to observe SystemTrayDelegate.
class CustodianInfoTrayObserver {
public:
// Called when information about the supervised user's custodian is changed,
// e.g. the display name.
virtual void OnCustodianInfoChanged() = 0;
protected:
virtual ~CustodianInfoTrayObserver() {}
};
} // namespace ash
#endif // ASH_SYSTEM_CHROMEOS_SUPERVISED_CUSTODIAN_INFO_TRAY_OBSERVER_H_
...@@ -31,9 +31,16 @@ TraySupervisedUser::TraySupervisedUser(SystemTray* system_tray) ...@@ -31,9 +31,16 @@ TraySupervisedUser::TraySupervisedUser(SystemTray* system_tray)
tray_view_(NULL), tray_view_(NULL),
status_(ash::user::LOGGED_IN_NONE), status_(ash::user::LOGGED_IN_NONE),
is_user_supervised_(false) { is_user_supervised_(false) {
Shell::GetInstance()->system_tray_delegate()->
AddCustodianInfoTrayObserver(this);
} }
TraySupervisedUser::~TraySupervisedUser() { TraySupervisedUser::~TraySupervisedUser() {
// We need the check as on shell destruction delegate is destroyed first.
SystemTrayDelegate* system_tray_delegate =
Shell::GetInstance()->system_tray_delegate();
if (system_tray_delegate)
system_tray_delegate->RemoveCustodianInfoTrayObserver(this);
} }
void TraySupervisedUser::UpdateMessage() { void TraySupervisedUser::UpdateMessage() {
...@@ -75,9 +82,10 @@ void TraySupervisedUser::UpdateAfterLoginStatusChange( ...@@ -75,9 +82,10 @@ void TraySupervisedUser::UpdateAfterLoginStatusChange(
return; return;
if (is_user_supervised && if (is_user_supervised &&
status_ != ash::user::LOGGED_IN_LOCKED) { status_ != ash::user::LOGGED_IN_LOCKED &&
CreateOrUpdateNotification(delegate->GetSupervisedUserMessage()); !delegate->GetSupervisedUserManager().empty())
} CreateOrUpdateSupervisedWarningNotification();
status_ = status; status_ = status;
is_user_supervised_ = is_user_supervised; is_user_supervised_ = is_user_supervised;
} }
...@@ -96,4 +104,20 @@ void TraySupervisedUser::CreateOrUpdateNotification( ...@@ -96,4 +104,20 @@ void TraySupervisedUser::CreateOrUpdateNotification(
message_center::MessageCenter::Get()->AddNotification(notification.Pass()); message_center::MessageCenter::Get()->AddNotification(notification.Pass());
} }
void TraySupervisedUser::CreateOrUpdateSupervisedWarningNotification() {
SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
CreateOrUpdateNotification(delegate->GetSupervisedUserMessage());
}
void TraySupervisedUser::OnCustodianInfoChanged() {
SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
std::string manager_name = delegate->GetSupervisedUserManager();
if (!manager_name.empty()) {
if (!message_center::MessageCenter::Get()->FindVisibleNotificationById(
kNotificationId))
CreateOrUpdateSupervisedWarningNotification();
UpdateMessage();
}
}
} // namespace ash } // namespace ash
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define ASH_SYSTEM_CHROMEOS_SUPERVISED_TRAY_SUPERVISED_USER_H #define ASH_SYSTEM_CHROMEOS_SUPERVISED_TRAY_SUPERVISED_USER_H
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/system/chromeos/supervised/custodian_info_tray_observer.h"
#include "ash/system/tray/system_tray_item.h" #include "ash/system/tray/system_tray_item.h"
#include "ash/system/tray/view_click_listener.h" #include "ash/system/tray/view_click_listener.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
...@@ -15,7 +16,8 @@ class LabelTrayView; ...@@ -15,7 +16,8 @@ class LabelTrayView;
class SystemTray; class SystemTray;
class ASH_EXPORT TraySupervisedUser : public SystemTrayItem, class ASH_EXPORT TraySupervisedUser : public SystemTrayItem,
public ViewClickListener { public ViewClickListener,
public CustodianInfoTrayObserver {
public: public:
explicit TraySupervisedUser(SystemTray* system_tray); explicit TraySupervisedUser(SystemTray* system_tray);
virtual ~TraySupervisedUser(); virtual ~TraySupervisedUser();
...@@ -32,6 +34,9 @@ class ASH_EXPORT TraySupervisedUser : public SystemTrayItem, ...@@ -32,6 +34,9 @@ class ASH_EXPORT TraySupervisedUser : public SystemTrayItem,
// Overridden from ViewClickListener. // Overridden from ViewClickListener.
virtual void OnViewClicked(views::View* sender) override; virtual void OnViewClicked(views::View* sender) override;
// Overridden from CustodianInfoTrayObserver:
virtual void OnCustodianInfoChanged() override;
private: private:
friend class TraySupervisedUserTest; friend class TraySupervisedUserTest;
...@@ -39,7 +44,10 @@ class ASH_EXPORT TraySupervisedUser : public SystemTrayItem, ...@@ -39,7 +44,10 @@ class ASH_EXPORT TraySupervisedUser : public SystemTrayItem,
void CreateOrUpdateNotification(const base::string16& new_message); void CreateOrUpdateNotification(const base::string16& new_message);
void CreateOrUpdateSupervisedWarningNotification();
LabelTrayView* tray_view_; LabelTrayView* tray_view_;
// Previous login status to avoid showing notification upon unlock. // Previous login status to avoid showing notification upon unlock.
user::LoginStatus status_; user::LoginStatus status_;
......
...@@ -72,7 +72,9 @@ const base::string16 DefaultSystemTrayDelegate::GetEnterpriseMessage() const { ...@@ -72,7 +72,9 @@ const base::string16 DefaultSystemTrayDelegate::GetEnterpriseMessage() const {
const std::string const std::string
DefaultSystemTrayDelegate::GetSupervisedUserManager() const { DefaultSystemTrayDelegate::GetSupervisedUserManager() const {
if (!IsUserSupervised())
return std::string(); return std::string();
return "manager@chrome.com";
} }
const base::string16 const base::string16
...@@ -87,7 +89,7 @@ const base::string16 DefaultSystemTrayDelegate::GetSupervisedUserMessage() ...@@ -87,7 +89,7 @@ const base::string16 DefaultSystemTrayDelegate::GetSupervisedUserMessage()
} }
bool DefaultSystemTrayDelegate::IsUserSupervised() const { bool DefaultSystemTrayDelegate::IsUserSupervised() const {
return false; return GetUserLoginStatus() == ash::user::LOGGED_IN_SUPERVISED;
} }
void DefaultSystemTrayDelegate::GetSystemUpdateInfo(UpdateInfo* info) const { void DefaultSystemTrayDelegate::GetSystemUpdateInfo(UpdateInfo* info) const {
...@@ -291,4 +293,12 @@ tray::UserAccountsDelegate* DefaultSystemTrayDelegate::GetUserAccountsDelegate( ...@@ -291,4 +293,12 @@ tray::UserAccountsDelegate* DefaultSystemTrayDelegate::GetUserAccountsDelegate(
return NULL; return NULL;
} }
void DefaultSystemTrayDelegate::AddCustodianInfoTrayObserver(
CustodianInfoTrayObserver* observer) {
}
void DefaultSystemTrayDelegate::RemoveCustodianInfoTrayObserver(
CustodianInfoTrayObserver* observer) {
}
} // namespace ash } // namespace ash
...@@ -88,6 +88,10 @@ class ASH_EXPORT DefaultSystemTrayDelegate : public SystemTrayDelegate { ...@@ -88,6 +88,10 @@ class ASH_EXPORT DefaultSystemTrayDelegate : public SystemTrayDelegate {
virtual bool IsSearchKeyMappedToCapsLock() override; virtual bool IsSearchKeyMappedToCapsLock() override;
virtual tray::UserAccountsDelegate* GetUserAccountsDelegate( virtual tray::UserAccountsDelegate* GetUserAccountsDelegate(
const std::string& user_id) override; const std::string& user_id) override;
virtual void AddCustodianInfoTrayObserver(
CustodianInfoTrayObserver* observer) override;
virtual void RemoveCustodianInfoTrayObserver(
CustodianInfoTrayObserver* observer) override;
private: private:
bool bluetooth_enabled_; bool bluetooth_enabled_;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/system/user/login_status.h" #include "ash/system/user/login_status.h"
#include "base/callback_forward.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/i18n/time_formatting.h" #include "base/i18n/time_formatting.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
...@@ -23,6 +24,8 @@ class TimeTicks; ...@@ -23,6 +24,8 @@ class TimeTicks;
namespace ash { namespace ash {
class CustodianInfoTrayObserver;
struct ASH_EXPORT NetworkIconInfo { struct ASH_EXPORT NetworkIconInfo {
NetworkIconInfo(); NetworkIconInfo();
~NetworkIconInfo(); ~NetworkIconInfo();
...@@ -311,6 +314,13 @@ class ASH_EXPORT SystemTrayDelegate { ...@@ -311,6 +314,13 @@ class ASH_EXPORT SystemTrayDelegate {
// Returns accounts delegate for given user. // Returns accounts delegate for given user.
virtual tray::UserAccountsDelegate* GetUserAccountsDelegate( virtual tray::UserAccountsDelegate* GetUserAccountsDelegate(
const std::string& user_id) = 0; const std::string& user_id) = 0;
// Adding observers that are notified when supervised info is being changed.
virtual void AddCustodianInfoTrayObserver(
CustodianInfoTrayObserver* observer) = 0;
virtual void RemoveCustodianInfoTrayObserver(
CustodianInfoTrayObserver* observer) = 0;
}; };
} // namespace ash } // namespace ash
......
...@@ -281,28 +281,31 @@ void SupervisedUserService::GetCategoryNames(CategoryList* list) { ...@@ -281,28 +281,31 @@ void SupervisedUserService::GetCategoryNames(CategoryList* list) {
} }
std::string SupervisedUserService::GetCustodianEmailAddress() const { std::string SupervisedUserService::GetCustodianEmailAddress() const {
std::string custodian_email = profile_->GetPrefs()->GetString(
prefs::kSupervisedUserCustodianEmail);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
return chromeos::ChromeUserManager::Get() if (custodian_email.empty()) {
custodian_email = chromeos::ChromeUserManager::Get()
->GetSupervisedUserManager() ->GetSupervisedUserManager()
->GetManagerDisplayEmail( ->GetManagerDisplayEmail(
user_manager::UserManager::Get()->GetActiveUser()->email()); user_manager::UserManager::Get()->GetActiveUser()->email());
#else }
return profile_->GetPrefs()->GetString(prefs::kSupervisedUserCustodianEmail);
#endif #endif
return custodian_email;
} }
std::string SupervisedUserService::GetCustodianName() const { std::string SupervisedUserService::GetCustodianName() const {
std::string name = profile_->GetPrefs()->GetString(
prefs::kSupervisedUserCustodianName);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
return base::UTF16ToUTF8( if (name.empty()) {
chromeos::ChromeUserManager::Get() name = base::UTF16ToUTF8(chromeos::ChromeUserManager::Get()
->GetSupervisedUserManager() ->GetSupervisedUserManager()
->GetManagerDisplayName( ->GetManagerDisplayName(
user_manager::UserManager::Get()->GetActiveUser()->email())); user_manager::UserManager::Get()->GetActiveUser()->email()));
#else }
std::string name = profile_->GetPrefs()->GetString(
prefs::kSupervisedUserCustodianName);
return name.empty() ? GetCustodianEmailAddress() : name;
#endif #endif
return name.empty() ? GetCustodianEmailAddress() : name;
} }
void SupervisedUserService::AddNavigationBlockedCallback( void SupervisedUserService::AddNavigationBlockedCallback(
......
...@@ -70,6 +70,8 @@ ...@@ -70,6 +70,8 @@
#include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h"
#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile_manager.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/multi_user/multi_user_util.h"
#include "chrome/browser/ui/ash/system_tray_delegate_utils.h" #include "chrome/browser/ui/ash/system_tray_delegate_utils.h"
#include "chrome/browser/ui/ash/user_accounts_delegate_chromeos.h" #include "chrome/browser/ui/ash/user_accounts_delegate_chromeos.h"
...@@ -312,6 +314,7 @@ SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { ...@@ -312,6 +314,7 @@ SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() {
BrowserList::RemoveObserver(this); BrowserList::RemoveObserver(this);
StopObservingAppWindowRegistry(); StopObservingAppWindowRegistry();
StopObservingCustodianInfoChanges();
policy::BrowserPolicyConnectorChromeOS* connector = policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos(); g_browser_process->platform_part()->browser_policy_connector_chromeos();
...@@ -380,31 +383,30 @@ const base::string16 SystemTrayDelegateChromeOS::GetEnterpriseMessage() const { ...@@ -380,31 +383,30 @@ const base::string16 SystemTrayDelegateChromeOS::GetEnterpriseMessage() const {
} }
const std::string SystemTrayDelegateChromeOS::GetSupervisedUserManager() const { const std::string SystemTrayDelegateChromeOS::GetSupervisedUserManager() const {
if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED) if (!IsUserSupervised())
return std::string(); return std::string();
return ChromeUserManager::Get() return SupervisedUserServiceFactory::GetForProfile(user_profile_)->
->GetSupervisedUserManager() GetCustodianEmailAddress();
->GetManagerDisplayEmail(
user_manager::UserManager::Get()->GetActiveUser()->email());
} }
const base::string16 const base::string16
SystemTrayDelegateChromeOS::GetSupervisedUserManagerName() const { SystemTrayDelegateChromeOS::GetSupervisedUserManagerName() const {
if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED) if (!IsUserSupervised())
return base::string16(); return base::string16();
return ChromeUserManager::Get() return base::UTF8ToUTF16(SupervisedUserServiceFactory::GetForProfile(
->GetSupervisedUserManager() user_profile_)->GetCustodianName());
->GetManagerDisplayName(
user_manager::UserManager::Get()->GetActiveUser()->email());
} }
const base::string16 SystemTrayDelegateChromeOS::GetSupervisedUserMessage() const base::string16 SystemTrayDelegateChromeOS::GetSupervisedUserMessage()
const { const {
if (!IsUserSupervised()) if (!IsUserSupervised())
return base::string16(); 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( return l10n_util::GetStringFUTF16(
IDS_USER_IS_SUPERVISED_BY_NOTICE, IDS_USER_IS_SUPERVISED_BY_NOTICE,
base::UTF8ToUTF16(GetSupervisedUserManager())); base::UTF8ToUTF16(user_manager_name));
} }
bool SystemTrayDelegateChromeOS::IsUserSupervised() const { bool SystemTrayDelegateChromeOS::IsUserSupervised() const {
...@@ -864,6 +866,16 @@ SystemTrayDelegateChromeOS::GetUserAccountsDelegate( ...@@ -864,6 +866,16 @@ SystemTrayDelegateChromeOS::GetUserAccountsDelegate(
return accounts_delegates_.get(user_id); 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);
}
void SystemTrayDelegateChromeOS::UserAddedToSession( void SystemTrayDelegateChromeOS::UserAddedToSession(
const user_manager::User* active_user) { const user_manager::User* active_user) {
} }
...@@ -891,11 +903,17 @@ void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { ...@@ -891,11 +903,17 @@ void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) {
// Stop observing the AppWindowRegistry of the current |user_profile_|. // Stop observing the AppWindowRegistry of the current |user_profile_|.
StopObservingAppWindowRegistry(); StopObservingAppWindowRegistry();
// Stop observing custodian info changes of the current |user_profile_|.
StopObservingCustodianInfoChanges();
user_profile_ = profile; user_profile_ = profile;
// Start observing the AppWindowRegistry of the newly set |user_profile_|. // Start observing the AppWindowRegistry of the newly set |user_profile_|.
extensions::AppWindowRegistry::Get(user_profile_)->AddObserver(this); 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(); PrefService* prefs = profile->GetPrefs();
user_pref_registrar_.reset(new PrefChangeRegistrar); user_pref_registrar_.reset(new PrefChangeRegistrar);
user_pref_registrar_->Init(prefs); user_pref_registrar_->Init(prefs);
...@@ -939,6 +957,7 @@ void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { ...@@ -939,6 +957,7 @@ void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) {
UpdateShowLogoutButtonInTray(); UpdateShowLogoutButtonInTray();
UpdateLogoutDialogDuration(); UpdateLogoutDialogDuration();
UpdatePerformanceTracing(); UpdatePerformanceTracing();
OnCustodianInfoChanged();
search_key_mapped_to_ = search_key_mapped_to_ =
profile->GetPrefs()->GetInteger(prefs::kLanguageRemapSearchKeyTo); profile->GetPrefs()->GetInteger(prefs::kLanguageRemapSearchKeyTo);
} }
...@@ -1043,6 +1062,16 @@ void SystemTrayDelegateChromeOS::StopObservingAppWindowRegistry() { ...@@ -1043,6 +1062,16 @@ void SystemTrayDelegateChromeOS::StopObservingAppWindowRegistry() {
registry->RemoveObserver(this); registry->RemoveObserver(this);
} }
void SystemTrayDelegateChromeOS::StopObservingCustodianInfoChanges() {
if (!user_profile_)
return;
SupervisedUserService* service = SupervisedUserServiceFactory::GetForProfile(
user_profile_);
if (service)
service->RemoveObserver(this);
}
void SystemTrayDelegateChromeOS::NotifyIfLastWindowClosed() { void SystemTrayDelegateChromeOS::NotifyIfLastWindowClosed() {
if (!user_profile_) if (!user_profile_)
return; return;
...@@ -1292,6 +1321,13 @@ void SystemTrayDelegateChromeOS::OnAppWindowRemoved( ...@@ -1292,6 +1321,13 @@ void SystemTrayDelegateChromeOS::OnAppWindowRemoved(
NotifyIfLastWindowClosed(); NotifyIfLastWindowClosed();
} }
// Overridden from SupervisedUserServiceObserver.
void SystemTrayDelegateChromeOS::OnCustodianInfoChanged() {
FOR_EACH_OBSERVER(
ash::CustodianInfoTrayObserver, custodian_info_changed_observers_,
OnCustodianInfoChanged());
}
void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged( void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged(
const AccessibilityStatusEventDetails& details) { const AccessibilityStatusEventDetails& details) {
if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN) if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN)
......
...@@ -5,20 +5,25 @@ ...@@ -5,20 +5,25 @@
#ifndef CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_DELEGATE_CHROMEOS_H_ #ifndef CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_DELEGATE_CHROMEOS_H_
#define CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_DELEGATE_CHROMEOS_H_ #define CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_DELEGATE_CHROMEOS_H_
#include <vector>
#include "ash/ime/input_method_menu_manager.h" #include "ash/ime/input_method_menu_manager.h"
#include "ash/session/session_state_observer.h" #include "ash/session/session_state_observer.h"
#include "ash/system/chromeos/supervised/custodian_info_tray_observer.h"
#include "ash/system/tray/system_tray.h" #include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_delegate.h" #include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/system_tray_notifier.h" #include "ash/system/tray/system_tray_notifier.h"
#include "base/callback_forward.h"
#include "base/callback_list.h" #include "base/callback_list.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/containers/scoped_ptr_hash_map.h" #include "base/containers/scoped_ptr_hash_map.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/prefs/pref_change_registrar.h" #include "base/prefs/pref_change_registrar.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" #include "chrome/browser/supervised_user/supervised_user_service_observer.h"
#include "chrome/browser/ui/browser_list_observer.h" #include "chrome/browser/ui/browser_list_observer.h"
#include "chromeos/audio/cras_audio_handler.h" #include "chromeos/audio/cras_audio_handler.h"
#include "chromeos/dbus/session_manager_client.h" #include "chromeos/dbus/session_manager_client.h"
...@@ -51,7 +56,8 @@ class SystemTrayDelegateChromeOS ...@@ -51,7 +56,8 @@ class SystemTrayDelegateChromeOS
public ash::SessionStateObserver, public ash::SessionStateObserver,
public chrome::BrowserListObserver, public chrome::BrowserListObserver,
public extensions::AppWindowRegistry::Observer, public extensions::AppWindowRegistry::Observer,
public user_manager::UserManager::UserSessionStateObserver { public user_manager::UserManager::UserSessionStateObserver,
public SupervisedUserServiceObserver {
public: public:
SystemTrayDelegateChromeOS(); SystemTrayDelegateChromeOS();
...@@ -132,6 +138,10 @@ class SystemTrayDelegateChromeOS ...@@ -132,6 +138,10 @@ class SystemTrayDelegateChromeOS
virtual bool IsSearchKeyMappedToCapsLock() override; virtual bool IsSearchKeyMappedToCapsLock() override;
virtual ash::tray::UserAccountsDelegate* GetUserAccountsDelegate( virtual ash::tray::UserAccountsDelegate* GetUserAccountsDelegate(
const std::string& user_id) override; const std::string& user_id) override;
virtual void AddCustodianInfoTrayObserver(
ash::CustodianInfoTrayObserver* observer) override;
virtual void RemoveCustodianInfoTrayObserver(
ash::CustodianInfoTrayObserver* observer) override;
// Overridden from user_manager::UserManager::UserSessionStateObserver: // Overridden from user_manager::UserManager::UserSessionStateObserver:
virtual void UserAddedToSession(const user_manager::User* active_user) virtual void UserAddedToSession(const user_manager::User* active_user)
...@@ -170,6 +180,8 @@ class SystemTrayDelegateChromeOS ...@@ -170,6 +180,8 @@ class SystemTrayDelegateChromeOS
void StopObservingAppWindowRegistry(); void StopObservingAppWindowRegistry();
void StopObservingCustodianInfoChanges();
// Notify observers if the current user has no more open browser or app // Notify observers if the current user has no more open browser or app
// windows. // windows.
void NotifyIfLastWindowClosed(); void NotifyIfLastWindowClosed();
...@@ -244,6 +256,9 @@ class SystemTrayDelegateChromeOS ...@@ -244,6 +256,9 @@ class SystemTrayDelegateChromeOS
// Overridden from extensions::AppWindowRegistry::Observer: // Overridden from extensions::AppWindowRegistry::Observer:
virtual void OnAppWindowRemoved(extensions::AppWindow* app_window) override; virtual void OnAppWindowRemoved(extensions::AppWindow* app_window) override;
// Overridden from SupervisedUserServiceObserver:
virtual void OnCustodianInfoChanged() override;
void OnAccessibilityStatusChanged( void OnAccessibilityStatusChanged(
const AccessibilityStatusEventDetails& details); const AccessibilityStatusEventDetails& details);
...@@ -270,6 +285,9 @@ class SystemTrayDelegateChromeOS ...@@ -270,6 +285,9 @@ class SystemTrayDelegateChromeOS
base::ScopedPtrHashMap<std::string, ash::tray::UserAccountsDelegate> base::ScopedPtrHashMap<std::string, ash::tray::UserAccountsDelegate>
accounts_delegates_; accounts_delegates_;
ObserverList<ash::CustodianInfoTrayObserver>
custodian_info_changed_observers_;
base::WeakPtrFactory<SystemTrayDelegateChromeOS> weak_ptr_factory_; base::WeakPtrFactory<SystemTrayDelegateChromeOS> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegateChromeOS); DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegateChromeOS);
......
...@@ -287,6 +287,14 @@ class SystemTrayDelegateLinux : public ash::SystemTrayDelegate, ...@@ -287,6 +287,14 @@ class SystemTrayDelegateLinux : public ash::SystemTrayDelegate,
return NULL; return NULL;
} }
virtual void AddCustodianInfoTrayObserver(
ash::CustodianInfoTrayObserver* observer) override {
}
virtual void RemoveCustodianInfoTrayObserver(
ash::CustodianInfoTrayObserver* observer) override {
}
private: private:
ash::SystemTrayNotifier* GetSystemTrayNotifier() { ash::SystemTrayNotifier* GetSystemTrayNotifier() {
return ash::Shell::GetInstance()->system_tray_notifier(); return ash::Shell::GetInstance()->system_tray_notifier();
......
...@@ -284,6 +284,14 @@ class SystemTrayDelegateWin : public ash::SystemTrayDelegate, ...@@ -284,6 +284,14 @@ class SystemTrayDelegateWin : public ash::SystemTrayDelegate,
return NULL; return NULL;
} }
virtual void AddCustodianInfoTrayObserver(
ash::CustodianInfoTrayObserver* observer) override {
}
virtual void RemoveCustodianInfoTrayObserver(
ash::CustodianInfoTrayObserver* observer) override {
}
private: private:
ash::SystemTrayNotifier* GetSystemTrayNotifier() { ash::SystemTrayNotifier* GetSystemTrayNotifier() {
return ash::Shell::GetInstance()->system_tray_notifier(); return ash::Shell::GetInstance()->system_tray_notifier();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment