| Index: ash/mus/disconnected_app_handler.cc
|
| diff --git a/ash/mus/disconnected_app_handler.cc b/ash/mus/disconnected_app_handler.cc
|
| index 3ae1f56ce2ae809c75fa0a1603ca16b0b54e3cde..cfc75fc4a7febbe4c830ec2367dca7325ac3848a 100644
|
| --- a/ash/mus/disconnected_app_handler.cc
|
| +++ b/ash/mus/disconnected_app_handler.cc
|
| @@ -7,62 +7,37 @@
|
| #include "ash/common/wm_window.h"
|
| #include "ash/public/cpp/shell_window_ids.h"
|
| #include "ui/aura/window.h"
|
| +#include "ui/aura/window_property.h"
|
| +
|
| +DECLARE_WINDOW_PROPERTY_TYPE(ash::mus::DisconnectedAppHandler*);
|
|
|
| namespace ash {
|
| namespace mus {
|
| namespace {
|
|
|
| -bool IsContainer(aura::Window* window) {
|
| - return WmWindow::Get(window)->GetShellWindowId() != kShellWindowId_Invalid;
|
| -}
|
| +DEFINE_OWNED_WINDOW_PROPERTY_KEY(DisconnectedAppHandler,
|
| + kDisconnectedAppHandlerKey,
|
| + nullptr);
|
|
|
| } // namespace
|
|
|
| -DisconnectedAppHandler::DisconnectedAppHandler(aura::Window* root_window) {
|
| - WmWindow* root = WmWindow::Get(root_window);
|
| - for (int shell_window_id = kShellWindowId_Min;
|
| - shell_window_id < kShellWindowId_Max; ++shell_window_id) {
|
| - // kShellWindowId_VirtualKeyboardContainer is lazily created.
|
| - // TODO(sky): http://crbug.com/616909 .
|
| - // kShellWindowId_PhantomWindow is not a container, but a window.
|
| - if (shell_window_id == kShellWindowId_VirtualKeyboardContainer ||
|
| - shell_window_id == kShellWindowId_PhantomWindow)
|
| - continue;
|
| -
|
| -// kShellWindowId_MouseCursorContainer is chromeos specific.
|
| -#if !defined(OS_CHROMEOS)
|
| - if (shell_window_id == kShellWindowId_MouseCursorContainer)
|
| - continue;
|
| -#endif
|
| -
|
| - WmWindow* container = root->GetChildByShellWindowId(shell_window_id);
|
| - Add(container->aura_window());
|
| -
|
| - // Add any pre-existing windows in the container to
|
| - // |disconnected_app_handler_|.
|
| - for (aura::Window* child : container->aura_window()->children()) {
|
| - if (!IsContainer(child))
|
| - Add(child);
|
| - }
|
| - }
|
| +// static
|
| +void DisconnectedAppHandler::Create(aura::Window* window) {
|
| + window->SetProperty(kDisconnectedAppHandlerKey,
|
| + new DisconnectedAppHandler(window));
|
| }
|
|
|
| -DisconnectedAppHandler::~DisconnectedAppHandler() {}
|
| -
|
| -void DisconnectedAppHandler::OnEmbeddedAppDisconnected(aura::Window* window) {
|
| - if (!IsContainer(window))
|
| - delete window;
|
| +DisconnectedAppHandler::DisconnectedAppHandler(aura::Window* window)
|
| + : window_(window) {
|
| + window->AddObserver(this);
|
| }
|
|
|
| -void DisconnectedAppHandler::OnWindowHierarchyChanging(
|
| - const HierarchyChangeParams& params) {
|
| - if (params.old_parent == params.receiver && IsContainer(params.old_parent))
|
| - Remove(params.target);
|
| -
|
| - if (params.new_parent == params.receiver && IsContainer(params.new_parent))
|
| - Add(params.target);
|
| +DisconnectedAppHandler::~DisconnectedAppHandler() {
|
| + window_->RemoveObserver(this);
|
| +}
|
|
|
| - aura::WindowTracker::OnWindowHierarchyChanging(params);
|
| +void DisconnectedAppHandler::OnEmbeddedAppDisconnected(aura::Window* window) {
|
| + delete window_;
|
| }
|
|
|
| } // namespace mus
|
|
|