Index: ash/common/wm/always_on_top_controller.cc |
diff --git a/ash/common/wm/always_on_top_controller.cc b/ash/common/wm/always_on_top_controller.cc |
index 275a4462df10cca3ace08399117dbfd1645a7ffc..92ff27d47122342f7dbd82baad7c2a51a84482a2 100644 |
--- a/ash/common/wm/always_on_top_controller.cc |
+++ b/ash/common/wm/always_on_top_controller.cc |
@@ -7,6 +7,7 @@ |
#include "ash/common/shell_window_ids.h" |
#include "ash/common/wm/workspace/workspace_layout_manager.h" |
#include "ash/common/wm/workspace/workspace_layout_manager_delegate.h" |
+#include "ash/common/wm_shell.h" |
#include "ash/common/wm_window.h" |
#include "ash/common/wm_window_property.h" |
#include "base/memory/ptr_util.h" |
@@ -17,14 +18,17 @@ AlwaysOnTopController::AlwaysOnTopController(WmWindow* viewport) |
: always_on_top_container_(viewport) { |
always_on_top_container_->SetLayoutManager( |
base::WrapUnique(new WorkspaceLayoutManager(viewport, nullptr))); |
+ WmShell::Get()->AddShellObserver(GetLayoutManager()); |
// Container should be empty. |
DCHECK(always_on_top_container_->GetChildren().empty()); |
always_on_top_container_->AddObserver(this); |
} |
AlwaysOnTopController::~AlwaysOnTopController() { |
- if (always_on_top_container_) |
+ if (always_on_top_container_) { |
always_on_top_container_->RemoveObserver(this); |
+ WmShell::Get()->RemoveShellObserver(GetLayoutManager()); |
+ } |
} |
WmWindow* AlwaysOnTopController::GetContainer(WmWindow* window) const { |
@@ -43,7 +47,9 @@ WorkspaceLayoutManager* AlwaysOnTopController::GetLayoutManager() const { |
void AlwaysOnTopController::SetLayoutManagerForTest( |
std::unique_ptr<WorkspaceLayoutManager> layout_manager) { |
+ WmShell::Get()->RemoveShellObserver(GetLayoutManager()); |
always_on_top_container_->SetLayoutManager(std::move(layout_manager)); |
+ WmShell::Get()->AddShellObserver(GetLayoutManager()); |
} |
void AlwaysOnTopController::OnWindowTreeChanged( |
@@ -70,6 +76,7 @@ void AlwaysOnTopController::OnWindowPropertyChanged(WmWindow* window, |
void AlwaysOnTopController::OnWindowDestroying(WmWindow* window) { |
if (window == always_on_top_container_) { |
always_on_top_container_->RemoveObserver(this); |
+ WmShell::Get()->RemoveShellObserver(GetLayoutManager()); |
always_on_top_container_ = nullptr; |
} |
} |