diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-11 03:53:27 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-11 03:53:27 +0000 |
commit | 792b9b17fc2a2399062ff801ad4fc9814ad5f133 (patch) | |
tree | a18db13983feeba1332290d5e644dfe9e5ef62dc /ash/test | |
parent | 499c7fd28b97645052d01d2fae2b99be171756e8 (diff) | |
download | chromium_src-792b9b17fc2a2399062ff801ad4fc9814ad5f133.zip chromium_src-792b9b17fc2a2399062ff801ad4fc9814ad5f133.tar.gz chromium_src-792b9b17fc2a2399062ff801ad4fc9814ad5f133.tar.bz2 |
Consolidates activation and focus change observers a bit.
Focus observation @ target -> FocusChangeObserver set on target instead of WindowDelegate methods.
Activation observation @ target -> ActivationChangeObserver set on target instead of ActivationDelegate methods.
Changes FocusChange notifications to be sent regardless of whether or not focus is being cleared.
Changes signature of both observers to carry gaining and losing focus/activation.
http://crbug.com/162100
R=sky@chromium.org
Review URL: https://codereview.chromium.org/11490015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172258 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/test')
-rw-r--r-- | ash/test/test_activation_delegate.cc | 29 | ||||
-rw-r--r-- | ash/test/test_activation_delegate.h | 12 |
2 files changed, 15 insertions, 26 deletions
diff --git a/ash/test/test_activation_delegate.cc b/ash/test/test_activation_delegate.cc index a85a982..5c57609 100644 --- a/ash/test/test_activation_delegate.cc +++ b/ash/test/test_activation_delegate.cc @@ -37,7 +37,7 @@ TestActivationDelegate::TestActivationDelegate(bool activate) void TestActivationDelegate::SetWindow(aura::Window* window) { window_ = window; aura::client::SetActivationDelegate(window, this); - window_->AddPreTargetHandler(this); + aura::client::SetActivationChangeObserver(window, this); } bool TestActivationDelegate::ShouldActivate() const { @@ -45,26 +45,15 @@ bool TestActivationDelegate::ShouldActivate() const { return activate_; } -void TestActivationDelegate::OnActivated() { - activated_count_++; -} - -void TestActivationDelegate::OnLostActive() { - if (lost_active_count_++ == 0) - window_was_active_ = wm::IsActiveWindow(window_); -} - -void TestActivationDelegate::OnEvent(ui::Event* event) { - if (event->target() == window_) { - if (event->type() == - views::corewm::FocusChangeEvent::activation_changed_event_type()) { - OnActivated(); - } else if (event->type() == - views::corewm::FocusChangeEvent::activation_changing_event_type()) { - OnLostActive(); - } +void TestActivationDelegate::OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) { + DCHECK(window_ == gained_active || window_ == lost_active); + if (window_ == gained_active) { + activated_count_++; + } else if (window_ == lost_active) { + if (lost_active_count_++ == 0) + window_was_active_ = wm::IsActiveWindow(window_); } - EventHandler::OnEvent(event); } } // namespace test diff --git a/ash/test/test_activation_delegate.h b/ash/test/test_activation_delegate.h index 1e3bec6..e898e74 100644 --- a/ash/test/test_activation_delegate.h +++ b/ash/test/test_activation_delegate.h @@ -7,6 +7,7 @@ #include "base/compiler_specific.h" #include "base/logging.h" +#include "ui/aura/client/activation_change_observer.h" #include "ui/aura/client/activation_delegate.h" #include "ui/base/events/event_handler.h" @@ -20,7 +21,7 @@ namespace test { // A test ActivationDelegate that can be used to track activation changes for // an aura::Window. class TestActivationDelegate : public aura::client::ActivationDelegate, - public ui::EventHandler { + public aura::client::ActivationChangeObserver { public: TestActivationDelegate(); explicit TestActivationDelegate(bool activate); @@ -38,14 +39,13 @@ class TestActivationDelegate : public aura::client::ActivationDelegate, window_was_active_ = false; } - // Overridden from client::ActivationDelegate: + // Overridden from aura::client::ActivationDelegate: virtual bool ShouldActivate() const OVERRIDE; - virtual void OnActivated() OVERRIDE; - virtual void OnLostActive() OVERRIDE; private: - // Overridden from ui::EventHandler: - virtual void OnEvent(ui::Event* event) OVERRIDE; + // Overridden from aura::client::ActivationChangeObserver: + virtual void OnWindowActivated(aura::Window* gained_active, + aura::Window* lost_active) OVERRIDE; aura::Window* window_; bool window_was_active_; |