Commit 3e552f39 authored by ben@chromium.org's avatar ben@chromium.org

Move DefaultActivationClient to wm/core

Several tests are using AuraTestHelper and were relying on it to set up the DefaultActivationClient, so I had to have them instantiate the DAC directly after calling SetUp() on the helper. I also had to make the DAC delete itself after the root window it's bound to is destroyed.

R=sky@chromium.org
http://crbug.com/308710

Review URL: https://codereview.chromium.org/250113002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266616 0039d316-1c4b-4281-b951-d872f2087c98
parent 284942a1
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "ui/aura/test/aura_test_helper.h" #include "ui/aura/test/aura_test_helper.h"
#include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_event_dispatcher.h"
#include "ui/compositor/test/context_factories_for_test.h" #include "ui/compositor/test/context_factories_for_test.h"
#include "ui/wm/core/default_activation_client.h"
#endif #endif
using base::ASCIIToUTF16; using base::ASCIIToUTF16;
...@@ -113,6 +114,7 @@ class AccessibilityEventRouterViewsTest ...@@ -113,6 +114,7 @@ class AccessibilityEventRouterViewsTest
aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
aura_test_helper_->SetUp(); aura_test_helper_->SetUp();
new wm::DefaultActivationClient(aura_test_helper_->root_window());
#endif // USE_AURA #endif // USE_AURA
EnableAccessibilityAndListenToFocusNotifications(); EnableAccessibilityAndListenToFocusNotifications();
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_event_dispatcher.h"
#include "ui/views/controls/webview/webview.h" #include "ui/views/controls/webview/webview.h"
#include "ui/wm/core/default_activation_client.h"
#include "ui/wm/core/easy_resize_window_targeter.h" #include "ui/wm/core/easy_resize_window_targeter.h"
class ShapedAppWindowTargeterTest : public aura::test::AuraTestBase { class ShapedAppWindowTargeterTest : public aura::test::AuraTestBase {
...@@ -28,6 +29,7 @@ class ShapedAppWindowTargeterTest : public aura::test::AuraTestBase { ...@@ -28,6 +29,7 @@ class ShapedAppWindowTargeterTest : public aura::test::AuraTestBase {
protected: protected:
virtual void SetUp() OVERRIDE { virtual void SetUp() OVERRIDE {
aura::test::AuraTestBase::SetUp(); aura::test::AuraTestBase::SetUp();
new wm::DefaultActivationClient(root_window());
widget_.reset(new views::Widget); widget_.reset(new views::Widget);
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.remove_standard_frame = true; params.remove_standard_frame = true;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#if defined(USE_AURA) #if defined(USE_AURA)
#include "ui/aura/test/aura_test_helper.h" #include "ui/aura/test/aura_test_helper.h"
#include "ui/compositor/test/context_factories_for_test.h" #include "ui/compositor/test/context_factories_for_test.h"
#include "ui/wm/core/default_activation_client.h"
#endif #endif
#if defined(USE_ASH) #if defined(USE_ASH)
...@@ -70,6 +71,7 @@ void BrowserWithTestWindowTest::SetUp() { ...@@ -70,6 +71,7 @@ void BrowserWithTestWindowTest::SetUp() {
aura_test_helper_.reset(new aura::test::AuraTestHelper( aura_test_helper_.reset(new aura::test::AuraTestHelper(
base::MessageLoopForUI::current())); base::MessageLoopForUI::current()));
aura_test_helper_->SetUp(); aura_test_helper_->SetUp();
new wm::DefaultActivationClient(aura_test_helper_->root_window());
#endif // USE_AURA #endif // USE_AURA
#if defined(TOOLKIT_VIEWS) #if defined(TOOLKIT_VIEWS)
views_delegate_.reset(CreateViewsDelegate()); views_delegate_.reset(CreateViewsDelegate());
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "ui/message_center/message_center.h" #include "ui/message_center/message_center.h"
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/wm/core/default_activation_client.h"
#include "ui/wm/core/wm_state.h" #include "ui/wm/core/wm_state.h"
#if defined(USE_ASH) #if defined(USE_ASH)
...@@ -140,6 +141,7 @@ void ViewEventTestBase::SetUp() { ...@@ -140,6 +141,7 @@ void ViewEventTestBase::SetUp() {
aura_test_helper_.reset( aura_test_helper_.reset(
new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); new aura::test::AuraTestHelper(base::MessageLoopForUI::current()));
aura_test_helper_->SetUp(); aura_test_helper_->SetUp();
new wm::DefaultActivationClient(aura_test_helper_->root_window());
context = aura_test_helper_->root_window(); context = aura_test_helper_->root_window();
#endif // !USE_ASH && USE_AURA #endif // !USE_ASH && USE_AURA
......
...@@ -91,7 +91,7 @@ include_rules = [ ...@@ -91,7 +91,7 @@ include_rules = [
"+ui/shell_dialogs", "+ui/shell_dialogs",
"+ui/snapshot", "+ui/snapshot",
"+ui/surface", "+ui/surface",
"+ui/wm/public", "+ui/wm",
# Content knows about grd files, but the specifics of how to get a resource # Content knows about grd files, but the specifics of how to get a resource
# given its id is left to the embedder. # given its id is left to the embedder.
"-ui/base/l10n", "-ui/base/l10n",
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ui/aura/test/test_window_delegate.h" #include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/compositor/test/context_factories_for_test.h" #include "ui/compositor/test/context_factories_for_test.h"
#include "ui/wm/core/default_activation_client.h"
using ::testing::_; using ::testing::_;
using ::testing::AnyNumber; using ::testing::AnyNumber;
...@@ -65,6 +66,7 @@ class DesktopCaptureDeviceAuraTest : public testing::Test { ...@@ -65,6 +66,7 @@ class DesktopCaptureDeviceAuraTest : public testing::Test {
ui::InitializeContextFactoryForTests(enable_pixel_output); ui::InitializeContextFactoryForTests(enable_pixel_output);
helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
helper_->SetUp(); helper_->SetUp();
new wm::DefaultActivationClient(helper_->root_window());
// We need a window to cover desktop area so that DesktopCaptureDeviceAura // We need a window to cover desktop area so that DesktopCaptureDeviceAura
// can use gfx::NativeWindow::GetWindowAtScreenPoint() to locate the // can use gfx::NativeWindow::GetWindowAtScreenPoint() to locate the
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "ui/compositor/test/in_process_context_factory.h" #include "ui/compositor/test/in_process_context_factory.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/event_utils.h" #include "ui/events/event_utils.h"
#include "ui/wm/core/default_activation_client.h"
using testing::_; using testing::_;
...@@ -205,6 +206,7 @@ class RenderWidgetHostViewAuraTest : public testing::Test { ...@@ -205,6 +206,7 @@ class RenderWidgetHostViewAuraTest : public testing::Test {
scoped_ptr<ui::ContextFactory>(new ui::InProcessContextFactory)); scoped_ptr<ui::ContextFactory>(new ui::InProcessContextFactory));
aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
aura_test_helper_->SetUp(); aura_test_helper_->SetUp();
new wm::DefaultActivationClient(aura_test_helper_->root_window());
browser_context_.reset(new TestBrowserContext); browser_context_.reset(new TestBrowserContext);
process_host_ = new MockRenderProcessHost(browser_context_.get()); process_host_ = new MockRenderProcessHost(browser_context_.get());
......
...@@ -305,6 +305,7 @@ ...@@ -305,6 +305,7 @@
'dependencies': [ 'dependencies': [
'../ui/aura/aura.gyp:aura_test_support', '../ui/aura/aura.gyp:aura_test_support',
'../ui/resources/ui_resources.gyp:ui_test_pak', '../ui/resources/ui_resources.gyp:ui_test_pak',
'../ui/wm/wm.gyp:wm',
], ],
}], }],
['use_aura==1 or OS=="mac"', { ['use_aura==1 or OS=="mac"', {
...@@ -858,6 +859,7 @@ ...@@ -858,6 +859,7 @@
['use_aura==1', { ['use_aura==1', {
'dependencies': [ 'dependencies': [
'../ui/aura/aura.gyp:aura', '../ui/aura/aura.gyp:aura',
'../ui/wm/wm.gyp:wm',
] ]
}], }],
['use_aura==1 or toolkit_views==1', { ['use_aura==1 or toolkit_views==1', {
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#if defined(USE_AURA) #if defined(USE_AURA)
#include "ui/aura/test/aura_test_helper.h" #include "ui/aura/test/aura_test_helper.h"
#include "ui/compositor/test/context_factories_for_test.h" #include "ui/compositor/test/context_factories_for_test.h"
#include "ui/wm/core/default_activation_client.h"
#endif #endif
namespace content { namespace content {
...@@ -174,6 +175,7 @@ void RenderViewHostTestHarness::SetUp() { ...@@ -174,6 +175,7 @@ void RenderViewHostTestHarness::SetUp() {
aura_test_helper_.reset( aura_test_helper_.reset(
new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); new aura::test::AuraTestHelper(base::MessageLoopForUI::current()));
aura_test_helper_->SetUp(); aura_test_helper_->SetUp();
new wm::DefaultActivationClient(aura_test_helper_->root_window());
#endif #endif
DCHECK(!browser_context_); DCHECK(!browser_context_);
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "content/shell/browser/shell.h" #include "content/shell/browser/shell.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/default_activation_client.h"
#include "ui/aura/client/default_capture_client.h" #include "ui/aura/client/default_capture_client.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/layout_manager.h" #include "ui/aura/layout_manager.h"
...@@ -18,6 +17,7 @@ ...@@ -18,6 +17,7 @@
#include "ui/base/ime/input_method_delegate.h" #include "ui/base/ime/input_method_delegate.h"
#include "ui/base/ime/input_method_factory.h" #include "ui/base/ime/input_method_factory.h"
#include "ui/gfx/screen.h" #include "ui/gfx/screen.h"
#include "ui/wm/core/default_activation_client.h"
namespace content { namespace content {
...@@ -121,8 +121,7 @@ ShellPlatformDataAura::ShellPlatformDataAura(const gfx::Size& initial_size) { ...@@ -121,8 +121,7 @@ ShellPlatformDataAura::ShellPlatformDataAura(const gfx::Size& initial_size) {
focus_client_.reset(new aura::test::TestFocusClient()); focus_client_.reset(new aura::test::TestFocusClient());
aura::client::SetFocusClient(host_->window(), focus_client_.get()); aura::client::SetFocusClient(host_->window(), focus_client_.get());
activation_client_.reset( new wm::DefaultActivationClient(host_->window());
new aura::client::DefaultActivationClient(host_->window()));
capture_client_.reset( capture_client_.reset(
new aura::client::DefaultCaptureClient(host_->window())); new aura::client::DefaultCaptureClient(host_->window()));
window_tree_client_.reset( window_tree_client_.reset(
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
namespace aura { namespace aura {
namespace client { namespace client {
class DefaultActivationClient;
class DefaultCaptureClient; class DefaultCaptureClient;
class FocusClient; class FocusClient;
class WindowTreeClient; class WindowTreeClient;
...@@ -40,7 +39,6 @@ class ShellPlatformDataAura { ...@@ -40,7 +39,6 @@ class ShellPlatformDataAura {
private: private:
scoped_ptr<aura::WindowTreeHost> host_; scoped_ptr<aura::WindowTreeHost> host_;
scoped_ptr<aura::client::FocusClient> focus_client_; scoped_ptr<aura::client::FocusClient> focus_client_;
scoped_ptr<aura::client::DefaultActivationClient> activation_client_;
scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; scoped_ptr<aura::client::WindowTreeClient> window_tree_client_;
scoped_ptr<ui::EventHandler> ime_filter_; scoped_ptr<ui::EventHandler> ime_filter_;
......
...@@ -8,5 +8,6 @@ include_rules = [ ...@@ -8,5 +8,6 @@ include_rules = [
"+ui/gfx", "+ui/gfx",
"+ui/gl", "+ui/gl",
"+ui/views", "+ui/views",
"+ui/wm",
"+webkit/common/gpu", "+webkit/common/gpu",
] ]
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "mojo/public/interfaces/shell/shell.mojom.h" #include "mojo/public/interfaces/shell/shell.mojom.h"
#include "mojo/services/native_viewport/native_viewport.mojom.h" #include "mojo/services/native_viewport/native_viewport.mojom.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/default_activation_client.h"
#include "ui/aura/client/default_capture_client.h" #include "ui/aura/client/default_capture_client.h"
#include "ui/aura/client/window_tree_client.h" #include "ui/aura/client/window_tree_client.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
...@@ -45,6 +44,7 @@ ...@@ -45,6 +44,7 @@
#include "ui/views/layout/fill_layout.h" #include "ui/views/layout/fill_layout.h"
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/wm/core/default_activation_client.h"
#include "url/gurl.h" #include "url/gurl.h"
#if defined(WIN32) #if defined(WIN32)
...@@ -244,8 +244,7 @@ class LauncherImpl : public Application, ...@@ -244,8 +244,7 @@ class LauncherImpl : public Application,
focus_client_.reset(new aura::test::TestFocusClient()); focus_client_.reset(new aura::test::TestFocusClient());
aura::client::SetFocusClient(window_tree_host_->window(), aura::client::SetFocusClient(window_tree_host_->window(),
focus_client_.get()); focus_client_.get());
activation_client_.reset( new wm::DefaultActivationClient(window_tree_host_->window());
new aura::client::DefaultActivationClient(window_tree_host_->window()));
capture_client_.reset( capture_client_.reset(
new aura::client::DefaultCaptureClient(window_tree_host_->window())); new aura::client::DefaultCaptureClient(window_tree_host_->window()));
ime_filter_.reset(new MinimalInputEventFilter(window_tree_host_->window())); ime_filter_.reset(new MinimalInputEventFilter(window_tree_host_->window()));
...@@ -263,7 +262,6 @@ class LauncherImpl : public Application, ...@@ -263,7 +262,6 @@ class LauncherImpl : public Application,
scoped_ptr<DemoScreen> screen_; scoped_ptr<DemoScreen> screen_;
scoped_ptr<LauncherWindowTreeClient> window_tree_client_; scoped_ptr<LauncherWindowTreeClient> window_tree_client_;
scoped_ptr<aura::client::DefaultActivationClient> activation_client_;
scoped_ptr<aura::client::FocusClient> focus_client_; scoped_ptr<aura::client::FocusClient> focus_client_;
scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
scoped_ptr<ui::EventHandler> ime_filter_; scoped_ptr<ui::EventHandler> ime_filter_;
......
...@@ -255,6 +255,7 @@ ...@@ -255,6 +255,7 @@
'../ui/gfx/gfx.gyp:gfx', '../ui/gfx/gfx.gyp:gfx',
'../ui/gfx/gfx.gyp:gfx_geometry', '../ui/gfx/gfx.gyp:gfx_geometry',
'../ui/views/views.gyp:views', '../ui/views/views.gyp:views',
'../ui/wm/wm.gyp:wm',
'../url/url.gyp:url_lib', '../url/url.gyp:url_lib',
'mojo_aura_demo_support', 'mojo_aura_demo_support',
'mojo_common_lib', 'mojo_common_lib',
......
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
'client/cursor_client.h', 'client/cursor_client.h',
'client/cursor_client_observer.h', 'client/cursor_client_observer.h',
'client/cursor_client_observer.cc', 'client/cursor_client_observer.cc',
'client/default_activation_client.cc',
'client/default_activation_client.h',
'client/default_capture_client.cc', 'client/default_capture_client.cc',
'client/default_capture_client.h', 'client/default_capture_client.h',
'client/event_client.cc', 'client/event_client.cc',
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/default_activation_client.h"
#include "ui/aura/client/default_capture_client.h" #include "ui/aura/client/default_capture_client.h"
#include "ui/aura/client/focus_client.h" #include "ui/aura/client/focus_client.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
...@@ -71,8 +70,6 @@ void AuraTestHelper::SetUp() { ...@@ -71,8 +70,6 @@ void AuraTestHelper::SetUp() {
focus_client_.reset(new TestFocusClient); focus_client_.reset(new TestFocusClient);
client::SetFocusClient(root_window(), focus_client_.get()); client::SetFocusClient(root_window(), focus_client_.get());
stacking_client_.reset(new TestWindowTreeClient(root_window())); stacking_client_.reset(new TestWindowTreeClient(root_window()));
activation_client_.reset(
new client::DefaultActivationClient(root_window()));
capture_client_.reset(new client::DefaultCaptureClient(root_window())); capture_client_.reset(new client::DefaultCaptureClient(root_window()));
test_input_method_.reset(new ui::DummyInputMethod); test_input_method_.reset(new ui::DummyInputMethod);
root_window()->SetProperty( root_window()->SetProperty(
...@@ -88,7 +85,6 @@ void AuraTestHelper::TearDown() { ...@@ -88,7 +85,6 @@ void AuraTestHelper::TearDown() {
teardown_called_ = true; teardown_called_ = true;
test_input_method_.reset(); test_input_method_.reset();
stacking_client_.reset(); stacking_client_.reset();
activation_client_.reset();
capture_client_.reset(); capture_client_.reset();
focus_client_.reset(); focus_client_.reset();
client::SetFocusClient(root_window(), NULL); client::SetFocusClient(root_window(), NULL);
......
...@@ -22,7 +22,6 @@ class ScopedAnimationDurationScaleMode; ...@@ -22,7 +22,6 @@ class ScopedAnimationDurationScaleMode;
namespace aura { namespace aura {
class TestScreen; class TestScreen;
namespace client { namespace client {
class DefaultActivationClient;
class DefaultCaptureClient; class DefaultCaptureClient;
class FocusClient; class FocusClient;
} }
...@@ -60,7 +59,6 @@ class AuraTestHelper { ...@@ -60,7 +59,6 @@ class AuraTestHelper {
bool owns_host_; bool owns_host_;
scoped_ptr<WindowTreeHost> host_; scoped_ptr<WindowTreeHost> host_;
scoped_ptr<TestWindowTreeClient> stacking_client_; scoped_ptr<TestWindowTreeClient> stacking_client_;
scoped_ptr<client::DefaultActivationClient> activation_client_;
scoped_ptr<client::DefaultCaptureClient> capture_client_; scoped_ptr<client::DefaultCaptureClient> capture_client_;
scoped_ptr<ui::InputMethod> test_input_method_; scoped_ptr<ui::InputMethod> test_input_method_;
scoped_ptr<client::FocusClient> focus_client_; scoped_ptr<client::FocusClient> focus_client_;
......
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
'../gfx/gfx.gyp:gfx', '../gfx/gfx.gyp:gfx',
'../gfx/gfx.gyp:gfx_geometry', '../gfx/gfx.gyp:gfx_geometry',
'../resources/ui_resources.gyp:ui_test_pak', '../resources/ui_resources.gyp:ui_test_pak',
'../wm/wm.gyp:wm',
'keyboard', 'keyboard',
], ],
'sources': [ 'sources': [
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "ui/keyboard/keyboard_controller_proxy.h" #include "ui/keyboard/keyboard_controller_proxy.h"
#include "ui/keyboard/keyboard_switches.h" #include "ui/keyboard/keyboard_switches.h"
#include "ui/keyboard/keyboard_util.h" #include "ui/keyboard/keyboard_util.h"
#include "ui/wm/core/default_activation_client.h"
namespace keyboard { namespace keyboard {
namespace { namespace {
...@@ -168,6 +169,7 @@ class KeyboardControllerTest : public testing::Test { ...@@ -168,6 +169,7 @@ class KeyboardControllerTest : public testing::Test {
aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
aura_test_helper_->SetUp(); aura_test_helper_->SetUp();
new wm::DefaultActivationClient(aura_test_helper_->root_window());
ui::SetUpInputMethodFactoryForTesting(); ui::SetUpInputMethodFactoryForTesting();
focus_controller_.reset(new TestFocusController(root_window())); focus_controller_.reset(new TestFocusController(root_window()));
proxy_ = new TestKeyboardControllerProxy(); proxy_ = new TestKeyboardControllerProxy();
......
...@@ -8,4 +8,5 @@ include_rules = [ ...@@ -8,4 +8,5 @@ include_rules = [
"+ui/compositor", "+ui/compositor",
"+ui/gfx", "+ui/gfx",
"+ui/gl", "+ui/gl",
"+ui/wm",
] ]
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
'../aura/aura.gyp:aura_test_support', '../aura/aura.gyp:aura_test_support',
'../compositor/compositor.gyp:compositor', '../compositor/compositor.gyp:compositor',
'../compositor/compositor.gyp:compositor_test_support', '../compositor/compositor.gyp:compositor_test_support',
'../wm/wm.gyp:wm',
], ],
}], }],
# See http://crbug.com/162998#c4 for why this is needed. # See http://crbug.com/162998#c4 for why this is needed.
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "ui/gfx/size_conversions.h" #include "ui/gfx/size_conversions.h"
#include "ui/gfx/transform.h" #include "ui/gfx/transform.h"
#include "ui/gl/gl_implementation.h" #include "ui/gl/gl_implementation.h"
#include "ui/wm/core/default_activation_client.h"
namespace ui { namespace ui {
namespace { namespace {
...@@ -93,6 +94,7 @@ class SnapshotAuraTest : public testing::Test { ...@@ -93,6 +94,7 @@ class SnapshotAuraTest : public testing::Test {
helper_.reset( helper_.reset(
new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); new aura::test::AuraTestHelper(base::MessageLoopForUI::current()));
helper_->SetUp(); helper_->SetUp();
new ::wm::DefaultActivationClient(helper_->root_window());
} }
virtual void TearDown() OVERRIDE { virtual void TearDown() OVERRIDE {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_event_dispatcher.h"
#include "ui/compositor/test/context_factories_for_test.h" #include "ui/compositor/test/context_factories_for_test.h"
#include "ui/wm/core/capture_controller.h" #include "ui/wm/core/capture_controller.h"
#include "ui/wm/core/default_activation_client.h"
#include "ui/wm/core/wm_state.h" #include "ui/wm/core/wm_state.h"
namespace views { namespace views {
...@@ -39,6 +40,7 @@ void ViewsTestBase::SetUp() { ...@@ -39,6 +40,7 @@ void ViewsTestBase::SetUp() {
aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
aura_test_helper_->SetUp(); aura_test_helper_->SetUp();
new wm::DefaultActivationClient(aura_test_helper_->root_window());
wm_state_.reset(new ::wm::WMState); wm_state_.reset(new ::wm::WMState);
ui::InitializeInputMethodForTesting(); ui::InitializeInputMethodForTesting();
} }
......
...@@ -2,44 +2,64 @@ ...@@ -2,44 +2,64 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/aura/client/default_activation_client.h" #include "ui/wm/core/default_activation_client.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/wm/public/activation_change_observer.h" #include "ui/wm/public/activation_change_observer.h"
#include "ui/wm/public/activation_delegate.h" #include "ui/wm/public/activation_delegate.h"
namespace aura { namespace wm {
namespace client {
// Takes care of observing root window destruction & destroying the client.
class DefaultActivationClient::Deleter : public aura::WindowObserver {
public:
Deleter(DefaultActivationClient* client, aura::Window* root_window)
: client_(client),
root_window_(root_window) {
root_window_->AddObserver(this);
}
private:
virtual ~Deleter() {}
// Overridden from WindowObserver:
virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE {
DCHECK_EQ(window, root_window_);
root_window_->RemoveObserver(this);
delete client_;
delete this;
}
DefaultActivationClient* client_;
aura::Window* root_window_;
DISALLOW_COPY_AND_ASSIGN(Deleter);
};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// DefaultActivationClient, public: // DefaultActivationClient, public:
DefaultActivationClient::DefaultActivationClient(Window* root_window) DefaultActivationClient::DefaultActivationClient(aura::Window* root_window)
: last_active_(NULL) { : last_active_(NULL) {
client::SetActivationClient(root_window, this); aura::client::SetActivationClient(root_window, this);
} new Deleter(this, root_window);
DefaultActivationClient::~DefaultActivationClient() {
for (unsigned int i = 0; i < active_windows_.size(); ++i) {
active_windows_[i]->RemoveObserver(this);
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// DefaultActivationClient, client::ActivationClient implementation: // DefaultActivationClient, client::ActivationClient implementation:
void DefaultActivationClient::AddObserver( void DefaultActivationClient::AddObserver(
client::ActivationChangeObserver* observer) { aura::client::ActivationChangeObserver* observer) {
observers_.AddObserver(observer); observers_.AddObserver(observer);
} }
void DefaultActivationClient::RemoveObserver( void DefaultActivationClient::RemoveObserver(
client::ActivationChangeObserver* observer) { aura::client::ActivationChangeObserver* observer) {
observers_.RemoveObserver(observer); observers_.RemoveObserver(observer);
} }
void DefaultActivationClient::ActivateWindow(Window* window) { void DefaultActivationClient::ActivateWindow(aura::Window* window) {
Window* last_active = GetActiveWindow(); aura::Window* last_active = GetActiveWindow();
if (last_active == window) if (last_active == window)
return; return;
...@@ -49,7 +69,7 @@ void DefaultActivationClient::ActivateWindow(Window* window) { ...@@ -49,7 +69,7 @@ void DefaultActivationClient::ActivateWindow(Window* window) {
window->parent()->StackChildAtTop(window); window->parent()->StackChildAtTop(window);
window->AddObserver(this); window->AddObserver(this);
FOR_EACH_OBSERVER(client::ActivationChangeObserver, FOR_EACH_OBSERVER(aura::client::ActivationChangeObserver,
observers_, observers_,
OnWindowActivated(window, last_active)); OnWindowActivated(window, last_active));
...@@ -62,7 +82,7 @@ void DefaultActivationClient::ActivateWindow(Window* window) { ...@@ -62,7 +82,7 @@ void DefaultActivationClient::ActivateWindow(Window* window) {
observer->OnWindowActivated(window, last_active); observer->OnWindowActivated(window, last_active);
} }
void DefaultActivationClient::DeactivateWindow(Window* window) { void DefaultActivationClient::DeactivateWindow(aura::Window* window) {
aura::client::ActivationChangeObserver* observer = aura::client::ActivationChangeObserver* observer =
aura::client::GetActivationChangeObserver(window); aura::client::GetActivationChangeObserver(window);
if (observer) if (observer)
...@@ -71,39 +91,40 @@ void DefaultActivationClient::DeactivateWindow(Window* window) { ...@@ -71,39 +91,40 @@ void DefaultActivationClient::DeactivateWindow(Window* window) {
ActivateWindow(last_active_); ActivateWindow(last_active_);
} }
Window* DefaultActivationClient::GetActiveWindow() { aura::Window* DefaultActivationClient::GetActiveWindow() {
if (active_windows_.empty()) if (active_windows_.empty())
return NULL; return NULL;
return active_windows_.back(); return active_windows_.back();
} }
Window* DefaultActivationClient::GetActivatableWindow(Window* window) { aura::Window* DefaultActivationClient::GetActivatableWindow(
aura::Window* window) {
return NULL; return NULL;
} }
Window* DefaultActivationClient::GetToplevelWindow(Window* window) { aura::Window* DefaultActivationClient::GetToplevelWindow(aura::Window* window) {
return NULL; return NULL;
} }
bool DefaultActivationClient::OnWillFocusWindow(Window* window, bool DefaultActivationClient::OnWillFocusWindow(aura::Window* window,
const ui::Event* event) { const ui::Event* event) {
return true; return true;
} }
bool DefaultActivationClient::CanActivateWindow(Window* window) const { bool DefaultActivationClient::CanActivateWindow(aura::Window* window) const {
return true; return true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// DefaultActivationClient, WindowObserver implementation: // DefaultActivationClient, aura::WindowObserver implementation:
void DefaultActivationClient::OnWindowDestroyed(Window* window) { void DefaultActivationClient::OnWindowDestroyed(aura::Window* window) {
if (window == last_active_) if (window == last_active_)
last_active_ = NULL; last_active_ = NULL;
if (window == GetActiveWindow()) { if (window == GetActiveWindow()) {
active_windows_.pop_back(); active_windows_.pop_back();
Window* next_active = GetActiveWindow(); aura::Window* next_active = GetActiveWindow();
if (next_active && aura::client::GetActivationChangeObserver(next_active)) { if (next_active && aura::client::GetActivationChangeObserver(next_active)) {
aura::client::GetActivationChangeObserver(next_active)->OnWindowActivated( aura::client::GetActivationChangeObserver(next_active)->OnWindowActivated(
next_active, NULL); next_active, NULL);
...@@ -114,7 +135,16 @@ void DefaultActivationClient::OnWindowDestroyed(Window* window) { ...@@ -114,7 +135,16 @@ void DefaultActivationClient::OnWindowDestroyed(Window* window) {
RemoveActiveWindow(window); RemoveActiveWindow(window);
} }
void DefaultActivationClient::RemoveActiveWindow(Window* window) { ////////////////////////////////////////////////////////////////////////////////
// DefaultActivationClient, private:
DefaultActivationClient::~DefaultActivationClient() {
for (unsigned int i = 0; i < active_windows_.size(); ++i) {
active_windows_[i]->RemoveObserver(this);
}
}
void DefaultActivationClient::RemoveActiveWindow(aura::Window* window) {
for (unsigned int i = 0; i < active_windows_.size(); ++i) { for (unsigned int i = 0; i < active_windows_.size(); ++i) {
if (active_windows_[i] == window) { if (active_windows_[i] == window) {
active_windows_.erase(active_windows_.begin() + i); active_windows_.erase(active_windows_.begin() + i);
...@@ -124,5 +154,4 @@ void DefaultActivationClient::RemoveActiveWindow(Window* window) { ...@@ -124,5 +154,4 @@ void DefaultActivationClient::RemoveActiveWindow(Window* window) {
} }
} }
} // namespace client } // namespace wm
} // namespace aura
...@@ -2,68 +2,72 @@ ...@@ -2,68 +2,72 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef UI_AURA_CLIENT_DEFAULT_ACTIVATION_CLIENT_H_ #ifndef UI_WM_CORE_DEFAULT_ACTIVATION_CLIENT_H_
#define UI_AURA_CLIENT_DEFAULT_ACTIVATION_CLIENT_H_ #define UI_WM_CORE_DEFAULT_ACTIVATION_CLIENT_H_
#include <vector> #include <vector>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "ui/aura/aura_export.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/wm/public/activation_client.h" #include "ui/wm/public/activation_client.h"
#include "ui/wm/wm_export.h"
namespace aura { namespace aura {
namespace client { namespace client {
class ActivationChangeObserver; class ActivationChangeObserver;
} }
}
namespace client { namespace wm {
// Simple ActivationClient implementation for use by tests and other targets // Simple ActivationClient implementation for use by tests and other targets
// that just need basic behavior (e.g. activate windows whenever requested, // that just need basic behavior (e.g. activate windows whenever requested,
// restack windows at the top when they're activated, etc.). // restack windows at the top when they're activated, etc.). This object deletes
class AURA_EXPORT DefaultActivationClient : public client::ActivationClient, // itself when the root window it is associated with is destroyed.
public WindowObserver { class WM_EXPORT DefaultActivationClient : public aura::client::ActivationClient,
public aura::WindowObserver {
public: public:
explicit DefaultActivationClient(Window* root_window); explicit DefaultActivationClient(aura::Window* root_window);
virtual ~DefaultActivationClient();
// Overridden from client::ActivationClient: // Overridden from aura::client::ActivationClient:
virtual void AddObserver(client::ActivationChangeObserver* observer) OVERRIDE; virtual void AddObserver(
aura::client::ActivationChangeObserver* observer) OVERRIDE;
virtual void RemoveObserver( virtual void RemoveObserver(
client::ActivationChangeObserver* observer) OVERRIDE; aura::client::ActivationChangeObserver* observer) OVERRIDE;
virtual void ActivateWindow(Window* window) OVERRIDE; virtual void ActivateWindow(aura::Window* window) OVERRIDE;
virtual void DeactivateWindow(Window* window) OVERRIDE; virtual void DeactivateWindow(aura::Window* window) OVERRIDE;
virtual Window* GetActiveWindow() OVERRIDE; virtual aura::Window* GetActiveWindow() OVERRIDE;
virtual Window* GetActivatableWindow(Window* window) OVERRIDE; virtual aura::Window* GetActivatableWindow(aura::Window* window) OVERRIDE;
virtual Window* GetToplevelWindow(Window* window) OVERRIDE; virtual aura::Window* GetToplevelWindow(aura::Window* window) OVERRIDE;
virtual bool OnWillFocusWindow(Window* window, virtual bool OnWillFocusWindow(aura::Window* window,
const ui::Event* event) OVERRIDE; const ui::Event* event) OVERRIDE;
virtual bool CanActivateWindow(Window* window) const OVERRIDE; virtual bool CanActivateWindow(aura::Window* window) const OVERRIDE;
// Overridden from WindowObserver: // Overridden from WindowObserver:
virtual void OnWindowDestroyed(Window* window) OVERRIDE; virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
private: private:
void RemoveActiveWindow(Window* window); class Deleter;
virtual ~DefaultActivationClient();
void RemoveActiveWindow(aura::Window* window);
// This class explicitly does NOT store the active window in a window property // This class explicitly does NOT store the active window in a window property
// to make sure that ActivationChangeObserver is not treated as part of the // to make sure that ActivationChangeObserver is not treated as part of the
// aura API. Assumptions to that end will cause tests that use this client to // aura API. Assumptions to that end will cause tests that use this client to
// fail. // fail.
std::vector<Window*> active_windows_; std::vector<aura::Window*> active_windows_;
// The window which was active before the currently active one. // The window which was active before the currently active one.
Window* last_active_; aura::Window* last_active_;
ObserverList<client::ActivationChangeObserver> observers_; ObserverList<aura::client::ActivationChangeObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(DefaultActivationClient); DISALLOW_COPY_AND_ASSIGN(DefaultActivationClient);
}; };
} // namespace client } // namespace wm
} // namespace aura
#endif // UI_AURA_CLIENT_DEFAULT_ACTIVATION_CLIENT_H_ #endif // UI_WM_CORE_DEFAULT_ACTIVATION_CLIENT_H_
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
#include "ui/wm/test/wm_test_helper.h" #include "ui/wm/test/wm_test_helper.h"
#include "ui/aura/client/default_activation_client.h"
#include "ui/aura/client/default_capture_client.h" #include "ui/aura/client/default_capture_client.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/test/test_focus_client.h" #include "ui/aura/test/test_focus_client.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/wm/core/compound_event_filter.h" #include "ui/wm/core/compound_event_filter.h"
#include "ui/wm/core/default_activation_client.h"
#include "ui/wm/core/input_method_event_filter.h" #include "ui/wm/core/input_method_event_filter.h"
namespace wm { namespace wm {
...@@ -31,8 +31,7 @@ WMTestHelper::WMTestHelper(const gfx::Size& default_window_size) { ...@@ -31,8 +31,7 @@ WMTestHelper::WMTestHelper(const gfx::Size& default_window_size) {
input_method_filter_->SetInputMethodPropertyInRootWindow(host_->window()); input_method_filter_->SetInputMethodPropertyInRootWindow(host_->window());
root_window_event_filter_->AddHandler(input_method_filter_.get()); root_window_event_filter_->AddHandler(input_method_filter_.get());
activation_client_.reset( new wm::DefaultActivationClient(host_->window());
new aura::client::DefaultActivationClient(host_->window()));
capture_client_.reset( capture_client_.reset(
new aura::client::DefaultCaptureClient(host_->window())); new aura::client::DefaultCaptureClient(host_->window()));
......
...@@ -14,7 +14,6 @@ namespace aura { ...@@ -14,7 +14,6 @@ namespace aura {
class Window; class Window;
class WindowTreeHost; class WindowTreeHost;
namespace client { namespace client {
class DefaultActivationClient;
class DefaultCaptureClient; class DefaultCaptureClient;
class FocusClient; class FocusClient;
} }
...@@ -51,7 +50,6 @@ class WMTestHelper : public aura::client::WindowTreeClient { ...@@ -51,7 +50,6 @@ class WMTestHelper : public aura::client::WindowTreeClient {
scoped_ptr<wm::CompoundEventFilter> root_window_event_filter_; scoped_ptr<wm::CompoundEventFilter> root_window_event_filter_;
scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
scoped_ptr<wm::InputMethodEventFilter> input_method_filter_; scoped_ptr<wm::InputMethodEventFilter> input_method_filter_;
scoped_ptr<aura::client::DefaultActivationClient> activation_client_;
scoped_ptr<aura::client::FocusClient> focus_client_; scoped_ptr<aura::client::FocusClient> focus_client_;
DISALLOW_COPY_AND_ASSIGN(WMTestHelper); DISALLOW_COPY_AND_ASSIGN(WMTestHelper);
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
'core/compound_event_filter.h', 'core/compound_event_filter.h',
'core/cursor_manager.cc', 'core/cursor_manager.cc',
'core/cursor_manager.h', 'core/cursor_manager.h',
'core/default_activation_client.cc',
'core/default_activation_client.h',
'core/easy_resize_window_targeter.cc', 'core/easy_resize_window_targeter.cc',
'core/easy_resize_window_targeter.h', 'core/easy_resize_window_targeter.h',
'core/focus_controller.cc', 'core/focus_controller.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment