| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/aura/test/test_activation_client.h" | 5 #include "ui/aura/test/test_activation_client.h" |
| 6 | 6 |
| 7 #include "ui/aura/client/activation_change_observer.h" |
| 7 #include "ui/aura/client/activation_delegate.h" | 8 #include "ui/aura/client/activation_delegate.h" |
| 8 #include "ui/aura/root_window.h" | 9 #include "ui/aura/root_window.h" |
| 9 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 10 | 11 |
| 11 namespace aura { | 12 namespace aura { |
| 12 namespace test { | 13 namespace test { |
| 13 | 14 |
| 14 //////////////////////////////////////////////////////////////////////////////// | 15 //////////////////////////////////////////////////////////////////////////////// |
| 15 // TestActivationClient, public: | 16 // TestActivationClient, public: |
| 16 | 17 |
| 17 TestActivationClient::TestActivationClient(RootWindow* root_window) { | 18 TestActivationClient::TestActivationClient(RootWindow* root_window) { |
| 18 client::SetActivationClient(root_window, this); | 19 client::SetActivationClient(root_window, this); |
| 19 } | 20 } |
| 20 | 21 |
| 21 TestActivationClient::~TestActivationClient() { | 22 TestActivationClient::~TestActivationClient() { |
| 22 for (unsigned int i = 0; i < active_windows_.size(); ++i) { | 23 for (unsigned int i = 0; i < active_windows_.size(); ++i) { |
| 23 active_windows_[i]->RemoveObserver(this); | 24 active_windows_[i]->RemoveObserver(this); |
| 24 } | 25 } |
| 25 } | 26 } |
| 26 | 27 |
| 27 //////////////////////////////////////////////////////////////////////////////// | 28 //////////////////////////////////////////////////////////////////////////////// |
| 28 // TestActivationClient, client::ActivationClient implementation: | 29 // TestActivationClient, client::ActivationClient implementation: |
| 29 | 30 |
| 30 void TestActivationClient::AddObserver( | 31 void TestActivationClient::AddObserver( |
| 31 client::ActivationChangeObserver* observer) { | 32 client::ActivationChangeObserver* observer) { |
| 33 observers_.AddObserver(observer); |
| 32 } | 34 } |
| 33 | 35 |
| 34 void TestActivationClient::RemoveObserver( | 36 void TestActivationClient::RemoveObserver( |
| 35 client::ActivationChangeObserver* observer) { | 37 client::ActivationChangeObserver* observer) { |
| 38 observers_.RemoveObserver(observer); |
| 36 } | 39 } |
| 37 | 40 |
| 38 void TestActivationClient::ActivateWindow(Window* window) { | 41 void TestActivationClient::ActivateWindow(Window* window) { |
| 39 Window *last_active = GetActiveWindow(); | 42 Window* last_active = GetActiveWindow(); |
| 40 if (last_active == window) | 43 if (last_active == window) |
| 41 return; | 44 return; |
| 42 | 45 |
| 43 RemoveActiveWindow(window); | 46 RemoveActiveWindow(window); |
| 44 active_windows_.push_back(window); | 47 active_windows_.push_back(window); |
| 45 window->AddObserver(this); | 48 window->AddObserver(this); |
| 49 |
| 50 FOR_EACH_OBSERVER(client::ActivationChangeObserver, |
| 51 observers_, |
| 52 OnWindowActivated(window, last_active)); |
| 53 |
| 46 if (aura::client::GetActivationDelegate(window)) | 54 if (aura::client::GetActivationDelegate(window)) |
| 47 aura::client::GetActivationDelegate(window)->OnActivated(); | 55 aura::client::GetActivationDelegate(window)->OnActivated(); |
| 48 | 56 |
| 49 if (last_active && aura::client::GetActivationDelegate(last_active)) | 57 if (last_active && aura::client::GetActivationDelegate(last_active)) |
| 50 aura::client::GetActivationDelegate(last_active)->OnLostActive(); | 58 aura::client::GetActivationDelegate(last_active)->OnLostActive(); |
| 51 } | 59 } |
| 52 | 60 |
| 53 void TestActivationClient::DeactivateWindow(Window* window) { | 61 void TestActivationClient::DeactivateWindow(Window* window) { |
| 54 if (aura::client::GetActivationDelegate(window)) | 62 if (aura::client::GetActivationDelegate(window)) |
| 55 aura::client::GetActivationDelegate(window)->OnLostActive(); | 63 aura::client::GetActivationDelegate(window)->OnLostActive(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 if (active_windows_[i] == window) { | 99 if (active_windows_[i] == window) { |
| 92 active_windows_.erase(active_windows_.begin() + i); | 100 active_windows_.erase(active_windows_.begin() + i); |
| 93 window->RemoveObserver(this); | 101 window->RemoveObserver(this); |
| 94 return; | 102 return; |
| 95 } | 103 } |
| 96 } | 104 } |
| 97 } | 105 } |
| 98 | 106 |
| 99 } // namespace test | 107 } // namespace test |
| 100 } // namespace aura | 108 } // namespace aura |
| OLD | NEW |