diff options
34 files changed, 162 insertions, 115 deletions
diff --git a/ash/accelerators/nested_dispatcher_controller.cc b/ash/accelerators/nested_dispatcher_controller.cc index dda0d2ad..c08d7f4 100644 --- a/ash/accelerators/nested_dispatcher_controller.cc +++ b/ash/accelerators/nested_dispatcher_controller.cc @@ -5,11 +5,12 @@ #include "ash/accelerators/nested_dispatcher_controller.h" #include "ash/accelerators/accelerator_dispatcher.h" +#include "ash/shell.h" namespace ash { NestedDispatcherController::NestedDispatcherController() { - aura::client::SetDispatcherClient(this); + aura::client::SetDispatcherClient(Shell::GetRootWindow(), this); } NestedDispatcherController::~NestedDispatcherController() { diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc index 9ff111c..d491621 100644 --- a/ash/drag_drop/drag_drop_controller.cc +++ b/ash/drag_drop/drag_drop_controller.cc @@ -42,7 +42,7 @@ DragDropController::DragDropController() drag_drop_in_progress_(false), should_block_during_drag_drop_(true) { Shell::GetInstance()->AddRootWindowEventFilter(this); - aura::client::SetDragDropClient(this); + aura::client::SetDragDropClient(Shell::GetRootWindow(), this); } DragDropController::~DragDropController() { diff --git a/ash/drag_drop/drag_drop_controller_unittest.cc b/ash/drag_drop/drag_drop_controller_unittest.cc index a2a0d00..a17a485 100644 --- a/ash/drag_drop/drag_drop_controller_unittest.cc +++ b/ash/drag_drop/drag_drop_controller_unittest.cc @@ -185,12 +185,13 @@ class DragDropControllerTest : public AshTestBase { AshTestBase::SetUp(); drag_drop_controller_.reset(new TestDragDropController); drag_drop_controller_->set_should_block_during_drag_drop(false); - aura::client::SetDragDropClient(drag_drop_controller_.get()); + aura::client::SetDragDropClient(Shell::GetRootWindow(), + drag_drop_controller_.get()); views_delegate_.reset(new views::TestViewsDelegate); } void TearDown() OVERRIDE { - aura::client::SetDragDropClient(NULL); + aura::client::SetDragDropClient(Shell::GetRootWindow(), NULL); drag_drop_controller_.reset(); AshTestBase::TearDown(); } diff --git a/ash/focus_cycler.cc b/ash/focus_cycler.cc index f1877d1..6a62757b 100644 --- a/ash/focus_cycler.cc +++ b/ash/focus_cycler.cc @@ -66,7 +66,8 @@ void FocusCycler::RotateFocus(Direction direction) { Shell::GetInstance()->delegate()->GetCycleWindowList( ShellDelegate::SOURCE_LAUNCHER, ShellDelegate::ORDER_MRU); if (!windows.empty()) { - aura::client::GetActivationClient()->ActivateWindow(windows[0]); + aura::client::GetActivationClient(Shell::GetRootWindow())-> + ActivateWindow(windows[0]); break; } } else { diff --git a/ash/shell.cc b/ash/shell.cc index 22a2f38..c4fcc52 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -225,7 +225,7 @@ Shell::~Shell() { // TooltipController is deleted with the Shell so removing its references. RemoveRootWindowEventFilter(tooltip_controller_.get()); - aura::client::SetTooltipClient(NULL); + aura::client::SetTooltipClient(GetRootWindow(), NULL); // Make sure we delete WorkspaceController before launcher is // deleted as it has a reference to launcher model. @@ -344,11 +344,9 @@ void Shell::Init() { AddRootWindowEventFilter(window_modality_controller_.get()); visibility_controller_.reset(new internal::VisibilityController); - aura::client::SetVisibilityClient(visibility_controller_.get()); tooltip_controller_.reset(new internal::TooltipController); AddRootWindowEventFilter(tooltip_controller_.get()); - aura::client::SetTooltipClient(tooltip_controller_.get()); drag_drop_controller_.reset(new internal::DragDropController); power_button_controller_.reset(new PowerButtonController); diff --git a/ash/tooltips/tooltip_controller.cc b/ash/tooltips/tooltip_controller.cc index a999c59..b23d227 100644 --- a/ash/tooltips/tooltip_controller.cc +++ b/ash/tooltips/tooltip_controller.cc @@ -219,6 +219,7 @@ TooltipController::TooltipController() tooltip_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTooltipTimeoutMs), this, &TooltipController::TooltipTimerFired); + aura::client::SetTooltipClient(Shell::GetRootWindow(), this); } TooltipController::~TooltipController() { diff --git a/ash/tooltips/tooltip_controller_unittest.cc b/ash/tooltips/tooltip_controller_unittest.cc index badae3c..f07dfd5 100644 --- a/ash/tooltips/tooltip_controller_unittest.cc +++ b/ash/tooltips/tooltip_controller_unittest.cc @@ -68,7 +68,7 @@ void AddViewToWidgetAndResize(views::Widget* widget, views::View* view) { ash::internal::TooltipController* GetController() { return static_cast<ash::internal::TooltipController*>( - aura::client::GetTooltipClient()); + aura::client::GetTooltipClient(Shell::GetRootWindow())); } } // namespace @@ -99,7 +99,7 @@ class TooltipControllerTest : public AshTestBase { }; TEST_F(TooltipControllerTest, NonNullTooltipClient) { - EXPECT_TRUE(aura::client::GetTooltipClient() != NULL); + EXPECT_TRUE(aura::client::GetTooltipClient(Shell::GetRootWindow()) != NULL); EXPECT_EQ(ASCIIToUTF16(""), GetTooltipText()); EXPECT_EQ(NULL, GetTooltipWindow()); EXPECT_FALSE(IsTooltipVisible()); diff --git a/ash/wm/activation_controller.cc b/ash/wm/activation_controller.cc index 93cc530..ffbeb5a 100644 --- a/ash/wm/activation_controller.cc +++ b/ash/wm/activation_controller.cc @@ -71,7 +71,7 @@ void StackTransientParentsBelowModalWindow(aura::Window* window) { ActivationController::ActivationController() : updating_activation_(false), default_container_for_test_(NULL) { - aura::client::SetActivationClient(this); + aura::client::SetActivationClient(Shell::GetRootWindow(), this); aura::Env::GetInstance()->AddObserver(this); Shell::GetRootWindow()->AddRootWindowObserver(this); } diff --git a/ash/wm/visibility_controller.cc b/ash/wm/visibility_controller.cc index 94b9397..2c13698 100644 --- a/ash/wm/visibility_controller.cc +++ b/ash/wm/visibility_controller.cc @@ -4,6 +4,7 @@ #include "ash/wm/visibility_controller.h" +#include "ash/shell.h" #include "ash/wm/window_animations.h" #include "ui/aura/window.h" #include "ui/aura/window_property.h" @@ -31,6 +32,7 @@ bool GetChildWindowVisibilityChangesAnimated(aura::Window* window) { } // namespace VisibilityController::VisibilityController() { + aura::client::SetVisibilityClient(Shell::GetRootWindow(), this); } VisibilityController::~VisibilityController() { diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc index 5571464..bdc6ccb 100644 --- a/ash/wm/window_util.cc +++ b/ash/wm/window_util.cc @@ -4,6 +4,7 @@ #include "ash/wm/window_util.h" +#include "ash/shell.h" #include "ash/wm/activation_controller.h" #include "ui/aura/client/activation_client.h" #include "ui/aura/client/aura_constants.h" @@ -26,11 +27,13 @@ const aura::WindowProperty<bool>* const } // namespace void ActivateWindow(aura::Window* window) { - aura::client::GetActivationClient()->ActivateWindow(window); + aura::client::GetActivationClient(Shell::GetRootWindow())->ActivateWindow( + window); } void DeactivateWindow(aura::Window* window) { - aura::client::GetActivationClient()->DeactivateWindow(window); + aura::client::GetActivationClient(Shell::GetRootWindow())->DeactivateWindow( + window); } bool IsActiveWindow(aura::Window* window) { @@ -38,7 +41,8 @@ bool IsActiveWindow(aura::Window* window) { } aura::Window* GetActiveWindow() { - return aura::client::GetActivationClient()->GetActiveWindow(); + return aura::client::GetActivationClient(Shell::GetRootWindow())-> + GetActiveWindow(); } aura::Window* GetActivatableWindow(aura::Window* window) { diff --git a/chrome/browser/ui/views/simple_message_box_views.cc b/chrome/browser/ui/views/simple_message_box_views.cc index 442fdba..3846d0f 100644 --- a/chrome/browser/ui/views/simple_message_box_views.cc +++ b/chrome/browser/ui/views/simple_message_box_views.cc @@ -62,8 +62,8 @@ bool SimpleMessageBoxViews::ShowYesNoBox(gfx::NativeWindow parent_window, g_browser_process->AddRefModule(); #if defined(USE_AURA) - aura::client::GetDispatcherClient()->RunWithDispatcher(dialog, - parent_window, true); + aura::client::GetDispatcherClient(parent_window->GetRootWindow())-> + RunWithDispatcher(dialog, parent_window, true); #else { MessageLoop::ScopedNestableTaskAllower allow(MessageLoopForUI::current()); diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc index 6d22fd8..8834f81 100644 --- a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc +++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc @@ -200,7 +200,8 @@ void NativeTabContentsViewAura::StartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask ops, const SkBitmap& image, const gfx::Point& image_offset) { - if (!aura::client::GetDragDropClient()) + aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); + if (!aura::client::GetDragDropClient(root_window)) return; ui::OSExchangeDataProviderAura* provider = new ui::OSExchangeDataProviderAura; @@ -219,10 +220,10 @@ void NativeTabContentsViewAura::StartDragging(const WebDropData& drop_data, // always start from a mouse-event (e.g. a touch or gesture event could // initiate the drag). The location information should be carried over from // webkit. http://crbug.com/114754 - gfx::Point location(ash::Shell::GetRootWindow()->last_mouse_location()); + gfx::Point location(root_window->last_mouse_location()); location.Offset(-image_offset.x(), -image_offset.y()); MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); - result_op = aura::client::GetDragDropClient()->StartDragAndDrop( + result_op = aura::client::GetDragDropClient(root_window)->StartDragAndDrop( data, location, ConvertFromWeb(ops)); } @@ -231,13 +232,15 @@ void NativeTabContentsViewAura::StartDragging(const WebDropData& drop_data, } void NativeTabContentsViewAura::CancelDrag() { - if (aura::client::GetDragDropClient()) - aura::client::GetDragDropClient()->DragCancel(); + aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); + if (aura::client::GetDragDropClient(root_window)) + aura::client::GetDragDropClient(root_window)->DragCancel(); } bool NativeTabContentsViewAura::IsDoingDrag() const { - if (aura::client::GetDragDropClient()) - return aura::client::GetDragDropClient()->IsDragDropInProgress(); + aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); + if (aura::client::GetDragDropClient(root_window)) + return aura::client::GetDragDropClient(root_window)->IsDragDropInProgress(); return false; } diff --git a/chrome/test/base/browser_with_test_window_test.cc b/chrome/test/base/browser_with_test_window_test.cc index 47be6d8..49cc3cc9 100644 --- a/chrome/test/base/browser_with_test_window_test.cc +++ b/chrome/test/base/browser_with_test_window_test.cc @@ -1,4 +1,4 @@ -// 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. @@ -18,6 +18,10 @@ #include "content/public/browser/web_contents.h" #include "content/public/common/page_transition_types.h" +#if defined(USE_AURA) +#include "ui/aura/root_window.h" +#endif + using content::BrowserThread; using content::NavigationController; using content::WebContents; @@ -32,9 +36,6 @@ BrowserWithTestWindowTest::BrowserWithTestWindowTest() #if defined(OS_WIN) OleInitialize(NULL); #endif -#if defined(USE_AURA) - test_activation_client_.reset(new aura::test::TestActivationClient); -#endif } void BrowserWithTestWindowTest::SetUp() { @@ -44,6 +45,18 @@ void BrowserWithTestWindowTest::SetUp() { browser_.reset(new Browser(Browser::TYPE_TABBED, profile())); window_.reset(new TestBrowserWindow(browser())); browser_->SetWindowForTesting(window_.get()); +#if defined(USE_AURA) + aura::RootWindow* root_window = aura::RootWindow::GetInstance(); + test_activation_client_.reset( + new aura::test::TestActivationClient(root_window)); +#endif +} + +void BrowserWithTestWindowTest::TearDown() { + testing::Test::TearDown(); +#if defined(USE_AURA) + aura::RootWindow::DeleteInstance(); +#endif } BrowserWithTestWindowTest::~BrowserWithTestWindowTest() { diff --git a/chrome/test/base/browser_with_test_window_test.h b/chrome/test/base/browser_with_test_window_test.h index ab88c6a..75477cc 100644 --- a/chrome/test/base/browser_with_test_window_test.h +++ b/chrome/test/base/browser_with_test_window_test.h @@ -1,4 +1,4 @@ -// 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. @@ -61,6 +61,7 @@ class BrowserWithTestWindowTest : public testing::Test { virtual ~BrowserWithTestWindowTest(); virtual void SetUp() OVERRIDE; + virtual void TearDown() OVERRIDE; // Returns the current RenderViewHost for the current tab as a // TestRenderViewHost. diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 20c2d6e..ae30aa4 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -337,8 +337,9 @@ void RenderWidgetHostViewAura::Destroy() { void RenderWidgetHostViewAura::SetTooltipText(const string16& tooltip_text) { tooltip_ = tooltip_text; - if (aura::client::GetTooltipClient()) - aura::client::GetTooltipClient()->UpdateTooltip(window_); + aura::RootWindow* root_window = window_->GetRootWindow(); + if (aura::client::GetTooltipClient(root_window)) + aura::client::GetTooltipClient(root_window)->UpdateTooltip(window_); } void RenderWidgetHostViewAura::SelectionBoundsChanged( @@ -530,8 +531,8 @@ bool RenderWidgetHostViewAura::LockMouse() { root_window->ShowCursor(false); synthetic_move_sent_ = true; root_window->MoveCursorTo(window_->bounds().CenterPoint()); - if (aura::client::GetTooltipClient()) - aura::client::GetTooltipClient()->SetTooltipsEnabled(false); + if (aura::client::GetTooltipClient(root_window)) + aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(false); return true; } else { mouse_locked_ = false; @@ -550,8 +551,8 @@ void RenderWidgetHostViewAura::UnlockMouse() { root_window->ReleaseCapture(window_); root_window->MoveCursorTo(unlocked_global_mouse_position_); root_window->ShowCursor(true); - if (aura::client::GetTooltipClient()) - aura::client::GetTooltipClient()->SetTooltipsEnabled(true); + if (aura::client::GetTooltipClient(root_window)) + aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(true); host_->LostMouseLock(); } 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())); diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc index 1cce7fa..5a06c3f 100644 --- a/ui/views/controls/menu/menu_controller.cc +++ b/ui/views/controls/menu/menu_controller.cc @@ -321,8 +321,9 @@ MenuItemView* MenuController::Run(Widget* parent, // from a task none of the tasks we schedule are processed and the menu // appears totally broken. #if defined(USE_AURA) - aura::client::GetDispatcherClient()->RunWithDispatcher(this, - parent->GetNativeWindow(), true); + aura::client::GetDispatcherClient( + parent->GetNativeWindow()->GetRootWindow())-> + RunWithDispatcher(this, parent->GetNativeWindow(), true); #else { MessageLoopForUI* loop = MessageLoopForUI::current(); diff --git a/ui/views/test/views_test_base.cc b/ui/views/test/views_test_base.cc index 2b33f9c..cbcef299 100644 --- a/ui/views/test/views_test_base.cc +++ b/ui/views/test/views_test_base.cc @@ -66,7 +66,6 @@ ViewsTestBase::ViewsTestBase() OleInitialize(NULL); #endif #if defined(USE_AURA) - test_activation_client_.reset(new aura::test::TestActivationClient); test_input_method_.reset(new DummyInputMethod); #endif } @@ -91,6 +90,8 @@ void ViewsTestBase::SetUp() { root_window_->SetProperty( aura::client::kRootWindowInputMethodKey, test_input_method_.get()); + test_activation_client_.reset( + new aura::test::TestActivationClient(root_window_)); #endif } @@ -102,6 +103,7 @@ void ViewsTestBase::TearDown() { views_delegate_.reset(); testing::Test::TearDown(); #if defined(USE_AURA) + test_activation_client_.reset(); aura::RootWindow::DeleteInstance(); #endif } diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index 1423418..e1e9d8e 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -121,8 +121,9 @@ class NativeWidgetAura::ActiveWindowObserver : public aura::WindowObserver { key != aura::client::kRootWindowActiveWindowKey) { return; } + aura::RootWindow* root_window = window->GetRootWindow(); aura::Window* active = - aura::client::GetActivationClient()->GetActiveWindow(); + aura::client::GetActivationClient(root_window)->GetActiveWindow(); if (!active || (active != host_->window_ && active->transient_parent() != host_->window_)) { host_->delegate_->EnableInactiveRendering(); @@ -519,15 +520,18 @@ bool NativeWidgetAura::IsVisible() const { } void NativeWidgetAura::Activate() { - aura::client::GetActivationClient()->ActivateWindow(window_); + aura::client::GetActivationClient(window_->GetRootWindow())->ActivateWindow( + window_); } void NativeWidgetAura::Deactivate() { - aura::client::GetActivationClient()->DeactivateWindow(window_); + aura::client::GetActivationClient(window_->GetRootWindow())->DeactivateWindow( + window_); } bool NativeWidgetAura::IsActive() const { - return aura::client::GetActivationClient()->GetActiveWindow() == window_; + return aura::client::GetActivationClient(window_->GetRootWindow())-> + GetActiveWindow() == window_; } void NativeWidgetAura::SetAlwaysOnTop(bool on_top) { @@ -596,11 +600,12 @@ void NativeWidgetAura::RunShellDrag(View* view, const gfx::Point& location, int operation) { gfx::Point root_location(location); - aura::Window::ConvertPointToWindow(window_, - window_->GetRootWindow(), &root_location); - if (aura::client::GetDragDropClient()) - aura::client::GetDragDropClient()->StartDragAndDrop(data, root_location, - operation); + aura::RootWindow* root_window = window_->GetRootWindow(); + aura::Window::ConvertPointToWindow(window_, root_window, &root_location); + if (aura::client::GetDragDropClient(root_window)) { + aura::client::GetDragDropClient(root_window)->StartDragAndDrop(data, + root_location, operation); + } } void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { diff --git a/ui/views/widget/tooltip_manager_aura.cc b/ui/views/widget/tooltip_manager_aura.cc index 3bed930..01e3e60 100644 --- a/ui/views/widget/tooltip_manager_aura.cc +++ b/ui/views/widget/tooltip_manager_aura.cc @@ -1,4 +1,4 @@ -// 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. @@ -51,44 +51,40 @@ TooltipManagerAura::~TooltipManagerAura() { // TooltipManagerAura, TooltipManager implementation: void TooltipManagerAura::UpdateTooltip() { - if (aura::client::GetTooltipClient()) { - aura::RootWindow* root_window = - native_widget_aura_->GetNativeView()->GetRootWindow(); + aura::Window* window = native_widget_aura_->GetNativeView(); + aura::RootWindow* root_window = window->GetRootWindow(); + if (aura::client::GetTooltipClient(root_window)) { gfx::Point view_point = root_window->last_mouse_location(); - aura::Window::ConvertPointToWindow(root_window, - native_widget_aura_->GetNativeView(), &view_point); + aura::Window::ConvertPointToWindow(root_window, window, &view_point); View* view = GetViewUnderPoint(view_point); if (view) { View::ConvertPointFromWidget(view, &view_point); if (!view->GetTooltipText(view_point, &tooltip_text_)) - tooltip_text_.clear(); + tooltip_text_.clear(); } else { tooltip_text_.clear(); } - aura::client::GetTooltipClient()->UpdateTooltip( - native_widget_aura_->GetNativeView()); + aura::client::GetTooltipClient(root_window)->UpdateTooltip(window); } } void TooltipManagerAura::TooltipTextChanged(View* view) { - if (aura::client::GetTooltipClient()) { - aura::RootWindow* root_window = - native_widget_aura_->GetNativeView()->GetRootWindow(); + aura::Window* window = native_widget_aura_->GetNativeView(); + aura::RootWindow* root_window = window->GetRootWindow(); + if (aura::client::GetTooltipClient(root_window)) { gfx::Point view_point = root_window->last_mouse_location(); - aura::Window::ConvertPointToWindow(root_window, - native_widget_aura_->GetNativeView(), &view_point); + aura::Window::ConvertPointToWindow(root_window, window, &view_point); View* target = GetViewUnderPoint(view_point); if (target != view) return; if (target) { View::ConvertPointFromWidget(view, &view_point); if (!view->GetTooltipText(view_point, &tooltip_text_)) - tooltip_text_.clear(); + tooltip_text_.clear(); } else { tooltip_text_.clear(); } - aura::client::GetTooltipClient()->UpdateTooltip( - native_widget_aura_->GetNativeView()); + aura::client::GetTooltipClient(root_window)->UpdateTooltip(window); } } |