summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser_list.cc7
-rw-r--r--chrome/browser/browser_shutdown.cc6
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc16
-rw-r--r--chrome/common/notification_type.h10
4 files changed, 35 insertions, 4 deletions
diff --git a/chrome/browser/browser_list.cc b/chrome/browser/browser_list.cc
index 413fda9..7f7b753 100644
--- a/chrome/browser/browser_list.cc
+++ b/chrome/browser/browser_list.cc
@@ -151,7 +151,12 @@ void BrowserList::AddBrowser(Browser* browser) {
void BrowserList::RemoveBrowser(Browser* browser) {
RemoveBrowserFrom(browser, &last_active_browsers_);
- bool close_app = (browsers_.size() == 1);
+ bool close_app = false;
+ // Since closing all windows does not indicate quitting the application on
+ // Mac, don't check the condition based on the number of browser windows.
+#if defined(OS_WIN) || defined(OS_LINUX)
+ close_app = (browsers_.size() == 1);
+#endif
NotificationService::current()->Notify(
NotificationType::BROWSER_CLOSED,
Source<Browser>(browser), Details<bool>(&close_app));
diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc
index 520ead7..3062dd7 100644
--- a/chrome/browser/browser_shutdown.cc
+++ b/chrome/browser/browser_shutdown.cc
@@ -24,6 +24,7 @@
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_widget_host.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/common/chrome_plugin_lib.h"
@@ -90,6 +91,11 @@ FilePath GetShutdownMsPath() {
#endif
void Shutdown() {
+#if defined(OS_MACOSX)
+ NotificationService::current()->Notify(NotificationType::APP_TERMINATING,
+ NotificationService::AllSources(),
+ NotificationService::NoDetails());
+#endif
// Unload plugins. This needs to happen on the IO thread.
ChromeThread::PostTask(
ChromeThread::IO, FROM_HERE,
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 78cd214..34b647b 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -49,6 +49,10 @@ ExtensionProcessManager::ExtensionProcessManager(Profile* profile)
NotificationService::AllSources());
registrar_.Add(this, NotificationType::BROWSER_CLOSED,
NotificationService::AllSources());
+#if defined(OS_MACOSX)
+ registrar_.Add(this, NotificationType::APP_TERMINATING,
+ NotificationService::AllSources());
+#endif
}
ExtensionProcessManager::~ExtensionProcessManager() {
@@ -246,13 +250,23 @@ void ExtensionProcessManager::Observe(NotificationType type,
case NotificationType::BROWSER_CLOSED: {
// Close background hosts when the last browser is closed so that they
// have time to shutdown various objects on different threads. Our
- // destructor is called too late in the shutdown sequence.
+ // destructor is called too late in the shutdown sequence. This will never
+ // occur on Mac. See the APP_TERMINATING case below.
bool app_closing = *Details<bool>(details).ptr();
if (app_closing)
CloseBackgroundHosts();
break;
}
+#if defined(OS_MACOSX)
+ case NotificationType::APP_TERMINATING: {
+ // This is a Mac-specific notification since app_closing will never be
+ // true in the BROWSER_CLOSED case.
+ CloseBackgroundHosts();
+ break;
+ }
+#endif
+
default:
NOTREACHED();
}
diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h
index ed930c2..f7a1f0c 100644
--- a/chrome/common/notification_type.h
+++ b/chrome/common/notification_type.h
@@ -195,8 +195,8 @@ class NotificationType {
// Source<Browser> containing the affected Browser. Details is a boolean
// that if true indicates that the application will be closed as a result of
// this browser window closure (i.e. this was the last opened browser
- // window). Note that the boolean pointed to by Details is only valid for
- // the duration of this call.
+ // window on win/linux). Note that the boolean pointed to by details is
+ // only valid for the duration of this call.
BROWSER_CLOSED,
// This message is sent when the last window considered to be an
@@ -205,10 +205,16 @@ class NotificationType {
// details are passed.
ALL_APPWINDOWS_CLOSED,
+#if defined(OS_MACOSX)
// This message is sent when the application is made active (Mac OS X only
// at present). No source or details are passed.
APP_ACTIVATED,
+ // This message is sent when the application is terminating (Mac OS X only
+ // at present). No source or details are passed.
+ APP_TERMINATING,
+#endif
+
// Indicates that a top window has been closed. The source is the HWND
// that was closed, no details are expected.
WINDOW_CLOSED,