diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-18 22:07:34 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-18 22:07:34 +0000 |
commit | 980969549b2d830274e99d8919d6bb2fa0d82b5e (patch) | |
tree | f45d0ba2f57b6c2bbd0dc52417664d0e7ac3d38a | |
parent | 145e5a1d4494df83036fa4a6f81fd5bf3adbcf90 (diff) | |
download | chromium_src-980969549b2d830274e99d8919d6bb2fa0d82b5e.zip chromium_src-980969549b2d830274e99d8919d6bb2fa0d82b5e.tar.gz chromium_src-980969549b2d830274e99d8919d6bb2fa0d82b5e.tar.bz2 |
Attempt to re-land FocusManager removal from Aura.
content_browsertests ContentWindowReparent test was failing, presumably because a focus notification wasn't being broadcast by the new test focus client.
R=sky@chromium.org
BUG=
Review URL: https://codereview.chromium.org/29883002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229480 0039d316-1c4b-4281-b951-d872f2087c98
32 files changed, 143 insertions, 279 deletions
diff --git a/ash/shell.cc b/ash/shell.cc index 7af0a3c..6e25c52 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -83,7 +83,6 @@ #include "ui/aura/client/aura_constants.h" #include "ui/aura/client/user_action_client.h" #include "ui/aura/env.h" -#include "ui/aura/focus_manager.h" #include "ui/aura/layout_manager.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" diff --git a/ash/wm/dock/docked_window_layout_manager.cc b/ash/wm/dock/docked_window_layout_manager.cc index e0a08e3..e30a94b 100644 --- a/ash/wm/dock/docked_window_layout_manager.cc +++ b/ash/wm/dock/docked_window_layout_manager.cc @@ -22,7 +22,7 @@ #include "base/command_line.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/aura/client/activation_client.h" -#include "ui/aura/focus_manager.h" +#include "ui/aura/client/focus_client.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" #include "ui/aura/window_delegate.h" diff --git a/ash/wm/panels/panel_layout_manager.cc b/ash/wm/panels/panel_layout_manager.cc index 2100925..cf75c29 100644 --- a/ash/wm/panels/panel_layout_manager.cc +++ b/ash/wm/panels/panel_layout_manager.cc @@ -24,7 +24,7 @@ #include "third_party/skia/include/core/SkPaint.h" #include "third_party/skia/include/core/SkPath.h" #include "ui/aura/client/activation_client.h" -#include "ui/aura/focus_manager.h" +#include "ui/aura/client/focus_client.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" #include "ui/compositor/scoped_layer_animation_settings.h" diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc index 1248754..b87a6af 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc @@ -55,7 +55,7 @@ #endif #if defined(USE_AURA) -#include "ui/aura/focus_manager.h" +#include "ui/aura/client/focus_client.h" #include "ui/aura/root_window.h" #include "ui/compositor/layer.h" #endif diff --git a/content/browser/web_contents/web_contents_view_aura_browsertest.cc b/content/browser/web_contents/web_contents_view_aura_browsertest.cc index 7b06029..0ccea28 100644 --- a/content/browser/web_contents/web_contents_view_aura_browsertest.cc +++ b/content/browser/web_contents/web_contents_view_aura_browsertest.cc @@ -555,15 +555,15 @@ IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, EXPECT_EQ(NULL, screenshot_manager()->screenshot_taken_for()); } -// Failing on win7_aura trybot (see crbug.com/260983). -#if defined(OS_WIN) -#define MAYBE_ContentWindowReparent \ - DISABLED_ContentWindowReparent -#else -#define MAYBE_ContentWindowReparent ContentWindowReparent -#endif +// TODO(sadrul): This test is disabled because it reparents in a way the +// FocusController does not support. This code would crash in +// a production build. It only passed prior to this revision +// because testing used the old FocusManager which did some +// different (osbolete) processing. TODO(sadrul) to figure out +// how this test should work that mimics production code a bit +// better. IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, - MAYBE_ContentWindowReparent) { + DISABLED_ContentWindowReparent) { ASSERT_NO_FATAL_FAILURE( StartTestWithPage("files/overscroll_navigation.html")); diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index 249f05e..d793ac3 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -79,8 +79,6 @@ 'env.cc', 'env.h', 'env_observer.h', - 'focus_manager.cc', - 'focus_manager.h', 'input_state_lookup.cc', 'input_state_lookup.h', 'input_state_lookup_win.cc', @@ -159,6 +157,8 @@ 'test/test_cursor_client.h', 'test/test_event_handler.cc', 'test/test_event_handler.h', + 'test/test_focus_client.cc', + 'test/test_focus_client.h', 'test/test_screen.cc', 'test/test_screen.h', 'test/test_stacking_client.cc', diff --git a/ui/aura/bench/bench_main.cc b/ui/aura/bench/bench_main.cc index a93bc1f..67ba3a6 100644 --- a/ui/aura/bench/bench_main.cc +++ b/ui/aura/bench/bench_main.cc @@ -15,8 +15,8 @@ #include "third_party/skia/include/core/SkXfermode.h" #include "ui/aura/client/default_capture_client.h" #include "ui/aura/env.h" -#include "ui/aura/focus_manager.h" #include "ui/aura/root_window.h" +#include "ui/aura/test/test_focus_client.h" #include "ui/aura/test/test_screen.h" #include "ui/aura/window.h" #include "ui/base/hit_test.h" @@ -318,7 +318,8 @@ int main(int argc, char** argv) { root_window.get(), new aura::client::DefaultCaptureClient(root_window.get())); - scoped_ptr<aura::client::FocusClient> focus_client(new aura::FocusManager); + scoped_ptr<aura::client::FocusClient> focus_client( + new aura::test::TestFocusClient); aura::client::SetFocusClient(root_window.get(), focus_client.get()); // add layers diff --git a/ui/aura/client/focus_client.h b/ui/aura/client/focus_client.h index ff5f7f6..ad55d5e 100644 --- a/ui/aura/client/focus_client.h +++ b/ui/aura/client/focus_client.h @@ -23,7 +23,6 @@ class AURA_EXPORT FocusClient { public: virtual ~FocusClient() {} - // TODO(beng): these methods will be OBSOLETE by FocusChangeEvent. virtual void AddObserver(FocusChangeObserver* observer) = 0; virtual void RemoveObserver(FocusChangeObserver* observer) = 0; @@ -36,14 +35,6 @@ class AURA_EXPORT FocusClient { // Retrieves the focused window, or NULL if there is none. virtual Window* GetFocusedWindow() = 0; - - // TODO(beng): temporary compat until FocusController is on. - // Called when |window|'s disposition in |root_window| changes such that - // focus must be shifted away from it. |destroyed| is true if the disposition - // change is that |window| is being destroyed. - virtual void OnWindowHiddenInRootWindow(aura::Window* window, - aura::RootWindow* root_window, - bool destroyed) = 0; }; // Sets/Gets the focus client on the RootWindow. diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc index e56ab71..abdd514 100644 --- a/ui/aura/demo/demo_main.cc +++ b/ui/aura/demo/demo_main.cc @@ -11,8 +11,8 @@ #include "ui/aura/client/default_capture_client.h" #include "ui/aura/client/stacking_client.h" #include "ui/aura/env.h" -#include "ui/aura/focus_manager.h" #include "ui/aura/root_window.h" +#include "ui/aura/test/test_focus_client.h" #include "ui/aura/test/test_screen.h" #include "ui/aura/window.h" #include "ui/aura/window_delegate.h" @@ -122,8 +122,8 @@ int DemoMain() { test_screen->CreateRootWindowForPrimaryDisplay()); scoped_ptr<DemoStackingClient> stacking_client(new DemoStackingClient( root_window.get())); - aura::FocusManager focus_manager; - aura::client::SetFocusClient(root_window.get(), &focus_manager); + aura::test::TestFocusClient focus_client; + aura::client::SetFocusClient(root_window.get(), &focus_client); // Create a hierarchy of test windows. DemoWindowDelegate window_delegate1(SK_ColorBLUE); diff --git a/ui/aura/focus_manager.cc b/ui/aura/focus_manager.cc deleted file mode 100644 index 921406b..0000000 --- a/ui/aura/focus_manager.cc +++ /dev/null @@ -1,105 +0,0 @@ -// 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/focus_manager.h" - -#include "ui/aura/client/activation_client.h" -#include "ui/aura/client/focus_change_observer.h" -#include "ui/aura/root_window.h" -#include "ui/aura/window_delegate.h" - -namespace aura { - -//////////////////////////////////////////////////////////////////////////////// -// FocusManager, public: - -FocusManager::FocusManager() : focused_window_(NULL) { -} - -FocusManager::~FocusManager() { -} - -//////////////////////////////////////////////////////////////////////////////// -// FocusManager, client::FocusClient implementation: - -void FocusManager::AddObserver(client::FocusChangeObserver* observer) { - observers_.AddObserver(observer); -} - -void FocusManager::RemoveObserver(client::FocusChangeObserver* observer) { - observers_.RemoveObserver(observer); -} - -void FocusManager::FocusWindow(Window* focused_window) { - if (focused_window == focused_window_) - return; - if (focused_window && !focused_window->CanFocus()) - return; - // 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) { - RootWindow* root = focused_window->GetRootWindow(); - DCHECK(root); - if (client::GetActivationClient(root) && - !client::GetActivationClient(root)->OnWillFocusWindow( - focused_window, NULL)) { - return; - } - } - - Window* old_focused_window = focused_window_; - focused_window_ = focused_window; - - FOR_EACH_OBSERVER(client::FocusChangeObserver, observers_, - OnWindowFocused(focused_window, old_focused_window)); - client::FocusChangeObserver* observer = - client::GetFocusChangeObserver(old_focused_window); - if (observer) - observer->OnWindowFocused(focused_window_, old_focused_window); - observer = client::GetFocusChangeObserver(focused_window_); - if (observer) - observer->OnWindowFocused(focused_window_, old_focused_window); -} - -void FocusManager::ResetFocusWithinActiveWindow(Window* window) { - FocusWindow(window); -} - -Window* FocusManager::GetFocusedWindow() { - return focused_window_; -} - -void FocusManager::OnWindowHiddenInRootWindow( - aura::Window* window, - aura::RootWindow* root_window, - bool destroyed) { - Window* focused_window = - client::GetFocusClient(root_window)->GetFocusedWindow(); - if (window->Contains(focused_window)) { - Window* focus_to = window->transient_parent(); - if (focus_to) { - // Has to be removed from the transient parent before focusing, - // otherwise |window| will be focused again. - if (destroyed) - focus_to->RemoveTransientChild(window); - } else { - // If the invisible view has no visible transient window, focus to the - // topmost visible parent window. - focus_to = window->parent(); - } - if (focus_to && - (!focus_to->IsVisible() || - !focus_to->CanFocus() || - (client::GetActivationClient(root_window) && - !client::GetActivationClient(root_window)->OnWillFocusWindow( - focus_to, NULL)))) { - focus_to = NULL; - } - client::GetFocusClient(root_window)->FocusWindow(focus_to); - } -} - -} // namespace aura diff --git a/ui/aura/focus_manager.h b/ui/aura/focus_manager.h deleted file mode 100644 index b3a1331..0000000 --- a/ui/aura/focus_manager.h +++ /dev/null @@ -1,49 +0,0 @@ -// 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. - -#ifndef UI_AURA_FOCUS_MANAGER_H_ -#define UI_AURA_FOCUS_MANAGER_H_ - -#include "base/basictypes.h" -#include "base/observer_list.h" -#include "ui/aura/aura_export.h" -#include "ui/aura/client/focus_client.h" - -namespace ui { -class Event; -} - -namespace aura { - -class Window; - -// An interface implemented by the Desktop to expose the focused window and -// allow for it to be changed. -class AURA_EXPORT FocusManager : public client::FocusClient { - public: - FocusManager(); - virtual ~FocusManager(); - - private: - // Overridden from client::FocusClient: - virtual void AddObserver(client::FocusChangeObserver* observer) OVERRIDE; - virtual void RemoveObserver(client::FocusChangeObserver* observer) OVERRIDE; - virtual void FocusWindow(Window* window) OVERRIDE; - virtual void ResetFocusWithinActiveWindow(Window* window) OVERRIDE; - virtual Window* GetFocusedWindow() OVERRIDE; - virtual void OnWindowHiddenInRootWindow(aura::Window* window, - aura::RootWindow* root_window, - bool destroyed) OVERRIDE; - - protected: - aura::Window* focused_window_; - - ObserverList<client::FocusChangeObserver> observers_; - - DISALLOW_COPY_AND_ASSIGN(FocusManager); -}; - -} // namespace aura - -#endif // UI_AURA_FOCUS_MANAGER_H_ diff --git a/ui/aura/remote_root_window_host_win.cc b/ui/aura/remote_root_window_host_win.cc index 8e54836..e3578c8 100644 --- a/ui/aura/remote_root_window_host_win.cc +++ b/ui/aura/remote_root_window_host_win.cc @@ -11,7 +11,6 @@ #include "base/message_loop/message_loop.h" #include "ipc/ipc_message.h" #include "ipc/ipc_sender.h" -#include "ui/aura/client/capture_client.h" #include "ui/aura/client/cursor_client.h" #include "ui/aura/root_window.h" #include "ui/base/cursor/cursor_loader_win.h" diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index 19c60bf..bfd6b35 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -11,7 +11,6 @@ #include "base/debug/trace_event.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" -#include "ui/aura/client/activation_client.h" #include "ui/aura/client/capture_client.h" #include "ui/aura/client/cursor_client.h" #include "ui/aura/client/event_client.h" @@ -706,12 +705,6 @@ void RootWindow::OnWindowRemovedFromRootWindow(Window* detached, } void RootWindow::OnWindowHidden(Window* invisible, WindowHiddenReason reason) { - // TODO(beng): This should be removed once FocusController is turned on. - if (client::GetFocusClient(this)) { - client::GetFocusClient(this)->OnWindowHiddenInRootWindow( - invisible, this, reason == WINDOW_DESTROYED); - } - // Do not clear the capture, and the |event_dispatch_target_| if the // window is moving across root windows, because the target itself // is actually still visible and clearing them stops further event diff --git a/ui/aura/root_window_host_win.cc b/ui/aura/root_window_host_win.cc index e5658f7..020a766 100644 --- a/ui/aura/root_window_host_win.cc +++ b/ui/aura/root_window_host_win.cc @@ -9,7 +9,6 @@ #include <algorithm> #include "base/message_loop/message_loop.h" -#include "ui/aura/client/capture_client.h" #include "ui/aura/client/cursor_client.h" #include "ui/aura/root_window.h" #include "ui/base/cursor/cursor_loader_win.h" diff --git a/ui/aura/root_window_host_x11.cc b/ui/aura/root_window_host_x11.cc index 112e23e..65dde3b 100644 --- a/ui/aura/root_window_host_x11.cc +++ b/ui/aura/root_window_host_x11.cc @@ -27,7 +27,6 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/sys_info.h" -#include "ui/aura/client/capture_client.h" #include "ui/aura/client/cursor_client.h" #include "ui/aura/client/screen_position_client.h" #include "ui/aura/client/user_action_client.h" diff --git a/ui/aura/root_window_unittest.cc b/ui/aura/root_window_unittest.cc index 2820515..8a4947f 100644 --- a/ui/aura/root_window_unittest.cc +++ b/ui/aura/root_window_unittest.cc @@ -8,8 +8,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/aura/client/event_client.h" +#include "ui/aura/client/focus_client.h" #include "ui/aura/env.h" -#include "ui/aura/focus_manager.h" #include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/event_generator.h" #include "ui/aura/test/test_cursor_client.h" diff --git a/ui/aura/test/aura_test_helper.cc b/ui/aura/test/aura_test_helper.cc index 1b6ec92..2e6e389 100644 --- a/ui/aura/test/aura_test_helper.cc +++ b/ui/aura/test/aura_test_helper.cc @@ -11,10 +11,10 @@ #include "ui/aura/client/default_capture_client.h" #include "ui/aura/client/focus_client.h" #include "ui/aura/env.h" -#include "ui/aura/focus_manager.h" #include "ui/aura/input_state_lookup.h" #include "ui/aura/root_window.h" #include "ui/aura/test/env_test_helper.h" +#include "ui/aura/test/test_focus_client.h" #include "ui/aura/test/test_screen.h" #include "ui/aura/test/test_stacking_client.h" #include "ui/base/ime/dummy_input_method.h" @@ -77,7 +77,7 @@ void AuraTestHelper::SetUp() { gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); root_window_.reset(test_screen_->CreateRootWindowForPrimaryDisplay()); - focus_client_.reset(new FocusManager); + focus_client_.reset(new TestFocusClient); client::SetFocusClient(root_window_.get(), focus_client_.get()); stacking_client_.reset(new TestStackingClient(root_window_.get())); activation_client_.reset( diff --git a/ui/aura/test/test_cursor_client.h b/ui/aura/test/test_cursor_client.h index c10552a..696f34d 100644 --- a/ui/aura/test/test_cursor_client.h +++ b/ui/aura/test/test_cursor_client.h @@ -5,6 +5,7 @@ #ifndef UI_AURA_TEST_TEST_CURSOR_CLIENT_H_ #define UI_AURA_TEST_TEST_CURSOR_CLIENT_H_ +#include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/observer_list.h" #include "ui/aura/client/cursor_client.h" diff --git a/ui/aura/test/test_focus_client.cc b/ui/aura/test/test_focus_client.cc new file mode 100644 index 0000000..c7f9f8c --- /dev/null +++ b/ui/aura/test/test_focus_client.cc @@ -0,0 +1,70 @@ +// Copyright 2013 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_focus_client.h" + +#include "ui/aura/client/focus_change_observer.h" +#include "ui/aura/window.h" + +namespace aura { +namespace test { + +//////////////////////////////////////////////////////////////////////////////// +// TestFocusClient, public: + +TestFocusClient::TestFocusClient() + : focused_window_(NULL), + observer_manager_(this) { +} + +TestFocusClient::~TestFocusClient() { +} + +//////////////////////////////////////////////////////////////////////////////// +// TestFocusClient, client::FocusClient implementation: + +void TestFocusClient::AddObserver(client::FocusChangeObserver* observer) { +} + +void TestFocusClient::RemoveObserver(client::FocusChangeObserver* observer) { +} + +void TestFocusClient::FocusWindow(Window* window) { + if (window && !window->CanFocus()) + return; + if (focused_window_) + observer_manager_.Remove(focused_window_); + aura::Window* old_focused_window = focused_window_; + focused_window_ = window; + if (focused_window_) + observer_manager_.Add(focused_window_); + + client::FocusChangeObserver* observer = + client::GetFocusChangeObserver(old_focused_window); + if (observer) + observer->OnWindowFocused(focused_window_, old_focused_window); + observer = client::GetFocusChangeObserver(focused_window_); + if (observer) + observer->OnWindowFocused(focused_window_, old_focused_window); +} + +void TestFocusClient::ResetFocusWithinActiveWindow(Window* window) { + if (!window->Contains(focused_window_)) + FocusWindow(window); +} + +Window* TestFocusClient::GetFocusedWindow() { + return focused_window_; +} + +//////////////////////////////////////////////////////////////////////////////// +// TestFocusClient, WindowObserver implementation: + +void TestFocusClient::OnWindowDestroying(Window* window) { + DCHECK_EQ(window, focused_window_); + FocusWindow(NULL); +} + +} // namespace test +} // namespace aura diff --git a/ui/aura/test/test_focus_client.h b/ui/aura/test/test_focus_client.h new file mode 100644 index 0000000..b58671f --- /dev/null +++ b/ui/aura/test/test_focus_client.h @@ -0,0 +1,43 @@ +// Copyright 2013 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. + +#ifndef UI_AURA_TEST_TEST_FOCUS_CLIENT_H_ +#define UI_AURA_TEST_TEST_FOCUS_CLIENT_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "base/scoped_observer.h" +#include "ui/aura/client/focus_client.h" +#include "ui/aura/window_observer.h" + +namespace aura { +namespace test { + +class TestFocusClient : public client::FocusClient, + public WindowObserver { + public: + TestFocusClient(); + virtual ~TestFocusClient(); + + private: + // Overridden from client::FocusClient: + virtual void AddObserver(client::FocusChangeObserver* observer) OVERRIDE; + virtual void RemoveObserver(client::FocusChangeObserver* observer) OVERRIDE; + virtual void FocusWindow(Window* window) OVERRIDE; + virtual void ResetFocusWithinActiveWindow(Window* window) OVERRIDE; + virtual Window* GetFocusedWindow() OVERRIDE; + + // Overridden from WindowObserver: + virtual void OnWindowDestroying(Window* window) OVERRIDE; + + Window* focused_window_; + ScopedObserver<Window, WindowObserver> observer_manager_; + + DISALLOW_COPY_AND_ASSIGN(TestFocusClient); +}; + +} // namespace test +} // namespace aura + +#endif // UI_AURA_TEST_TEST_FOCUS_CLIENT_H_
\ No newline at end of file diff --git a/ui/aura/window.cc b/ui/aura/window.cc index c0c5744..e7f0c2a 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -15,11 +15,11 @@ #include "base/strings/stringprintf.h" #include "ui/aura/client/capture_client.h" #include "ui/aura/client/event_client.h" +#include "ui/aura/client/focus_client.h" #include "ui/aura/client/screen_position_client.h" #include "ui/aura/client/stacking_client.h" #include "ui/aura/client/visibility_client.h" #include "ui/aura/env.h" -#include "ui/aura/focus_manager.h" #include "ui/aura/layout_manager.h" #include "ui/aura/root_window.h" #include "ui/aura/window_delegate.h" diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc index 2c44d3c..620130a 100644 --- a/ui/aura/window_unittest.cc +++ b/ui/aura/window_unittest.cc @@ -202,30 +202,6 @@ class CaptureWindowDelegateImpl : public TestWindowDelegate { DISALLOW_COPY_AND_ASSIGN(CaptureWindowDelegateImpl); }; -// aura::WindowDelegate that tracks the window that was reported as having the -// focus before us. -class FocusDelegate : public TestWindowDelegate, - public aura::client::FocusChangeObserver { - public: - FocusDelegate() : previous_focused_window_(NULL) { - } - - aura::Window* previous_focused_window() const { - return previous_focused_window_; - } - - // Overridden from client::FocusChangeObserver: - virtual void OnWindowFocused(Window* gained_focus, - Window* lost_focus) OVERRIDE { - previous_focused_window_ = lost_focus; - } - - private: - aura::Window* previous_focused_window_; - - DISALLOW_COPY_AND_ASSIGN(FocusDelegate); -}; - // Keeps track of the location of the gesture. class GestureTrackPositionDelegate : public TestWindowDelegate { public: @@ -1782,44 +1758,6 @@ TEST_F(WindowTest, TransientChildrenGroupBelow) { EXPECT_EQ("2 22 21 213 211 212 1 11", ChildWindowIDsAsString(parent.get())); } -// Tests that when a focused window is closed, its parent inherits the focus. -TEST_F(WindowTest, FocusedWindowTest) { - scoped_ptr<Window> parent(CreateTestWindowWithId(0, root_window())); - scoped_ptr<Window> child(CreateTestWindowWithId(1, parent.get())); - - parent->Show(); - - child->Focus(); - EXPECT_TRUE(child->HasFocus()); - EXPECT_FALSE(parent->HasFocus()); - - child.reset(); - EXPECT_TRUE(parent->HasFocus()); -} - -// Tests that the previously-focused window is passed to OnWindowFocused. -// TODO(beng): Remove once the FocusController lands. -TEST_F(WindowTest, OldFocusedWindowTest) { - const gfx::Rect kBounds(0, 0, 100, 100); - - FocusDelegate delegate1; - scoped_ptr<Window> window1( - CreateTestWindowWithDelegate(&delegate1, 0, kBounds, root_window())); - client::SetFocusChangeObserver(window1.get(), &delegate1); - window1->Focus(); - ASSERT_TRUE(window1->HasFocus()); - EXPECT_TRUE(delegate1.previous_focused_window() == NULL); - - FocusDelegate delegate2; - scoped_ptr<Window> window2( - CreateTestWindowWithDelegate(&delegate2, 1, kBounds, root_window())); - client::SetFocusChangeObserver(window2.get(), &delegate2); - window2->Focus(); - ASSERT_TRUE(window2->HasFocus()); - EXPECT_FALSE(window1->HasFocus()); - EXPECT_EQ(window1.get(), delegate2.previous_focused_window()); -} - namespace { DEFINE_WINDOW_PROPERTY_KEY(int, kIntKey, -2); DEFINE_WINDOW_PROPERTY_KEY(const char*, kStringKey, "squeamish"); diff --git a/ui/shell/minimal_shell.cc b/ui/shell/minimal_shell.cc index 9c3ca11..556c16e 100644 --- a/ui/shell/minimal_shell.cc +++ b/ui/shell/minimal_shell.cc @@ -7,8 +7,8 @@ #include "ui/aura/client/default_activation_client.h" #include "ui/aura/client/default_capture_client.h" #include "ui/aura/env.h" -#include "ui/aura/focus_manager.h" #include "ui/aura/root_window.h" +#include "ui/aura/test/test_focus_client.h" #include "ui/views/corewm/compound_event_filter.h" #include "ui/views/corewm/input_method_event_filter.h" @@ -22,7 +22,7 @@ MinimalShell::MinimalShell(const gfx::Size& default_window_size) { root_window_->Init(); aura::client::SetStackingClient(root_window_.get(), this); - focus_client_.reset(new aura::FocusManager); + focus_client_.reset(new aura::test::TestFocusClient); aura::client::SetFocusClient(root_window_.get(), focus_client_.get()); root_window_event_filter_ = new views::corewm::CompoundEventFilter; diff --git a/ui/views/controls/native/native_view_host_aura.cc b/ui/views/controls/native/native_view_host_aura.cc index 444f580..a71e230 100644 --- a/ui/views/controls/native/native_view_host_aura.cc +++ b/ui/views/controls/native/native_view_host_aura.cc @@ -5,7 +5,7 @@ #include "ui/views/controls/native/native_view_host_aura.h" #include "base/logging.h" -#include "ui/aura/focus_manager.h" +#include "ui/aura/client/focus_client.h" #include "ui/aura/window.h" #include "ui/views/controls/native/native_view_host.h" #include "ui/views/view_constants_aura.h" diff --git a/ui/views/corewm/compound_event_filter.cc b/ui/views/corewm/compound_event_filter.cc index 89fa198..0d021bd 100644 --- a/ui/views/corewm/compound_event_filter.cc +++ b/ui/views/corewm/compound_event_filter.cc @@ -10,7 +10,6 @@ #include "ui/aura/client/cursor_client.h" #include "ui/aura/client/drag_drop_client.h" #include "ui/aura/env.h" -#include "ui/aura/focus_manager.h" #include "ui/aura/root_window.h" #include "ui/aura/window_delegate.h" #include "ui/aura/window_tracker.h" diff --git a/ui/views/corewm/focus_controller.cc b/ui/views/corewm/focus_controller.cc index a5fe9c3..8c05ac2 100644 --- a/ui/views/corewm/focus_controller.cc +++ b/ui/views/corewm/focus_controller.cc @@ -179,15 +179,6 @@ aura::Window* FocusController::GetFocusedWindow() { return focused_window_; } -void FocusController::OnWindowHiddenInRootWindow( - aura::Window* window, - aura::RootWindow* root_window, - bool destroyed) { - //NOTREACHED(); - // This method is only for compat with aura::FocusManager. It should not be - // needed in the new FocusController. -} - //////////////////////////////////////////////////////////////////////////////// // FocusController, ui::EventHandler implementation: void FocusController::OnKeyEvent(ui::KeyEvent* event) { diff --git a/ui/views/corewm/focus_controller.h b/ui/views/corewm/focus_controller.h index 0026436..d3d34e6 100644 --- a/ui/views/corewm/focus_controller.h +++ b/ui/views/corewm/focus_controller.h @@ -64,9 +64,6 @@ class VIEWS_EXPORT FocusController : public aura::client::ActivationClient, virtual void FocusWindow(aura::Window* window) OVERRIDE; virtual void ResetFocusWithinActiveWindow(aura::Window* window) OVERRIDE; virtual aura::Window* GetFocusedWindow() OVERRIDE; - virtual void OnWindowHiddenInRootWindow(aura::Window* window, - aura::RootWindow* root_window, - bool destroyed) OVERRIDE; // Overridden from ui::EventHandler: virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc index 8cffb57..347cbb2 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc @@ -8,8 +8,8 @@ #include "ui/aura/client/activation_client.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/client/cursor_client.h" +#include "ui/aura/client/focus_client.h" #include "ui/aura/client/stacking_client.h" -#include "ui/aura/focus_manager.h" #include "ui/aura/root_window.h" #include "ui/aura/root_window_host.h" #include "ui/aura/window.h" diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc index 9d1a330..ea5c1ae 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc @@ -9,7 +9,7 @@ #include "third_party/skia/include/core/SkRegion.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/client/cursor_client.h" -#include "ui/aura/focus_manager.h" +#include "ui/aura/client/focus_client.h" #include "ui/aura/root_window.h" #include "ui/aura/window_property.h" #include "ui/base/cursor/cursor_loader_win.h" diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc index 9890b0a..391beb4 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc @@ -17,7 +17,6 @@ #include "third_party/skia/include/core/SkPath.h" #include "ui/aura/client/screen_position_client.h" #include "ui/aura/client/user_action_client.h" -#include "ui/aura/focus_manager.h" #include "ui/aura/root_window.h" #include "ui/aura/window_property.h" #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" diff --git a/ui/views/widget/desktop_aura/x11_desktop_handler.cc b/ui/views/widget/desktop_aura/x11_desktop_handler.cc index 0c96565..179bc75 100644 --- a/ui/views/widget/desktop_aura/x11_desktop_handler.cc +++ b/ui/views/widget/desktop_aura/x11_desktop_handler.cc @@ -6,7 +6,6 @@ #include "base/message_loop/message_loop.h" #include "ui/aura/env.h" -#include "ui/aura/focus_manager.h" #include "ui/aura/root_window.h" #include "ui/base/x/x11_util.h" diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index b3320d1..e0778c0 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -11,12 +11,12 @@ #include "ui/aura/client/aura_constants.h" #include "ui/aura/client/cursor_client.h" #include "ui/aura/client/drag_drop_client.h" +#include "ui/aura/client/focus_client.h" #include "ui/aura/client/screen_position_client.h" #include "ui/aura/client/stacking_client.h" #include "ui/aura/client/window_move_client.h" #include "ui/aura/client/window_types.h" #include "ui/aura/env.h" -#include "ui/aura/focus_manager.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" #include "ui/aura/window_observer.h" |