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

Unified Diff: ash/mus/disconnected_app_handler.cc

Issue 2629523006: chromeos: changes DisconnectedAppHandler to be associated with a single window (Closed)
Patch Set: merge Created 3 years, 11 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
« no previous file with comments | « ash/mus/disconnected_app_handler.h ('k') | ash/mus/root_window_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ash/mus/disconnected_app_handler.h ('k') | ash/mus/root_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698