Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Backed out changeset f3a6aff3dbbc (bug 827188) because of build failures
Browse files Browse the repository at this point in the history
--HG--
extra : rebase_source : 87d6ba184e23dbe83a3a0e2ae83c44c5ecdb46db
  • Loading branch information
ehsan committed Jan 8, 2013
1 parent c894a9a commit 68aa898
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 116 deletions.
16 changes: 6 additions & 10 deletions content/base/src/nsCCUncollectableMarker.cpp
Expand Up @@ -368,16 +368,12 @@ nsCCUncollectableMarker::Observe(nsISupports* aSubject, const char* aTopic,
MarkDocShell(shellTreeNode, cleanupJS, prepareForCC);
}
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
bool hasHiddenPrivateWindow = false;
appShell->GetHasHiddenPrivateWindow(&hasHiddenPrivateWindow);
if (hasHiddenPrivateWindow) {
appShell->GetHiddenPrivateWindow(getter_AddRefs(hw));
if (hw) {
nsCOMPtr<nsIDocShell> shell;
hw->GetDocShell(getter_AddRefs(shell));
nsCOMPtr<nsIDocShellTreeNode> shellTreeNode = do_QueryInterface(shell);
MarkDocShell(shellTreeNode, cleanupJS, prepareForCC);
}
appShell->GetHiddenPrivateWindow(getter_AddRefs(hw));
if (hw) {
nsCOMPtr<nsIDocShell> shell;
hw->GetDocShell(getter_AddRefs(shell));
nsCOMPtr<nsIDocShellTreeNode> shellTreeNode = do_QueryInterface(shell);
MarkDocShell(shellTreeNode, cleanupJS, prepareForCC);
}
#endif
}
Expand Down
31 changes: 5 additions & 26 deletions docshell/base/nsDocShell.cpp
Expand Up @@ -193,10 +193,7 @@
#include "mozilla/Telemetry.h"
#include "nsISecurityUITelemetry.h"

#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
#include "nsIAppShellService.h"
#include "nsAppShellCID.h"
#else
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
#include "nsIPrivateBrowsingService.h"
#endif

Expand All @@ -223,9 +220,9 @@ static uint32_t gNumberOfPrivateDocShells = 0;

// Global count of private docshells which will always remain open
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
static uint32_t gNumberOfAlwaysOpenPrivateDocShells = 0; // the private hidden window
static const uint32_t kNumberOfAlwaysOpenPrivateDocShells = 1; // the private hidden window
#else
static const uint32_t gNumberOfAlwaysOpenPrivateDocShells = 0;
static const uint32_t kNumberOfAlwaysOpenPrivateDocShells = 0;
#endif

// Global reference to the URI fixup service.
Expand Down Expand Up @@ -691,27 +688,11 @@ 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 > gNumberOfAlwaysOpenPrivateDocShells + 1 ||
if (gNumberOfPrivateDocShells > kNumberOfAlwaysOpenPrivateDocShells + 1 ||
XRE_GetProcessType() != GeckoProcessType_Content) {
return;
}
Expand All @@ -723,11 +704,9 @@ IncreasePrivateDocShellCount()
static void
DecreasePrivateDocShellCount()
{
AdjustAlwaysOpenPrivateDocShellCount();

MOZ_ASSERT(gNumberOfPrivateDocShells > 0);
gNumberOfPrivateDocShells--;
if (gNumberOfPrivateDocShells == gNumberOfAlwaysOpenPrivateDocShells)
if (gNumberOfPrivateDocShells == kNumberOfAlwaysOpenPrivateDocShells)
{
if (XRE_GetProcessType() == GeckoProcessType_Content) {
mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton();
Expand Down
28 changes: 10 additions & 18 deletions toolkit/components/startup/nsAppStartup.cpp
Expand Up @@ -314,23 +314,19 @@ nsAppStartup::Quit(uint32_t aMode)

// If we're considering quitting, we will only do so if:
if (ferocity == eConsiderQuit) {
#ifdef XP_MACOSX
nsCOMPtr<nsIAppShellService> appShell
(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
bool hasHiddenPrivateWindow = false;
if (appShell) {
appShell->GetHasHiddenPrivateWindow(&hasHiddenPrivateWindow);
}
int32_t suspiciousCount = hasHiddenPrivateWindow ? 2 : 1;
#endif

if (mConsiderQuitStopper == 0) {
// there are no windows...
ferocity = eAttemptQuit;
}
#ifdef XP_MACOSX
else if (mConsiderQuitStopper == suspiciousCount) {
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
else if (mConsiderQuitStopper == 2) {
#else
else if (mConsiderQuitStopper == 1) {
#endif
// ... or there is only a hiddenWindow left, and it's useless:
nsCOMPtr<nsIAppShellService> appShell
(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));

// Failure shouldn't be fatal, but will abort quit attempt:
if (!appShell)
Expand All @@ -341,15 +337,11 @@ nsAppStartup::Quit(uint32_t aMode)
nsCOMPtr<nsIXULWindow> hiddenWindow;
appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
// If the remaining windows are useful, we won't quit:
nsCOMPtr<nsIXULWindow> hiddenPrivateWindow;
if (hasHiddenPrivateWindow) {
appShell->GetHiddenPrivateWindow(getter_AddRefs(hiddenPrivateWindow));
if ((!hiddenWindow && !hiddenPrivateWindow) || usefulHiddenWindow)
return NS_OK;
} else if (!hiddenWindow || usefulHiddenWindow) {
appShell->GetHiddenPrivateWindow(getter_AddRefs(hiddenPrivateWindow));
// If the remaining windows are useful, we won't quit:
if ((!hiddenWindow && !hiddenPrivateWindow) || usefulHiddenWindow)
return NS_OK;
}
#else
// If the one window is useful, we won't quit:
if (!hiddenWindow || usefulHiddenWindow)
Expand Down
8 changes: 1 addition & 7 deletions xpfe/appshell/public/nsIAppShellService.idl
Expand Up @@ -16,7 +16,7 @@ interface nsIAppShell;
struct JSContext;
%}

[scriptable, uuid(5c19ab54-67bf-46d0-ac5b-21abd9050c3b)]
[scriptable, uuid(76e6364a-5453-47c7-ad83-8c30eff20a75)]
interface nsIAppShellService : nsISupports
{
/**
Expand Down Expand Up @@ -117,10 +117,4 @@ interface nsIAppShellService : nsISupports
* @param aWindow you see the pattern
*/
void unregisterTopLevelWindow(in nsIXULWindow aWindow);

/**
* Whether the hidden private window has been lazily created.
*/
[noscript]
readonly attribute boolean hasHiddenPrivateWindow;
};
66 changes: 14 additions & 52 deletions xpfe/appshell/src/nsAppShellService.cpp
Expand Up @@ -82,20 +82,6 @@ NS_IMPL_ISUPPORTS2(nsAppShellService,

NS_IMETHODIMP
nsAppShellService::CreateHiddenWindow()
{
return CreateHiddenWindowHelper(false);
}

void
nsAppShellService::EnsurePrivateHiddenWindow()
{
if (!mHiddenPrivateWindow) {
CreateHiddenWindowHelper(true);
}
}

nsresult
nsAppShellService::CreateHiddenWindowHelper(bool aIsPrivate)
{
nsresult rv;
int32_t initialHeight = 100, initialWidth = 100;
Expand All @@ -105,11 +91,7 @@ nsAppShellService::CreateHiddenWindowHelper(bool aIsPrivate)
nsAdoptingCString prefVal =
Preferences::GetCString("browser.hiddenWindowChromeURL");
const char* hiddenWindowURL = prefVal.get() ? prefVal.get() : DEFAULT_HIDDENWINDOW_URL;
if (aIsPrivate) {
hiddenWindowURL = DEFAULT_HIDDENWINDOW_URL;
} else {
mApplicationProvidedHiddenWindow = prefVal.get() ? true : false;
}
mApplicationProvidedHiddenWindow = prefVal.get() ? true : false;
#else
static const char hiddenWindowURL[] = DEFAULT_HIDDENWINDOW_URL;
uint32_t chromeMask = nsIWebBrowserChrome::CHROME_ALL;
Expand All @@ -120,26 +102,23 @@ nsAppShellService::CreateHiddenWindowHelper(bool aIsPrivate)
NS_ENSURE_SUCCESS(rv, rv);

nsRefPtr<nsWebShellWindow> newWindow;
if (!aIsPrivate) {
rv = JustCreateTopWindow(nullptr, url,
chromeMask, initialWidth, initialHeight,
true, getter_AddRefs(newWindow));
NS_ENSURE_SUCCESS(rv, rv);
rv = JustCreateTopWindow(nullptr, url,
chromeMask, initialWidth, initialHeight,
true, getter_AddRefs(newWindow));
NS_ENSURE_SUCCESS(rv, rv);

mHiddenWindow.swap(newWindow);

mHiddenWindow.swap(newWindow);
}
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
else {
// Create the hidden private window
chromeMask |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
// Create the hidden private window
chromeMask |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;

rv = JustCreateTopWindow(nullptr, url,
chromeMask, initialWidth, initialHeight,
true, getter_AddRefs(newWindow));
NS_ENSURE_SUCCESS(rv, rv);
rv = JustCreateTopWindow(nullptr, url,
chromeMask, initialWidth, initialHeight,
true, getter_AddRefs(newWindow));
NS_ENSURE_SUCCESS(rv, rv);

mHiddenPrivateWindow.swap(newWindow);
}
mHiddenPrivateWindow.swap(newWindow);
#endif

// RegisterTopLevelWindow(newWindow); -- Mac only
Expand Down Expand Up @@ -467,8 +446,6 @@ nsAppShellService::GetHiddenPrivateWindow(nsIXULWindow **aWindow)
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
NS_ENSURE_ARG_POINTER(aWindow);

EnsurePrivateHiddenWindow();

*aWindow = mHiddenPrivateWindow;
NS_IF_ADDREF(*aWindow);
return *aWindow ? NS_OK : NS_ERROR_FAILURE;
Expand All @@ -481,8 +458,6 @@ NS_IMETHODIMP
nsAppShellService::GetHiddenPrivateDOMWindow(nsIDOMWindow **aWindow)
{
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
EnsurePrivateHiddenWindow();

nsresult rv;
nsCOMPtr<nsIDocShell> docShell;
NS_ENSURE_TRUE(mHiddenPrivateWindow, NS_ERROR_FAILURE);
Expand All @@ -501,19 +476,6 @@ nsAppShellService::GetHiddenPrivateDOMWindow(nsIDOMWindow **aWindow)
#endif
}

NS_IMETHODIMP
nsAppShellService::GetHasHiddenPrivateWindow(bool* aHasPrivateWindow)
{
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
NS_ENSURE_ARG_POINTER(aHasPrivateWindow);

*aHasPrivateWindow = !!mHiddenPrivateWindow;
return NS_OK;
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}

NS_IMETHODIMP
nsAppShellService::GetHiddenWindowAndJSContext(nsIDOMWindow **aWindow,
JSContext **aJSContext)
Expand Down
3 changes: 0 additions & 3 deletions xpfe/appshell/src/nsAppShellService.h
Expand Up @@ -32,9 +32,6 @@ class nsAppShellService MOZ_FINAL : public nsIAppShellService,
protected:
~nsAppShellService();

nsresult CreateHiddenWindowHelper(bool aIsPrivate);
void EnsurePrivateHiddenWindow();

nsresult JustCreateTopWindow(nsIXULWindow *aParent,
nsIURI *aUrl,
uint32_t aChromeMask,
Expand Down

0 comments on commit 68aa898

Please sign in to comment.