Bug 372453 - XULRunner apps should quit if the hidden window is not useful and no other windows are open

r=benjamin@smedbergs.us (Benjamin Smedberg)
r=joshmoz@gmail.com (Josh Aas)
This commit is contained in:
gijskruitbosch%gmail.com 2007-05-25 19:54:32 +00:00
Родитель 079fe65bc9
Коммит 4d9a7c26cf
4 изменённых файлов: 45 добавлений и 6 удалений

Просмотреть файл

@ -206,9 +206,31 @@ nsAppStartup::Quit(PRUint32 aMode)
nsCOMPtr<nsIWindowMediator> mediator
(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
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;
}
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;
}
}
/* Currently ferocity can never have the value of eForceQuit here.
@ -364,8 +386,8 @@ nsAppStartup::ExitLastWindowClosingSurvivalArea(void)
NS_ASSERTION(mConsiderQuitStopper > 0, "consider quit stopper out of bounds");
--mConsiderQuitStopper;
if (!mShuttingDown && mRunning && mConsiderQuitStopper == 0)
Quit(eAttemptQuit);
if (!mShuttingDown && mRunning && (mConsiderQuitStopper <= 1))
Quit(eConsiderQuit);
return NS_OK;
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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)
*/

Просмотреть файл

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