Bug 1221992 - Skip closed windows in GetMostRecentNonPBWindow. r=smaug

This commit is contained in:
Catalin Badea 2015-12-11 13:32:15 -05:00
parent 348cbf2c9f
commit 4a0c60b2ef
2 changed files with 9 additions and 3 deletions

View File

@ -311,7 +311,8 @@ nsWindowMediator::GetMostRecentNonPBWindow(const char16_t* aType, nsIDOMWindow**
}
nsWindowInfo*
nsWindowMediator::MostRecentWindowInfo(const char16_t* inType, bool aSkipPrivateBrowsing)
nsWindowMediator::MostRecentWindowInfo(const char16_t* inType,
bool aSkipPrivateBrowsingOrClosed)
{
int32_t lastTimeStamp = -1;
nsAutoString typeString(inType);
@ -334,13 +335,18 @@ nsWindowMediator::MostRecentWindowInfo(const char16_t* inType, bool aSkipPrivate
if (!searchInfo->mWindow) {
continue;
}
if (aSkipPrivateBrowsing) {
if (aSkipPrivateBrowsingOrClosed) {
nsCOMPtr<nsIDocShell> docShell;
searchInfo->mWindow->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
if (!loadContext || loadContext->UsePrivateBrowsing()) {
continue;
}
nsCOMPtr<nsPIDOMWindow> piwindow = do_QueryInterface(docShell->GetWindow());
if (!piwindow || piwindow->Closed()) {
continue;
}
}
foundInfo = searchInfo;

View File

@ -57,7 +57,7 @@ private:
int32_t AddEnumerator(nsAppShellWindowEnumerator* inEnumerator);
int32_t RemoveEnumerator(nsAppShellWindowEnumerator* inEnumerator);
nsWindowInfo* MostRecentWindowInfo(const char16_t* inType,
bool aSkipPrivateBrowsing = false);
bool aSkipPrivateBrowsingOrClosed = false);
nsresult UnregisterWindow(nsWindowInfo *inInfo);
nsWindowInfo *GetInfoFor(nsIXULWindow *aWindow);