| OLD | NEW |
| 1 // Copyright (c) 2010 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 CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_ | 5 #ifndef CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_ |
| 6 #define CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_ | 6 #define CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #ifdef __OBJC__ | 9 #ifdef __OBJC__ |
| 10 | 10 |
| 11 #import "content/common/chrome_application_mac.h" | 11 #import "content/common/chrome_application_mac.h" |
| 12 | 12 |
| 13 @interface BrowserCrApplication : CrApplication | 13 // Event hooks must implement this protocol. |
| 14 @protocol CrApplicationEventHookProtocol |
| 15 - (void)hookForEvent:(NSEvent*)theEvent; |
| 16 @end |
| 17 |
| 18 @interface BrowserCrApplication : CrApplication { |
| 19 @private |
| 20 // Array of objects implementing CrApplicationEventHookProtocol. |
| 21 scoped_nsobject<NSMutableArray> eventHooks_; |
| 22 } |
| 23 |
| 14 // Our implementation of |-terminate:| only attempts to terminate the | 24 // Our implementation of |-terminate:| only attempts to terminate the |
| 15 // application, i.e., begins a process which may lead to termination. This | 25 // application, i.e., begins a process which may lead to termination. This |
| 16 // method cancels that process. | 26 // method cancels that process. |
| 17 - (void)cancelTerminate:(id)sender; | 27 - (void)cancelTerminate:(id)sender; |
| 28 |
| 29 // Add or remove an event hook to be called for every sendEvent: |
| 30 // that the application receives. These handlers are called before |
| 31 // the normal [NSApplication sendEvent:] call is made. |
| 32 |
| 33 // This is not a good alternative to a nested event loop. It should |
| 34 // be used only when normal event logic and notification breaks down |
| 35 // (e.g. when clicking outside a canBecomeKey:NO window to "switch |
| 36 // context" out of it). |
| 37 - (void)addEventHook:(id<CrApplicationEventHookProtocol>)hook; |
| 38 - (void)removeEventHook:(id<CrApplicationEventHookProtocol>)hook; |
| 18 @end | 39 @end |
| 19 | 40 |
| 20 namespace chrome_browser_application_mac { | 41 namespace chrome_browser_application_mac { |
| 21 | 42 |
| 22 // Bin for unknown exceptions. Exposed for testing purposes. | 43 // Bin for unknown exceptions. Exposed for testing purposes. |
| 23 extern const size_t kUnknownNSException; | 44 extern const size_t kUnknownNSException; |
| 24 | 45 |
| 25 // Returns the histogram bin for |exception| if it is one we track | 46 // Returns the histogram bin for |exception| if it is one we track |
| 26 // specifically, or |kUnknownNSException| if unknown. Exposed for testing | 47 // specifically, or |kUnknownNSException| if unknown. Exposed for testing |
| 27 // purposes. | 48 // purposes. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 41 | 62 |
| 42 // Calls -[NSApp terminate:]. | 63 // Calls -[NSApp terminate:]. |
| 43 void Terminate(); | 64 void Terminate(); |
| 44 | 65 |
| 45 // Cancels a termination started by |Terminate()|. | 66 // Cancels a termination started by |Terminate()|. |
| 46 void CancelTerminate(); | 67 void CancelTerminate(); |
| 47 | 68 |
| 48 } // namespace chrome_browser_application_mac | 69 } // namespace chrome_browser_application_mac |
| 49 | 70 |
| 50 #endif // CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_ | 71 #endif // CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_ |
| OLD | NEW |