| 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.
|
|
|