Fix clank compilation errors in the relocation_packer.
[chromium-blink-merge.git] / base / mac / scoped_sending_event.h
blob92c2155e155c451d929db9d0a09f958f974118b1
1 // Copyright (c) 2012 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 BASE_MAC_SCOPED_SENDING_EVENT_H_
6 #define BASE_MAC_SCOPED_SENDING_EVENT_H_
8 #include "base/base_export.h"
9 #include "base/basictypes.h"
10 #include "base/message_loop/message_pump_mac.h"
12 // Nested event loops can pump IPC messages, including
13 // script-initiated tab closes, which could release objects that the
14 // nested event loop might message. CrAppProtocol defines how to ask
15 // the embedding NSApplication subclass if an event is currently being
16 // handled, in which case such closes are deferred to the top-level
17 // event loop.
19 // ScopedSendingEvent allows script-initiated event loops to work like
20 // a nested event loop, as such events do not arrive via -sendEvent:.
21 // CrAppControlProtocol lets ScopedSendingEvent tell the embedding
22 // NSApplication what to return from -handlingSendEvent.
24 @protocol CrAppControlProtocol<CrAppProtocol>
25 - (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
26 @end
28 namespace base {
29 namespace mac {
31 class BASE_EXPORT ScopedSendingEvent {
32 public:
33 ScopedSendingEvent();
34 ~ScopedSendingEvent();
36 private:
37 // The NSApp in control at the time the constructor was run, to be
38 // sure the |handling_| setting is restored appropriately.
39 NSObject<CrAppControlProtocol>* app_;
40 BOOL handling_; // Value of -[app_ handlingSendEvent] at construction.
42 DISALLOW_COPY_AND_ASSIGN(ScopedSendingEvent);
45 } // namespace mac
46 } // namespace base
48 #endif // BASE_MAC_SCOPED_SENDING_EVENT_H_