diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-15 05:37:08 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-15 05:37:08 +0000 |
commit | dfd34848757ec4200740257704b650cb4f0fd417 (patch) | |
tree | c4bc133792aea617c949fbae88429c246bdcc377 | |
parent | 9fc4b43a90d4726e9e67b87b6812782cd9226b06 (diff) | |
download | chromium_src-dfd34848757ec4200740257704b650cb4f0fd417.zip chromium_src-dfd34848757ec4200740257704b650cb4f0fd417.tar.gz chromium_src-dfd34848757ec4200740257704b650cb4f0fd417.tar.bz2 |
ash: Remove the associated-window from AcceleratorDispatcher.
The associated-window parameter was added to fix event-dispatch if the
lock screen came up from a nested message-loop created by the menu
(crbug.com/113247). This is not possible anymore, and so remove this code.
BUG=none
R=oshima@chromium.org, sky@chromium.org
Review URL: https://codereview.chromium.org/198703003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257299 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/accelerators/accelerator_dispatcher.cc | 25 | ||||
-rw-r--r-- | ash/accelerators/accelerator_dispatcher.h | 16 | ||||
-rw-r--r-- | ash/accelerators/nested_dispatcher_controller.cc | 5 | ||||
-rw-r--r-- | ash/accelerators/nested_dispatcher_controller.h | 5 | ||||
-rw-r--r-- | ash/accelerators/nested_dispatcher_controller_unittest.cc | 21 | ||||
-rw-r--r-- | ash/wm/lock_state_controller.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/views/first_run_dialog.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/views/simple_message_box_views.cc | 3 | ||||
-rw-r--r-- | ui/aura/client/dispatcher_client.cc | 1 | ||||
-rw-r--r-- | ui/aura/client/dispatcher_client.h | 4 | ||||
-rw-r--r-- | ui/views/controls/menu/menu_controller.cc | 1 | ||||
-rw-r--r-- | ui/views/controls/menu/menu_controller_aura.cc | 3 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_dispatcher_client.cc | 3 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_dispatcher_client.h | 4 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc | 2 |
15 files changed, 25 insertions, 73 deletions
diff --git a/ash/accelerators/accelerator_dispatcher.cc b/ash/accelerators/accelerator_dispatcher.cc index 91ea13b..8b5db50 100644 --- a/ash/accelerators/accelerator_dispatcher.cc +++ b/ash/accelerators/accelerator_dispatcher.cc @@ -6,11 +6,6 @@ #if defined(USE_X11) #include <X11/Xlib.h> - -// Xlib defines RootWindow -#ifdef RootWindow -#undef RootWindow -#endif #endif // defined(USE_X11) #include "ash/accelerators/accelerator_controller.h" @@ -66,30 +61,14 @@ bool IsPossibleAcceleratorNotForMenu(const ui::KeyEvent& key_event) { } // namespace AcceleratorDispatcher::AcceleratorDispatcher( - base::MessagePumpDispatcher* nested_dispatcher, - aura::Window* associated_window) - : nested_dispatcher_(nested_dispatcher), - associated_window_(associated_window) { - associated_window_->AddObserver(this); + base::MessagePumpDispatcher* nested_dispatcher) + : nested_dispatcher_(nested_dispatcher) { } AcceleratorDispatcher::~AcceleratorDispatcher() { - if (associated_window_) - associated_window_->RemoveObserver(this); -} - -void AcceleratorDispatcher::OnWindowDestroying(aura::Window* window) { - if (associated_window_ == window) - associated_window_ = NULL; } uint32_t AcceleratorDispatcher::Dispatch(const base::NativeEvent& event) { - if (!associated_window_) - return POST_DISPATCH_QUIT_LOOP; - - if (!associated_window_->CanReceiveEvents()) - return POST_DISPATCH_PERFORM_DEFAULT; - if (IsKeyEvent(event)) { ui::KeyEvent key_event(event, false); if (IsPossibleAcceleratorNotForMenu(key_event)) { diff --git a/ash/accelerators/accelerator_dispatcher.h b/ash/accelerators/accelerator_dispatcher.h index a46368c..081b56b 100644 --- a/ash/accelerators/accelerator_dispatcher.h +++ b/ash/accelerators/accelerator_dispatcher.h @@ -6,9 +6,8 @@ #define ASH_ACCELERATORS_ACCELERATOR_DISPATCHER_H_ #include "ash/ash_export.h" +#include "base/macros.h" #include "base/message_loop/message_pump_dispatcher.h" -#include "ui/aura/window.h" -#include "ui/aura/window_observer.h" namespace ash { @@ -19,26 +18,17 @@ namespace ash { // passed back to the default dispatcher. // TODO(pkotwicz): Add support for a |nested_dispatcher| which sends // events to a system IME. -class ASH_EXPORT AcceleratorDispatcher : public base::MessagePumpDispatcher, - public aura::WindowObserver { +class ASH_EXPORT AcceleratorDispatcher : public base::MessagePumpDispatcher { public: - AcceleratorDispatcher(base::MessagePumpDispatcher* nested_dispatcher, - aura::Window* associated_window); + explicit AcceleratorDispatcher(base::MessagePumpDispatcher* dispatcher); virtual ~AcceleratorDispatcher(); // MessagePumpDispatcher overrides: virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE; - // aura::WindowObserver overrides: - virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; - private: base::MessagePumpDispatcher* nested_dispatcher_; - // Window associated with |nested_dispatcher_| which is used to determine - // whether the |nested_dispatcher_| is allowed to receive events. - aura::Window* associated_window_; - DISALLOW_COPY_AND_ASSIGN(AcceleratorDispatcher); }; diff --git a/ash/accelerators/nested_dispatcher_controller.cc b/ash/accelerators/nested_dispatcher_controller.cc index 6977f07..c4b36f9 100644 --- a/ash/accelerators/nested_dispatcher_controller.cc +++ b/ash/accelerators/nested_dispatcher_controller.cc @@ -18,12 +18,11 @@ NestedDispatcherController::~NestedDispatcherController() { } void NestedDispatcherController::RunWithDispatcher( - base::MessagePumpDispatcher* nested_dispatcher, - aura::Window* associated_window) { + base::MessagePumpDispatcher* nested_dispatcher) { base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); - AcceleratorDispatcher dispatcher(nested_dispatcher, associated_window); + AcceleratorDispatcher dispatcher(nested_dispatcher); // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them // use run_loop.QuitClosure(). diff --git a/ash/accelerators/nested_dispatcher_controller.h b/ash/accelerators/nested_dispatcher_controller.h index 1f8b52e..74dcd902 100644 --- a/ash/accelerators/nested_dispatcher_controller.h +++ b/ash/accelerators/nested_dispatcher_controller.h @@ -9,7 +9,6 @@ #include "base/callback.h" #include "base/message_loop/message_loop.h" #include "ui/aura/client/dispatcher_client.h" -#include "ui/aura/window.h" namespace ash { @@ -24,8 +23,8 @@ class ASH_EXPORT NestedDispatcherController virtual ~NestedDispatcherController(); // aura::client::DispatcherClient: - virtual void RunWithDispatcher(base::MessagePumpDispatcher* dispatcher, - aura::Window* associated_window) OVERRIDE; + virtual void RunWithDispatcher( + base::MessagePumpDispatcher* dispatcher) OVERRIDE; virtual void QuitNestedMessageLoop() OVERRIDE; private: diff --git a/ash/accelerators/nested_dispatcher_controller_unittest.cc b/ash/accelerators/nested_dispatcher_controller_unittest.cc index 47dcce6b..b40903e 100644 --- a/ash/accelerators/nested_dispatcher_controller_unittest.cc +++ b/ash/accelerators/nested_dispatcher_controller_unittest.cc @@ -98,21 +98,6 @@ void DispatchKeyReleaseA() { typedef AshTestBase NestedDispatcherTest; -// Aura window below lock screen in z order. -TEST_F(NestedDispatcherTest, AssociatedWindowBelowLockScreen) { - MockDispatcher inner_dispatcher; - scoped_ptr<aura::Window> associated_window(CreateTestWindowInShellWithId(0)); - - Shell::GetInstance()->session_state_delegate()->LockScreen(); - DispatchKeyReleaseA(); - aura::Window* root_window = ash::Shell::GetPrimaryRootWindow(); - aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( - &inner_dispatcher, - associated_window.get()); - EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); - Shell::GetInstance()->session_state_delegate()->UnlockScreen(); -} - // Aura window above lock screen in z order. TEST_F(NestedDispatcherTest, AssociatedWindowAboveLockScreen) { MockDispatcher inner_dispatcher; @@ -127,8 +112,7 @@ TEST_F(NestedDispatcherTest, AssociatedWindowAboveLockScreen) { DispatchKeyReleaseA(); aura::Window* root_window = ash::Shell::GetPrimaryRootWindow(); aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( - &inner_dispatcher, - associated_window.get()); + &inner_dispatcher); EXPECT_EQ(1, inner_dispatcher.num_key_events_dispatched()); } @@ -145,8 +129,7 @@ TEST_F(NestedDispatcherTest, AcceleratorsHandled) { DispatchKeyReleaseA(); aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( - &inner_dispatcher, - root_window); + &inner_dispatcher); EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); EXPECT_EQ(1, target.accelerator_pressed_count()); } diff --git a/ash/wm/lock_state_controller.cc b/ash/wm/lock_state_controller.cc index 304a444..1bb6cd9 100644 --- a/ash/wm/lock_state_controller.cc +++ b/ash/wm/lock_state_controller.cc @@ -20,6 +20,7 @@ #include "ui/aura/window_event_dispatcher.h" #include "ui/compositor/layer_animation_sequence.h" #include "ui/compositor/scoped_layer_animation_settings.h" +#include "ui/views/controls/menu/menu_controller.h" #include "ui/wm/core/compound_event_filter.h" #if defined(OS_CHROMEOS) @@ -615,6 +616,7 @@ void LockStateController::PostLockAnimationFinished() { lock_screen_displayed_callback_.Run(); lock_screen_displayed_callback_.Reset(); } + CHECK(!views::MenuController::GetActiveInstance()); if (shutdown_after_lock_) { shutdown_after_lock_ = false; StartLockToShutdownTimer(); diff --git a/chrome/browser/ui/views/first_run_dialog.cc b/chrome/browser/ui/views/first_run_dialog.cc index dc84312..4825735 100644 --- a/chrome/browser/ui/views/first_run_dialog.cc +++ b/chrome/browser/ui/views/first_run_dialog.cc @@ -17,6 +17,7 @@ #include "grit/theme_resources.h" #include "ui/aura/client/dispatcher_client.h" #include "ui/aura/env.h" +#include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/base/l10n/l10n_util.h" #include "ui/views/controls/button/checkbox.h" @@ -65,7 +66,7 @@ bool FirstRunDialog::Show(Profile* profile) { aura::Window* anchor = dialog->GetWidget()->GetNativeWindow(); aura::client::DispatcherClient* client = aura::client::GetDispatcherClient(anchor->GetRootWindow()); - client->RunWithDispatcher(NULL, anchor); + client->RunWithDispatcher(NULL); dialog_shown = true; } #endif // defined(GOOGLE_CHROME_BUILD) diff --git a/chrome/browser/ui/views/simple_message_box_views.cc b/chrome/browser/ui/views/simple_message_box_views.cc index 59a412c..c5f1a93 100644 --- a/chrome/browser/ui/views/simple_message_box_views.cc +++ b/chrome/browser/ui/views/simple_message_box_views.cc @@ -15,6 +15,7 @@ #include "grit/generated_resources.h" #include "ui/aura/client/dispatcher_client.h" #include "ui/aura/env.h" +#include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/native_widget_types.h" @@ -224,7 +225,7 @@ MessageBoxResult ShowMessageBoxImpl(gfx::NativeWindow parent, aura::Window* anchor = dialog->GetWidget()->GetNativeWindow(); aura::client::DispatcherClient* client = aura::client::GetDispatcherClient(anchor->GetRootWindow()); - client->RunWithDispatcher(NULL, anchor); + client->RunWithDispatcher(NULL); return dialog->result(); } diff --git a/ui/aura/client/dispatcher_client.cc b/ui/aura/client/dispatcher_client.cc index a220221..55eda0e 100644 --- a/ui/aura/client/dispatcher_client.cc +++ b/ui/aura/client/dispatcher_client.cc @@ -4,6 +4,7 @@ #include "ui/aura/client/dispatcher_client.h" +#include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_property.h" diff --git a/ui/aura/client/dispatcher_client.h b/ui/aura/client/dispatcher_client.h index 769c266..42cb25e 100644 --- a/ui/aura/client/dispatcher_client.h +++ b/ui/aura/client/dispatcher_client.h @@ -7,7 +7,6 @@ #include "base/message_loop/message_pump_dispatcher.h" #include "ui/aura/aura_export.h" -#include "ui/aura/window.h" namespace aura { class Window; @@ -16,8 +15,7 @@ namespace client { // An interface implemented by an object which handles nested dispatchers. class AURA_EXPORT DispatcherClient { public: - virtual void RunWithDispatcher(base::MessagePumpDispatcher* dispatcher, - aura::Window* associated_window) = 0; + virtual void RunWithDispatcher(base::MessagePumpDispatcher* dispatcher) = 0; virtual void QuitNestedMessageLoop() = 0; }; diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc index 0cd2c72..6a52292 100644 --- a/ui/views/controls/menu/menu_controller.cc +++ b/ui/views/controls/menu/menu_controller.cc @@ -15,6 +15,7 @@ #include "base/time/time.h" #include "ui/aura/client/dispatcher_client.h" #include "ui/aura/env.h" +#include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/base/dragdrop/drag_utils.h" #include "ui/base/dragdrop/os_exchange_data.h" diff --git a/ui/views/controls/menu/menu_controller_aura.cc b/ui/views/controls/menu/menu_controller_aura.cc index 7045651..726b8c4 100644 --- a/ui/views/controls/menu/menu_controller_aura.cc +++ b/ui/views/controls/menu/menu_controller_aura.cc @@ -89,8 +89,7 @@ void MenuController::RunMessageLoop(bool nested_menu) { scoped_ptr<ActivationChangeObserverImpl> observer; if (!nested_menu) observer.reset(new ActivationChangeObserverImpl(this, root)); - aura::client::GetDispatcherClient(root)-> - RunWithDispatcher(this, owner_->GetNativeWindow()); + aura::client::GetDispatcherClient(root)->RunWithDispatcher(this); } else { base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); base::MessageLoop::ScopedNestableTaskAllower allow(loop); diff --git a/ui/views/widget/desktop_aura/desktop_dispatcher_client.cc b/ui/views/widget/desktop_aura/desktop_dispatcher_client.cc index 33bb96a..6c01751 100644 --- a/ui/views/widget/desktop_aura/desktop_dispatcher_client.cc +++ b/ui/views/widget/desktop_aura/desktop_dispatcher_client.cc @@ -16,8 +16,7 @@ DesktopDispatcherClient::~DesktopDispatcherClient() { } void DesktopDispatcherClient::RunWithDispatcher( - base::MessagePumpDispatcher* nested_dispatcher, - aura::Window* associated_window) { + base::MessagePumpDispatcher* nested_dispatcher) { // TODO(erg): This class has been copypastad from // ash/accelerators/nested_dispatcher_controller.cc. I have left my changes // commented out because I don't entirely understand the implications of the diff --git a/ui/views/widget/desktop_aura/desktop_dispatcher_client.h b/ui/views/widget/desktop_aura/desktop_dispatcher_client.h index e9493bb..0d01df2 100644 --- a/ui/views/widget/desktop_aura/desktop_dispatcher_client.h +++ b/ui/views/widget/desktop_aura/desktop_dispatcher_client.h @@ -20,8 +20,8 @@ class VIEWS_EXPORT DesktopDispatcherClient DesktopDispatcherClient(); virtual ~DesktopDispatcherClient(); - virtual void RunWithDispatcher(base::MessagePumpDispatcher* dispatcher, - aura::Window* associated_window) OVERRIDE; + virtual void RunWithDispatcher( + base::MessagePumpDispatcher* dispatcher) OVERRIDE; virtual void QuitNestedMessageLoop() OVERRIDE; private: diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc index 7683230..9b4a157 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc @@ -213,7 +213,7 @@ TEST_F(DesktopNativeWidgetAuraTest, WidgetCanBeDestroyedFromNestedLoop) { // |RunWithDispatcher()| below. message_loop()->PostTask(FROM_HERE, base::Bind(&QuitNestedLoopAndCloseWidget, base::Passed(&widget), client)); - client->RunWithDispatcher(NULL, NULL); + client->RunWithDispatcher(NULL); } } // namespace views |