| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PLATFORM_PLATFORM_EVENT_SOURCE_H_ | 5 #ifndef UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ |
| 6 #define UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ | 6 #define UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/auto_reset.h" | 14 #include "base/auto_reset.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "ui/events/events_export.h" | 17 #include "ui/events/events_export.h" |
| 18 #include "ui/events/platform/platform_event_types.h" | 18 #include "ui/events/platform/platform_event_types.h" |
| 19 | 19 |
| 20 namespace ui { | 20 namespace ui { |
| 21 | 21 |
| 22 class Event; | 22 class Event; |
| 23 class PlatformEventDispatcher; | 23 class PlatformEventDispatcher; |
| 24 class PlatformEventObserver; | 24 class PlatformEventObserver; |
| 25 class ScopedEventDispatcher; | 25 class ScopedEventDispatcher; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 47 void RemovePlatformEventDispatcher(PlatformEventDispatcher* dispatcher); | 47 void RemovePlatformEventDispatcher(PlatformEventDispatcher* dispatcher); |
| 48 | 48 |
| 49 // Installs a PlatformEventDispatcher that receives all the events. The | 49 // Installs a PlatformEventDispatcher that receives all the events. The |
| 50 // dispatcher can process the event, or request that the default dispatchers | 50 // dispatcher can process the event, or request that the default dispatchers |
| 51 // be invoked by setting |POST_DISPATCH_PERFORM_DEFAULT| flag from the | 51 // be invoked by setting |POST_DISPATCH_PERFORM_DEFAULT| flag from the |
| 52 // |DispatchEvent()| override. | 52 // |DispatchEvent()| override. |
| 53 // The returned |ScopedEventDispatcher| object is a handler for the overridden | 53 // The returned |ScopedEventDispatcher| object is a handler for the overridden |
| 54 // dispatcher. When this handler is destroyed, it removes the overridden | 54 // dispatcher. When this handler is destroyed, it removes the overridden |
| 55 // dispatcher, and restores the previous override-dispatcher (or NULL if there | 55 // dispatcher, and restores the previous override-dispatcher (or NULL if there |
| 56 // wasn't any). | 56 // wasn't any). |
| 57 scoped_ptr<ScopedEventDispatcher> OverrideDispatcher( | 57 std::unique_ptr<ScopedEventDispatcher> OverrideDispatcher( |
| 58 PlatformEventDispatcher* dispatcher); | 58 PlatformEventDispatcher* dispatcher); |
| 59 | 59 |
| 60 // Called to indicate that the source should stop dispatching the current | 60 // Called to indicate that the source should stop dispatching the current |
| 61 // stream of events and wait until the next iteration of the message-loop to | 61 // stream of events and wait until the next iteration of the message-loop to |
| 62 // dispatch the rest of the events. | 62 // dispatch the rest of the events. |
| 63 virtual void StopCurrentEventStream(); | 63 virtual void StopCurrentEventStream(); |
| 64 | 64 |
| 65 void AddPlatformEventObserver(PlatformEventObserver* observer); | 65 void AddPlatformEventObserver(PlatformEventObserver* observer); |
| 66 void RemovePlatformEventObserver(PlatformEventObserver* observer); | 66 void RemovePlatformEventObserver(PlatformEventObserver* observer); |
| 67 | 67 |
| 68 static scoped_ptr<PlatformEventSource> CreateDefault(); | 68 static std::unique_ptr<PlatformEventSource> CreateDefault(); |
| 69 | 69 |
| 70 protected: | 70 protected: |
| 71 PlatformEventSource(); | 71 PlatformEventSource(); |
| 72 | 72 |
| 73 // Dispatches |platform_event| to the dispatchers. If there is an override | 73 // Dispatches |platform_event| to the dispatchers. If there is an override |
| 74 // dispatcher installed using |OverrideDispatcher()|, then that dispatcher | 74 // dispatcher installed using |OverrideDispatcher()|, then that dispatcher |
| 75 // receives the event first. |POST_DISPATCH_QUIT_LOOP| flag is set in the | 75 // receives the event first. |POST_DISPATCH_QUIT_LOOP| flag is set in the |
| 76 // returned value if the event-source should stop dispatching events at the | 76 // returned value if the event-source should stop dispatching events at the |
| 77 // current message-loop iteration. | 77 // current message-loop iteration. |
| 78 virtual uint32_t DispatchEvent(PlatformEvent platform_event); | 78 virtual uint32_t DispatchEvent(PlatformEvent platform_event); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 103 bool overridden_dispatcher_restored_; | 103 bool overridden_dispatcher_restored_; |
| 104 | 104 |
| 105 base::ObserverList<PlatformEventObserver> observers_; | 105 base::ObserverList<PlatformEventObserver> observers_; |
| 106 | 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(PlatformEventSource); | 107 DISALLOW_COPY_AND_ASSIGN(PlatformEventSource); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 } // namespace ui | 110 } // namespace ui |
| 111 | 111 |
| 112 #endif // UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ | 112 #endif // UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_ |
| OLD | NEW |