forked from mirrors/gecko-dev
Bug 1335678 - Revert patch for bug 1302566, r=ehsan
This commit is contained in:
parent
2618be0754
commit
869af55a16
4 changed files with 51 additions and 25 deletions
|
|
@ -1797,8 +1797,7 @@ nsContentUtils::ParseLegacyFontSize(const nsAString& aValue)
|
|||
bool
|
||||
nsContentUtils::IsControlledByServiceWorker(nsIDocument* aDocument)
|
||||
{
|
||||
if (aDocument &&
|
||||
aDocument->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId) {
|
||||
if (nsContentUtils::IsInPrivateBrowsing(aDocument)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -3202,6 +3201,40 @@ nsContentUtils::GetOriginAttributes(nsILoadGroup* aLoadGroup)
|
|||
return attrs;
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
nsContentUtils::IsInPrivateBrowsing(nsIDocument* aDoc)
|
||||
{
|
||||
if (!aDoc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = aDoc->GetDocumentLoadGroup();
|
||||
if (loadGroup) {
|
||||
return IsInPrivateBrowsing(loadGroup);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> channel = aDoc->GetChannel();
|
||||
return channel && NS_UsePrivateBrowsing(channel);
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
nsContentUtils::IsInPrivateBrowsing(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
if (!aLoadGroup) {
|
||||
return false;
|
||||
}
|
||||
bool isPrivate = false;
|
||||
nsCOMPtr<nsIInterfaceRequestor> callbacks;
|
||||
aLoadGroup->GetNotificationCallbacks(getter_AddRefs(callbacks));
|
||||
if (callbacks) {
|
||||
nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(callbacks);
|
||||
isPrivate = loadContext && loadContext->UsePrivateBrowsing();
|
||||
}
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
bool
|
||||
nsContentUtils::DocumentInactiveForImageLoads(nsIDocument* aDocument)
|
||||
{
|
||||
|
|
@ -3221,26 +3254,9 @@ nsContentUtils::GetImgLoaderForDocument(nsIDocument* aDoc)
|
|||
if (!aDoc) {
|
||||
return imgLoader::NormalLoader();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = aDoc->GetDocumentLoadGroup();
|
||||
if (loadGroup) {
|
||||
nsCOMPtr<nsIInterfaceRequestor> callbacks;
|
||||
loadGroup->GetNotificationCallbacks(getter_AddRefs(callbacks));
|
||||
if (callbacks) {
|
||||
nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(callbacks);
|
||||
if (loadContext && loadContext->UsePrivateBrowsing()) {
|
||||
return imgLoader::PrivateBrowsingLoader();
|
||||
}
|
||||
}
|
||||
return imgLoader::NormalLoader();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> channel = aDoc->GetChannel();
|
||||
if (channel && NS_UsePrivateBrowsing(channel)) {
|
||||
return imgLoader::PrivateBrowsingLoader();
|
||||
}
|
||||
|
||||
return imgLoader::NormalLoader();
|
||||
bool isPrivate = IsInPrivateBrowsing(aDoc);
|
||||
return isPrivate ? imgLoader::PrivateBrowsingLoader()
|
||||
: imgLoader::NormalLoader();
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
@ -8647,7 +8663,7 @@ nsContentUtils::InternalStorageAllowedForPrincipal(nsIPrincipal* aPrincipal,
|
|||
}
|
||||
|
||||
// Check if we are in private browsing, and record that fact
|
||||
if (document->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId) {
|
||||
if (IsInPrivateBrowsing(document)) {
|
||||
access = StorageAccess::ePrivateBrowsing;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -817,6 +817,16 @@ public:
|
|||
static mozilla::OriginAttributes
|
||||
GetOriginAttributes(nsILoadGroup* aLoadGroup);
|
||||
|
||||
/**
|
||||
* Returns true if this document is in a Private Browsing window.
|
||||
*/
|
||||
static bool IsInPrivateBrowsing(nsIDocument* aDoc);
|
||||
|
||||
/**
|
||||
* Returns true if this loadGroup uses Private Browsing.
|
||||
*/
|
||||
static bool IsInPrivateBrowsing(nsILoadGroup* aLoadGroup);
|
||||
|
||||
/**
|
||||
* If aNode is not an element, return true exactly when aContent's binding
|
||||
* parent is null.
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ ServiceWorkerContainer::IsEnabled(JSContext* aCx, JSObject* aGlobal)
|
|||
}
|
||||
|
||||
nsIDocument* doc = window->GetExtantDoc();
|
||||
if (!doc || doc->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId) {
|
||||
if (!doc || nsContentUtils::IsInPrivateBrowsing(doc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2561,7 +2561,7 @@ ServiceWorkerManager::IsControlled(nsIDocument* aDoc, ErrorResult& aRv)
|
|||
{
|
||||
MOZ_ASSERT(aDoc);
|
||||
|
||||
if (aDoc->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId) {
|
||||
if (nsContentUtils::IsInPrivateBrowsing(aDoc)) {
|
||||
// Handle the case where a service worker was previously registered in
|
||||
// a non-private window (bug 1255621).
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue