Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: ash/common/wm/always_on_top_controller.cc

Issue 2072853002: Implement "pinned" mode in ash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}
}

Powered by Google App Engine
This is Rietveld 408576698