| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_COMMON_MAC_SCOPED_SENDING_EVENT_H_ | 5 #ifndef BASE_MAC_SCOPED_SENDING_EVENT_H_ |
| 6 #define CONTENT_COMMON_MAC_SCOPED_SENDING_EVENT_H_ | 6 #define BASE_MAC_SCOPED_SENDING_EVENT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/scoped_nsobject.h" | 10 #include "base/memory/scoped_nsobject.h" |
| 11 #include "base/message_pump_mac.h" | 11 #include "base/message_pump_mac.h" |
| 12 | 12 |
| 13 // Nested event loops can pump IPC messages, including | 13 // Nested event loops can pump IPC messages, including |
| 14 // script-initiated tab closes, which could release objects that the | 14 // script-initiated tab closes, which could release objects that the |
| 15 // nested event loop might message. CrAppProtocol defines how to ask | 15 // nested event loop might message. CrAppProtocol defines how to ask |
| 16 // the embedding NSApplication subclass if an event is currently being | 16 // the embedding NSApplication subclass if an event is currently being |
| 17 // handled, in which case such closes are deferred to the top-level | 17 // handled, in which case such closes are deferred to the top-level |
| 18 // event loop. | 18 // event loop. |
| 19 // | 19 // |
| 20 // ScopedSendingEvent allows script-initiated event loops to work like | 20 // ScopedSendingEvent allows script-initiated event loops to work like |
| 21 // a nested event loop, as such events do not arrive via -sendEvent:. | 21 // a nested event loop, as such events do not arrive via -sendEvent:. |
| 22 // CrAppControlProtocol lets ScopedSendingEvent tell the embedding | 22 // CrAppControlProtocol lets ScopedSendingEvent tell the embedding |
| 23 // NSApplication what to return from -handlingSendEvent. | 23 // NSApplication what to return from -handlingSendEvent. |
| 24 | 24 |
| 25 @protocol CrAppControlProtocol<CrAppProtocol> | 25 @protocol CrAppControlProtocol<CrAppProtocol> |
| 26 - (void)setHandlingSendEvent:(BOOL)handlingSendEvent; | 26 - (void)setHandlingSendEvent:(BOOL)handlingSendEvent; |
| 27 @end | 27 @end |
| 28 | 28 |
| 29 namespace content { | 29 namespace base { |
| 30 namespace mac { | 30 namespace mac { |
| 31 | 31 |
| 32 class ScopedSendingEvent { | 32 class ScopedSendingEvent { |
| 33 public: | 33 public: |
| 34 ScopedSendingEvent(); | 34 ScopedSendingEvent(); |
| 35 ~ScopedSendingEvent(); | 35 ~ScopedSendingEvent(); |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 // The NSApp in control at the time the constructor was run, to be | 38 // The NSApp in control at the time the constructor was run, to be |
| 39 // sure the |handling_| setting is restored appropriately. | 39 // sure the |handling_| setting is restored appropriately. |
| 40 NSObject<CrAppControlProtocol>* app_; | 40 NSObject<CrAppControlProtocol>* app_; |
| 41 BOOL handling_; // Value of -[app_ handlingSendEvent] at construction. | 41 BOOL handling_; // Value of -[app_ handlingSendEvent] at construction. |
| 42 | 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(ScopedSendingEvent); | 43 DISALLOW_COPY_AND_ASSIGN(ScopedSendingEvent); |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 } // namespace mac | 46 } // namespace mac |
| 47 } // namespace content | 47 } // namespace base |
| 48 | 48 |
| 49 #endif // CONTENT_COMMON_MAC_SCOPED_SENDING_EVENT_H_ | 49 #endif // BASE_MAC_SCOPED_SENDING_EVENT_H_ |
| OLD | NEW |