summaryrefslogtreecommitdiffstats
path: root/ui/aura
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-26 14:49:09 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-26 14:49:09 +0000
commit32c2a46c5f820f42cdb37b869e99633d8a2d73ad (patch)
tree9e09f67ffd197c2067a286e4e45927ee5c5aa429 /ui/aura
parent08f8feb39b2c8801dd39a1531fb5958644162e6d (diff)
downloadchromium_src-32c2a46c5f820f42cdb37b869e99633d8a2d73ad.zip
chromium_src-32c2a46c5f820f42cdb37b869e99633d8a2d73ad.tar.gz
chromium_src-32c2a46c5f820f42cdb37b869e99633d8a2d73ad.tar.bz2
Migrate client API setters/getters to take a RootWindow.
http://crbug.com/112131 TEST=none TBR=sky Review URL: https://chromiumcodereview.appspot.com/9455081 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123690 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r--ui/aura/client/activation_client.cc10
-rw-r--r--ui/aura/client/activation_client.h6
-rw-r--r--ui/aura/client/dispatcher_client.cc8
-rw-r--r--ui/aura/client/dispatcher_client.h7
-rw-r--r--ui/aura/client/drag_drop_client.cc9
-rw-r--r--ui/aura/client/drag_drop_client.h6
-rw-r--r--ui/aura/client/tooltip_client.cc9
-rw-r--r--ui/aura/client/tooltip_client.h6
-rw-r--r--ui/aura/client/visibility_client.cc10
-rw-r--r--ui/aura/client/visibility_client.h6
-rw-r--r--ui/aura/root_window.cc8
-rw-r--r--ui/aura/test/test_activation_client.cc8
-rw-r--r--ui/aura/test/test_activation_client.h3
-rw-r--r--ui/aura/window.cc9
-rw-r--r--ui/aura/window_unittest.cc16
15 files changed, 69 insertions, 52 deletions
diff --git a/ui/aura/client/activation_client.cc b/ui/aura/client/activation_client.cc
index 09e29f0..7ceb005 100644
--- a/ui/aura/client/activation_client.cc
+++ b/ui/aura/client/activation_client.cc
@@ -27,13 +27,13 @@ const WindowProperty<ActivationClient*>* const
const WindowProperty<Window*>* const
kRootWindowActiveWindowKey = &kRootWindowActiveWindowProp;
-void SetActivationClient(ActivationClient* client) {
- RootWindow::GetInstance()->SetProperty(kRootWindowActivationClientKey,
- client);
+void SetActivationClient(RootWindow* root_window, ActivationClient* client) {
+ root_window->SetProperty(kRootWindowActivationClientKey, client);
}
-ActivationClient* GetActivationClient() {
- return RootWindow::GetInstance()->GetProperty(kRootWindowActivationClientKey);
+ActivationClient* GetActivationClient(RootWindow* root_window) {
+ return root_window ?
+ root_window->GetProperty(kRootWindowActivationClientKey) : NULL;
}
} // namespace client
diff --git a/ui/aura/client/activation_client.h b/ui/aura/client/activation_client.h
index dcbe289..9893a34 100644
--- a/ui/aura/client/activation_client.h
+++ b/ui/aura/client/activation_client.h
@@ -10,6 +10,7 @@
#include "ui/aura/window.h"
namespace aura {
+class RootWindow;
namespace client {
// An interface implemented by an object that manages window activation.
@@ -34,8 +35,9 @@ class AURA_EXPORT ActivationClient {
};
// Sets/Gets the activation client on the RootWindow.
-AURA_EXPORT void SetActivationClient(ActivationClient* client);
-AURA_EXPORT ActivationClient* GetActivationClient();
+AURA_EXPORT void SetActivationClient(RootWindow* root_window,
+ ActivationClient* client);
+AURA_EXPORT ActivationClient* GetActivationClient(RootWindow* root_window);
// A property key to store what the client defines as the active window on the
// RootWindow.
diff --git a/ui/aura/client/dispatcher_client.cc b/ui/aura/client/dispatcher_client.cc
index 56a2227..2fb71dd 100644
--- a/ui/aura/client/dispatcher_client.cc
+++ b/ui/aura/client/dispatcher_client.cc
@@ -20,12 +20,12 @@ const WindowProperty<DispatcherClient*>* const
} // namespace
-void SetDispatcherClient(DispatcherClient* client) {
- RootWindow::GetInstance()->SetProperty(kDispatcherClientKey, client);
+void SetDispatcherClient(RootWindow* root_window, DispatcherClient* client) {
+ root_window->SetProperty(kDispatcherClientKey, client);
}
-DispatcherClient* GetDispatcherClient() {
- return RootWindow::GetInstance()->GetProperty(kDispatcherClientKey);
+DispatcherClient* GetDispatcherClient(RootWindow* root_window) {
+ return root_window ? root_window->GetProperty(kDispatcherClientKey) : NULL;
}
} // namespace client
diff --git a/ui/aura/client/dispatcher_client.h b/ui/aura/client/dispatcher_client.h
index 88e4127..4abe298 100644
--- a/ui/aura/client/dispatcher_client.h
+++ b/ui/aura/client/dispatcher_client.h
@@ -11,7 +11,7 @@
#include "base/message_loop.h"
namespace aura {
-
+class RootWindow;
namespace client {
// An interface implemented by an object which handles nested dispatchers.
@@ -22,8 +22,9 @@ class AURA_EXPORT DispatcherClient {
bool nestable_tasks_allowed) = 0;
};
-AURA_EXPORT void SetDispatcherClient(DispatcherClient* client);
-AURA_EXPORT DispatcherClient* GetDispatcherClient();
+AURA_EXPORT void SetDispatcherClient(RootWindow* root_window,
+ DispatcherClient* client);
+AURA_EXPORT DispatcherClient* GetDispatcherClient(RootWindow* root_window);
} // namespace client
} // namespace aura
diff --git a/ui/aura/client/drag_drop_client.cc b/ui/aura/client/drag_drop_client.cc
index f7c0ff1..d89aef1 100644
--- a/ui/aura/client/drag_drop_client.cc
+++ b/ui/aura/client/drag_drop_client.cc
@@ -20,12 +20,13 @@ const WindowProperty<DragDropClient*>* const
} // namespace
-void SetDragDropClient(DragDropClient* client) {
- RootWindow::GetInstance()->SetProperty(kRootWindowDragDropClientKey, client);
+void SetDragDropClient(RootWindow* root_window, DragDropClient* client) {
+ root_window->SetProperty(kRootWindowDragDropClientKey, client);
}
-DragDropClient* GetDragDropClient() {
- return RootWindow::GetInstance()->GetProperty(kRootWindowDragDropClientKey);
+DragDropClient* GetDragDropClient(RootWindow* root_window) {
+ return root_window ?
+ root_window->GetProperty(kRootWindowDragDropClientKey) : NULL;
}
} // namespace client
diff --git a/ui/aura/client/drag_drop_client.h b/ui/aura/client/drag_drop_client.h
index 5e51221..58b00ed 100644
--- a/ui/aura/client/drag_drop_client.h
+++ b/ui/aura/client/drag_drop_client.h
@@ -14,6 +14,7 @@ class OSExchangeData;
}
namespace aura {
+class RootWindow;
class Window;
namespace client {
@@ -42,8 +43,9 @@ class AURA_EXPORT DragDropClient {
virtual bool IsDragDropInProgress() = 0;
};
-AURA_EXPORT void SetDragDropClient(DragDropClient* client);
-AURA_EXPORT DragDropClient* GetDragDropClient();
+AURA_EXPORT void SetDragDropClient(RootWindow* root_window,
+ DragDropClient* client);
+AURA_EXPORT DragDropClient* GetDragDropClient(RootWindow* root_window);
} // namespace client
} // namespace aura
diff --git a/ui/aura/client/tooltip_client.cc b/ui/aura/client/tooltip_client.cc
index 072336a..fab7499 100644
--- a/ui/aura/client/tooltip_client.cc
+++ b/ui/aura/client/tooltip_client.cc
@@ -25,12 +25,13 @@ const WindowProperty<string16*>* const kTooltipTextKey = &kTooltipTextProp;
} // namespace
-void SetTooltipClient(TooltipClient* client) {
- RootWindow::GetInstance()->SetProperty(kRootWindowTooltipClientKey, client);
+void SetTooltipClient(RootWindow* root_window, TooltipClient* client) {
+ root_window->SetProperty(kRootWindowTooltipClientKey, client);
}
-TooltipClient* GetTooltipClient() {
- return RootWindow::GetInstance()->GetProperty(kRootWindowTooltipClientKey);
+TooltipClient* GetTooltipClient(RootWindow* root_window) {
+ return root_window ?
+ root_window->GetProperty(kRootWindowTooltipClientKey) : NULL;
}
void SetTooltipText(Window* window, string16* tooltip_text) {
diff --git a/ui/aura/client/tooltip_client.h b/ui/aura/client/tooltip_client.h
index b99f329..5e68d82 100644
--- a/ui/aura/client/tooltip_client.h
+++ b/ui/aura/client/tooltip_client.h
@@ -11,6 +11,7 @@
#include "ui/gfx/font.h"
namespace aura {
+class RootWindow;
class Window;
namespace client {
@@ -23,8 +24,9 @@ class AURA_EXPORT TooltipClient {
virtual void SetTooltipsEnabled(bool enable) = 0;
};
-AURA_EXPORT void SetTooltipClient(TooltipClient* client);
-AURA_EXPORT TooltipClient* GetTooltipClient();
+AURA_EXPORT void SetTooltipClient(RootWindow* root_window,
+ TooltipClient* client);
+AURA_EXPORT TooltipClient* GetTooltipClient(RootWindow* root_window);
AURA_EXPORT void SetTooltipText(Window* window, string16* tooltip_text);
AURA_EXPORT const string16 GetTooltipText(Window* window);
diff --git a/ui/aura/client/visibility_client.cc b/ui/aura/client/visibility_client.cc
index fdb9d9a..24f8dd6 100644
--- a/ui/aura/client/visibility_client.cc
+++ b/ui/aura/client/visibility_client.cc
@@ -21,13 +21,13 @@ const WindowProperty<VisibilityClient*>* const
} // namespace
-void SetVisibilityClient(VisibilityClient* client) {
- RootWindow::GetInstance()->SetProperty(kRootWindowVisibilityClientKey,
- client);
+void SetVisibilityClient(RootWindow* root_window, VisibilityClient* client) {
+ root_window->SetProperty(kRootWindowVisibilityClientKey, client);
}
-VisibilityClient* GetVisibilityClient() {
- return RootWindow::GetInstance()->GetProperty(kRootWindowVisibilityClientKey);
+VisibilityClient* GetVisibilityClient(RootWindow* root_window) {
+ return root_window ?
+ root_window->GetProperty(kRootWindowVisibilityClientKey) : NULL;
}
} // namespace client
diff --git a/ui/aura/client/visibility_client.h b/ui/aura/client/visibility_client.h
index bde4ba5..4b28ffe 100644
--- a/ui/aura/client/visibility_client.h
+++ b/ui/aura/client/visibility_client.h
@@ -9,6 +9,7 @@
#include "ui/aura/aura_export.h"
namespace aura {
+class RootWindow;
class Window;
namespace client {
@@ -26,8 +27,9 @@ class AURA_EXPORT VisibilityClient {
};
// Sets/Gets the VisibilityClient on the RootWindow.
-AURA_EXPORT void SetVisibilityClient(VisibilityClient* client);
-AURA_EXPORT VisibilityClient* GetVisibilityClient();
+AURA_EXPORT void SetVisibilityClient(RootWindow* root_window,
+ VisibilityClient* client);
+AURA_EXPORT VisibilityClient* GetVisibilityClient(RootWindow* root_window);
} // namespace clients
} // namespace aura
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 36ee2cd..685b89d 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -690,8 +690,8 @@ void RootWindow::OnWindowHidden(Window* invisible, bool destroyed) {
}
if (focus_to &&
(!focus_to->IsVisible() ||
- (client::GetActivationClient() &&
- !client::GetActivationClient()->CanFocusWindow(focus_to)))) {
+ (client::GetActivationClient(this) &&
+ !client::GetActivationClient(this)->CanFocusWindow(focus_to)))) {
focus_to = NULL;
}
SetFocusedWindow(focus_to);
@@ -755,8 +755,8 @@ void RootWindow::SetFocusedWindow(Window* focused_window) {
// The NULL-check of |focused_window| is essential here before asking the
// activation client, since it is valid to clear the focus by calling
// SetFocusedWindow() to NULL.
- if (focused_window && client::GetActivationClient() &&
- !client::GetActivationClient()->CanFocusWindow(focused_window)) {
+ if (focused_window && client::GetActivationClient(this) &&
+ !client::GetActivationClient(this)->CanFocusWindow(focused_window)) {
return;
}
diff --git a/ui/aura/test/test_activation_client.cc b/ui/aura/test/test_activation_client.cc
index a6aef6a..7ba0d41 100644
--- a/ui/aura/test/test_activation_client.cc
+++ b/ui/aura/test/test_activation_client.cc
@@ -1,9 +1,10 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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/test/test_activation_client.h"
+#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
namespace aura {
@@ -12,8 +13,9 @@ namespace test {
////////////////////////////////////////////////////////////////////////////////
// TestActivationClient, public:
-TestActivationClient::TestActivationClient() : active_window_(NULL) {
- client::SetActivationClient(this);
+TestActivationClient::TestActivationClient(RootWindow* root_window)
+ : active_window_(NULL) {
+ client::SetActivationClient(root_window, this);
}
TestActivationClient::~TestActivationClient() {
diff --git a/ui/aura/test/test_activation_client.h b/ui/aura/test/test_activation_client.h
index 8dd7e98b..6221d21 100644
--- a/ui/aura/test/test_activation_client.h
+++ b/ui/aura/test/test_activation_client.h
@@ -12,12 +12,13 @@
#include "ui/aura/window_observer.h"
namespace aura {
+class RootWindow;
namespace test {
class TestActivationClient : public client::ActivationClient,
public WindowObserver {
public:
- TestActivationClient();
+ explicit TestActivationClient(RootWindow* root_window);
virtual ~TestActivationClient();
// Overridden from client::ActivationClient:
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index f907c9a..3706b34 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -578,10 +578,13 @@ void Window::SetVisible(bool visible) {
bool was_visible = IsVisible();
if (visible != layer_->visible()) {
- if (client::GetVisibilityClient())
- client::GetVisibilityClient()->UpdateLayerVisibility(this, visible);
- else
+ RootWindow* root_window = GetRootWindow();
+ if (client::GetVisibilityClient(root_window)) {
+ client::GetVisibilityClient(root_window)->UpdateLayerVisibility(
+ this, visible);
+ } else {
layer_->SetVisible(visible);
+ }
}
visible_ = visible;
bool is_visible = IsVisible();
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index 45055f2..d3779df 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -1280,11 +1280,11 @@ TEST_F(WindowTest, StackTransientsWhoseLayersHaveNoDelegate) {
class TestVisibilityClient : public client::VisibilityClient {
public:
- TestVisibilityClient() : ignore_visibility_changes_(false) {
- client::SetVisibilityClient(this);
+ explicit TestVisibilityClient(RootWindow* root_window)
+ : ignore_visibility_changes_(false) {
+ client::SetVisibilityClient(root_window, this);
}
virtual ~TestVisibilityClient() {
- client::SetVisibilityClient(NULL);
}
void set_ignore_visibility_changes(bool ignore_visibility_changes) {
@@ -1304,7 +1304,7 @@ public:
};
TEST_F(WindowTest, VisibilityClientIsVisible) {
- TestVisibilityClient client;
+ TestVisibilityClient client(root_window());
scoped_ptr<Window> window(CreateTestWindowWithId(1, NULL));
EXPECT_TRUE(window->IsVisible());
@@ -1442,11 +1442,11 @@ class StackingMadrigalLayoutManager : public LayoutManager {
class StackingMadrigalVisibilityClient : public client::VisibilityClient {
public:
- StackingMadrigalVisibilityClient() : ignored_window_(NULL) {
- client::SetVisibilityClient(this);
+ explicit StackingMadrigalVisibilityClient(RootWindow* root_window)
+ : ignored_window_(NULL) {
+ client::SetVisibilityClient(root_window, this);
}
virtual ~StackingMadrigalVisibilityClient() {
- client::SetVisibilityClient(NULL);
}
void set_ignored_window(Window* ignored_window) {
@@ -1489,7 +1489,7 @@ class StackingMadrigalVisibilityClient : public client::VisibilityClient {
// verifies this fix.
TEST_F(WindowTest, StackingMadrigal) {
new StackingMadrigalLayoutManager(root_window());
- StackingMadrigalVisibilityClient visibility_client;
+ StackingMadrigalVisibilityClient visibility_client(root_window());
scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL));
scoped_ptr<Window> window11(CreateTransientChild(11, window1.get()));