Bug 827188 - Initialize the hidden private window lazily; r=bzbarsky
This commit is contained in:
@@ -193,7 +193,10 @@
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "nsISecurityUITelemetry.h"
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsAppShellCID.h"
|
||||
#else
|
||||
#include "nsIPrivateBrowsingService.h"
|
||||
#endif
|
||||
|
||||
@@ -220,9 +223,9 @@ static uint32_t gNumberOfPrivateDocShells = 0;
|
||||
|
||||
// Global count of private docshells which will always remain open
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
static const uint32_t kNumberOfAlwaysOpenPrivateDocShells = 1; // the private hidden window
|
||||
static uint32_t gNumberOfAlwaysOpenPrivateDocShells = 0; // the private hidden window
|
||||
#else
|
||||
static const uint32_t kNumberOfAlwaysOpenPrivateDocShells = 0;
|
||||
static const uint32_t gNumberOfAlwaysOpenPrivateDocShells = 0;
|
||||
#endif
|
||||
|
||||
// Global reference to the URI fixup service.
|
||||
@@ -688,11 +691,27 @@ ConvertLoadTypeToNavigationType(uint32_t aLoadType)
|
||||
|
||||
static nsISHEntry* GetRootSHEntry(nsISHEntry *entry);
|
||||
|
||||
static void
|
||||
AdjustAlwaysOpenPrivateDocShellCount()
|
||||
{
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
nsCOMPtr<nsIAppShellService> appShell
|
||||
(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
|
||||
bool hasHiddenPrivateWindow = false;
|
||||
if (appShell) {
|
||||
appShell->GetHasHiddenPrivateWindow(&hasHiddenPrivateWindow);
|
||||
}
|
||||
gNumberOfAlwaysOpenPrivateDocShells = hasHiddenPrivateWindow ? 1 : 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
IncreasePrivateDocShellCount()
|
||||
{
|
||||
AdjustAlwaysOpenPrivateDocShellCount();
|
||||
|
||||
gNumberOfPrivateDocShells++;
|
||||
if (gNumberOfPrivateDocShells > kNumberOfAlwaysOpenPrivateDocShells + 1 ||
|
||||
if (gNumberOfPrivateDocShells > gNumberOfAlwaysOpenPrivateDocShells + 1 ||
|
||||
XRE_GetProcessType() != GeckoProcessType_Content) {
|
||||
return;
|
||||
}
|
||||
@@ -704,9 +723,11 @@ IncreasePrivateDocShellCount()
|
||||
static void
|
||||
DecreasePrivateDocShellCount()
|
||||
{
|
||||
AdjustAlwaysOpenPrivateDocShellCount();
|
||||
|
||||
MOZ_ASSERT(gNumberOfPrivateDocShells > 0);
|
||||
gNumberOfPrivateDocShells--;
|
||||
if (gNumberOfPrivateDocShells == kNumberOfAlwaysOpenPrivateDocShells)
|
||||
if (gNumberOfPrivateDocShells == gNumberOfAlwaysOpenPrivateDocShells)
|
||||
{
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton();
|
||||
|
||||
Reference in New Issue
Block a user