Chromium Code Reviews| 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" | 14 #include "base/memory/scoped_nsobject.h" |
|
Robert Sesek
2011/11/09 18:16:25
nit: remove
Scott Hess - ex-Googler
2011/11/09 18:36:53
Done.
| |
| 15 #import "content/common/mac/scoped_sending_event.h" | 15 #import "content/common/mac/scoped_sending_event.h" |
|
Robert Sesek
2011/11/09 18:16:25
can move into .mm
Scott Hess - ex-Googler
2011/11/09 18:36:53
Defines the necessary protocol.
Robert Sesek
2011/11/09 18:38:59
Oops, you're right.
| |
| 16 | 16 |
| 17 // Event hooks must implement this protocol. | |
| 18 @protocol CrApplicationEventHookProtocol | |
| 19 - (void)hookForEvent:(NSEvent*)theEvent; | |
| 20 @end | |
| 21 | |
| 22 @interface CrApplication : NSApplication<CrAppControlProtocol> { | 17 @interface CrApplication : NSApplication<CrAppControlProtocol> { |
| 23 @private | 18 @private |
| 24 BOOL handlingSendEvent_; | 19 BOOL handlingSendEvent_; |
| 25 // Array of objects implementing the CrApplicationEventHookProtocol | |
| 26 scoped_nsobject<NSMutableArray> eventHooks_; | |
| 27 } | 20 } |
| 28 - (BOOL)isHandlingSendEvent; | 21 - (BOOL)isHandlingSendEvent; |
| 29 | 22 |
| 30 // Unconditionally clears |handlingSendEvent_|. This should not be | 23 // Unconditionally clears |handlingSendEvent_|. This should not be |
| 31 // used except in recovering from some sort of exceptional condition. | 24 // used except in recovering from some sort of exceptional condition. |
| 32 - (void)clearIsHandlingSendEvent; | 25 - (void)clearIsHandlingSendEvent; |
| 33 | 26 |
| 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; | 27 + (NSApplication*)sharedApplication; |
| 46 @end | 28 @end |
| 47 | 29 |
| 48 #endif // defined(__OBJC__) | 30 #endif // defined(__OBJC__) |
| 49 | 31 |
| 50 namespace chrome_application_mac { | 32 namespace chrome_application_mac { |
| 51 | 33 |
| 52 // To be used to instantiate CrApplication from C++ code. | 34 // To be used to instantiate CrApplication from C++ code. |
| 53 void RegisterCrApp(); | 35 void RegisterCrApp(); |
| 54 | 36 |
| 55 } // namespace chrome_application_mac | 37 } // namespace chrome_application_mac |
| 56 | 38 |
| 57 #endif // CONTENT_COMMON_CHROME_APPLICATION_MAC_H_ | 39 #endif // CONTENT_COMMON_CHROME_APPLICATION_MAC_H_ |
| OLD | NEW |