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
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_PLATFORM_SCOPED_EVENT_DISPATCHER_H_
6 #define UI_EVENTS_PLATFORM_SCOPED_EVENT_DISPATCHER_H_
8 #include "base/auto_reset.h"
9 #include "base/basictypes.h"
10 #include "ui/events/events_export.h"
14 class PlatformEventDispatcher
;
16 // A temporary PlatformEventDispatcher can be installed on a
17 // PlatformEventSource that overrides all installed event dispatchers, and
18 // always gets a chance to dispatch the event first. The PlatformEventSource
19 // returns a ScopedEventDispatcher object in such cases. This
20 // ScopedEventDispatcher object can be used to dispatch the event to any
21 // previous overridden dispatcher. When this object is destroyed, it removes the
22 // override-dispatcher, and restores the previous override-dispatcher.
23 class EVENTS_EXPORT ScopedEventDispatcher
{
25 ScopedEventDispatcher(PlatformEventDispatcher
** scoped_dispatcher
,
26 PlatformEventDispatcher
* new_dispatcher
);
27 ~ScopedEventDispatcher();
29 operator PlatformEventDispatcher
*() const { return original_
; }
32 PlatformEventDispatcher
* original_
;
33 base::AutoReset
<PlatformEventDispatcher
*> restore_
;
35 DISALLOW_COPY_AND_ASSIGN(ScopedEventDispatcher
);
40 #endif // UI_EVENTS_PLATFORM_SCOPED_EVENT_DISPATCHER_H_