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

Unified Diff: ash/wm/window_manager_extension.cc

Issue 10803037: [WIP] ash/extensions: Add experimental extension support for window-management in ash. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge-152100 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/wm/window_manager_extension.h ('k') | ash/wm/window_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/window_manager_extension.cc
diff --git a/ash/wm/window_manager_extension.cc b/ash/wm/window_manager_extension.cc
new file mode 100644
index 0000000000000000000000000000000000000000..37ffde77caf8cf680f82876749e91bcdf64307ab
--- /dev/null
+++ b/ash/wm/window_manager_extension.cc
@@ -0,0 +1,76 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/wm/window_manager_extension.h"
+
+#include "ash/shell.h"
+#include "ui/aura/client/activation_client.h"
+#include "ui/aura/env.h"
+#include "ui/aura/window.h"
+
+namespace ash {
+namespace internal {
+
+////////////////////////////////////////////////////////////////////////////////
+// WindowManagerExtension, public:
+
+WindowManagerExtension::WindowManagerExtension()
+ : delegate_(NULL) {
+ aura::Env::GetInstance()->AddObserver(this);
+ aura::client::GetActivationClient(
+ Shell::GetPrimaryRootWindow())->AddObserver(this);
+}
+
+WindowManagerExtension::~WindowManagerExtension() {
+ aura::client::GetActivationClient(
+ Shell::GetPrimaryRootWindow())->RemoveObserver(this);
+ aura::Env::GetInstance()->RemoveObserver(this);
+ for (size_t i = 0; i < windows_.size(); ++i)
+ windows_[i]->RemoveObserver(this);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WindowManagerExtension, aura::EnvObserver implementation:
+
+void WindowManagerExtension::OnWindowInitialized(aura::Window* window) {
+ windows_.push_back(window);
+ window->AddObserver(this);
+
+ if (delegate_)
+ delegate_->OnWindowCreated(window);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WindowManagerExtension, aura::WindowObserver implementation:
+
+void WindowManagerExtension::OnWindowVisibilityChanged(
+ aura::Window* window,
+ bool visible) {
+ if (delegate_) {
+ if (visible)
+ delegate_->OnWindowShown(window);
+ else
+ delegate_->OnWindowHidden(window);
+ }
+}
+
+void WindowManagerExtension::OnWindowDestroyed(aura::Window* window) {
+ windows_.erase(std::find(windows_.begin(), windows_.end(), window));
+ window->RemoveObserver(this);
+
+ if (delegate_)
+ delegate_->OnWindowClosed(window);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WindowManagerExtension, aura::WindowObserver implementation:
+
+void WindowManagerExtension::OnWindowActivated(aura::Window* active,
+ aura::Window* old_active) {
+ if (delegate_)
+ delegate_->OnActiveWindowChanged(active);
+}
+
+} // namespace internal
+} // namespace ash
« no previous file with comments | « ash/wm/window_manager_extension.h ('k') | ash/wm/window_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698