Bug 769288 - Part 4: Clear SSL session cache upon leaving private browsing. r=bsmith
☠☠ backed out by 553a3bcf1fe7 ☠ ☠
authorJosh Matthews <josh@joshmatthews.net>
Thu, 06 Dec 2012 22:05:34 -0500
changeset 115623 e75cd1e1fca33d040197fd6c752703bb88651456
parent 115622 e10c24f10bd21d8887cfc96f521107ffb02ac783
child 115624 6d8d78bd56a972dd3bf51472192d09f173643278
push idunknown
push userunknown
push dateunknown
reviewersbsmith
bugs769288
milestone20.0a1
Bug 769288 - Part 4: Clear SSL session cache upon leaving private browsing. r=bsmith
security/manager/ssl/src/nsNSSComponent.cpp
--- a/security/manager/ssl/src/nsNSSComponent.cpp
+++ b/security/manager/ssl/src/nsNSSComponent.cpp
@@ -2133,16 +2133,17 @@ nsNSSComponent::RandomUpdate(void *entro
 
 #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"
+#define LEAVE_PRIVATE_BROWSING_TOPIC "last-pb-context-exited"
 
 NS_IMETHODIMP
 nsNSSComponent::Observe(nsISupports *aSubject, const char *aTopic, 
                         const PRUnichar *someData)
 {
   if (nsCRT::strcmp(aTopic, PROFILE_APPROVE_CHANGE_TOPIC) == 0) {
     DoProfileApproveChange(aSubject);
   }
@@ -2280,16 +2281,19 @@ nsNSSComponent::Observe(nsISupports *aSu
   else if (nsCRT::strcmp(aTopic, PROFILE_CHANGE_NET_TEARDOWN_TOPIC) == 0) {
     PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("receiving network teardown topic\n"));
     DoProfileChangeNetTeardown();
   }
   else if (nsCRT::strcmp(aTopic, PROFILE_CHANGE_NET_RESTORE_TOPIC) == 0) {
     PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("receiving network restore topic\n"));
     DoProfileChangeNetRestore();
   }
+  else if (nsCRT::strcmp(aTopic, LEAVE_PRIVATE_BROWSING_TOPIC) == 0) {
+    SSL_ClearSessionCache();
+  }
 
   return NS_OK;
 }
 
 /*static*/ nsresult
 nsNSSComponent::GetNewPrompter(nsIPrompt ** result)
 {
   NS_ENSURE_ARG_POINTER(result);
@@ -2379,16 +2383,17 @@ nsNSSComponent::RegisterObservers()
 
     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);
     observerService->AddObserver(this, PROFILE_CHANGE_NET_RESTORE_TOPIC, false);
+    observerService->AddObserver(this, LEAVE_PRIVATE_BROWSING_TOPIC, false);
   }
   return NS_OK;
 }
 
 nsresult
 nsNSSComponent::DeregisterObservers()
 {
   if (!mObserversRegistered)
@@ -2404,16 +2409,17 @@ nsNSSComponent::DeregisterObservers()
 
     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);
     observerService->RemoveObserver(this, PROFILE_CHANGE_NET_RESTORE_TOPIC);
+    observerService->RemoveObserver(this, LEAVE_PRIVATE_BROWSING_TOPIC);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNSSComponent::RememberCert(CERTCertificate *cert)
 {
   nsNSSShutDownPreventionLock locker;