summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_main_mac.mm
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 21:36:11 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 21:36:11 +0000
commit3b6aa8b6ca80f33b3a5af490dc29e65f6d9a6dc4 (patch)
treecb3a85d96d53560f62c0b094ebbc02c97a07fc81 /chrome/browser/browser_main_mac.mm
parent262c3f2ea113d3fb4ffe535226cf172a6a108e82 (diff)
downloadchromium_src-3b6aa8b6ca80f33b3a5af490dc29e65f6d9a6dc4.zip
chromium_src-3b6aa8b6ca80f33b3a5af490dc29e65f6d9a6dc4.tar.gz
chromium_src-3b6aa8b6ca80f33b3a5af490dc29e65f6d9a6dc4.tar.bz2
Chrome should shut down cleanly when quit from the Dock icon menu, during
user logout, and during system restart and shutdown. MainMenu.xib changes (because you're not expected to parse nibs yourself): - The quit menu item's action is changed from the AppController object's -quit: method (which no longer exists) to the application object's -terminate: method (the Cocoa standard). - The application and owner object types are changed from NSApplication to CrApplication. - The application menu name is changed from Chromium to ^IDS_SHORT_PRODUCT_NAME. Cocoa doesn't use this anyway, it gets replaced at runtime with the localized value of CFBundleName, but we shouldn't have branding-specific strings in our nibs. BUG=18078 TEST=Use Chrome for a while, quit it from the Dock icon menu, and relaunch. You should NOT see the "Google Chrome didn't shut down correctly" info bar. Review URL: http://codereview.chromium.org/201121 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26269 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_main_mac.mm')
-rw-r--r--chrome/browser/browser_main_mac.mm38
1 files changed, 21 insertions, 17 deletions
diff --git a/chrome/browser/browser_main_mac.mm b/chrome/browser/browser_main_mac.mm
index ca6d346..8ed837f 100644
--- a/chrome/browser/browser_main_mac.mm
+++ b/chrome/browser/browser_main_mac.mm
@@ -11,25 +11,33 @@
#include "base/debug_util.h"
#include "chrome/app/breakpad_mac.h"
#import "chrome/app/keystone_glue.h"
+#import "chrome/browser/app_controller_mac.h"
#include "chrome/browser/browser_main_win.h"
+#import "chrome/browser/chrome_application_mac.h"
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/common/main_function_params.h"
#include "chrome/common/result_codes.h"
namespace Platform {
-// Perform any platform-specific work that needs to be done before the main
-// message loop is created and initialized.
-//
-// For Mac, this involves telling Cooca to finish its initalization, which we
-// want to do manually instead of calling NSApplicationMain(). The primary
-// reason is that NSAM() never returns, which would leave all the objects
-// currently on the stack in scoped_ptrs hanging and never cleaned up. We then
-// load the main nib directly. The main event loop is run from common code using
-// the MessageLoop API, which works out ok for us because it's a wrapper around
+// Tell Cooca to finish its initalization, which we want to do manually
+// instead of calling NSApplicationMain(). The primary reason is that NSAM()
+// never returns, which would leave all the objects currently on the stack
+// in scoped_ptrs hanging and never cleaned up. We then load the main nib
+// directly. The main event loop is run from common code using the
+// MessageLoop API, which works out ok for us because it's a wrapper around
// CFRunLoop.
void WillInitializeMainMessageLoop(const MainFunctionParams& parameters) {
- [NSApplication sharedApplication];
+ // Initialize NSApplication using the custom subclass. Check whether NSApp
+ // was already initialized using another class, because that would break
+ // some things.
+ [CrApplication sharedApplication];
+ if (![NSApp isKindOfClass:[CrApplication class]]) {
+ LOG(ERROR) << "NSApp should be of type CrApplication, not "
+ << [[NSApp className] UTF8String];
+ DCHECK(false) << "NSApp is of wrong type";
+ }
+
// Before we load the nib, we need to start up the resource bundle so we have
// the strings avaiable for localization.
if (!parameters.ui_task) {
@@ -46,13 +54,9 @@ void WillInitializeMainMessageLoop(const MainFunctionParams& parameters) {
[[KeystoneGlue defaultKeystoneGlue] registerWithKeystone];
}
-// Perform platform-specific work that needs to be done after the main event
-// loop has ended. We need to send the notifications that Cooca normally would
-// telling everyone the app is about to end.
-void WillTerminate() {
- [[NSNotificationCenter defaultCenter]
- postNotificationName:NSApplicationWillTerminateNotification
- object:NSApp];
+void DidEndMainMessageLoop() {
+ AppController* appController = [NSApp delegate];
+ [appController didEndMainMessageLoop];
}
void RecordBreakpadStatusUMA(MetricsService* metrics) {