#ifndef UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_
#define UI_EVENTS_PLATFORM_PLATFORM_EVENT_SOURCE_H_
#include <map>
#include <vector>
#include "base/auto_reset.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "ui/events/events_export.h"
#include "ui/events/platform/platform_event_types.h"
namespace ui {
class Event;
class PlatformEventDispatcher;
class PlatformEventObserver;
class ScopedEventDispatcher;
class EVENTS_EXPORT PlatformEventSource {
public:
virtual ~PlatformEventSource();
static PlatformEventSource* GetInstance();
void AddPlatformEventDispatcher(PlatformEventDispatcher* dispatcher);
void RemovePlatformEventDispatcher(PlatformEventDispatcher* dispatcher);
scoped_ptr<ScopedEventDispatcher> OverrideDispatcher(
PlatformEventDispatcher* dispatcher);
void AddPlatformEventObserver(PlatformEventObserver* observer);
void RemovePlatformEventObserver(PlatformEventObserver* observer);
protected:
PlatformEventSource();
virtual uint32_t DispatchEvent(PlatformEvent platform_event);
private:
friend class ScopedEventDispatcher;
static PlatformEventSource* instance_;
void OnOverriddenDispatcherRestored();
bool WillProcessEvent(PlatformEvent platform_event);
void DidProcessEvent(PlatformEvent platform_event);
typedef std::vector<PlatformEventDispatcher*> PlatformEventDispatcherList;
PlatformEventDispatcherList dispatchers_;
PlatformEventDispatcher* overridden_dispatcher_;
bool overridden_dispatcher_restored_;
ObserverList<PlatformEventObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(PlatformEventSource);
};
}
#endif