Commit 7b6fd275 authored by David Black's avatar David Black Committed by Commit Bot

Handle holding space model already attached during tray creation.

The holding space model may already be attached when the holding space
tray is creating, such as if the user connects an external monitor
after login. When this occurs, we need to make sure to handle the
already attached model.

Bug: 1148044, 1147261
Change-Id: I842555a7cc27fd5e0bcd256179c202298baf8e61
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533291
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826569}
parent e851c8e5
...@@ -54,6 +54,12 @@ HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) { ...@@ -54,6 +54,12 @@ HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) {
// Icon. // Icon.
icon_ = tray_container()->AddChildView( icon_ = tray_container()->AddChildView(
std::make_unique<HoldingSpaceTrayIcon>(shelf)); std::make_unique<HoldingSpaceTrayIcon>(shelf));
// It's possible that this holding space tray was created after login, such as
// would occur if the user connects an external display. In such situations
// the holding space model will already have been attached.
if (HoldingSpaceController::Get()->model())
OnHoldingSpaceModelAttached(HoldingSpaceController::Get()->model());
} }
HoldingSpaceTray::~HoldingSpaceTray() = default; HoldingSpaceTray::~HoldingSpaceTray() = default;
......
...@@ -58,6 +58,12 @@ HoldingSpaceTrayIcon::HoldingSpaceTrayIcon(Shelf* shelf) : shelf_(shelf) { ...@@ -58,6 +58,12 @@ HoldingSpaceTrayIcon::HoldingSpaceTrayIcon(Shelf* shelf) : shelf_(shelf) {
controller_observer_.Add(HoldingSpaceController::Get()); controller_observer_.Add(HoldingSpaceController::Get());
shell_observer_.Add(Shell::Get()); shell_observer_.Add(Shell::Get());
session_observer_.Add(Shell::Get()->session_controller()); session_observer_.Add(Shell::Get()->session_controller());
// It's possible that this holding space tray icon was created after login,
// such as would occur if the user connects an external display. In such
// situations the holding space model will already have been attached.
if (HoldingSpaceController::Get()->model())
OnHoldingSpaceModelAttached(HoldingSpaceController::Get()->model());
} }
} }
......
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