| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_EVENTS_EVENT_SOURCE_H_ | 5 #ifndef UI_EVENTS_EVENT_SOURCE_H_ |
| 6 #define UI_EVENTS_EVENT_SOURCE_H_ | 6 #define UI_EVENTS_EVENT_SOURCE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "ui/events/event_dispatcher.h" | 11 #include "ui/events/event_dispatcher.h" |
| 12 #include "ui/events/events_export.h" | 12 #include "ui/events/events_export.h" |
| 13 | 13 |
| 14 namespace ui { | 14 namespace ui { |
| 15 | 15 |
| 16 class Event; | 16 class Event; |
| 17 class EventProcessor; | 17 class EventSink; |
| 18 class EventRewriter; | 18 class EventRewriter; |
| 19 | 19 |
| 20 // EventSource receives events from the native platform (e.g. X11, win32 etc.) | 20 // EventSource receives events from the native platform (e.g. X11, win32 etc.) |
| 21 // and sends the events to an EventProcessor. | 21 // and sends the events to an EventSink. |
| 22 class EVENTS_EXPORT EventSource { | 22 class EVENTS_EXPORT EventSource { |
| 23 public: | 23 public: |
| 24 EventSource(); | 24 EventSource(); |
| 25 virtual ~EventSource(); | 25 virtual ~EventSource(); |
| 26 | 26 |
| 27 virtual EventProcessor* GetEventProcessor() = 0; | 27 virtual EventSink* GetEventSink() = 0; |
| 28 | 28 |
| 29 // Adds a rewriter to modify events before they are sent to the | 29 // Adds a rewriter to modify events before they are sent to the |
| 30 // EventProcessor. The rewriter must be explicitly removed from the | 30 // EventSink. The rewriter must be explicitly removed from the |
| 31 // EventSource before the rewriter is destroyed. The EventSource | 31 // EventSource before the rewriter is destroyed. The EventSource |
| 32 // does not take ownership of the rewriter. | 32 // does not take ownership of the rewriter. |
| 33 void AddEventRewriter(EventRewriter* rewriter); | 33 void AddEventRewriter(EventRewriter* rewriter); |
| 34 void RemoveEventRewriter(EventRewriter* rewriter); | 34 void RemoveEventRewriter(EventRewriter* rewriter); |
| 35 | 35 |
| 36 protected: | 36 protected: |
| 37 EventDispatchDetails SendEventToProcessor(Event* event); | 37 EventDispatchDetails SendEventToSink(Event* event); |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 friend class EventSourceTestApi; | 40 friend class EventSourceTestApi; |
| 41 | 41 |
| 42 EventDispatchDetails DeliverEventToProcessor(Event* event); | 42 EventDispatchDetails DeliverEventToSink(Event* event); |
| 43 | 43 |
| 44 typedef std::vector<EventRewriter*> EventRewriterList; | 44 typedef std::vector<EventRewriter*> EventRewriterList; |
| 45 EventRewriterList rewriter_list_; | 45 EventRewriterList rewriter_list_; |
| 46 DISALLOW_COPY_AND_ASSIGN(EventSource); | 46 DISALLOW_COPY_AND_ASSIGN(EventSource); |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 } // namespace ui | 49 } // namespace ui |
| 50 | 50 |
| 51 #endif // UI_EVENTS_EVENT_SOURCE_H_ | 51 #endif // UI_EVENTS_EVENT_SOURCE_H_ |
| OLD | NEW |