summaryrefslogtreecommitdiffstats
path: root/chrome/browser/app_controller_mac.mm
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/app_controller_mac.mm')
-rw-r--r--chrome/browser/app_controller_mac.mm21
1 files changed, 19 insertions, 2 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 2b8bbfa..12b4398 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -377,6 +377,12 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
name:NSWorkspaceActiveSpaceDidChangeNotification
object:nil];
+ [[[NSWorkspace sharedWorkspace] notificationCenter]
+ addObserver:self
+ selector:@selector(willPowerOff:)
+ name:NSWorkspaceWillPowerOffNotification
+ object:nil];
+
// Set up the command updater for when there are no windows open
[self initMenuState];
@@ -408,6 +414,10 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
}
- (BOOL)tryToTerminateApplication:(NSApplication*)app {
+ // Reset this now that we've received the call to terminate.
+ BOOL isPoweringOff = isPoweringOff_;
+ isPoweringOff_ = NO;
+
// Check for in-process downloads, and prompt the user if they really want
// to quit (and thus cancel downloads). Only check if we're not already
// shutting down, else the user might be prompted multiple times if the
@@ -428,8 +438,8 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
// Check for active apps. If quitting is prevented, only close browsers and
// sessions.
- if (!browser_shutdown::IsTryingToQuit() && quitWithAppsController_.get() &&
- !quitWithAppsController_->ShouldQuit()) {
+ if (!browser_shutdown::IsTryingToQuit() && !isPoweringOff &&
+ quitWithAppsController_.get() && !quitWithAppsController_->ShouldQuit()) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kHostedAppQuitNotification)) {
return NO;
@@ -670,6 +680,13 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
}
}
+// Called when shutting down or logging out.
+- (void)willPowerOff:(NSNotification*)notify {
+ // Don't attempt any shutdown here. Cocoa will shortly call
+ // -[BrowserCrApplication terminate:].
+ isPoweringOff_ = YES;
+}
+
// Called on Lion and later when a popover (e.g. dictionary) is shown.
- (void)popoverDidShow:(NSNotification*)notify {
hasPopover_ = YES;