appStartup->EnterLastWindowClosingSurvivalArea();
ShowProfileManager(nsIToolkitProfileService* aProfileSvc,                   nsINativeAppSupport* aNative){  nsresult rv;  nsCOMPtr<nsILocalFile> profD, profLD;  {    ScopedXPCOMStartup xpcom;    rv = xpcom.Initialize();    NS_ENSURE_SUCCESS(rv, rv);    rv = xpcom.RegisterProfileService(aProfileSvc);    rv |= xpcom.DoAutoreg();    rv |= xpcom.InitEventQueue();    rv |= xpcom.SetWindowCreator(aNative);    NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);    { //extra scoping is needed so we release these components before xpcom shutdown      nsCOMPtr<nsIWindowWatcher> windowWatcher        (do_GetService(NS_WINDOWWATCHER_CONTRACTID));      nsCOMPtr<nsIDialogParamBlock> ioParamBlock        (do_CreateInstance(NS_DIALOGPARAMBLOCK_CONTRACTID));      nsCOMPtr<nsIMutableArray> dlgArray (do_CreateInstance(NS_ARRAY_CONTRACTID));      NS_ENSURE_TRUE(windowWatcher && ioParamBlock && dlgArray, NS_ERROR_FAILURE);      ioParamBlock->SetObjects(dlgArray);      nsCOMPtr<nsIAppStartup> appStartup        (do_GetService(NS_APPSTARTUP_CONTRACTID));      NS_ENSURE_TRUE(appStartup, NS_ERROR_FAILURE);      appStartup->EnterLastWindowClosingSurvivalArea();      nsCOMPtr<nsIDOMWindow> newWindow;      rv = windowWatcher->OpenWindow(nsnull,                                     kProfileManagerURL,                                     "_blank",                                     "centerscreen,chrome,modal,titlebar",                                     ioParamBlock,                                     getter_AddRefs(newWindow));      appStartup->ExitLastWindowClosingSurvivalArea();      NS_ENSURE_SUCCESS_LOG(rv, rv);      aProfileSvc->Flush();      PRInt32 dialogConfirmed;      rv = ioParamBlock->GetInt(0, &dialogConfirmed);      if (NS_FAILED(rv) || dialogConfirmed == 0) return NS_ERROR_ABORT;      nsCOMPtr<nsIProfileLock> lock;      rv = dlgArray->QueryElementAt(0, NS_GET_IID(nsIProfileLock),                                    getter_AddRefs(lock));      NS_ENSURE_SUCCESS_LOG(rv, rv);      rv = lock->GetDirectory(getter_AddRefs(profD));      NS_ENSURE_SUCCESS(rv, rv);      rv = lock->GetLocalDirectory(getter_AddRefs(profLD));      NS_ENSURE_SUCCESS(rv, rv);      lock->Unlock();    }  }  SaveFileToEnv("XRE_PROFILE_PATH", profD);  SaveFileToEnv("XRE_PROFILE_LOCAL_PATH", profLD);  PRBool offline = PR_FALSE;  aProfileSvc->GetStartOffline(&offline);  if (offline) {    PR_SetEnv("XRE_START_OFFLINE=1");  }  return LaunchChild(aNative);}