summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_list.cc8
-rw-r--r--chrome/browser/browser_shutdown.cc6
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc19
-rw-r--r--chrome/common/notification_type.h10
4 files changed, 36 insertions, 7 deletions
diff --git a/chrome/browser/browser_list.cc b/chrome/browser/browser_list.cc
index 413fda9..63712d7 100644
--- a/chrome/browser/browser_list.cc
+++ b/chrome/browser/browser_list.cc
@@ -151,10 +151,14 @@ void BrowserList::AddBrowser(Browser* browser) {
void BrowserList::RemoveBrowser(Browser* browser) {
RemoveBrowserFrom(browser, &last_active_browsers_);
- bool close_app = (browsers_.size() == 1);
+ // Closing all windows does not indicate quitting the application on the Mac,
+ // however, many UI tests rely on this behavior so leave it be for now and
+ // simply ignore the behavior on the Mac outside of unit tests.
+ // TODO(andybons): Fix the UI tests to Do The Right Thing.
+ bool close_app_non_mac = (browsers_.size() == 1);
NotificationService::current()->Notify(
NotificationType::BROWSER_CLOSED,
- Source<Browser>(browser), Details<bool>(&close_app));
+ Source<Browser>(browser), Details<bool>(&close_app_non_mac));
// Send out notifications before anything changes. Do some basic checking to
// try to catch evil observers that change the list from under us.
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..4a2b6d1 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -47,8 +47,13 @@ ExtensionProcessManager::ExtensionProcessManager(Profile* profile)
NotificationService::AllSources());
registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED,
NotificationService::AllSources());
+#if defined(OS_WIN) || defined(OS_LINUX)
registrar_.Add(this, NotificationType::BROWSER_CLOSED,
NotificationService::AllSources());
+#elif defined(OS_MACOSX)
+ registrar_.Add(this, NotificationType::APP_TERMINATING,
+ NotificationService::AllSources());
+#endif
}
ExtensionProcessManager::~ExtensionProcessManager() {
@@ -242,16 +247,24 @@ void ExtensionProcessManager::Observe(NotificationType type,
UnregisterExtensionProcess(host->id());
break;
}
-
+#if defined(OS_WIN) || defined(OS_LINUX)
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.
- bool app_closing = *Details<bool>(details).ptr();
- if (app_closing)
+ bool app_closing_non_mac = *Details<bool>(details).ptr();
+ if (app_closing_non_mac)
CloseBackgroundHosts();
break;
}
+#elif defined(OS_MACOSX)
+ case NotificationType::APP_TERMINATING: {
+ // Don't follow the behavior of having the last browser window closed
+ // being an indication that the app should close.
+ CloseBackgroundHosts();
+ break;
+ }
+#endif
default:
NOTREACHED();
diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h
index 92b6a7e..3bd5c4b 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,