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_CHROME_APPLICATION_MAC_H_ | 5 #ifndef CONTENT_COMMON_CHROME_APPLICATION_MAC_H_ |
6 #define CONTENT_COMMON_CHROME_APPLICATION_MAC_H_ | 6 #define CONTENT_COMMON_CHROME_APPLICATION_MAC_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #if defined(__OBJC__) | 9 #if defined(__OBJC__) |
10 | 10 |
11 #import <AppKit/AppKit.h> | 11 #import <AppKit/AppKit.h> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/memory/scoped_nsobject.h" | |
15 #import "content/common/mac/scoped_sending_event.h" | 14 #import "content/common/mac/scoped_sending_event.h" |
16 | 15 |
17 // Event hooks must implement this protocol. | |
18 @protocol CrApplicationEventHookProtocol | |
19 - (void)hookForEvent:(NSEvent*)theEvent; | |
20 @end | |
21 | |
22 @interface CrApplication : NSApplication<CrAppControlProtocol> { | 16 @interface CrApplication : NSApplication<CrAppControlProtocol> { |
23 @private | 17 @private |
24 BOOL handlingSendEvent_; | 18 BOOL handlingSendEvent_; |
25 // Array of objects implementing the CrApplicationEventHookProtocol | |
26 scoped_nsobject<NSMutableArray> eventHooks_; | |
27 } | 19 } |
28 - (BOOL)isHandlingSendEvent; | 20 - (BOOL)isHandlingSendEvent; |
29 | 21 |
30 // Unconditionally clears |handlingSendEvent_|. This should not be | 22 // Unconditionally clears |handlingSendEvent_|. This should not be |
31 // used except in recovering from some sort of exceptional condition. | 23 // used except in recovering from some sort of exceptional condition. |
32 - (void)clearIsHandlingSendEvent; | 24 - (void)clearIsHandlingSendEvent; |
33 | 25 |
34 // Add or remove an event hook to be called for every sendEvent: | |
35 // that the application receives. These handlers are called before | |
36 // the normal [NSApplication sendEvent:] call is made. | |
37 | |
38 // This is not a good alternative to a nested event loop. It should | |
39 // be used only when normal event logic and notification breaks down | |
40 // (e.g. when clicking outside a canBecomeKey:NO window to "switch | |
41 // context" out of it). | |
42 - (void)addEventHook:(id<CrApplicationEventHookProtocol>)hook; | |
43 - (void)removeEventHook:(id<CrApplicationEventHookProtocol>)hook; | |
44 | |
45 + (NSApplication*)sharedApplication; | 26 + (NSApplication*)sharedApplication; |
46 @end | 27 @end |
47 | 28 |
48 #endif // defined(__OBJC__) | 29 #endif // defined(__OBJC__) |
49 | 30 |
50 namespace chrome_application_mac { | 31 namespace chrome_application_mac { |
51 | 32 |
52 // To be used to instantiate CrApplication from C++ code. | 33 // To be used to instantiate CrApplication from C++ code. |
53 void RegisterCrApp(); | 34 void RegisterCrApp(); |
54 | 35 |
55 } // namespace chrome_application_mac | 36 } // namespace chrome_application_mac |
56 | 37 |
57 #endif // CONTENT_COMMON_CHROME_APPLICATION_MAC_H_ | 38 #endif // CONTENT_COMMON_CHROME_APPLICATION_MAC_H_ |
OLD | NEW |