Bug 1086936 part 2 - Add a flag to nsIAppStartup::quit that restarts the browser without using the same profile and use it for the Aurora UI switch. r=bsmedberg

This commit is contained in:
Panos Astithas 2014-10-27 21:46:56 +02:00
parent 3ac61e6080
commit b7cb73552a
7 changed files with 37 additions and 11 deletions

View File

@ -171,7 +171,7 @@ var gMainPane = {
separateProfileModeChange: function ()
{
function quitApp() {
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestartNotSameProfile);
}
function revertCheckbox(error) {
separateProfileModeCheckbox.checked = !separateProfileModeCheckbox.checked;

View File

@ -87,7 +87,7 @@ var gMainPane = {
separateProfileModeChange: function ()
{
function quitApp() {
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestartNotSameProfile);
}
function revertCheckbox(error) {
separateProfileModeCheckbox.checked = !separateProfileModeCheckbox.checked;

View File

@ -143,7 +143,8 @@ nsAppStartup::nsAppStartup() :
mInterrupted(false),
mIsSafeModeNecessary(false),
mStartupCrashTrackingEnded(false),
mRestartTouchEnvironment(false)
mRestartTouchEnvironment(false),
mRestartNotSameProfile(false)
{ }
@ -287,6 +288,8 @@ nsAppStartup::Run(void)
retval = NS_SUCCESS_RESTART_METRO_APP;
} else if (mRestart) {
retval = NS_SUCCESS_RESTART_APP;
} else if (mRestartNotSameProfile) {
retval = NS_SUCCESS_RESTART_APP_NOT_SAME_PROFILE;
}
return retval;
@ -386,7 +389,12 @@ nsAppStartup::Quit(uint32_t aMode)
gRestartMode = (aMode & 0xF0);
}
if (mRestart || mRestartTouchEnvironment) {
if (!mRestartNotSameProfile) {
mRestartNotSameProfile = (aMode & eRestartNotSameProfile) != 0;
gRestartMode = (aMode & 0xF0);
}
if (mRestart || mRestartTouchEnvironment || mRestartNotSameProfile) {
// Mark the next startup as a restart.
PR_SetEnv("MOZ_APP_RESTART=1");
@ -456,7 +464,7 @@ nsAppStartup::Quit(uint32_t aMode)
NS_NAMED_LITERAL_STRING(shutdownStr, "shutdown");
NS_NAMED_LITERAL_STRING(restartStr, "restart");
obsService->NotifyObservers(nullptr, "quit-application",
(mRestart || mRestartTouchEnvironment) ?
(mRestart || mRestartTouchEnvironment || mRestartNotSameProfile) ?
restartStr.get() : shutdownStr.get());
}

View File

@ -62,7 +62,8 @@ private:
bool mInterrupted; // Was startup interrupted by an interactive prompt?
bool mIsSafeModeNecessary; // Whether safe mode is necessary
bool mStartupCrashTrackingEnded; // Whether startup crash tracking has already ended
bool mRestartTouchEnvironment; // Quit (eRestartTouchEnvironment)
bool mRestartTouchEnvironment; // Quit (eRestartTouchEnvironment)
bool mRestartNotSameProfile; // Quit(eRestartNotSameProfile)
#if defined(XP_WIN)
//Interaction with OS-provided profiling probes

View File

@ -36,6 +36,11 @@ interface nsIAppStartup : nsISupports
* This return code indicates that the application should be
* restarted in metro because quit was called with the
* eRestartTouchEnviroment flag.
* @returnCode NS_SUCCESS_RESTART_APP_NOT_SAME_PROFILE
* This return code indicates that the application should be
* restarted without necessarily using the same profile because
* quit was called with the eRestartNotSameProfile flag.
*/
void run();
@ -134,6 +139,13 @@ interface nsIAppStartup : nsISupports
*/
const uint32_t eRestartTouchEnvironment = 0x80;
/**
* Restart the application after quitting. The application will be
* restarted with an empty command line and the normal profile selection
* process will take place on startup.
*/
const uint32_t eRestartNotSameProfile = 0x100;
/**
* Exit the event loop, and shut down the app.
*

View File

@ -4176,7 +4176,9 @@ XREMain::XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
// Check for an application initiated restart. This is one that
// corresponds to nsIAppStartup.quit(eRestart)
if (rv == NS_SUCCESS_RESTART_APP || rv == NS_SUCCESS_RESTART_METRO_APP) {
if (rv == NS_SUCCESS_RESTART_APP
|| rv == NS_SUCCESS_RESTART_METRO_APP
|| rv == NS_SUCCESS_RESTART_APP_NOT_SAME_PROFILE) {
appInitiatedRestart = true;
// We have an application restart don't do any shutdown checks here
@ -4209,10 +4211,12 @@ XREMain::XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
if (appInitiatedRestart) {
RestoreStateForAppInitiatedRestart();
// Ensure that these environment variables are set:
SaveFileToEnvIfUnset("XRE_PROFILE_PATH", mProfD);
SaveFileToEnvIfUnset("XRE_PROFILE_LOCAL_PATH", mProfLD);
SaveWordToEnvIfUnset("XRE_PROFILE_NAME", mProfileName);
if (rv != NS_SUCCESS_RESTART_APP_NOT_SAME_PROFILE) {
// Ensure that these environment variables are set:
SaveFileToEnvIfUnset("XRE_PROFILE_PATH", mProfD);
SaveFileToEnvIfUnset("XRE_PROFILE_LOCAL_PATH", mProfLD);
SaveWordToEnvIfUnset("XRE_PROFILE_NAME", mProfileName);
}
#ifdef MOZ_WIDGET_GTK
MOZ_gdk_display_close(mGdkDisplay);

View File

@ -906,6 +906,7 @@
* case in which nsIAppStartup::Quit was called with the eRestart flag. */
ERROR(NS_SUCCESS_RESTART_APP, SUCCESS(1)),
ERROR(NS_SUCCESS_RESTART_METRO_APP, SUCCESS(2)),
ERROR(NS_SUCCESS_RESTART_APP_NOT_SAME_PROFILE, SUCCESS(3)),
ERROR(NS_SUCCESS_UNORM_NOTFOUND, SUCCESS(17)),