Bug 1265368 - enable refresh to be used with the -p switch, r=MattN

MozReview-Commit-ID: 7LAkVljrlAS

--HG--
extra : rebase_source : d2c8e237de0809d571d83cf6658fda150863b0b3
extra : histedit_source : 5289b6c7fa764443f4c3a139cce4e4c1e7d1bc78
This commit is contained in:
Gijs Kruitbosch 2016-04-18 13:46:47 +01:00
parent 939515d3cc
commit 88ffc8d332

View File

@ -2460,8 +2460,30 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n
getter_AddRefs(profile));
if (NS_SUCCEEDED(rv)) {
if (gDoProfileReset) {
NS_WARNING("Profile reset is not supported in conjunction with -p .");
{
// Check that the source profile is not in use by temporarily acquiring its lock.
nsIProfileLock* tempProfileLock;
nsCOMPtr<nsIProfileUnlocker> unlocker;
rv = profile->Lock(getter_AddRefs(unlocker), &tempProfileLock);
if (NS_FAILED(rv))
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);
gDoProfileReset = false;
}
}
}
nsCOMPtr<nsIProfileUnlocker> unlocker;