summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--browser/components/migration/FirefoxProfileMigrator.js2
-rw-r--r--browser/components/migration/MigrationUtils.jsm1
-rw-r--r--toolkit/modules/ResetProfile.jsm6
-rw-r--r--toolkit/xre/ProfileReset.cpp12
-rw-r--r--toolkit/xre/ProfileReset.h1
-rw-r--r--toolkit/xre/nsAppRunner.cpp101
6 files changed, 78 insertions, 45 deletions
diff --git a/browser/components/migration/FirefoxProfileMigrator.js b/browser/components/migration/FirefoxProfileMigrator.js
index 60ffcf627..2714cdbcd 100644
--- a/browser/components/migration/FirefoxProfileMigrator.js
+++ b/browser/components/migration/FirefoxProfileMigrator.js
@@ -7,7 +7,7 @@
"use strict";
/*
- * Migrates from a Firefox profile in a lossy manner in order to clean up a
+ * Migrates from a Basilisk profile in a lossy manner in order to clean up a
* user's profile. Data is only migrated where the benefits outweigh the
* potential problems caused by importing undesired/invalid configurations
* from the source profile.
diff --git a/browser/components/migration/MigrationUtils.jsm b/browser/components/migration/MigrationUtils.jsm
index 104efe005..e133ec520 100644
--- a/browser/components/migration/MigrationUtils.jsm
+++ b/browser/components/migration/MigrationUtils.jsm
@@ -726,6 +726,7 @@ this.MigrationUtils = Object.freeze({
"Internet Explorer": "ie",
"Microsoft Edge": "edge",
"Safari": "safari",
+ "Basilisk": "firefox",
"Firefox": "firefox",
"Nightly": "firefox",
"Google Chrome": "chrome", // Windows, Linux
diff --git a/toolkit/modules/ResetProfile.jsm b/toolkit/modules/ResetProfile.jsm
index fe0d1cfe8..c1839af4f 100644
--- a/toolkit/modules/ResetProfile.jsm
+++ b/toolkit/modules/ResetProfile.jsm
@@ -11,7 +11,11 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
-const MOZ_APP_NAME = AppConstants.MOZ_APP_NAME;
+// For Basilisk and Pale Moon
+// Hard-code MOZ_APP_NAME to firefox because of hard-coded type in migrator.
+const MOZ_APP_NAME = (((AppConstants.MOZ_APP_NAME == "basilisk")
+ || (AppConstants.MOZ_APP_NAME == "palemoon"))
+ ? "firefox" : AppConstants.MOZ_APP_NAME);
const MOZ_BUILD_APP = AppConstants.MOZ_BUILD_APP;
this.ResetProfile = {
diff --git a/toolkit/xre/ProfileReset.cpp b/toolkit/xre/ProfileReset.cpp
index aef2d7746..c9e2ef8d4 100644
--- a/toolkit/xre/ProfileReset.cpp
+++ b/toolkit/xre/ProfileReset.cpp
@@ -31,13 +31,19 @@ static const char kProfileProperties[] =
* Creates a new profile with a timestamp in the name to use for profile reset.
*/
nsresult
-CreateResetProfile(nsIToolkitProfileService* aProfileSvc, nsIToolkitProfile* *aNewProfile)
+CreateResetProfile(nsIToolkitProfileService* aProfileSvc, const nsACString& aOldProfileName, nsIToolkitProfile* *aNewProfile)
{
MOZ_ASSERT(aProfileSvc, "NULL profile service");
nsCOMPtr<nsIToolkitProfile> newProfile;
- // Make the new profile "default-" + the time in seconds since epoch for uniqueness.
- nsAutoCString newProfileName("default-");
+ // Make the new profile the old profile (or "default-") + the time in seconds since epoch for uniqueness.
+ nsAutoCString newProfileName;
+ if (!aOldProfileName.IsEmpty()) {
+ newProfileName.Assign(aOldProfileName);
+ newProfileName.Append("-");
+ } else {
+ newProfileName.Assign("default-");
+ }
newProfileName.Append(nsPrintfCString("%lld", PR_Now() / 1000));
nsresult rv = aProfileSvc->CreateProfile(nullptr, // choose a default dir for us
newProfileName,
diff --git a/toolkit/xre/ProfileReset.h b/toolkit/xre/ProfileReset.h
index 7b5efbc4e..a164fe075 100644
--- a/toolkit/xre/ProfileReset.h
+++ b/toolkit/xre/ProfileReset.h
@@ -11,6 +11,7 @@ static bool gProfileResetCleanupCompleted = false;
static const char kResetProgressURL[] = "chrome://global/content/resetProfileProgress.xul";
nsresult CreateResetProfile(nsIToolkitProfileService* aProfileSvc,
+ const nsACString& aOldProfileName,
nsIToolkitProfile* *aNewProfile);
nsresult ProfileResetCleanup(nsIToolkitProfile* aOldProfile);
diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
index 530e4a353..776044d72 100644
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -1357,7 +1357,9 @@ DumpHelp()
" -v or --version Print %s version.\n"
" -P <profile> Start with <profile>.\n"
" --profile <path> Start with profile at <path>.\n"
+#ifdef MC_BASILISK
" --migration Start with migration wizard.\n"
+#endif
" --ProfileManager Start with ProfileManager.\n"
" --no-remote Do not accept or send remote commands;\n"
" implies --new-instance.\n"
@@ -1886,17 +1888,20 @@ ShowProfileManager(nsIToolkitProfileService* aProfileSvc,
}
/**
- * Set the currently running profile as the default/selected one.
+ * Get the currently running profile using its root directory.
*
+ * @param aProfileSvc The profile service
* @param aCurrentProfileRoot The root directory of the current profile.
- * @return an error if aCurrentProfileRoot is not found or the profile could not
- * be set as the default.
+ * @param aProfile Out-param that returns the profile object.
+ * @return an error if aCurrentProfileRoot is not found
*/
static nsresult
-SetCurrentProfileAsDefault(nsIToolkitProfileService* aProfileSvc,
- nsIFile* aCurrentProfileRoot)
+GetCurrentProfile(nsIToolkitProfileService* aProfileSvc,
+ nsIFile* aCurrentProfileRoot,
+ nsIToolkitProfile** aProfile)
{
NS_ENSURE_ARG_POINTER(aProfileSvc);
+ NS_ENSURE_ARG_POINTER(aProfile);
nsCOMPtr<nsISimpleEnumerator> profiles;
nsresult rv = aProfileSvc->GetProfiles(getter_AddRefs(profiles));
@@ -1912,7 +1917,8 @@ SetCurrentProfileAsDefault(nsIToolkitProfileService* aProfileSvc,
profile->GetRootDir(getter_AddRefs(profileRoot));
profileRoot->Equals(aCurrentProfileRoot, &foundMatchingProfile);
if (foundMatchingProfile) {
- return aProfileSvc->SetSelectedProfile(profile);
+ profile.forget(aProfile);
+ return NS_OK;
}
rv = profiles->GetNext(getter_AddRefs(supports));
}
@@ -2000,7 +2006,7 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n
if (gDoProfileReset) {
// If we're resetting a profile, create a new one and use it to startup.
nsCOMPtr<nsIToolkitProfile> newProfile;
- rv = CreateResetProfile(aProfileSvc, getter_AddRefs(newProfile));
+ rv = CreateResetProfile(aProfileSvc, gResetOldProfileName, getter_AddRefs(newProfile));
if (NS_SUCCEEDED(rv)) {
rv = newProfile->GetRootDir(getter_AddRefs(lf));
NS_ENSURE_SUCCESS(rv, rv);
@@ -2146,20 +2152,20 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n
return ProfileLockedDialog(profile, unlocker, aNative, &tempProfileLock);
}
- nsCOMPtr<nsIToolkitProfile> newProfile;
- rv = CreateResetProfile(aProfileSvc, getter_AddRefs(newProfile));
- if (NS_FAILED(rv)) {
- NS_WARNING("Failed to create a profile to reset to.");
- gDoProfileReset = false;
- } else {
- nsresult gotName = profile->GetName(gResetOldProfileName);
- if (NS_SUCCEEDED(gotName)) {
- profile = newProfile;
- } else {
- NS_WARNING("Failed to get the name of the profile we're resetting, so aborting reset.");
- gResetOldProfileName.Truncate(0);
+ nsresult gotName = profile->GetName(gResetOldProfileName);
+ if (NS_SUCCEEDED(gotName)) {
+ nsCOMPtr<nsIToolkitProfile> newProfile;
+ rv = CreateResetProfile(aProfileSvc, gResetOldProfileName, getter_AddRefs(newProfile));
+ if (NS_FAILED(rv)) {
+ NS_WARNING("Failed to create a profile to reset to.");
gDoProfileReset = false;
+ } else {
+ profile = newProfile;
}
+ } else {
+ NS_WARNING("Failed to get the name of the profile we're resetting, so aborting reset.");
+ gResetOldProfileName.Truncate(0);
+ gDoProfileReset = false;
}
}
@@ -2254,20 +2260,22 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n
return ProfileLockedDialog(profile, unlocker, aNative, &tempProfileLock);
}
- nsCOMPtr<nsIToolkitProfile> newProfile;
- rv = CreateResetProfile(aProfileSvc, getter_AddRefs(newProfile));
- if (NS_FAILED(rv)) {
- NS_WARNING("Failed to create a profile to reset to.");
- gDoProfileReset = false;
- } else {
- nsresult gotName = profile->GetName(gResetOldProfileName);
- if (NS_SUCCEEDED(gotName)) {
- profile = newProfile;
- } else {
- NS_WARNING("Failed to get the name of the profile we're resetting, so aborting reset.");
- gResetOldProfileName.Truncate(0);
+ nsresult gotName = profile->GetName(gResetOldProfileName);
+ if (NS_SUCCEEDED(gotName)) {
+ nsCOMPtr<nsIToolkitProfile> newProfile;
+ rv = CreateResetProfile(aProfileSvc, gResetOldProfileName, getter_AddRefs(newProfile));
+ if (NS_FAILED(rv)) {
+ NS_WARNING("Failed to create a profile to reset to.");
gDoProfileReset = false;
}
+ else {
+ profile = newProfile;
+ }
+ }
+ else {
+ NS_WARNING("Failed to get the name of the profile we're resetting, so aborting reset.");
+ gResetOldProfileName.Truncate(0);
+ gDoProfileReset = false;
}
}
@@ -3739,7 +3747,12 @@ XREMain::XRE_mainRun()
if (gDoProfileReset) {
// Automatically migrate from the current application if we just
// reset the profile.
- aKey = MOZ_APP_NAME;
+ // For Basilisk and Pale Moon:
+ // Hard-code MOZ_APP_NAME to firefox because of hard-coded type in migrator.
+ aKey = (((MOZ_APP_NAME == "basilisk")
+ || (MOZ_APP_NAME == "palemoon"))
+ ? "firefox" : MOZ_APP_NAME);
+
}
pm->Migrate(&mDirProvider, aKey, gResetOldProfileName);
}
@@ -3749,15 +3762,23 @@ XREMain::XRE_mainRun()
nsresult backupCreated = ProfileResetCleanup(profileBeingReset);
if (NS_FAILED(backupCreated)) NS_WARNING("Could not cleanup the profile that was reset");
- // Set the new profile as the default after we're done cleaning up the old profile,
- // iff that profile was already the default
- if (profileWasSelected) {
- // this is actually "broken" - see bug 1122124
- rv = SetCurrentProfileAsDefault(mProfileSvc, mProfD);
- if (NS_FAILED(rv)) NS_WARNING("Could not set current profile as the default");
+ nsCOMPtr<nsIToolkitProfile> newProfile;
+ rv = GetCurrentProfile(mProfileSvc, mProfD, getter_AddRefs(newProfile));
+ if (NS_SUCCEEDED(rv)) {
+ newProfile->SetName(gResetOldProfileName);
+ mProfileName.Assign(gResetOldProfileName);
+ // Set the new profile as the default after we're done cleaning up the old profile,
+ // iff that profile was already the default
+ if (profileWasSelected) {
+ rv = mProfileSvc->SetDefaultProfile(newProfile);
+ if (NS_FAILED(rv)) NS_WARNING("Could not set current profile as the default");
+ }
+ } else {
+ NS_WARNING("Could not find current profile to set as default / change name.");
}
- // Need to write out the fact that the profile has been removed and potentially
- // that the selected/default profile changed.
+
+ // Need to write out the fact that the profile has been removed, the new profile
+ // renamed, and potentially that the selected/default profile changed.
mProfileSvc->Flush();
}
}