Bug 725210 - Add observer notification for last PB docshell going away. r=bz

This commit is contained in:
Josh Matthews 2012-02-08 01:52:39 -05:00
Родитель e8fdadcb87
Коммит a6e1c0a812
1 изменённых файлов: 26 добавлений и 1 удалений

Просмотреть файл

@ -242,6 +242,9 @@ static PRInt32 gNumberOfDocumentsLoading = 0;
// Global count of existing docshells.
static PRInt32 gDocShellCount = 0;
// Global count of docshells with the private attribute set
static PRUint32 gNumberOfPrivateDocShells = 0;
// Global reference to the URI fixup service.
nsIURIFixup *nsDocShell::sURIFixup = 0;
@ -710,6 +713,19 @@ ConvertLoadTypeToNavigationType(PRUint32 aLoadType)
static nsISHEntry* GetRootSHEntry(nsISHEntry *entry);
static void
DecreasePrivateDocShellCount()
{
MOZ_ASSERT(gNumberOfPrivateDocShells > 0);
gNumberOfPrivateDocShells--;
if (!gNumberOfPrivateDocShells)
{
nsCOMPtr<nsIObserverService> obsvc = mozilla::services::GetObserverService();
if (obsvc)
obsvc->NotifyObservers(nsnull, "last-pb-context-exited", nsnull);
}
}
//*****************************************************************************
//*** nsDocShell: Object Management
//*****************************************************************************
@ -816,6 +832,10 @@ nsDocShell::~nsDocShell()
printf("--DOCSHELL %p == %ld\n", (void*) this, gNumberOfDocShells);
}
#endif
if (mInPrivateBrowsing) {
DecreasePrivateDocShellCount();
}
}
nsresult
@ -1998,7 +2018,12 @@ NS_IMETHODIMP
nsDocShell::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
{
mInPrivateBrowsing = aUsePrivateBrowsing;
if (aUsePrivateBrowsing) {
gNumberOfPrivateDocShells++;
} else {
DecreasePrivateDocShellCount();
}
PRInt32 count = mChildList.Count();
for (PRInt32 i = 0; i < count; ++i) {
nsCOMPtr<nsILoadContext> shell = do_QueryInterface(ChildAt(i));