summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-14 06:02:34 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-14 06:02:34 +0000
commitda56a47ab4279016cd690e576bee1d81d414aac5 (patch)
treef77bb17fa1c452d39c8898d2e2ad0c055236630d
parentae80a8856c70ea6d58bb7f174a518c91ccedaca2 (diff)
downloadchromium_src-da56a47ab4279016cd690e576bee1d81d414aac5.zip
chromium_src-da56a47ab4279016cd690e576bee1d81d414aac5.tar.gz
chromium_src-da56a47ab4279016cd690e576bee1d81d414aac5.tar.bz2
Store StackingClient on RootWindow in a property.
BUG=none TEST=existing unit tests. Review URL: http://codereview.chromium.org/8926008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114369 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/test/base/browser_with_test_window_test.cc9
-rw-r--r--chrome/test/base/browser_with_test_window_test.h16
-rw-r--r--chrome/test/base/chrome_render_view_host_test_harness.cc11
-rw-r--r--ui/aura/aura.gyp1
-rw-r--r--ui/aura/client/aura_constants.cc1
-rw-r--r--ui/aura/client/aura_constants.h4
-rw-r--r--ui/aura/client/stacking_client.cc24
-rw-r--r--ui/aura/client/stacking_client.h7
-rw-r--r--ui/aura/root_window.cc25
-rw-r--r--ui/aura/root_window.h6
-rw-r--r--ui/aura/test/aura_test_base.cc3
-rw-r--r--ui/aura/test/test_stacking_client.cc2
-rw-r--r--ui/aura/window.cc4
-rw-r--r--ui/aura/window_unittest.cc1
-rw-r--r--ui/aura_shell/root_window_event_filter_unittest.cc7
-rw-r--r--ui/aura_shell/shell.cc8
-rw-r--r--ui/aura_shell/shell.h2
-rw-r--r--ui/aura_shell/stacking_controller.cc11
-rw-r--r--ui/aura_shell/stacking_controller.h3
-rw-r--r--ui/aura_shell/toplevel_window_event_filter_unittest.cc9
-rw-r--r--ui/aura_shell/workspace/workspace_manager_unittest.cc7
21 files changed, 70 insertions, 91 deletions
diff --git a/chrome/test/base/browser_with_test_window_test.cc b/chrome/test/base/browser_with_test_window_test.cc
index b65704a..7c0abe0 100644
--- a/chrome/test/base/browser_with_test_window_test.cc
+++ b/chrome/test/base/browser_with_test_window_test.cc
@@ -18,6 +18,10 @@
#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/common/page_transition_types.h"
+#if defined(USE_AURA)
+#include "ui/aura_shell/shell.h"
+#endif
+
using content::BrowserThread;
BrowserWithTestWindowTest::BrowserWithTestWindowTest()
@@ -29,7 +33,7 @@ BrowserWithTestWindowTest::BrowserWithTestWindowTest()
OleInitialize(NULL);
#endif
#if defined(USE_AURA)
- test_activation_client_.reset(new aura::test::TestActivationClient);
+ aura_shell::Shell::CreateInstance(NULL);
#endif
}
@@ -54,6 +58,9 @@ BrowserWithTestWindowTest::~BrowserWithTestWindowTest() {
#if defined(OS_WIN)
OleUninitialize();
#endif
+#if defined(USE_AURA)
+ aura_shell::Shell::DeleteInstance();
+#endif
}
TestRenderViewHost* BrowserWithTestWindowTest::TestRenderViewHostForTab(
diff --git a/chrome/test/base/browser_with_test_window_test.h b/chrome/test/base/browser_with_test_window_test.h
index 34ecb6c..bc71179 100644
--- a/chrome/test/base/browser_with_test_window_test.h
+++ b/chrome/test/base/browser_with_test_window_test.h
@@ -14,18 +14,6 @@
#include "content/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
-#if defined(USE_AURA)
-#include "ui/aura/test/test_activation_client.h"
-#endif
-
-#if defined(USE_AURA)
-namespace aura {
-namespace test {
-class TestActivationClient;
-}
-}
-#endif
-
class GURL;
class NavigationController;
@@ -119,10 +107,6 @@ class BrowserWithTestWindowTest : public testing::Test {
MockRenderProcessHostFactory rph_factory_;
TestRenderViewHostFactory rvh_factory_;
-#if defined(USE_AURA)
- scoped_ptr<aura::test::TestActivationClient> test_activation_client_;
-#endif
-
DISALLOW_COPY_AND_ASSIGN(BrowserWithTestWindowTest);
};
diff --git a/chrome/test/base/chrome_render_view_host_test_harness.cc b/chrome/test/base/chrome_render_view_host_test_harness.cc
index 26569e7..fc52a60 100644
--- a/chrome/test/base/chrome_render_view_host_test_harness.cc
+++ b/chrome/test/base/chrome_render_view_host_test_harness.cc
@@ -13,9 +13,16 @@
ChromeRenderViewHostTestHarness::ChromeRenderViewHostTestHarness()
: RenderViewHostTestHarness() {
+#if defined(USE_AURA)
+ aura_shell::Shell::CreateInstance(NULL);
+#endif
}
ChromeRenderViewHostTestHarness::~ChromeRenderViewHostTestHarness() {
+#if defined(USE_AURA)
+ aura_shell::Shell::DeleteInstance();
+ aura::RootWindow::DeleteInstance();
+#endif
}
TestingProfile* ChromeRenderViewHostTestHarness::profile() {
@@ -30,8 +37,4 @@ void ChromeRenderViewHostTestHarness::SetUp() {
void ChromeRenderViewHostTestHarness::TearDown() {
RenderViewHostTestHarness::TearDown();
-#if defined(USE_AURA)
- aura_shell::Shell::DeleteInstance();
- aura::RootWindow::DeleteInstance();
-#endif
}
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index 9ac8248..a9d0cba 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -32,6 +32,7 @@
'client/aura_constants.cc',
'client/aura_constants.h',
'client/drag_drop_client.h',
+ 'client/stacking_client.cc',
'client/stacking_client.h',
'client/tooltip_client.h',
'client/window_drag_drop_delegate.h',
diff --git a/ui/aura/client/aura_constants.cc b/ui/aura/client/aura_constants.cc
index c1d0d6e..c39dd15 100644
--- a/ui/aura/client/aura_constants.cc
+++ b/ui/aura/client/aura_constants.cc
@@ -16,6 +16,7 @@ const char kRootWindowDragDropClientKey[] = "RootWindowDragDropClient";
const char kRootWindowTooltipClientKey[] = "RootWindowTooltipClient";
const char kRootWindowActiveWindow[] = "RootWindowActiveWindow";
const char kRootWindowActivationClient[] = "RootWindowActivationClient";
+const char kRootWindowStackingClient[] = "RootWindowStackingClient";
const char kShadowTypeKey[] = "ShadowType";
const char kShowStateKey[] = "ShowState";
const char kTooltipTextKey[] = "TooltipText";
diff --git a/ui/aura/client/aura_constants.h b/ui/aura/client/aura_constants.h
index f5f2920..191c7ad 100644
--- a/ui/aura/client/aura_constants.h
+++ b/ui/aura/client/aura_constants.h
@@ -46,6 +46,10 @@ AURA_EXPORT extern const char kRootWindowActiveWindow[];
// the value is |aura::ActivationClient*|.
AURA_EXPORT extern const char kRootWindowActivationClient[];
+// A property key to store a client that handles window stacking. The type of
+// the value is |aura::StackingClient*|.
+AURA_EXPORT extern const char kRootWindowStackingClient[];
+
// A property key for a value from aura::ShadowType describing the drop shadow
// that should be displayed under the window. If unset, no shadow is displayed.
AURA_EXPORT extern const char kShadowTypeKey[];
diff --git a/ui/aura/client/stacking_client.cc b/ui/aura/client/stacking_client.cc
new file mode 100644
index 0000000..56f96e6
--- /dev/null
+++ b/ui/aura/client/stacking_client.cc
@@ -0,0 +1,24 @@
+// Copyright (c) 2011 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 "ui/aura/client/stacking_client.h"
+
+#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/root_window.h"
+
+namespace aura {
+
+// static
+void StackingClient::SetStackingClient(StackingClient* stacking_client) {
+ RootWindow::GetInstance()->SetProperty(kRootWindowStackingClient,
+ stacking_client);
+}
+
+// static
+StackingClient* StackingClient::GetStackingClient() {
+ return reinterpret_cast<StackingClient*>(
+ RootWindow::GetInstance()->GetProperty(kRootWindowStackingClient));
+}
+
+} // namespace aura
diff --git a/ui/aura/client/stacking_client.h b/ui/aura/client/stacking_client.h
index 6e89636..60712e7 100644
--- a/ui/aura/client/stacking_client.h
+++ b/ui/aura/client/stacking_client.h
@@ -15,12 +15,17 @@ class Window;
// An interface implemented by an object that stacks windows.
class AURA_EXPORT StackingClient {
public:
- virtual ~StackingClient() {}
+ // Sets/Gets the StackingClient for the RootWindow.
+ static void SetStackingClient(StackingClient* stacking_client);
+ static StackingClient* GetStackingClient();
// Called by the Window when its parent is set to NULL. The delegate is given
// an opportunity to inspect the window and add it to a default parent window
// of its choosing.
virtual void AddChildToDefaultParent(Window* window) = 0;
+
+ protected:
+ virtual ~StackingClient() {}
};
} // namespace aura
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 7396ad6..16b6376 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -16,7 +16,6 @@
#include "ui/aura/aura_switches.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/drag_drop_client.h"
-#include "ui/aura/client/stacking_client.h"
#include "ui/aura/client/tooltip_client.h"
#include "ui/aura/client/window_drag_drop_delegate.h"
#include "ui/aura/root_window_host.h"
@@ -58,24 +57,6 @@ bool IsNonClientLocation(Window* target, const gfx::Point& location) {
return hit_test_code != HTCLIENT && hit_test_code != HTNOWHERE;
}
-class DefaultStackingClient : public StackingClient {
- public:
- explicit DefaultStackingClient(RootWindow* root_window)
- : root_window_(root_window) {}
- virtual ~DefaultStackingClient() {}
-
- private:
-
- // Overridden from StackingClient:
- virtual void AddChildToDefaultParent(Window* window) OVERRIDE {
- root_window_->AddChild(window);
- }
-
- RootWindow* root_window_;
-
- DISALLOW_COPY_AND_ASSIGN(DefaultStackingClient);
-};
-
typedef std::vector<EventFilter*> EventFilters;
void GetEventFiltersToNotify(Window* target, EventFilters* filters) {
@@ -110,10 +91,6 @@ void RootWindow::DeleteInstance() {
instance_ = NULL;
}
-void RootWindow::SetStackingClient(StackingClient* stacking_client) {
- stacking_client_.reset(stacking_client);
-}
-
void RootWindow::ShowRootWindow() {
host_->Show();
}
@@ -333,8 +310,6 @@ void RootWindow::ToggleFullScreen() {
RootWindow::RootWindow()
: Window(NULL),
host_(aura::RootWindowHost::Create(GetInitialHostWindowBounds())),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- stacking_client_(new DefaultStackingClient(this))),
ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)),
mouse_button_flags_(0),
last_cursor_(kCursorNull),
diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h
index 52640dc..76f70b5 100644
--- a/ui/aura/root_window.h
+++ b/ui/aura/root_window.h
@@ -37,7 +37,6 @@ class RootWindowObserver;
class KeyEvent;
class MouseEvent;
class ScreenAura;
-class StackingClient;
class TouchEvent;
// RootWindow is responsible for hosting a set of windows.
@@ -56,13 +55,10 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
ui::Compositor* compositor() { return compositor_.get(); }
gfx::Point last_mouse_location() const { return last_mouse_location_; }
gfx::NativeCursor last_cursor() const { return last_cursor_; }
- StackingClient* stacking_client() { return stacking_client_.get(); }
Window* mouse_pressed_handler() { return mouse_pressed_handler_; }
Window* capture_window() { return capture_window_; }
ScreenAura* screen() { return screen_; }
- void SetStackingClient(StackingClient* stacking_client);
-
// Shows the root window host.
void ShowRootWindow();
@@ -181,8 +177,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
scoped_ptr<RootWindowHost> host_;
- scoped_ptr<StackingClient> stacking_client_;
-
static RootWindow* instance_;
// If set before the RootWindow is created, the host window will cover the
diff --git a/ui/aura/test/aura_test_base.cc b/ui/aura/test/aura_test_base.cc
index 6ffbfb9..7e05390 100644
--- a/ui/aura/test/aura_test_base.cc
+++ b/ui/aura/test/aura_test_base.cc
@@ -46,8 +46,7 @@ AuraTestBase::~AuraTestBase() {
}
TestStackingClient* AuraTestBase::GetTestStackingClient() {
- return static_cast<TestStackingClient*>(
- aura::RootWindow::GetInstance()->stacking_client());
+ return static_cast<TestStackingClient*>(StackingClient::GetStackingClient());
}
void AuraTestBase::SetUp() {
diff --git a/ui/aura/test/test_stacking_client.cc b/ui/aura/test/test_stacking_client.cc
index 18048f3..2bc4ebe 100644
--- a/ui/aura/test/test_stacking_client.cc
+++ b/ui/aura/test/test_stacking_client.cc
@@ -11,7 +11,7 @@ namespace test {
TestStackingClient::TestStackingClient()
: default_container_(new Window(NULL)) {
- RootWindow::GetInstance()->SetStackingClient(this);
+ StackingClient::SetStackingClient(this);
default_container_->Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
default_container_->SetBounds(
gfx::Rect(gfx::Point(), RootWindow::GetInstance()->GetHostSize()));
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index 8a10667..58a493d 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -155,8 +155,8 @@ void Window::SetCanvas(const SkCanvas& canvas, const gfx::Point& origin) {
void Window::SetParent(Window* parent) {
if (parent)
parent->AddChild(this);
- else if (RootWindow::GetInstance()->stacking_client())
- RootWindow::GetInstance()->stacking_client()->AddChildToDefaultParent(this);
+ else if (StackingClient::GetStackingClient())
+ StackingClient::GetStackingClient()->AddChildToDefaultParent(this);
else
NOTREACHED();
}
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index ccd9fe8..52474dd 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -8,7 +8,6 @@
#include "base/compiler_specific.h"
#include "base/stringprintf.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/aura/client/stacking_client.h"
#include "ui/aura/event.h"
#include "ui/aura/focus_manager.h"
#include "ui/aura/root_window.h"
diff --git a/ui/aura_shell/root_window_event_filter_unittest.cc b/ui/aura_shell/root_window_event_filter_unittest.cc
index d53cdc8..80ff962 100644
--- a/ui/aura_shell/root_window_event_filter_unittest.cc
+++ b/ui/aura_shell/root_window_event_filter_unittest.cc
@@ -31,14 +31,11 @@ class RootWindowEventFilterTest : public aura::test::AuraTestBase {
aura::RootWindow::GetInstance()->SetEventFilter(
new internal::RootWindowEventFilter);
- aura::test::TestStackingClient* stacking_client =
- static_cast<aura::test::TestStackingClient*>(
- aura::RootWindow::GetInstance()->stacking_client());
- stacking_client->default_container()->set_id(
+ GetTestStackingClient()->default_container()->set_id(
internal::kShellWindowId_DefaultContainer);
activation_controller_.reset(new internal::ActivationController);
activation_controller_->set_default_container_for_test(
- stacking_client->default_container());
+ GetTestStackingClient()->default_container());
}
virtual ~RootWindowEventFilterTest() {
aura::RootWindow::GetInstance()->SetEventFilter(NULL);
diff --git a/ui/aura_shell/shell.cc b/ui/aura_shell/shell.cc
index 51c1b99..b9aaca5 100644
--- a/ui/aura_shell/shell.cc
+++ b/ui/aura_shell/shell.cc
@@ -120,8 +120,6 @@ Shell::Shell(ShellDelegate* delegate)
delegate_(delegate) {
aura::RootWindow::GetInstance()->SetEventFilter(
new internal::RootWindowEventFilter);
- aura::RootWindow::GetInstance()->SetStackingClient(
- new internal::StackingController);
}
Shell::~Shell() {
@@ -192,10 +190,8 @@ void Shell::Init() {
(*i)->Show();
}
- internal::StackingController* stacking_controller =
- static_cast<internal::StackingController*>(
- root_window->stacking_client());
- stacking_controller->Init();
+ // This is created after the special containers, since it expects them.
+ stacking_controller_.reset(new internal::StackingController);
internal::RootWindowLayoutManager* root_window_layout =
new internal::RootWindowLayoutManager(root_window);
diff --git a/ui/aura_shell/shell.h b/ui/aura_shell/shell.h
index 80f5060..6006340 100644
--- a/ui/aura_shell/shell.h
+++ b/ui/aura_shell/shell.h
@@ -37,6 +37,7 @@ class AppList;
class DragDropController;
class ShadowController;
class ShellAcceleratorFilter;
+class StackingController;
class WorkspaceController;
}
@@ -113,6 +114,7 @@ class AURA_SHELL_EXPORT Shell {
scoped_ptr<internal::AppList> app_list_;
+ scoped_ptr<internal::StackingController> stacking_controller_;
scoped_ptr<internal::ActivationController> activation_controller_;
scoped_ptr<internal::DragDropController> drag_drop_controller_;
scoped_ptr<internal::WorkspaceController> workspace_controller_;
diff --git a/ui/aura_shell/stacking_controller.cc b/ui/aura_shell/stacking_controller.cc
index dba6da1..dedf726 100644
--- a/ui/aura_shell/stacking_controller.cc
+++ b/ui/aura_shell/stacking_controller.cc
@@ -29,19 +29,16 @@ bool IsWindowModal(aura::Window* window) {
// StackingController, public:
StackingController::StackingController() {
- aura::RootWindow::GetInstance()->SetStackingClient(this);
-}
-
-StackingController::~StackingController() {
-}
-
-void StackingController::Init() {
+ aura::StackingClient::SetStackingClient(this);
always_on_top_controller_.reset(new internal::AlwaysOnTopController);
always_on_top_controller_->SetContainers(
GetContainer(internal::kShellWindowId_DefaultContainer),
GetContainer(internal::kShellWindowId_AlwaysOnTopContainer));
}
+StackingController::~StackingController() {
+}
+
////////////////////////////////////////////////////////////////////////////////
// StackingController, aura::StackingClient implementation:
diff --git a/ui/aura_shell/stacking_controller.h b/ui/aura_shell/stacking_controller.h
index d7b2edd..bd6430f 100644
--- a/ui/aura_shell/stacking_controller.h
+++ b/ui/aura_shell/stacking_controller.h
@@ -21,9 +21,6 @@ class StackingController : public aura::StackingClient {
StackingController();
virtual ~StackingController();
- // Initializes this controller.
- void Init();
-
// Overridden from aura::StackingClient:
virtual void AddChildToDefaultParent(aura::Window* window) OVERRIDE;
diff --git a/ui/aura_shell/toplevel_window_event_filter_unittest.cc b/ui/aura_shell/toplevel_window_event_filter_unittest.cc
index f4cc00e..c366693 100644
--- a/ui/aura_shell/toplevel_window_event_filter_unittest.cc
+++ b/ui/aura_shell/toplevel_window_event_filter_unittest.cc
@@ -67,12 +67,9 @@ class ToplevelWindowEventFilterTest : public aura::test::AuraTestBase {
virtual void SetUp() OVERRIDE {
aura::test::AuraTestBase::SetUp();
- aura::Window* default_container =
- static_cast<aura::test::TestStackingClient*>(
- aura::RootWindow::GetInstance()->stacking_client())->
- default_container();
- default_container->SetEventFilter(
- new ToplevelWindowEventFilter(default_container));
+ GetTestStackingClient()->default_container()->SetEventFilter(
+ new ToplevelWindowEventFilter(
+ GetTestStackingClient()->default_container()));
}
protected:
diff --git a/ui/aura_shell/workspace/workspace_manager_unittest.cc b/ui/aura_shell/workspace/workspace_manager_unittest.cc
index 91e72b5..77b9d19 100644
--- a/ui/aura_shell/workspace/workspace_manager_unittest.cc
+++ b/ui/aura_shell/workspace/workspace_manager_unittest.cc
@@ -80,14 +80,11 @@ namespace internal {
class WorkspaceManagerTestBase : public aura::test::AuraTestBase {
public:
WorkspaceManagerTestBase() {
- aura::test::TestStackingClient* stacking_client =
- static_cast<aura::test::TestStackingClient*>(
- aura::RootWindow::GetInstance()->stacking_client());
- stacking_client->default_container()->set_id(
+ GetTestStackingClient()->default_container()->set_id(
internal::kShellWindowId_DefaultContainer);
activation_controller_.reset(new internal::ActivationController);
activation_controller_->set_default_container_for_test(
- stacking_client->default_container());
+ GetTestStackingClient()->default_container());
}
virtual ~WorkspaceManagerTestBase() {}