Roll src/third_party/skia 591a2ca:b3fe1b8
[chromium-blink-merge.git] / ui / events / platform / scoped_event_dispatcher.h
bloba2f52945d91183d40ab07693cb6f3d7527f3e678
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"
12 namespace ui {
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 {
24 public:
25 ScopedEventDispatcher(PlatformEventDispatcher** scoped_dispatcher,
26 PlatformEventDispatcher* new_dispatcher);
27 ~ScopedEventDispatcher();
29 operator PlatformEventDispatcher*() const { return original_; }
31 private:
32 PlatformEventDispatcher* original_;
33 base::AutoReset<PlatformEventDispatcher*> restore_;
35 DISALLOW_COPY_AND_ASSIGN(ScopedEventDispatcher);
38 } // namespace ui
40 #endif // UI_EVENTS_PLATFORM_SCOPED_EVENT_DISPATCHER_H_