chromeos: bluetooth: tie Proxy lifetime to object, not observer
[chromium-blink-merge.git] / chrome / browser / chrome_browser_application_mac.h
blobc6147fdd852471739c863796920fed49319afdae
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_
6 #define CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_
7 #pragma once
9 #ifdef __OBJC__
11 #import <AppKit/AppKit.h>
13 #import "base/mac/scoped_sending_event.h"
14 #import "base/memory/scoped_nsobject.h"
15 #import "base/message_pump_mac.h"
17 // Event hooks must implement this protocol.
18 @protocol CrApplicationEventHookProtocol
19 - (void)hookForEvent:(NSEvent*)theEvent;
20 @end
22 @interface BrowserCrApplication : NSApplication<CrAppProtocol,
23 CrAppControlProtocol> {
24 @private
25 BOOL handlingSendEvent_;
27 // Array of objects implementing CrApplicationEventHookProtocol.
28 scoped_nsobject<NSMutableArray> eventHooks_;
31 // Our implementation of |-terminate:| only attempts to terminate the
32 // application, i.e., begins a process which may lead to termination. This
33 // method cancels that process.
34 - (void)cancelTerminate:(id)sender;
36 // Add or remove an event hook to be called for every sendEvent:
37 // that the application receives. These handlers are called before
38 // the normal [NSApplication sendEvent:] call is made.
40 // This is not a good alternative to a nested event loop. It should
41 // be used only when normal event logic and notification breaks down
42 // (e.g. when clicking outside a canBecomeKey:NO window to "switch
43 // context" out of it).
44 - (void)addEventHook:(id<CrApplicationEventHookProtocol>)hook;
45 - (void)removeEventHook:(id<CrApplicationEventHookProtocol>)hook;
46 @end
48 namespace chrome_browser_application_mac {
50 // Bin for unknown exceptions. Exposed for testing purposes.
51 extern const size_t kUnknownNSException;
53 // Returns the histogram bin for |exception| if it is one we track
54 // specifically, or |kUnknownNSException| if unknown. Exposed for testing
55 // purposes.
56 size_t BinForException(NSException* exception);
58 // Use UMA to track exception occurance. Exposed for testing purposes.
59 void RecordExceptionWithUma(NSException* exception);
61 } // namespace chrome_browser_application_mac
63 #endif // __OBJC__
65 namespace chrome_browser_application_mac {
67 // To be used to instantiate BrowserCrApplication from C++ code.
68 void RegisterBrowserCrApp();
70 // Calls -[NSApp terminate:].
71 void Terminate();
73 // Cancels a termination started by |Terminate()|.
74 void CancelTerminate();
76 } // namespace chrome_browser_application_mac
78 #endif // CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_