Commit 1d721775 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Remove NOTIFICATION_PROFILE_DESTROYED from //c/b/chromeos

Bug: 268984
Change-Id: Iabb05901e16d6002304ddf1ad427e0ea2836468b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1873215
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708425}
parent 80ca9f23
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/extensions/api/braille_display_private/stub_braille_controller.h" #include "chrome/browser/extensions/api/braille_display_private/stub_braille_controller.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.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/singleton_tabs.h" #include "chrome/browser/ui/singleton_tabs.h"
...@@ -241,8 +240,6 @@ AccessibilityManager::AccessibilityManager() { ...@@ -241,8 +240,6 @@ AccessibilityManager::AccessibilityManager() {
notification_registrar_.Add(this, notification_registrar_.Add(this,
chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
content::NotificationService::AllSources()); content::NotificationService::AllSources());
notification_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
content::NotificationService::AllSources());
notification_registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, notification_registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
content::NotificationService::AllSources()); content::NotificationService::AllSources());
notification_registrar_.Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, notification_registrar_.Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
...@@ -1052,10 +1049,19 @@ void AccessibilityManager::OnActiveOutputNodeChanged() { ...@@ -1052,10 +1049,19 @@ void AccessibilityManager::OnActiveOutputNodeChanged() {
} }
} }
void AccessibilityManager::OnProfileWillBeDestroyed(Profile* profile) {
DCHECK_EQ(profile_, profile);
SetProfile(nullptr);
}
void AccessibilityManager::SetProfile(Profile* profile) { void AccessibilityManager::SetProfile(Profile* profile) {
if (profile_ == profile) if (profile_ == profile)
return; return;
if (profile_)
profile_observer_.Remove(profile_);
DCHECK(!profile_observer_.IsObservingSources());
pref_change_registrar_.reset(); pref_change_registrar_.reset();
local_state_pref_change_registrar_.reset(); local_state_pref_change_registrar_.reset();
...@@ -1141,6 +1147,8 @@ void AccessibilityManager::SetProfile(Profile* profile) { ...@@ -1141,6 +1147,8 @@ void AccessibilityManager::SetProfile(Profile* profile) {
extensions::ExtensionRegistry::Get(profile); extensions::ExtensionRegistry::Get(profile);
if (!extension_registry_observer_.IsObserving(registry)) if (!extension_registry_observer_.IsObserving(registry))
extension_registry_observer_.Add(registry); extension_registry_observer_.Add(registry);
profile_observer_.Add(profile);
} }
bool had_profile = (profile_ != NULL); bool had_profile = (profile_ != NULL);
...@@ -1278,13 +1286,6 @@ void AccessibilityManager::Observe( ...@@ -1278,13 +1286,6 @@ void AccessibilityManager::Observe(
SetProfile(profile); SetProfile(profile);
break; break;
} }
case chrome::NOTIFICATION_PROFILE_DESTROYED: {
// Update |profile_| when exiting a session or shutting down.
Profile* profile = content::Source<Profile>(source).ptr();
if (profile_ == profile)
SetProfile(nullptr);
break;
}
case chrome::NOTIFICATION_APP_TERMINATING: { case chrome::NOTIFICATION_APP_TERMINATING: {
app_terminating_ = true; app_terminating_ = true;
break; break;
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "chrome/browser/chromeos/accessibility/chromevox_panel.h" #include "chrome/browser/chromeos/accessibility/chromevox_panel.h"
#include "chrome/browser/chromeos/accessibility/switch_access_panel.h" #include "chrome/browser/chromeos/accessibility/switch_access_panel.h"
#include "chrome/browser/extensions/api/braille_display_private/braille_controller.h" #include "chrome/browser/extensions/api/braille_display_private/braille_controller.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_observer.h"
#include "chromeos/audio/cras_audio_handler.h" #include "chromeos/audio/cras_audio_handler.h"
#include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_change_registrar.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
...@@ -35,7 +37,6 @@ ...@@ -35,7 +37,6 @@
#include "ui/base/ime/chromeos/input_method_manager.h" #include "ui/base/ime/chromeos/input_method_manager.h"
class Browser; class Browser;
class Profile;
class SwitchAccessEventHandlerDelegate; class SwitchAccessEventHandlerDelegate;
namespace ash { namespace ash {
...@@ -109,7 +110,8 @@ class AccessibilityManager ...@@ -109,7 +110,8 @@ class AccessibilityManager
public extensions::ExtensionRegistryObserver, public extensions::ExtensionRegistryObserver,
public user_manager::UserManager::UserSessionStateObserver, public user_manager::UserManager::UserSessionStateObserver,
public input_method::InputMethodManager::Observer, public input_method::InputMethodManager::Observer,
public CrasAudioHandler::AudioObserver { public CrasAudioHandler::AudioObserver,
public ProfileObserver {
public: public:
// Creates an instance of AccessibilityManager, this should be called once, // Creates an instance of AccessibilityManager, this should be called once,
// because only one instance should exist at the same time. // because only one instance should exist at the same time.
...@@ -429,8 +431,12 @@ class AccessibilityManager ...@@ -429,8 +431,12 @@ class AccessibilityManager
// CrasAudioHandler::AudioObserver: // CrasAudioHandler::AudioObserver:
void OnActiveOutputNodeChanged() override; void OnActiveOutputNodeChanged() override;
// ProfileObserver:
void OnProfileWillBeDestroyed(Profile* profile) override;
// Profile which has the current a11y context. // Profile which has the current a11y context.
Profile* profile_ = nullptr; Profile* profile_ = nullptr;
ScopedObserver<Profile, ProfileObserver> profile_observer_{this};
content::NotificationRegistrar notification_registrar_; content::NotificationRegistrar notification_registrar_;
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -95,6 +94,11 @@ double MagnificationManager::GetSavedScreenMagnifierScale() const { ...@@ -95,6 +94,11 @@ double MagnificationManager::GetSavedScreenMagnifierScale() const {
ash::prefs::kAccessibilityScreenMagnifierScale); ash::prefs::kAccessibilityScreenMagnifierScale);
} }
void MagnificationManager::OnProfileWillBeDestroyed(Profile* profile) {
DCHECK_EQ(profile_, profile);
SetProfile(nullptr);
}
void MagnificationManager::OnViewEvent(views::View* view, void MagnificationManager::OnViewEvent(views::View* view,
ax::mojom::Event event_type) { ax::mojom::Event event_type) {
if (!fullscreen_magnifier_enabled_ && !IsDockedMagnifierEnabled()) if (!fullscreen_magnifier_enabled_ && !IsDockedMagnifierEnabled())
...@@ -114,8 +118,6 @@ void MagnificationManager::SetProfileForTest(Profile* profile) { ...@@ -114,8 +118,6 @@ void MagnificationManager::SetProfileForTest(Profile* profile) {
MagnificationManager::MagnificationManager() { MagnificationManager::MagnificationManager() {
registrar_.Add(this, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, registrar_.Add(this, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
content::NotificationService::AllSources()); content::NotificationService::AllSources());
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
content::NotificationService::AllSources());
// TODO(warx): observe focus changed in page notification when either // TODO(warx): observe focus changed in page notification when either
// fullscreen magnifier or docked magnifier is enabled. // fullscreen magnifier or docked magnifier is enabled.
registrar_.Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, registrar_.Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
...@@ -142,13 +144,6 @@ void MagnificationManager::Observe( ...@@ -142,13 +144,6 @@ void MagnificationManager::Observe(
SetProfile(profile); SetProfile(profile);
break; break;
} }
case chrome::NOTIFICATION_PROFILE_DESTROYED: {
// Update |profile_| when exiting a session or shutting down.
Profile* profile = content::Source<Profile>(source).ptr();
if (profile_ == profile)
SetProfile(NULL);
break;
}
case content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE: { case content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE: {
HandleFocusChangedInPage(details); HandleFocusChangedInPage(details);
break; break;
...@@ -170,6 +165,10 @@ void MagnificationManager::SetProfileByUser(const user_manager::User* user) { ...@@ -170,6 +165,10 @@ void MagnificationManager::SetProfileByUser(const user_manager::User* user) {
} }
void MagnificationManager::SetProfile(Profile* profile) { void MagnificationManager::SetProfile(Profile* profile) {
if (profile_)
profile_observer_.Remove(profile_);
DCHECK(!profile_observer_.IsObservingSources());
pref_change_registrar_.reset(); pref_change_registrar_.reset();
if (profile) { if (profile) {
...@@ -193,6 +192,8 @@ void MagnificationManager::SetProfile(Profile* profile) { ...@@ -193,6 +192,8 @@ void MagnificationManager::SetProfile(Profile* profile) {
base::BindRepeating( base::BindRepeating(
&MagnificationManager::UpdateDockedMagnifierFromPrefs, &MagnificationManager::UpdateDockedMagnifierFromPrefs,
base::Unretained(this))); base::Unretained(this)));
profile_observer_.Add(profile);
} }
profile_ = profile; profile_ = profile;
......
...@@ -7,13 +7,15 @@ ...@@ -7,13 +7,15 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_observer.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
#include "ui/views/accessibility/ax_event_observer.h" #include "ui/views/accessibility/ax_event_observer.h"
class PrefChangeRegistrar; class PrefChangeRegistrar;
class Profile;
namespace chromeos { namespace chromeos {
...@@ -32,6 +34,7 @@ namespace chromeos { ...@@ -32,6 +34,7 @@ namespace chromeos {
class MagnificationManager class MagnificationManager
: public content::NotificationObserver, : public content::NotificationObserver,
public user_manager::UserManager::UserSessionStateObserver, public user_manager::UserManager::UserSessionStateObserver,
public ProfileObserver,
public views::AXEventObserver { public views::AXEventObserver {
public: public:
// Creates an instance of MagnificationManager. This should be called once. // Creates an instance of MagnificationManager. This should be called once.
...@@ -61,6 +64,9 @@ class MagnificationManager ...@@ -61,6 +64,9 @@ class MagnificationManager
// Loads the Fullscreen magnifier scale from the pref. // Loads the Fullscreen magnifier scale from the pref.
double GetSavedScreenMagnifierScale() const; double GetSavedScreenMagnifierScale() const;
// ProfileObserver:
void OnProfileWillBeDestroyed(Profile* profile) override;
// views::AXEventObserver: // views::AXEventObserver:
void OnViewEvent(views::View* view, ax::mojom::Event event_type) override; void OnViewEvent(views::View* view, ax::mojom::Event event_type) override;
...@@ -94,6 +100,7 @@ class MagnificationManager ...@@ -94,6 +100,7 @@ class MagnificationManager
void HandleFocusChanged(const gfx::Rect& bounds_in_screen, bool is_editable); void HandleFocusChanged(const gfx::Rect& bounds_in_screen, bool is_editable);
Profile* profile_ = nullptr; Profile* profile_ = nullptr;
ScopedObserver<Profile, ProfileObserver> profile_observer_{this};
bool fullscreen_magnifier_enabled_ = false; bool fullscreen_magnifier_enabled_ = false;
bool keep_focus_centered_ = false; bool keep_focus_centered_ = false;
......
...@@ -4,18 +4,12 @@ ...@@ -4,18 +4,12 @@
#include "chrome/browser/chromeos/note_taking_controller_client.h" #include "chrome/browser/chromeos/note_taking_controller_client.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
namespace chromeos { namespace chromeos {
NoteTakingControllerClient::NoteTakingControllerClient(NoteTakingHelper* helper) NoteTakingControllerClient::NoteTakingControllerClient(NoteTakingHelper* helper)
: helper_(helper) { : helper_(helper) {
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
content::NotificationService::AllSources());
user_manager::UserManager::Get()->AddSessionStateObserver(this); user_manager::UserManager::Get()->AddSessionStateObserver(this);
} }
...@@ -41,20 +35,18 @@ void NoteTakingControllerClient::ActiveUserChanged( ...@@ -41,20 +35,18 @@ void NoteTakingControllerClient::ActiveUserChanged(
weak_ptr_factory_.GetWeakPtr(), active_user)); weak_ptr_factory_.GetWeakPtr(), active_user));
} }
void NoteTakingControllerClient::Observe( void NoteTakingControllerClient::OnProfileWillBeDestroyed(Profile* profile) {
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(type, chrome::NOTIFICATION_PROFILE_DESTROYED);
// Update |profile_| when exiting a session or shutting down. // Update |profile_| when exiting a session or shutting down.
Profile* profile = content::Source<Profile>(source).ptr(); DCHECK_EQ(profile_, profile);
if (profile_ == profile) profile_observer_.Remove(profile_);
profile_ = nullptr; profile_ = nullptr;
} }
void NoteTakingControllerClient::SetProfileByUser( void NoteTakingControllerClient::SetProfileByUser(
const user_manager::User* user) { const user_manager::User* user) {
profile_ = ProfileHelper::Get()->GetProfileByUser(user); profile_ = ProfileHelper::Get()->GetProfileByUser(user);
profile_observer_.RemoveAll();
profile_observer_.Add(profile_);
} }
} // namespace chromeos } // namespace chromeos
...@@ -9,18 +9,16 @@ ...@@ -9,18 +9,16 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/note_taking_helper.h" #include "chrome/browser/chromeos/note_taking_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_observer.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
class Profile;
namespace chromeos { namespace chromeos {
class NoteTakingControllerClient class NoteTakingControllerClient
: public ash::NoteTakingClient, : public ash::NoteTakingClient,
public user_manager::UserManager::UserSessionStateObserver, public user_manager::UserManager::UserSessionStateObserver,
public content::NotificationObserver { public ProfileObserver {
public: public:
explicit NoteTakingControllerClient(NoteTakingHelper* helper); explicit NoteTakingControllerClient(NoteTakingHelper* helper);
~NoteTakingControllerClient() override; ~NoteTakingControllerClient() override;
...@@ -32,10 +30,8 @@ class NoteTakingControllerClient ...@@ -32,10 +30,8 @@ class NoteTakingControllerClient
// user_manager::UserManager::UserSessionStateObserver: // user_manager::UserManager::UserSessionStateObserver:
void ActiveUserChanged(user_manager::User* active_user) override; void ActiveUserChanged(user_manager::User* active_user) override;
// content::NotificationObserver: // ProfileObserver:
void Observe(int type, void OnProfileWillBeDestroyed(Profile* profile) override;
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
void SetProfileForTesting(Profile* profile) { profile_ = profile; } void SetProfileForTesting(Profile* profile) { profile_ = profile; }
...@@ -47,8 +43,8 @@ class NoteTakingControllerClient ...@@ -47,8 +43,8 @@ class NoteTakingControllerClient
// Unowned pointer to the active profile. // Unowned pointer to the active profile.
Profile* profile_ = nullptr; Profile* profile_ = nullptr;
ScopedObserver<Profile, ProfileObserver> profile_observer_{this};
content::NotificationRegistrar registrar_;
base::WeakPtrFactory<NoteTakingControllerClient> weak_ptr_factory_{this}; base::WeakPtrFactory<NoteTakingControllerClient> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(NoteTakingControllerClient); DISALLOW_COPY_AND_ASSIGN(NoteTakingControllerClient);
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h" #include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/system/system_clock_observer.h" #include "chrome/browser/chromeos/system/system_clock_observer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chromeos/login/login_state/login_state.h" #include "chromeos/login/login_state/login_state.h"
#include "chromeos/settings/cros_settings_names.h" #include "chromeos/settings/cros_settings_names.h"
...@@ -54,8 +52,6 @@ SystemClock::SystemClock() { ...@@ -54,8 +52,6 @@ SystemClock::SystemClock() {
if (LoginState::IsInitialized()) if (LoginState::IsInitialized())
LoginState::Get()->AddObserver(this); LoginState::Get()->AddObserver(this);
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
content::NotificationService::AllSources());
user_manager::UserManager::Get()->AddSessionStateObserver(this); user_manager::UserManager::Get()->AddSessionStateObserver(this);
} }
...@@ -67,7 +63,6 @@ SystemClock::~SystemClock() { ...@@ -67,7 +63,6 @@ SystemClock::~SystemClock() {
user_manager::UserManager::Get()->RemoveSessionStateObserver(this); user_manager::UserManager::Get()->RemoveSessionStateObserver(this);
} }
// LoginState::Observer overrides.
void SystemClock::LoggedInStateChanged() { void SystemClock::LoggedInStateChanged() {
// It apparently sometimes takes a while after login before the current user // It apparently sometimes takes a while after login before the current user
// is recognized as the owner. Make sure that the system-wide clock setting // is recognized as the owner. Make sure that the system-wide clock setting
...@@ -76,15 +71,11 @@ void SystemClock::LoggedInStateChanged() { ...@@ -76,15 +71,11 @@ void SystemClock::LoggedInStateChanged() {
SetShouldUse24HourClock(ShouldUse24HourClock()); SetShouldUse24HourClock(ShouldUse24HourClock());
} }
// content::NotificationObserver implementation. void SystemClock::OnProfileWillBeDestroyed(Profile* profile) {
void SystemClock::Observe(int type, DCHECK_EQ(profile, user_profile_);
const content::NotificationSource& source, profile_observer_.Remove(profile);
const content::NotificationDetails& details) { user_pref_registrar_.reset();
DCHECK_EQ(type, chrome::NOTIFICATION_PROFILE_DESTROYED); user_profile_ = nullptr;
if (OnProfileDestroyed(content::Source<Profile>(source).ptr())) {
registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
content::NotificationService::AllSources());
}
} }
void SystemClock::ActiveUserChanged(user_manager::User* active_user) { void SystemClock::ActiveUserChanged(user_manager::User* active_user) {
...@@ -110,6 +101,8 @@ void SystemClock::SetProfileByUser(const user_manager::User* user) { ...@@ -110,6 +101,8 @@ void SystemClock::SetProfileByUser(const user_manager::User* user) {
void SystemClock::SetProfile(Profile* profile) { void SystemClock::SetProfile(Profile* profile) {
user_profile_ = profile; user_profile_ = profile;
profile_observer_.RemoveAll();
profile_observer_.Add(profile);
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);
...@@ -119,14 +112,6 @@ void SystemClock::SetProfile(Profile* profile) { ...@@ -119,14 +112,6 @@ void SystemClock::SetProfile(Profile* profile) {
UpdateClockType(); UpdateClockType();
} }
bool SystemClock::OnProfileDestroyed(Profile* profile) {
if (profile != user_profile_)
return false;
user_pref_registrar_.reset();
user_profile_ = NULL;
return true;
}
void SystemClock::SetLastFocusedPodHourClockType( void SystemClock::SetLastFocusedPodHourClockType(
base::HourClockType hour_clock_type) { base::HourClockType hour_clock_type) {
user_pod_was_focused_ = true; user_pod_was_focused_ = true;
......
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
#include "base/i18n/time_formatting.h" #include "base/i18n/time_formatting.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_observer.h"
#include "chromeos/login/login_state/login_state.h" #include "chromeos/login/login_state/login_state.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
class Profile;
class PrefChangeRegistrar; class PrefChangeRegistrar;
namespace user_manager { namespace user_manager {
...@@ -33,7 +33,7 @@ class SystemClockObserver; ...@@ -33,7 +33,7 @@ class SystemClockObserver;
// modify on-screen time representation (like ActiveUserChanged) and notifies // modify on-screen time representation (like ActiveUserChanged) and notifies
// observers. // observers.
class SystemClock : public chromeos::LoginState::Observer, class SystemClock : public chromeos::LoginState::Observer,
public content::NotificationObserver, public ProfileObserver,
public user_manager::UserManager::UserSessionStateObserver { public user_manager::UserManager::UserSessionStateObserver {
public: public:
SystemClock(); SystemClock();
...@@ -46,12 +46,10 @@ class SystemClock : public chromeos::LoginState::Observer, ...@@ -46,12 +46,10 @@ class SystemClock : public chromeos::LoginState::Observer,
bool ShouldUse24HourClock() const; bool ShouldUse24HourClock() const;
// content::NotificationObserver implementation. // ProfileObserver:
void Observe(int type, void OnProfileWillBeDestroyed(Profile* profile) override;
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
// user_manager::UserManager::UserSessionStateObserver overrides // user_manager::UserManager::UserSessionStateObserver:
void ActiveUserChanged(user_manager::User* active_user) override; void ActiveUserChanged(user_manager::User* active_user) override;
private: private:
...@@ -61,7 +59,6 @@ class SystemClock : public chromeos::LoginState::Observer, ...@@ -61,7 +59,6 @@ class SystemClock : public chromeos::LoginState::Observer,
void SetProfileByUser(const user_manager::User* user); void SetProfileByUser(const user_manager::User* user);
void SetProfile(Profile* profile); void SetProfile(Profile* profile);
bool OnProfileDestroyed(Profile* profile);
// LoginState::Observer overrides. // LoginState::Observer overrides.
void LoggedInStateChanged() override; void LoggedInStateChanged() override;
...@@ -74,7 +71,7 @@ class SystemClock : public chromeos::LoginState::Observer, ...@@ -74,7 +71,7 @@ class SystemClock : public chromeos::LoginState::Observer,
base::HourClockType last_focused_pod_hour_clock_type_ = base::k12HourClock; base::HourClockType last_focused_pod_hour_clock_type_ = base::k12HourClock;
Profile* user_profile_ = nullptr; Profile* user_profile_ = nullptr;
content::NotificationRegistrar registrar_; ScopedObserver<Profile, ProfileObserver> profile_observer_{this};
std::unique_ptr<PrefChangeRegistrar> user_pref_registrar_; std::unique_ptr<PrefChangeRegistrar> user_pref_registrar_;
base::ObserverList<SystemClockObserver>::Unchecked observer_list_; base::ObserverList<SystemClockObserver>::Unchecked observer_list_;
......
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