215094 - 235364 - invoke automigration code if there are no existing profiles in phoenix (will eventually becoem MOZ_XULAPP, and may move to xre/apprunner or a startup service). r=danm

This commit is contained in:
ben%bengoodger.com 2004-03-03 21:33:47 +00:00
Родитель ce905b03db
Коммит 279e23a6b5
2 изменённых файлов: 32 добавлений и 2 удалений

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

@ -85,6 +85,9 @@ static PRBool OnMacOSX();
#include "nsAppShellService.h"
#include "nsIProfileInternal.h"
#ifdef MOZ_PHOENIX
#include "nsIProfileMigrator.h"
#endif
#include "nsIProfileChangeStatus.h"
#include "nsICloseAllWindows.h"
#include "nsISupportsPrimitives.h"
@ -267,18 +270,41 @@ nsAppShellService::DoProfileStartup(nsICmdLineService *aCmdLineService, PRBool c
EnterLastWindowClosingSurvivalArea();
#ifdef MOZ_PHOENIX
// This will eventually change to MOZ_XULAPP
PRInt32 numProfiles = 0;
profileMgr->GetProfileCount(&numProfiles);
if (numProfiles == 0) {
nsCOMPtr<nsIProfileMigrator> pm(do_CreateInstance("@mozilla.org/profile/migrator;1", &rv));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIObserver> obs(do_QueryInterface(pm));
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
os->AddObserver(obs, "profile-initial-state", PR_FALSE);
rv = pm->Migrate();
}
if (NS_FAILED(rv)) {
// Migration failed for some reason, or there was no profile migrator.
// Create a generic default profile.
rv = profileMgr->CreateDefaultProfile();
}
}
#endif
// If we are being launched in turbo mode, profile mgr cannot show UI
rv = profileMgr->StartupWithArgs(aCmdLineService, canInteract);
if (!canInteract && rv == NS_ERROR_PROFILE_REQUIRES_INTERACTION) {
NS_WARNING("nsIProfileInternal::StartupWithArgs returned NS_ERROR_PROFILE_REQUIRES_INTERACTION");
rv = NS_OK;
}
#ifndef MOZ_PHOENIX
if (NS_SUCCEEDED(rv)) {
rv = CheckAndRemigrateDefunctProfile();
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to check and remigrate profile");
rv = NS_OK;
}
#endif
ExitLastWindowClosingSurvivalArea();
@ -288,6 +314,7 @@ nsAppShellService::DoProfileStartup(nsICmdLineService *aCmdLineService, PRBool c
return rv;
}
#ifndef MOZ_PHOENIX
nsresult
nsAppShellService::CheckAndRemigrateDefunctProfile()
{
@ -419,6 +446,7 @@ nsAppShellService::CheckAndRemigrateDefunctProfile()
}
return NS_OK;
}
#endif
NS_IMETHODIMP
nsAppShellService::CreateHiddenWindow()

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

@ -95,8 +95,10 @@ protected:
PR_STATIC_CALLBACK(void) DestroyExitEvent(PLEvent* aEvent);
private:
#ifndef MOZ_PHOENIX
nsresult CheckAndRemigrateDefunctProfile();
#endif
nsresult LaunchTask(const char *aParam,
PRInt32 height, PRInt32 width,
PRBool *windowOpened);