diff options
author | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-15 19:25:51 +0000 |
---|---|---|
committer | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-15 19:25:51 +0000 |
commit | 113e4193e40cc13b3e94c4df76a8209485db330c (patch) | |
tree | 1afb5cda71d5164589507ce7a493b85f3583a51b | |
parent | bd5c9a41f61de7500b1c9065ef1f431cf9eb52ea (diff) | |
download | chromium_src-113e4193e40cc13b3e94c4df76a8209485db330c.zip chromium_src-113e4193e40cc13b3e94c4df76a8209485db330c.tar.gz chromium_src-113e4193e40cc13b3e94c4df76a8209485db330c.tar.bz2 |
Reattempt at r465143. The UI tests rely too heavily on the current behavior of closing the last window indicating exiting the entire app, so that is left alone for now with a TODO added.
From the old description:
Mac: Fixes bug where extension background hosts were being cleared when the last window was closed. It assumed that this meant the app was closing. Not the case with Mac apps. Added a mac-only notification APP_TERMINATED and use that to perform cleanup upon shutdown.
TEST=More description in the bug, but basically just make sure that background views stick around even after you've closed the last window.
BUG=28666
Review URL: http://codereview.chromium.org/502012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34580 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser_list.cc | 8 | ||||
-rw-r--r-- | chrome/browser/browser_shutdown.cc | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_process_manager.cc | 19 | ||||
-rw-r--r-- | chrome/common/notification_type.h | 10 |
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, |