Bug 807757 part PSM - Remove nsIProfileChangeStatus and related veto notifications from PSM r=bsmith

--HG--
extra : rebase_source : a4611953352684c48913501d26e8ce782ba04f8f
This commit is contained in:
Benjamin Smedberg 2012-12-13 12:20:00 -05:00
parent f681aaffe9
commit e4c1ae9fc4
3 changed files with 5 additions and 68 deletions

View File

@ -349,8 +349,6 @@ CrlImportFailureNetworkProblem=Download of the CRL failed due to Network problem
CrlImportFailureReasonUnknown=Error Importing CRL to local Database. Error Code:
CrlImportFailure2=Please ask your system administrator for assistance.
NSSInitProblemX=Could not initialize the application's security component. The most likely cause is problems with files in your application's profile directory. Please check that this directory has no read/write restrictions and your hard disk is not full or close to full. It is recommended that you exit the application and fix the problem. If you continue to use this session, you might see incorrect application behaviour when accessing security features.
ProfileSwitchSocketsStillActive=The operation cannot be completed because of an internal failure. A secure network communication has not been cleaned up correctly.
ProfileSwitchCryptoUIActive=This operation is impossible at the current time. Please complete the operation that requests your attention in one of the other open windows.
VerifyExpired=<Expired>
VerifyRevoked=<Revoked>
VerifyNotTrusted=<Not Trusted>

View File

@ -24,7 +24,6 @@
#include "nsDirectoryServiceDefs.h"
#include "nsIX509Cert.h"
#include "nsIX509CertDB.h"
#include "nsIProfileChangeStatus.h"
#include "nsNSSCertificate.h"
#include "nsNSSHelper.h"
#include "nsSmartCardMonitor.h"
@ -1831,7 +1830,7 @@ nsNSSComponent::InitializeNSS(bool showWarningBox)
return NS_OK;
}
nsresult
void
nsNSSComponent::ShutdownNSS()
{
// Can be called both during init and profile change,
@ -1840,7 +1839,6 @@ nsNSSComponent::ShutdownNSS()
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsNSSComponent::ShutdownNSS\n"));
MutexAutoLock lock(mutex);
nsresult rv = NS_OK;
if (hashTableCerts) {
PL_HashTableEnumerateEntries(hashTableCerts, certHashtable_clearEntry, 0);
@ -1868,14 +1866,11 @@ nsNSSComponent::ShutdownNSS()
EnsureNSSInitialized(nssShutdown);
if (SECSuccess != ::NSS_Shutdown()) {
PR_LOG(gPIPNSSLog, PR_LOG_ALWAYS, ("NSS SHUTDOWN FAILURE\n"));
rv = NS_ERROR_FAILURE;
}
else {
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("NSS shutdown =====>> OK <<=====\n"));
}
}
return rv;
}
NS_IMETHODIMP
@ -2133,9 +2128,7 @@ nsNSSComponent::RandomUpdate(void *entropy, int32_t bufLen)
#define PROFILE_CHANGE_NET_TEARDOWN_TOPIC "profile-change-net-teardown"
#define PROFILE_CHANGE_NET_RESTORE_TOPIC "profile-change-net-restore"
#define PROFILE_APPROVE_CHANGE_TOPIC "profile-approve-change"
#define PROFILE_CHANGE_TEARDOWN_TOPIC "profile-change-teardown"
#define PROFILE_CHANGE_TEARDOWN_VETO_TOPIC "profile-change-teardown-veto"
#define PROFILE_BEFORE_CHANGE_TOPIC "profile-before-change"
#define PROFILE_DO_CHANGE_TOPIC "profile-do-change"
@ -2143,16 +2136,10 @@ NS_IMETHODIMP
nsNSSComponent::Observe(nsISupports *aSubject, const char *aTopic,
const PRUnichar *someData)
{
if (nsCRT::strcmp(aTopic, PROFILE_APPROVE_CHANGE_TOPIC) == 0) {
DoProfileApproveChange(aSubject);
}
else if (nsCRT::strcmp(aTopic, PROFILE_CHANGE_TEARDOWN_TOPIC) == 0) {
if (nsCRT::strcmp(aTopic, PROFILE_CHANGE_TEARDOWN_TOPIC) == 0) {
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("in PSM code, receiving change-teardown\n"));
DoProfileChangeTeardown(aSubject);
}
else if (nsCRT::strcmp(aTopic, PROFILE_CHANGE_TEARDOWN_VETO_TOPIC) == 0) {
mShutdownObjectList->allowUI();
}
else if (nsCRT::strcmp(aTopic, PROFILE_BEFORE_CHANGE_TOPIC) == 0) {
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("receiving profile change topic\n"));
DoProfileBeforeChange(aSubject);
@ -2166,7 +2153,6 @@ nsNSSComponent::Observe(nsISupports *aSubject, const char *aTopic,
// it again. We use the same cleanup functionality used when switching
// profiles. The order of function calls must correspond to the order
// of notifications sent by Profile Manager (nsProfile).
DoProfileApproveChange(aSubject);
DoProfileChangeNetTeardown();
DoProfileChangeTeardown(aSubject);
DoProfileBeforeChange(aSubject);
@ -2188,10 +2174,6 @@ nsNSSComponent::Observe(nsISupports *aSubject, const char *aTopic,
if (needsInit) {
if (NS_FAILED(InitializeNSS(false))) { // do not show a warning box on failure
PR_LOG(gPIPNSSLog, PR_LOG_ERROR, ("Unable to Initialize NSS after profile switch.\n"));
nsCOMPtr<nsIProfileChangeStatus> status = do_QueryInterface(aSubject);
if (status) {
status->ChangeFailed();
}
}
}
@ -2377,9 +2359,7 @@ nsNSSComponent::RegisterObservers()
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
observerService->AddObserver(this, PROFILE_APPROVE_CHANGE_TOPIC, false);
observerService->AddObserver(this, PROFILE_CHANGE_TEARDOWN_TOPIC, false);
observerService->AddObserver(this, PROFILE_CHANGE_TEARDOWN_VETO_TOPIC, false);
observerService->AddObserver(this, PROFILE_BEFORE_CHANGE_TOPIC, false);
observerService->AddObserver(this, PROFILE_DO_CHANGE_TOPIC, false);
observerService->AddObserver(this, PROFILE_CHANGE_NET_TEARDOWN_TOPIC, false);
@ -2402,9 +2382,7 @@ nsNSSComponent::DeregisterObservers()
observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
observerService->RemoveObserver(this, PROFILE_APPROVE_CHANGE_TOPIC);
observerService->RemoveObserver(this, PROFILE_CHANGE_TEARDOWN_TOPIC);
observerService->RemoveObserver(this, PROFILE_CHANGE_TEARDOWN_VETO_TOPIC);
observerService->RemoveObserver(this, PROFILE_BEFORE_CHANGE_TOPIC);
observerService->RemoveObserver(this, PROFILE_DO_CHANGE_TOPIC);
observerService->RemoveObserver(this, PROFILE_CHANGE_NET_TEARDOWN_TOPIC);
@ -2444,23 +2422,6 @@ nsNSSComponent::RememberCert(CERTCertificate *cert)
return NS_OK;
}
static const char PROFILE_SWITCH_CRYPTO_UI_ACTIVE[] =
"ProfileSwitchCryptoUIActive";
static const char PROFILE_SWITCH_SOCKETS_STILL_ACTIVE[] =
"ProfileSwitchSocketsStillActive";
void
nsNSSComponent::DoProfileApproveChange(nsISupports* aSubject)
{
if (mShutdownObjectList->isUIActive()) {
ShowAlertFromStringBundle(PROFILE_SWITCH_CRYPTO_UI_ACTIVE);
nsCOMPtr<nsIProfileChangeStatus> status = do_QueryInterface(aSubject);
if (status) {
status->VetoChange();
}
}
}
void
nsNSSComponent::DoProfileChangeNetTeardown()
{
@ -2472,23 +2433,7 @@ nsNSSComponent::DoProfileChangeNetTeardown()
void
nsNSSComponent::DoProfileChangeTeardown(nsISupports* aSubject)
{
bool callVeto = false;
if (!mShutdownObjectList->ifPossibleDisallowUI()) {
callVeto = true;
ShowAlertFromStringBundle(PROFILE_SWITCH_CRYPTO_UI_ACTIVE);
}
else if (mShutdownObjectList->areSSLSocketsActive()) {
callVeto = true;
ShowAlertFromStringBundle(PROFILE_SWITCH_SOCKETS_STILL_ACTIVE);
}
if (callVeto) {
nsCOMPtr<nsIProfileChangeStatus> status = do_QueryInterface(aSubject);
if (status) {
status->VetoChange();
}
}
mShutdownObjectList->ifPossibleDisallowUI();
}
void
@ -2512,12 +2457,7 @@ nsNSSComponent::DoProfileBeforeChange(nsISupports* aSubject)
StopCRLUpdateTimer();
if (needsCleanup) {
if (NS_FAILED(ShutdownNSS())) {
nsCOMPtr<nsIProfileChangeStatus> status = do_QueryInterface(aSubject);
if (status) {
status->ChangeFailed();
}
}
ShutdownNSS();
}
mShutdownObjectList->allowUI();
}

View File

@ -267,7 +267,7 @@ public:
private:
nsresult InitializeNSS(bool showWarningBox);
nsresult ShutdownNSS();
void ShutdownNSS();
#ifdef XP_MACOSX
void TryCFM2MachOMigration(nsIFile *cfmPath, nsIFile *machoPath);
@ -291,7 +291,6 @@ private:
// Methods that we use to handle the profile change notifications (and to
// synthesize a full profile change when we're just doing a profile startup):
void DoProfileApproveChange(nsISupports* aSubject);
void DoProfileChangeNetTeardown();
void DoProfileChangeTeardown(nsISupports* aSubject);
void DoProfileBeforeChange(nsISupports* aSubject);