Bug 372453 - XULRunner apps on mac without a hiddenwindow should be able to quit

r=benjamin@smedbergs.us
r=joshmoz@gmail.com
a=bzbarsky@mit.edu


git-svn-id: svn://10.0.0.236/trunk@232966 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
gijskruitbosch%gmail.com 2007-08-23 21:30:30 +00:00
parent 37dada0cd0
commit 319da2c47e
4 changed files with 52 additions and 6 deletions

View File

@ -207,9 +207,33 @@ nsAppStartup::Quit(PRUint32 aMode)
if (!mRestart)
mRestart = aMode & eRestart;
if (ferocity == eConsiderQuit && mConsiderQuitStopper == 0) {
// attempt quit if the last window has been unregistered/closed
ferocity = eAttemptQuit;
// If we're considering quitting, we will only do so if:
if (ferocity == eConsiderQuit) {
if (mConsiderQuitStopper == 0) {
// there are no windows...
ferocity = eAttemptQuit;
}
#ifdef XP_MACOSX
else if (mConsiderQuitStopper == 1) {
// ... or there is only a hiddenWindow left, and it's useless:
nsCOMPtr<nsIAppShellService> appShell
(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
// Failure shouldn't be fatal, but will abort quit attempt:
if (!appShell)
return NS_OK;
PRBool usefulHiddenWindow;
appShell->GetApplicationProvidedHiddenWindow(&usefulHiddenWindow);
nsCOMPtr<nsIXULWindow> hiddenWindow;
appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
// If the one window is useful, we won't quit:
if (!hiddenWindow || usefulHiddenWindow)
return NS_OK;
ferocity = eAttemptQuit;
}
#endif
}
/* Currently ferocity can never have the value of eForceQuit here.
@ -369,8 +393,13 @@ nsAppStartup::ExitLastWindowClosingSurvivalArea(void)
NS_ASSERTION(mConsiderQuitStopper > 0, "consider quit stopper out of bounds");
--mConsiderQuitStopper;
if (!mShuttingDown && mRunning && mConsiderQuitStopper == 0)
Quit(eAttemptQuit);
#ifdef XP_MACOSX
if (!mShuttingDown && mRunning && (mConsiderQuitStopper <= 1))
Quit(eConsiderQuit);
#else
if (!mShuttingDown && mRunning && (mConsiderQuitStopper == 0))
Quit(eConsiderQuit);
#endif
return NS_OK;
}

View File

@ -110,6 +110,13 @@ interface nsIAppShellService : nsISupports
void getHiddenWindowAndJSContext(out nsIDOMWindowInternal aHiddenDOMWindow,
out JSContext aJSContext);
/**
* Return true if the application hidden window was provided by the
* application. If it wasn't, the default hidden window was used. This will
* usually be false on all non-mac platforms.
*/
readonly attribute boolean applicationProvidedHiddenWindow;
/**
* Add a window to the application's registry of windows. These windows
* are generally shown in the Windows taskbar, and the application

View File

@ -84,7 +84,8 @@ class nsIAppShell;
nsAppShellService::nsAppShellService() :
mXPCOMShuttingDown(PR_FALSE),
mModalWindowCount(0)
mModalWindowCount(0),
mApplicationProvidedHiddenWindow(PR_FALSE)
{
nsCOMPtr<nsIObserverService> obs
(do_GetService("@mozilla.org/observer-service;1"));
@ -162,6 +163,7 @@ nsAppShellService::CreateHiddenWindow(nsIAppShell* aAppShell)
nsXPIDLCString prefVal;
rv = prefBranch->GetCharPref("browser.hiddenWindowChromeURL", getter_Copies(prefVal));
const char* hiddenWindowURL = prefVal.get() ? prefVal.get() : DEFAULT_HIDDENWINDOW_URL;
mApplicationProvidedHiddenWindow = prefVal.get() ? PR_TRUE : PR_FALSE;
#else
static const char hiddenWindowURL[] = DEFAULT_HIDDENWINDOW_URL;
PRUint32 chromeMask = nsIWebBrowserChrome::CHROME_ALL;
@ -446,6 +448,13 @@ nsAppShellService::GetHiddenWindowAndJSContext(nsIDOMWindowInternal **aWindow,
return rv;
}
NS_IMETHODIMP
nsAppShellService::GetApplicationProvidedHiddenWindow(PRBool* aAPHW)
{
*aAPHW = mApplicationProvidedHiddenWindow;
return NS_OK;
}
/*
* Register a new top level window (created elsewhere)
*/

View File

@ -76,6 +76,7 @@ protected:
nsRefPtr<nsWebShellWindow> mHiddenWindow;
PRPackedBool mXPCOMShuttingDown;
PRUint16 mModalWindowCount;
PRPackedBool mApplicationProvidedHiddenWindow;
};
#endif