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

Unified Diff: ash/shell/window_watcher.cc

Issue 10830365: Initial crack at new workspace behavior. Each workspace now has its (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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/shell/window_watcher.h ('k') | ash/shell_window_ids.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shell/window_watcher.cc
diff --git a/ash/shell/window_watcher.cc b/ash/shell/window_watcher.cc
index dfd54ffdaf6a2e9b10323f23ab1f9d14375d27a5..a85d8f6c282d4eb632cf3e438209cdf27da1daa5 100644
--- a/ash/shell/window_watcher.cc
+++ b/ash/shell/window_watcher.cc
@@ -13,17 +13,45 @@
namespace ash {
namespace shell {
+class WindowWatcher::WorkspaceWindowWatcher : public aura::WindowObserver {
+ public:
+ explicit WorkspaceWindowWatcher(WindowWatcher* watcher) : watcher_(watcher) {
+ watcher_->window_->AddObserver(this);
+ for (size_t i = 0; i < watcher_->window_->children().size(); ++i)
+ watcher_->window_->children()[i]->AddObserver(watcher_);
+ }
+
+ virtual ~WorkspaceWindowWatcher() {
+ watcher_->window_->RemoveObserver(this);
+ for (size_t i = 0; i < watcher_->window_->children().size(); ++i)
+ watcher_->window_->children()[i]->RemoveObserver(watcher_);
+ }
+
+ virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE {
+ new_window->AddObserver(watcher_);
+ }
+
+ virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE {
+ DCHECK(window->children().empty());
+ window->RemoveObserver(watcher_);
+ }
+
+ private:
+ WindowWatcher* watcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowWatcher);
+};
+
WindowWatcher::WindowWatcher()
: window_(ash::Shell::GetInstance()->launcher()->window_container()),
panel_container_(ash::Shell::GetContainer(
Shell::GetPrimaryRootWindow(),
internal::kShellWindowId_PanelContainer)) {
- window_->AddObserver(this);
+ workspace_window_watcher_.reset(new WorkspaceWindowWatcher(this));
panel_container_->AddObserver(this);
}
WindowWatcher::~WindowWatcher() {
- window_->RemoveObserver(this);
panel_container_->RemoveObserver(this);
}
« no previous file with comments | « ash/shell/window_watcher.h ('k') | ash/shell_window_ids.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698