• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_
6 #define CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_
7 
8 #ifdef __OBJC__
9 
10 #import <AppKit/AppKit.h>
11 
12 #include <vector>
13 
14 #import "base/mac/scoped_sending_event.h"
15 #import "base/message_loop/message_pump_mac.h"
16 #include "base/synchronization/lock.h"
17 
18 @interface BrowserCrApplication : NSApplication<CrAppProtocol,
19                                                 CrAppControlProtocol> {
20  @private
21   BOOL handlingSendEvent_;
22   BOOL cyclingWindows_;
23 
24   // App's previous key windows. Most recent key window is last.
25   // Does not include current key window. Elements of this vector are weak
26   // references.
27   std::vector<NSWindow*> previousKeyWindows_;
28 
29   // Guards previousKeyWindows_.
30   base::Lock previousKeyWindowsLock_;
31 }
32 
33 // Our implementation of |-terminate:| only attempts to terminate the
34 // application, i.e., begins a process which may lead to termination. This
35 // method cancels that process.
36 - (void)cancelTerminate:(id)sender;
37 
38 // Keep track of the previous key windows and whether windows are being
39 // cycled for use in determining whether a Panel window can become the
40 // key window.
41 - (NSWindow*)previousKeyWindow;
42 - (BOOL)isCyclingWindows;
43 @end
44 
45 namespace chrome_browser_application_mac {
46 
47 // Bin for unknown exceptions. Exposed for testing purposes.
48 extern const size_t kUnknownNSException;
49 
50 // Returns the histogram bin for |exception| if it is one we track
51 // specifically, or |kUnknownNSException| if unknown.  Exposed for testing
52 // purposes.
53 size_t BinForException(NSException* exception);
54 
55 // Use UMA to track exception occurance. Exposed for testing purposes.
56 void RecordExceptionWithUma(NSException* exception);
57 
58 }  // namespace chrome_browser_application_mac
59 
60 #endif  // __OBJC__
61 
62 namespace chrome_browser_application_mac {
63 
64 // To be used to instantiate BrowserCrApplication from C++ code.
65 void RegisterBrowserCrApp();
66 
67 // Calls -[NSApp terminate:].
68 void Terminate();
69 
70 // Cancels a termination started by |Terminate()|.
71 void CancelTerminate();
72 
73 }  // namespace chrome_browser_application_mac
74 
75 #endif  // CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_
76