Bug 729204 - Make docshell privacy notifications work across multiple processes. r=bz

This commit is contained in:
Josh Matthews
2012-04-19 20:13:20 -04:00
parent 493dd6880d
commit fc1a50067b
15 changed files with 139 additions and 5 deletions

View File

@@ -41,6 +41,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/dom/ContentChild.h"
#include "mozilla/Util.h"
#ifdef MOZ_LOGGING
@@ -714,6 +715,19 @@ ConvertLoadTypeToNavigationType(PRUint32 aLoadType)
static nsISHEntry* GetRootSHEntry(nsISHEntry *entry);
static void
IncreasePrivateDocShellCount()
{
gNumberOfPrivateDocShells++;
if (gNumberOfPrivateDocShells > 1 ||
XRE_GetProcessType() != GeckoProcessType_Content) {
return;
}
mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton();
cc->SendPrivateDocShellsExist(true);
}
static void
DecreasePrivateDocShellCount()
{
@@ -721,9 +735,16 @@ DecreasePrivateDocShellCount()
gNumberOfPrivateDocShells--;
if (!gNumberOfPrivateDocShells)
{
if (XRE_GetProcessType() == GeckoProcessType_Content) {
mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton();
cc->SendPrivateDocShellsExist(false);
return;
}
nsCOMPtr<nsIObserverService> obsvc = mozilla::services::GetObserverService();
if (obsvc)
if (obsvc) {
obsvc->NotifyObservers(nsnull, "last-pb-context-exited", nsnull);
}
}
}
@@ -2023,7 +2044,7 @@ nsDocShell::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
if (aUsePrivateBrowsing != mInPrivateBrowsing) {
mInPrivateBrowsing = aUsePrivateBrowsing;
if (aUsePrivateBrowsing) {
gNumberOfPrivateDocShells++;
IncreasePrivateDocShellCount();
} else {
DecreasePrivateDocShellCount();
}