Bug 1069669 - Add a nsContentUtils::IsInPrivateBrowsing function. r=ehsan

This commit is contained in:
Chris Pearce 2014-09-23 12:54:26 +12:00
parent 2d57e241bc
commit a7d967d228
2 changed files with 21 additions and 4 deletions

View File

@ -690,6 +690,11 @@ public:
bool aIsForWindow,
uint32_t *aArgCount, const char*** aArgNames);
/**
* Returns true if this document is in a Private Browsing window.
*/
static bool IsInPrivateBrowsing(nsIDocument* aDoc);
/**
* If aNode is not an element, return true exactly when aContent's binding
* parent is null.

View File

@ -2923,11 +2923,13 @@ nsContentUtils::CanLoadImage(nsIURI* aURI, nsISupports* aContext,
return NS_FAILED(rv) ? false : NS_CP_ACCEPTED(decision);
}
imgLoader*
nsContentUtils::GetImgLoaderForDocument(nsIDocument* aDoc)
// static
bool
nsContentUtils::IsInPrivateBrowsing(nsIDocument* aDoc)
{
if (!aDoc)
return imgLoader::Singleton();
if (!aDoc) {
return false;
}
bool isPrivate = false;
nsCOMPtr<nsILoadGroup> loadGroup = aDoc->GetDocumentLoadGroup();
nsCOMPtr<nsIInterfaceRequestor> callbacks;
@ -2941,6 +2943,16 @@ nsContentUtils::GetImgLoaderForDocument(nsIDocument* aDoc)
nsCOMPtr<nsIChannel> channel = aDoc->GetChannel();
isPrivate = channel && NS_UsePrivateBrowsing(channel);
}
return isPrivate;
}
imgLoader*
nsContentUtils::GetImgLoaderForDocument(nsIDocument* aDoc)
{
if (!aDoc) {
return imgLoader::Singleton();
}
bool isPrivate = IsInPrivateBrowsing(aDoc);
return isPrivate ? imgLoader::PBSingleton() : imgLoader::Singleton();
}