From eb8a59b8ab29c27c110a7104ec19934dd0b3db3a Mon Sep 17 00:00:00 2001 From: Brian Crowder Date: Wed, 26 Aug 2009 16:11:21 -0700 Subject: [PATCH] Bug 512728 - Fast startup allows restarts and activates itself always. -faststart-hidden only prevents the default chrome window from being shown. r=gavin --- toolkit/components/faststart/FastStartup.js | 27 +++++++++++++------ .../components/faststart/faststartstub.cpp | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/toolkit/components/faststart/FastStartup.js b/toolkit/components/faststart/FastStartup.js index 78821ad69ebf..ceda8fbad6da 100644 --- a/toolkit/components/faststart/FastStartup.js +++ b/toolkit/components/faststart/FastStartup.js @@ -114,11 +114,19 @@ function nsFastStartupObserver() { if (_browserWindowCount == 0) scheduleMemoryCleanup(); } + } else if (topic == "quit-application-granted") { + let appstartup = Cc["@mozilla.org/toolkit/app-startup;1"]. + getService(Ci.nsIAppStartup); + appstartup.exitLastWindowClosingSurvivalArea(); } } - // QI - this.QueryInterface = XPCOMUtils.generateQI([Ci.nsIObserver]); + /* + * QueryInterface + * We expect the WindowWatcher service to retain a strong reference to us, so supporting + * weak references is fine. + */ + this.QueryInterface = XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]); } function nsFastStartupCLH() { } @@ -129,10 +137,8 @@ nsFastStartupCLH.prototype = { // handle: function fs_handle(cmdLine) { // the rest of this only handles -faststart here - if (!cmdLine.handleFlag("faststart", false)) - return; - - cmdLine.preventDefault = true; + if (cmdLine.handleFlag("faststart-hidden", false)) + cmdLine.preventDefault = true; try { // did we already initialize faststart? if so, @@ -142,19 +148,24 @@ nsFastStartupCLH.prototype = { this.inited = true; + let fsobs = new nsFastStartupObserver(); let wwatch = Cc["@mozilla.org/embedcomp/window-watcher;1"]. getService(Ci.nsIWindowWatcher); - wwatch.registerNotification(new nsFastStartupObserver()); + wwatch.registerNotification(fsobs); let appstartup = Cc["@mozilla.org/toolkit/app-startup;1"]. getService(Ci.nsIAppStartup); + + let obsService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); + obsService.addObserver(fsobs, "quit-application-granted", true); + appstartup.enterLastWindowClosingSurvivalArea(); } catch (e) { Cu.reportError(e); } }, - helpInfo: " -faststart\n", + helpInfo: " -faststart-hidden\n", // QI QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]), diff --git a/toolkit/components/faststart/faststartstub.cpp b/toolkit/components/faststart/faststartstub.cpp index 7884a277071c..1b88902f132d 100644 --- a/toolkit/components/faststart/faststartstub.cpp +++ b/toolkit/components/faststart/faststartstub.cpp @@ -14,7 +14,7 @@ WinMain(HINSTANCE hInstance, wchar_t modfilename[MAX_PATH]; wchar_t execname[MAX_PATH]; wchar_t args[MAX_PATH]; - wcscpy(args, L"-nosplash -faststart"); + wcscpy(args, L"-nosplash -faststart-hidden"); HMODULE mod = GetModuleHandle(NULL); GetModuleFileNameW(mod, modfilename, sizeof(modfilename)/sizeof(modfilename[0]));