summaryrefslogtreecommitdiffstats
path: root/toolkit
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/xre/ProfileReset.cpp12
-rw-r--r--toolkit/xre/ProfileReset.h1
-rw-r--r--toolkit/xre/nsAppRunner.cpp52
3 files changed, 37 insertions, 28 deletions
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 a7b2b5146..cf6797599 100644
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2004,7 +2004,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);
@@ -2150,20 +2150,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;
}
}
@@ -2258,20 +2258,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;
}
}