| 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
|
|
|