From 743b26fcb8f2fa573f884d2d47736b5dfad69648 Mon Sep 17 00:00:00 2001 From: "flamingice%sourmilk.net" Date: Fri, 10 Aug 2007 03:05:54 +0000 Subject: [PATCH] Bug 386810, Move quit-application-granted notification to nsAppStartup::Quit, r=benjamin git-svn-id: svn://10.0.0.236/trunk@231779 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/tools/pageloader/quit.js | 19 ------------------- mozilla/layout/tools/reftest/quit.js | 1 - .../mochitest/tests/SimpleTest/quit.js | 1 - .../components/startup/src/nsAppStartup.cpp | 7 +++++-- mozilla/toolkit/content/globalOverlay.js | 1 - .../mozapps/extensions/content/extensions.js | 3 --- .../mozapps/extensions/content/list.js | 3 --- .../toolkit/mozapps/update/content/updates.js | 3 --- mozilla/toolkit/xre/MacApplicationDelegate.mm | 2 -- .../toolkit/xre/nsCommandLineServiceMac.cpp | 1 - .../toolkit/xre/nsNativeAppSupportUnix.cpp | 5 ----- mozilla/toolkit/xre/nsNativeAppSupportWin.cpp | 5 ----- 12 files changed, 5 insertions(+), 46 deletions(-) diff --git a/mozilla/layout/tools/pageloader/quit.js b/mozilla/layout/tools/pageloader/quit.js index ab3b0fdf8c2..9a212d64656 100644 --- a/mozilla/layout/tools/pageloader/quit.js +++ b/mozilla/layout/tools/pageloader/quit.js @@ -64,7 +64,6 @@ function canQuitApplication() catch (ex) { } - os.notifyObservers(null, "quit-application-granted", null); return true; } @@ -97,24 +96,6 @@ function goQuitApplication() throw 'goQuitApplication: no AppStartup/appShell'; } - var windowManager = Components. - classes['@mozilla.org/appshell/window-mediator;1'].getService(); - - var windowManagerInterface = windowManager. - QueryInterface(Components.interfaces.nsIWindowMediator); - - var enumerator = windowManagerInterface.getEnumerator(null); - - while (enumerator.hasMoreElements()) - { - var domWindow = enumerator.getNext(); - if (("tryToClose" in domWindow) && !domWindow.tryToClose()) - { - return false; - } - domWindow.close(); - } - try { appService.quit(forceQuit); diff --git a/mozilla/layout/tools/reftest/quit.js b/mozilla/layout/tools/reftest/quit.js index e5031d40603..9a212d64656 100644 --- a/mozilla/layout/tools/reftest/quit.js +++ b/mozilla/layout/tools/reftest/quit.js @@ -64,7 +64,6 @@ function canQuitApplication() catch (ex) { } - os.notifyObservers(null, "quit-application-granted", null); return true; } diff --git a/mozilla/testing/mochitest/tests/SimpleTest/quit.js b/mozilla/testing/mochitest/tests/SimpleTest/quit.js index 8b2a33973c9..67c5cc82848 100644 --- a/mozilla/testing/mochitest/tests/SimpleTest/quit.js +++ b/mozilla/testing/mochitest/tests/SimpleTest/quit.js @@ -78,7 +78,6 @@ function canQuitApplication() catch (ex) { } - os.notifyObservers(null, "quit-application-granted", null); return true; } diff --git a/mozilla/toolkit/components/startup/src/nsAppStartup.cpp b/mozilla/toolkit/components/startup/src/nsAppStartup.cpp index 60dc2f3ce8a..6ec6fa545ca 100644 --- a/mozilla/toolkit/components/startup/src/nsAppStartup.cpp +++ b/mozilla/toolkit/components/startup/src/nsAppStartup.cpp @@ -190,6 +190,11 @@ nsAppStartup::Quit(PRUint32 aMode) if (mShuttingDown) return NS_OK; + nsCOMPtr obsService + (do_GetService("@mozilla.org/observer-service;1")); + if (obsService) + obsService->NotifyObservers(nsnull, "quit-application-granted", nsnull); + /* eForceQuit doesn't actually work; it can cause a subtle crash if there are windows open which have unload handlers which open new windows. Use eAttemptQuit for now. */ @@ -264,8 +269,6 @@ nsAppStartup::Quit(PRUint32 aMode) // No chance of the shutdown being cancelled from here on; tell people // we're shutting down for sure while all services are still available. - nsCOMPtr obsService - (do_GetService("@mozilla.org/observer-service;1")); if (obsService) { NS_NAMED_LITERAL_STRING(shutdownStr, "shutdown"); NS_NAMED_LITERAL_STRING(restartStr, "restart"); diff --git a/mozilla/toolkit/content/globalOverlay.js b/mozilla/toolkit/content/globalOverlay.js index bd1a28ac5c9..6efa76500a3 100644 --- a/mozilla/toolkit/content/globalOverlay.js +++ b/mozilla/toolkit/content/globalOverlay.js @@ -43,7 +43,6 @@ function canQuitApplication() return false; } catch (ex) { } - os.notifyObservers(null, "quit-application-granted", null); return true; } diff --git a/mozilla/toolkit/mozapps/extensions/content/extensions.js b/mozilla/toolkit/mozapps/extensions/content/extensions.js index c88a84fc1bf..c9588f33003 100644 --- a/mozilla/toolkit/mozapps/extensions/content/extensions.js +++ b/mozilla/toolkit/mozapps/extensions/content/extensions.js @@ -1543,9 +1543,6 @@ function restartApp() { if (cancelQuit.data) return; - // Notify all windows that an application quit has been granted. - os.notifyObservers(null, "quit-application-granted", null); - Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup) .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit); } diff --git a/mozilla/toolkit/mozapps/extensions/content/list.js b/mozilla/toolkit/mozapps/extensions/content/list.js index 8c8a6231884..b2922df3c44 100755 --- a/mozilla/toolkit/mozapps/extensions/content/list.js +++ b/mozilla/toolkit/mozapps/extensions/content/list.js @@ -212,9 +212,6 @@ function restartApp() { if (cancelQuit.data) return; - // Notify all windows that an application quit has been granted. - os.notifyObservers(null, "quit-application-granted", null); - Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup) .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit); } diff --git a/mozilla/toolkit/mozapps/update/content/updates.js b/mozilla/toolkit/mozapps/update/content/updates.js index b08a631734f..43769d457ad 100755 --- a/mozilla/toolkit/mozapps/update/content/updates.js +++ b/mozilla/toolkit/mozapps/update/content/updates.js @@ -1655,9 +1655,6 @@ var gFinishedPage = { if (cancelQuit.data) return; - // Notify all windows that an application quit has been granted. - os.notifyObservers(null, "quit-application-granted", null); - var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]. getService(Components.interfaces.nsIAppStartup); diff --git a/mozilla/toolkit/xre/MacApplicationDelegate.mm b/mozilla/toolkit/xre/MacApplicationDelegate.mm index 79da26ec9bf..6bb4c51282c 100644 --- a/mozilla/toolkit/xre/MacApplicationDelegate.mm +++ b/mozilla/toolkit/xre/MacApplicationDelegate.mm @@ -273,8 +273,6 @@ static NSWindow* GetCocoaWindowForXULWindow(nsISupports *aXULWindow) if (abortQuit) return NSTerminateCancel; - obsServ->NotifyObservers(nsnull, "quit-application-granted", nsnull); - nsCOMPtr appService = do_GetService("@mozilla.org/toolkit/app-startup;1"); if (appService) diff --git a/mozilla/toolkit/xre/nsCommandLineServiceMac.cpp b/mozilla/toolkit/xre/nsCommandLineServiceMac.cpp index 9d11df56303..adef0a91fd1 100644 --- a/mozilla/toolkit/xre/nsCommandLineServiceMac.cpp +++ b/mozilla/toolkit/xre/nsCommandLineServiceMac.cpp @@ -480,7 +480,6 @@ OSErr nsMacCommandLine::Quit(TAskSave askSave) if (NS_FAILED(rv)) return errAEEventNotHandled; - obsServ->NotifyObservers(nsnull, "quit-application-granted", nsnull); appStartup->Quit(nsIAppStartup::eAttemptQuit); return noErr; } diff --git a/mozilla/toolkit/xre/nsNativeAppSupportUnix.cpp b/mozilla/toolkit/xre/nsNativeAppSupportUnix.cpp index 55de42678c5..807697be75d 100644 --- a/mozilla/toolkit/xre/nsNativeAppSupportUnix.cpp +++ b/mozilla/toolkit/xre/nsNativeAppSupportUnix.cpp @@ -117,14 +117,9 @@ gboolean save_yourself_cb(GnomeClient *client, gint phase, void die_cb(GnomeClient *client, gpointer user_data) { - nsCOMPtr obsServ = - do_GetService("@mozilla.org/observer-service;1"); nsCOMPtr appService = do_GetService("@mozilla.org/toolkit/app-startup;1"); - if (obsServ) - obsServ->NotifyObservers(nsnull, "quit-application-granted", nsnull); - if (appService) appService->Quit(nsIAppStartup::eForceQuit); } diff --git a/mozilla/toolkit/xre/nsNativeAppSupportWin.cpp b/mozilla/toolkit/xre/nsNativeAppSupportWin.cpp index e319bfb8651..6c310a5e983 100644 --- a/mozilla/toolkit/xre/nsNativeAppSupportWin.cpp +++ b/mozilla/toolkit/xre/nsNativeAppSupportWin.cpp @@ -646,14 +646,9 @@ struct MessageWindow { if (wp == FALSE) return TRUE; - nsCOMPtr obsServ = - do_GetService("@mozilla.org/observer-service;1"); nsCOMPtr appService = do_GetService("@mozilla.org/toolkit/app-startup;1"); - if (obsServ) - obsServ->NotifyObservers(nsnull, "quit-application-granted", nsnull); - if (appService) appService->Quit(nsIAppStartup::eForceQuit);