Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Unified Diff: ui/events/platform/platform_event_source.cc

Issue 313913004: Block internal PlatformEvents before they are dispatched in touchview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove obsolete comment and unnecessary includes. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/events/platform/platform_event_source.cc
diff --git a/ui/events/platform/platform_event_source.cc b/ui/events/platform/platform_event_source.cc
index 9607ab78232e971d8b4b099829f5395b47722694..2f3efb981203b5f0e8c2b55e9eefd4cd3aebd0c6 100644
--- a/ui/events/platform/platform_event_source.cc
+++ b/ui/events/platform/platform_event_source.cc
@@ -8,6 +8,7 @@
#include "base/message_loop/message_loop.h"
#include "ui/events/platform/platform_event_dispatcher.h"
+#include "ui/events/platform/platform_event_filter.h"
#include "ui/events/platform/platform_event_observer.h"
#include "ui/events/platform/scoped_event_dispatcher.h"
@@ -62,9 +63,30 @@ void PlatformEventSource::RemovePlatformEventObserver(
observers_.RemoveObserver(observer);
}
+void PlatformEventSource::AddPlatformEventFilter(PlatformEventFilter* filter) {
+ CHECK(filter);
+ filters_.AddObserver(filter);
+}
+
+void PlatformEventSource::RemovePlatformEventFilter(
+ PlatformEventFilter* filter) {
+ filters_.RemoveObserver(filter);
+}
+
uint32_t PlatformEventSource::DispatchEvent(PlatformEvent platform_event) {
uint32_t action = POST_DISPATCH_PERFORM_DEFAULT;
+ // Always deliver all events to all PlatformEventFilters, if any of them
+ // specify that the event should not be dispatched, return immediately to
+ // stop propagation.
+ ObserverList<PlatformEventFilter>::Iterator iter(filters_);
+ while (PlatformEventFilter* filter = iter.GetNext()) {
+ if (!filter->ShouldDispatchEvent(platform_event))
+ action = POST_DISPATCH_STOP_PROPAGATION;
+ }
+ if (action == POST_DISPATCH_STOP_PROPAGATION)
+ return action;
+
FOR_EACH_OBSERVER(PlatformEventObserver, observers_,
WillProcessEvent(platform_event));
// Give the overridden dispatcher a chance to dispatch the event first.

Powered by Google App Engine
This is Rietveld 408576698