1 // Copyright 2018 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.
4 
5 #ifndef CONTENT_PUBLIC_BROWSER_NATIVE_EVENT_PROCESSOR_OBSERVER_MAC_H_
6 #define CONTENT_PUBLIC_BROWSER_NATIVE_EVENT_PROCESSOR_OBSERVER_MAC_H_
7 
8 #include "base/macros.h"
9 #include "base/observer_list.h"
10 #include "content/common/content_export.h"
11 
12 #if defined(__OBJC__)
13 @class NSEvent;
14 #else   // __OBJC__
15 class NSEvent;
16 #endif  // __OBJC__
17 
18 namespace content {
19 
20 class NativeEventProcessorObserver {
21  public:
22   // Called right before a native event is run.
23   virtual void WillRunNativeEvent(const void* opaque_identifier) = 0;
24 
25   // Called right after a native event is run.
26   virtual void DidRunNativeEvent(const void* opaque_identifier) = 0;
27 };
28 
29 // The constructor sends a WillRunNativeEvent callback to each observer.
30 // The destructor sends a DidRunNativeEvent callback to each observer.
31 class CONTENT_EXPORT ScopedNotifyNativeEventProcessorObserver {
32  public:
33   ScopedNotifyNativeEventProcessorObserver(
34       base::ObserverList<NativeEventProcessorObserver>::Unchecked*
35           observer_list,
36       NSEvent* event);
37   ~ScopedNotifyNativeEventProcessorObserver();
38 
39  private:
40   base::ObserverList<NativeEventProcessorObserver>::Unchecked* observer_list_;
41   NSEvent* event_;
42   DISALLOW_COPY_AND_ASSIGN(ScopedNotifyNativeEventProcessorObserver);
43 };
44 
45 }  // namespace content
46 
47 #endif  // CONTENT_PUBLIC_BROWSER_NATIVE_EVENT_PROCESSOR_OBSERVER_MAC_H_
48