| Index: ui/aura/test/test_activation_client.cc
|
| diff --git a/ui/aura/test/test_activation_client.cc b/ui/aura/test/test_activation_client.cc
|
| index 7ba0d41e0f4f8134fef95060fed62db274acad2d..a1387f77e168ef83b79738520124195dc1b0f0f2 100644
|
| --- a/ui/aura/test/test_activation_client.cc
|
| +++ b/ui/aura/test/test_activation_client.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "ui/aura/test/test_activation_client.h"
|
|
|
| +#include "ui/aura/client/activation_delegate.h"
|
| #include "ui/aura/root_window.h"
|
| #include "ui/aura/window.h"
|
|
|
| @@ -13,34 +14,44 @@ namespace test {
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // TestActivationClient, public:
|
|
|
| -TestActivationClient::TestActivationClient(RootWindow* root_window)
|
| - : active_window_(NULL) {
|
| +TestActivationClient::TestActivationClient(RootWindow* root_window) {
|
| client::SetActivationClient(root_window, this);
|
| }
|
|
|
| TestActivationClient::~TestActivationClient() {
|
| + for (unsigned int i = 0; i < active_windows_.size(); ++i) {
|
| + active_windows_[i]->RemoveObserver(this);
|
| + }
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // TestActivationClient, client::ActivationClient implementation:
|
|
|
| void TestActivationClient::ActivateWindow(Window* window) {
|
| - if (active_window_)
|
| - active_window_->RemoveObserver(this);
|
| - active_window_ = window;
|
| - active_window_->AddObserver(this);
|
| + Window *last_active = GetActiveWindow();
|
| + if (last_active == window)
|
| + return;
|
| +
|
| + RemoveActiveWindow(window);
|
| + active_windows_.push_back(window);
|
| + window->AddObserver(this);
|
| + if (aura::client::GetActivationDelegate(window))
|
| + aura::client::GetActivationDelegate(window)->OnActivated();
|
| +
|
| + if (last_active && aura::client::GetActivationDelegate(last_active))
|
| + aura::client::GetActivationDelegate(last_active)->OnLostActive();
|
| +
|
| }
|
|
|
| void TestActivationClient::DeactivateWindow(Window* window) {
|
| - if (window == active_window_) {
|
| - if (active_window_)
|
| - active_window_->RemoveObserver(this);
|
| - active_window_ = NULL;
|
| - }
|
| + if (aura::client::GetActivationDelegate(window))
|
| + aura::client::GetActivationDelegate(window)->OnLostActive();
|
| }
|
|
|
| Window* TestActivationClient::GetActiveWindow() {
|
| - return active_window_;
|
| + if (active_windows_.empty())
|
| + return NULL;
|
| + return active_windows_.back();
|
| }
|
|
|
| bool TestActivationClient::CanFocusWindow(Window* window) const {
|
| @@ -51,9 +62,25 @@ bool TestActivationClient::CanFocusWindow(Window* window) const {
|
| // TestActivationClient, WindowObserver implementation:
|
|
|
| void TestActivationClient::OnWindowDestroyed(Window* window) {
|
| - if (window == active_window_) {
|
| + if (window == GetActiveWindow()) {
|
| window->RemoveObserver(this);
|
| - active_window_ = NULL;
|
| + active_windows_.pop_back();
|
| + Window* next_active = GetActiveWindow();
|
| + if (next_active && aura::client::GetActivationDelegate(next_active))
|
| + aura::client::GetActivationDelegate(next_active)->OnActivated();
|
| + return;
|
| + }
|
| +
|
| + RemoveActiveWindow(window);
|
| +}
|
| +
|
| +void TestActivationClient::RemoveActiveWindow(Window* window) {
|
| + for (unsigned int i = 0; i < active_windows_.size(); ++i) {
|
| + if (active_windows_[i] == window) {
|
| + active_windows_.erase(active_windows_.begin() + i);
|
| + window->RemoveObserver(this);
|
| + return;
|
| + }
|
| }
|
| }
|
|
|
|
|