Commit 551152ef authored by jdufault's avatar jdufault Committed by Commit bot

Shutdown the status tray before the system tray delegate.

This also deactivates the keyboard before shutting down the shelf, which fixes a crash introduced by the above change.

BUG=577413

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

Cr-Commit-Position: refs/heads/master@{#371847}
parent fce23e00
......@@ -471,6 +471,15 @@ void Shell::ShowShelf() {
(*iter)->ShowShelf();
}
void Shell::HideShelf() {
RootWindowControllerList controllers = GetAllRootWindowControllers();
for (RootWindowControllerList::iterator iter = controllers.begin();
iter != controllers.end(); ++iter) {
if ((*iter)->shelf())
(*iter)->shelf()->ShutdownStatusAreaWidget();
}
}
void Shell::AddShellObserver(ShellObserver* observer) {
observers_.AddObserver(observer);
}
......@@ -715,7 +724,13 @@ Shell::~Shell() {
logout_confirmation_controller_.reset();
#endif
// Destroy SystemTrayDelegate before destroying the status area(s).
// Destroy the keyboard before closing the shelf, since it will invoke a shelf
// layout.
DeactivateKeyboard();
// Destroy SystemTrayDelegate before destroying the status area(s). Make sure
// to deinitialize the shelf first, as it is initialized after the delegate.
HideShelf();
system_tray_delegate_->Shutdown();
system_tray_delegate_.reset();
......
......@@ -604,6 +604,9 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,
// Initializes the root window so that it can host browser windows.
void InitRootWindow(aura::Window* root_window);
// Hides the shelf view if any are visible.
void HideShelf();
// ash::SystemModalContainerEventFilterDelegate overrides:
bool CanWindowReceiveEvents(aura::Window* window) override;
......
......@@ -42,12 +42,6 @@ const int kStopButtonRightPadding = 18;
// Returns the active CastConfigDelegate instance.
ash::CastConfigDelegate* GetCastConfigDelegate() {
// When shutting down Chrome, there may not be a shell or a delegate instance.
if (!ash::Shell::GetInstance() ||
!ash::Shell::GetInstance()->system_tray_delegate()) {
return nullptr;
}
return ash::Shell::GetInstance()
->system_tray_delegate()
->GetCastConfigDelegate();
......@@ -560,14 +554,9 @@ TrayCast::TrayCast(SystemTray* system_tray) : SystemTrayItem(system_tray) {
}
TrayCast::~TrayCast() {
// TODO(jdufault): Remove these if checks (and the ones in
// GetCastConfigDelegate) by fixing deinit order. See crbug.com/577413.
if (Shell::GetInstance())
Shell::GetInstance()->RemoveShellObserver(this);
ash::CastConfigDelegate* cast_config_delegate = GetCastConfigDelegate();
if (added_observer_ && cast_config_delegate)
cast_config_delegate->RemoveObserver(this);
Shell::GetInstance()->RemoveShellObserver(this);
if (added_observer_)
GetCastConfigDelegate()->RemoveObserver(this);
}
void TrayCast::StartCastForTest(const std::string& receiver_id) {
......
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