diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-16 04:21:56 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-16 04:21:56 +0000 |
commit | 9d6182fbc636841f21e86a6479c7de9ecf310428 (patch) | |
tree | 6c762506b5d8830a4d868204cbd9bf9a5e81c710 /ash | |
parent | 4c090d2e47966acc72365fad22612f2235d89396 (diff) | |
download | chromium_src-9d6182fbc636841f21e86a6479c7de9ecf310428.zip chromium_src-9d6182fbc636841f21e86a6479c7de9ecf310428.tar.gz chromium_src-9d6182fbc636841f21e86a6479c7de9ecf310428.tar.bz2 |
event-rewrite: Clean up how events are rewritten.
Notable changes:
* Make the EventRewriter a MessagePumpObserver. This is necessary to make sure
that the event-rewrite happens before the event is dispatched.
* Move the EventRewriter in chrome/browser/chromeos (and in chromeos namespace),
since it does nothing on other platforms.
* Get rid of the event-rewrite code from ash, since it just adds an extra layer
of abstraction for no added value.
BUG=343639
R=derat@chromium.org, sky@chromium.org, stevenjb@chromium.org
Previously landed in r251382, but reverted in r251433 because it broke debug builds.
Review URL: https://codereview.chromium.org/165463002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251607 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/accelerators/accelerator_dispatcher.cc | 10 | ||||
-rw-r--r-- | ash/ash.gyp | 3 | ||||
-rw-r--r-- | ash/event_rewriter_delegate.h | 34 | ||||
-rw-r--r-- | ash/shell.cc | 4 | ||||
-rw-r--r-- | ash/shell.h | 6 | ||||
-rw-r--r-- | ash/wm/event_rewriter_event_filter.cc | 56 | ||||
-rw-r--r-- | ash/wm/event_rewriter_event_filter.h | 41 |
7 files changed, 0 insertions, 154 deletions
diff --git a/ash/accelerators/accelerator_dispatcher.cc b/ash/accelerators/accelerator_dispatcher.cc index c4c4f33..6088dfe 100644 --- a/ash/accelerators/accelerator_dispatcher.cc +++ b/ash/accelerators/accelerator_dispatcher.cc @@ -15,7 +15,6 @@ #include "ash/accelerators/accelerator_controller.h" #include "ash/shell.h" -#include "ash/wm/event_rewriter_event_filter.h" #include "ui/aura/env.h" #include "ui/aura/root_window.h" #include "ui/base/accelerators/accelerator.h" @@ -93,16 +92,7 @@ uint32_t AcceleratorDispatcher::Dispatch(const base::NativeEvent& event) { return POST_DISPATCH_PERFORM_DEFAULT; if (IsKeyEvent(event)) { - // Modifiers can be changed by the user preference, so we need to rewrite - // the event explicitly. ui::KeyEvent key_event(event, false); - ui::EventHandler* event_rewriter = - ash::Shell::GetInstance()->event_rewriter_filter(); - DCHECK(event_rewriter); - event_rewriter->OnKeyEvent(&key_event); - if (key_event.stopped_propagation()) - return POST_DISPATCH_NONE; - if (IsPossibleAcceleratorNotForMenu(key_event)) { if (views::MenuController* menu_controller = views::MenuController::GetActiveInstance()) { diff --git a/ash/ash.gyp b/ash/ash.gyp index 1dbf6bc..e37d958 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -150,7 +150,6 @@ 'drag_drop/drag_drop_tracker.h', 'drag_drop/drag_image_view.cc', 'drag_drop/drag_image_view.h', - 'event_rewriter_delegate.h', 'first_run/desktop_cleaner.cc', 'first_run/desktop_cleaner.h', 'first_run/first_run_helper.cc', @@ -496,8 +495,6 @@ 'wm/drag_window_resizer.h', 'wm/event_client_impl.cc', 'wm/event_client_impl.h', - 'wm/event_rewriter_event_filter.cc', - 'wm/event_rewriter_event_filter.h', 'wm/frame_border_hit_test_controller.cc', 'wm/frame_border_hit_test_controller.h', 'wm/header_painter.cc', diff --git a/ash/event_rewriter_delegate.h b/ash/event_rewriter_delegate.h deleted file mode 100644 index c54c9a3..0000000 --- a/ash/event_rewriter_delegate.h +++ /dev/null @@ -1,34 +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 ASH_EVENT_REWRITER_DELEGATE_H_ -#define ASH_EVENT_REWRITER_DELEGATE_H_ - -namespace ui { -class KeyEvent; -class LocatedEvent; -} // namespace aura - -namespace ash { - -// Delegate for rewriting or filtering an event. -class EventRewriterDelegate { - public: - enum Action { - ACTION_REWRITE_EVENT, - ACTION_DROP_EVENT, - }; - - virtual ~EventRewriterDelegate() {} - - // A derived class can do either of the following: - // 1) Just return ACTION_DROP_EVENT to drop the |event|. - // 2) Rewrite the |event| and return ACTION_REWRITE_EVENT. - virtual Action RewriteOrFilterKeyEvent(ui::KeyEvent* event) = 0; - virtual Action RewriteOrFilterLocatedEvent(ui::LocatedEvent* event) = 0; -}; - -} // namespace ash - -#endif // ASH_EVENT_REWRITER_DELEGATE_H_ diff --git a/ash/shell.cc b/ash/shell.cc index dfdb7b6..4789a88 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -58,7 +58,6 @@ #include "ash/wm/coordinate_conversion.h" #include "ash/wm/custom_frame_view_ash.h" #include "ash/wm/event_client_impl.h" -#include "ash/wm/event_rewriter_event_filter.h" #include "ash/wm/lock_state_controller.h" #include "ash/wm/mru_window_tracker.h" #include "ash/wm/overlay_event_filter.h" @@ -627,7 +626,6 @@ Shell::~Shell() { RemovePreTargetHandler(speech_feedback_handler_.get()); speech_feedback_handler_.reset(); #endif - RemovePreTargetHandler(event_rewriter_filter_.get()); RemovePreTargetHandler(user_activity_detector_.get()); RemovePreTargetHandler(overlay_filter_.get()); RemovePreTargetHandler(input_method_filter_.get()); @@ -840,8 +838,6 @@ void Shell::Init() { #endif // The order in which event filters are added is significant. - event_rewriter_filter_.reset(new internal::EventRewriterEventFilter); - AddPreTargetHandler(event_rewriter_filter_.get()); #if defined(OS_CHROMEOS) // The StickyKeysController also rewrites events and must be added diff --git a/ash/shell.h b/ash/shell.h index 53a4aed..b9222a6 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -327,9 +327,6 @@ class ASH_EXPORT Shell views::corewm::TooltipController* tooltip_controller() { return tooltip_controller_.get(); } - internal::EventRewriterEventFilter* event_rewriter_filter() { - return event_rewriter_filter_.get(); - } internal::OverlayEventFilter* overlay_filter() { return overlay_filter_.get(); } @@ -658,9 +655,6 @@ class ASH_EXPORT Shell event_transformation_handler_; scoped_ptr<WindowTreeHostFactory> window_tree_host_factory_; - // An event filter that rewrites or drops an event. - scoped_ptr<internal::EventRewriterEventFilter> event_rewriter_filter_; - // An event filter that pre-handles key events while the partial // screenshot UI or the keyboard overlay is active. scoped_ptr<internal::OverlayEventFilter> overlay_filter_; diff --git a/ash/wm/event_rewriter_event_filter.cc b/ash/wm/event_rewriter_event_filter.cc deleted file mode 100644 index dd87e2a..0000000 --- a/ash/wm/event_rewriter_event_filter.cc +++ /dev/null @@ -1,56 +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 "ash/wm/event_rewriter_event_filter.h" - -#include "ash/event_rewriter_delegate.h" -#include "base/logging.h" -#include "ui/events/event.h" - -namespace ash { -namespace internal { - -EventRewriterEventFilter::EventRewriterEventFilter() {} - -EventRewriterEventFilter::~EventRewriterEventFilter() {} - -void EventRewriterEventFilter::SetEventRewriterDelegate( - scoped_ptr<EventRewriterDelegate> delegate) { - delegate_ = delegate.Pass(); -} - -void EventRewriterEventFilter::OnKeyEvent(ui::KeyEvent* event) { - if (!delegate_) - return; - - // Do not consume a translated key event which is generated by an IME. - if (event->type() == ui::ET_TRANSLATED_KEY_PRESS || - event->type() == ui::ET_TRANSLATED_KEY_RELEASE) { - return; - } - - switch (delegate_->RewriteOrFilterKeyEvent(event)) { - case EventRewriterDelegate::ACTION_REWRITE_EVENT: - break; - case EventRewriterDelegate::ACTION_DROP_EVENT: - event->StopPropagation(); - break; - } -} - -void EventRewriterEventFilter::OnMouseEvent(ui::MouseEvent* event) { - if (!delegate_) - return; - - switch (delegate_->RewriteOrFilterLocatedEvent(event)) { - case EventRewriterDelegate::ACTION_REWRITE_EVENT: - break; - case EventRewriterDelegate::ACTION_DROP_EVENT: - event->StopPropagation(); - break; - } -} - -} // namespace internal -} // namespace ash diff --git a/ash/wm/event_rewriter_event_filter.h b/ash/wm/event_rewriter_event_filter.h deleted file mode 100644 index 86f7f53..0000000 --- a/ash/wm/event_rewriter_event_filter.h +++ /dev/null @@ -1,41 +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 ASH_WM_EVENT_REWRITER_EVENT_FILTER_ -#define ASH_WM_EVENT_REWRITER_EVENT_FILTER_ - -#include "ash/ash_export.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/memory/scoped_ptr.h" -#include "ui/events/event_handler.h" - -namespace ash { - -class EventRewriterDelegate; - -namespace internal { - -// An event filter that rewrites or drops an event. -class ASH_EXPORT EventRewriterEventFilter : public ui::EventHandler { - public: - EventRewriterEventFilter(); - virtual ~EventRewriterEventFilter(); - - void SetEventRewriterDelegate(scoped_ptr<EventRewriterDelegate> delegate); - - private: - // Overridden from ui::EventHandler: - virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; - virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; - - scoped_ptr<EventRewriterDelegate> delegate_; - - DISALLOW_COPY_AND_ASSIGN(EventRewriterEventFilter); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_WM_EVENT_REWRITER_EVENT_FILTER_ |