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