OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 BASE_CHROME_APPLICATION_MAC_H_ | 5 #ifndef CHROME_COMMON_CHROME_APPLICATION_MAC_H_ |
6 #define BASE_CHROME_APPLICATION_MAC_H_ | 6 #define CHROME_COMMON_CHROME_APPLICATION_MAC_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #import <AppKit/AppKit.h> | 9 #import <AppKit/AppKit.h> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/message_pump_mac.h" |
12 #include "base/scoped_nsobject.h" | 13 #include "base/scoped_nsobject.h" |
13 | 14 |
14 // Event hooks must implement this protocol. | 15 // Event hooks must implement this protocol. |
15 @protocol CrApplicationEventHookProtocol | 16 @protocol CrApplicationEventHookProtocol |
16 - (void)hookForEvent:(NSEvent*)theEvent; | 17 - (void)hookForEvent:(NSEvent*)theEvent; |
17 @end | 18 @end |
18 | 19 |
19 | 20 |
20 @interface CrApplication : NSApplication { | 21 @interface CrApplication : NSApplication<CrAppProtocol> { |
21 @private | 22 @private |
22 BOOL handlingSendEvent_; | 23 BOOL handlingSendEvent_; |
23 // Array of objects implementing the CrApplicationEventHookProtocol | 24 // Array of objects implementing the CrApplicationEventHookProtocol |
24 scoped_nsobject<NSMutableArray> eventHooks_; | 25 scoped_nsobject<NSMutableArray> eventHooks_; |
25 } | 26 } |
26 @property(readonly, | 27 - (BOOL)isHandlingSendEvent; |
27 getter=isHandlingSendEvent, | |
28 nonatomic) BOOL handlingSendEvent; | |
29 | 28 |
30 // Add or remove an event hook to be called for every sendEvent: | 29 // Add or remove an event hook to be called for every sendEvent: |
31 // that the application receives. These handlers are called before | 30 // that the application receives. These handlers are called before |
32 // the normal [NSApplication sendEvent:] call is made. | 31 // the normal [NSApplication sendEvent:] call is made. |
33 | 32 |
34 // This is not a good alternative to a nested event loop. It should | 33 // This is not a good alternative to a nested event loop. It should |
35 // be used only when normal event logic and notification breaks down | 34 // be used only when normal event logic and notification breaks down |
36 // (e.g. when clicking outside a canBecomeKey:NO window to "switch | 35 // (e.g. when clicking outside a canBecomeKey:NO window to "switch |
37 // context" out of it). | 36 // context" out of it). |
38 - (void)addEventHook:(id<CrApplicationEventHookProtocol>)hook; | 37 - (void)addEventHook:(id<CrApplicationEventHookProtocol>)hook; |
(...skipping 12 matching lines...) Expand all Loading... |
51 ~ScopedSendingEvent(); | 50 ~ScopedSendingEvent(); |
52 | 51 |
53 private: | 52 private: |
54 CrApplication* app_; | 53 CrApplication* app_; |
55 BOOL handling_; | 54 BOOL handling_; |
56 DISALLOW_COPY_AND_ASSIGN(ScopedSendingEvent); | 55 DISALLOW_COPY_AND_ASSIGN(ScopedSendingEvent); |
57 }; | 56 }; |
58 | 57 |
59 } // chrome_application_mac | 58 } // chrome_application_mac |
60 | 59 |
61 #endif // BASE_CHROME_APPLICATION_MAC_H_ | 60 #endif // CHROME_COMMON_CHROME_APPLICATION_MAC_H_ |
OLD | NEW |