1effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// Copyright 2014 The Chromium Authors. All rights reserved.
2effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// Use of this source code is governed by a BSD-style license that can be
3effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// found in the LICENSE file.
4effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
5effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#ifndef UI_EVENTS_PLATFORM_PLATFORM_EVENT_DISPATCHER_H_
6effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#define UI_EVENTS_PLATFORM_PLATFORM_EVENT_DISPATCHER_H_
7effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
8effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "base/basictypes.h"
9effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "ui/events/events_export.h"
10effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "ui/events/platform/platform_event_types.h"
11effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
12effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochnamespace ui {
13effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
14effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// See documentation for |PlatformEventDispatcher::DispatchEvent()| for
15effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// explanation of the meaning of the flags.
16effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochenum PostDispatchAction {
17effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  POST_DISPATCH_NONE = 0x0,
18cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  POST_DISPATCH_PERFORM_DEFAULT = 0x1,
19cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  POST_DISPATCH_STOP_PROPAGATION = 0x2,
20effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch};
21effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
22effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// PlatformEventDispatcher receives events from a PlatformEventSource and
23effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// dispatches them.
24effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochclass EVENTS_EXPORT PlatformEventDispatcher {
25effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch public:
26effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  // Returns whether this dispatcher wants to dispatch |event|.
27effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  virtual bool CanDispatchEvent(const PlatformEvent& event) = 0;
28effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
29effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  // Dispatches |event|. If this is not the default dispatcher, then the
30effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  // dispatcher can request that the default dispatcher gets a chance to
31effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  // dispatch the event by setting POST_DISPATCH_PERFORM_DEFAULT to the return
32cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // value. If the dispatcher has processed the event, and no other dispatcher
33cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // should be allowed to dispatch the event, then the dispatcher should set
34cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // POST_DISPATCH_STOP_PROPAGATION flag on the return value.
35effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  virtual uint32_t DispatchEvent(const PlatformEvent& event) = 0;
36effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
37effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch protected:
38effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  virtual ~PlatformEventDispatcher() {}
39effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch};
40effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
41effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch}  // namespace ui
42effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
43effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#endif  // UI_EVENTS_PLATFORM_PLATFORM_EVENT_DISPATCHER_H_
44