Revert 168224 - Update V8 to version 3.15.4.
[chromium-blink-merge.git] / chrome / browser / chrome_browser_application_mac.h
blob02c15588245e830c2e8e6e1e1167a243c40179ce
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_
6 #define CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_
8 #ifdef __OBJC__
10 #import <AppKit/AppKit.h>
12 #include <vector>
14 #import "base/mac/scoped_sending_event.h"
15 #import "base/memory/scoped_nsobject.h"
16 #import "base/message_pump_mac.h"
17 #include "base/synchronization/lock.h"
19 // Event hooks must implement this protocol.
20 @protocol CrApplicationEventHookProtocol
21 - (void)hookForEvent:(NSEvent*)theEvent;
22 @end
24 @interface BrowserCrApplication : NSApplication<CrAppProtocol,
25 CrAppControlProtocol> {
26 @private
27 BOOL handlingSendEvent_;
28 BOOL cyclingWindows_;
30 // Array of objects implementing CrApplicationEventHookProtocol.
31 scoped_nsobject<NSMutableArray> eventHooks_;
33 // App's previous key windows. Most recent key window is last.
34 // Does not include current key window. Elements of this vector are weak
35 // references.
36 std::vector<NSWindow*> previousKeyWindows_;
38 // Guards previousKeyWindows_.
39 base::Lock previousKeyWindowsLock_;
42 // Our implementation of |-terminate:| only attempts to terminate the
43 // application, i.e., begins a process which may lead to termination. This
44 // method cancels that process.
45 - (void)cancelTerminate:(id)sender;
47 // Add or remove an event hook to be called for every sendEvent:
48 // that the application receives. These handlers are called before
49 // the normal [NSApplication sendEvent:] call is made.
51 // This is not a good alternative to a nested event loop. It should
52 // be used only when normal event logic and notification breaks down
53 // (e.g. when clicking outside a canBecomeKey:NO window to "switch
54 // context" out of it).
55 - (void)addEventHook:(id<CrApplicationEventHookProtocol>)hook;
56 - (void)removeEventHook:(id<CrApplicationEventHookProtocol>)hook;
58 // Keep track of the previous key windows and whether windows are being
59 // cycled for use in determining whether a Panel window can become the
60 // key window.
61 - (NSWindow*)previousKeyWindow;
62 - (BOOL)isCyclingWindows;
63 @end
65 namespace chrome_browser_application_mac {
67 // Bin for unknown exceptions. Exposed for testing purposes.
68 extern const size_t kUnknownNSException;
70 // Returns the histogram bin for |exception| if it is one we track
71 // specifically, or |kUnknownNSException| if unknown. Exposed for testing
72 // purposes.
73 size_t BinForException(NSException* exception);
75 // Use UMA to track exception occurance. Exposed for testing purposes.
76 void RecordExceptionWithUma(NSException* exception);
78 } // namespace chrome_browser_application_mac
80 #endif // __OBJC__
82 namespace chrome_browser_application_mac {
84 // To be used to instantiate BrowserCrApplication from C++ code.
85 void RegisterBrowserCrApp();
87 // Calls -[NSApp terminate:].
88 void Terminate();
90 // Cancels a termination started by |Terminate()|.
91 void CancelTerminate();
93 } // namespace chrome_browser_application_mac
95 #endif // CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_