Index: ash/common/wm/workspace_controller.cc |
diff --git a/ash/wm/workspace_controller.cc b/ash/common/wm/workspace_controller.cc |
similarity index 92% |
rename from ash/wm/workspace_controller.cc |
rename to ash/common/wm/workspace_controller.cc |
index 7c893ca0117a3104bcd51c2942e4bc42ec5e255e..e29732631f133cbdc46150f24df116e5a6f6bd4d 100644 |
--- a/ash/wm/workspace_controller.cc |
+++ b/ash/common/wm/workspace_controller.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "ash/wm/workspace_controller.h" |
+#include "ash/common/wm/workspace_controller.h" |
#include <utility> |
@@ -19,14 +19,8 @@ |
#include "ash/common/wm_shell.h" |
#include "ash/common/wm_window.h" |
#include "base/memory/ptr_util.h" |
-#include "ui/aura/client/aura_constants.h" |
-#include "ui/aura/window.h" |
-#include "ui/aura/window_event_dispatcher.h" |
#include "ui/compositor/layer.h" |
#include "ui/compositor/scoped_layer_animation_settings.h" |
-#include "ui/wm/core/visibility_controller.h" |
-#include "ui/wm/core/window_animations.h" |
-#include "ui/wm/public/activation_client.h" |
namespace ash { |
namespace { |
@@ -44,11 +38,16 @@ WorkspaceController::WorkspaceController(WmWindow* viewport) |
: viewport_(viewport), |
event_handler_(WmShell::Get()->CreateWorkspaceEventHandler(viewport)), |
layout_manager_(new WorkspaceLayoutManager(viewport)) { |
+ viewport_->AddObserver(this); |
viewport_->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); |
viewport_->SetLayoutManager(base::WrapUnique(layout_manager_)); |
} |
WorkspaceController::~WorkspaceController() { |
+ if (!viewport_) |
+ return; |
+ |
+ viewport_->RemoveObserver(this); |
viewport_->SetLayoutManager(nullptr); |
} |
@@ -124,4 +123,12 @@ void WorkspaceController::SetMaximizeBackdropDelegate( |
layout_manager_->SetMaximizeBackdropDelegate(std::move(delegate)); |
} |
+void WorkspaceController::OnWindowDestroying(WmWindow* window) { |
+ DCHECK_EQ(window, viewport_); |
+ viewport_->RemoveObserver(this); |
+ viewport_ = nullptr; |
+ // Destroy |event_handler_| too as it depends upon |window|. |
+ event_handler_.reset(); |
+} |
+ |
} // namespace ash |