Bug 1173467 P2 Add nsGlobalWindow utility method to get private browsing boolean. r=ehsan

This commit is contained in:
Ben Kelly 2015-06-26 19:36:40 -07:00
parent 773760664f
commit 39905c5846
2 changed files with 11 additions and 10 deletions

View File

@ -10285,11 +10285,9 @@ nsGlobalWindow::GetSessionStorage(ErrorResult& aError)
return nullptr;
}
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
nsCOMPtr<nsIDOMStorage> storage;
aError = storageManager->CreateStorage(this, principal, documentURI,
loadContext && loadContext->UsePrivateBrowsing(),
IsPrivateBrowsing(),
getter_AddRefs(storage));
if (aError.Failed()) {
return nullptr;
@ -10365,12 +10363,9 @@ nsGlobalWindow::GetLocalStorage(ErrorResult& aError)
mDoc->GetDocumentURI(documentURI);
}
nsIDocShell* docShell = GetDocShell();
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
nsCOMPtr<nsIDOMStorage> storage;
aError = storageManager->CreateStorage(this, principal, documentURI,
loadContext && loadContext->UsePrivateBrowsing(),
IsPrivateBrowsing(),
getter_AddRefs(storage));
if (aError.Failed()) {
return nullptr;
@ -11200,9 +11195,7 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK;
}
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(GetDocShell());
bool isPrivate = loadContext && loadContext->UsePrivateBrowsing();
if (changingStorage->IsPrivate() != isPrivate) {
if (changingStorage->IsPrivate() != IsPrivateBrowsing()) {
return NS_OK;
}
@ -12634,6 +12627,13 @@ nsGlobalWindow::SecurityCheckURL(const char *aURL)
return NS_OK;
}
bool
nsGlobalWindow::IsPrivateBrowsing()
{
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(GetDocShell());
return loadContext && loadContext->UsePrivateBrowsing();
}
void
nsGlobalWindow::FlushPendingNotifications(mozFlushType aType)
{

View File

@ -1351,6 +1351,7 @@ public:
already_AddRefed<nsIBaseWindow> GetTreeOwnerWindow();
already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome();
nsresult SecurityCheckURL(const char *aURL);
bool IsPrivateBrowsing();
bool PopupWhitelisted();
PopupControlState RevisePopupAbuseLevel(PopupControlState);