mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-20 00:20:37 +00:00
Backed out changeset e374514be19b (bug 1863046) for causing Bug 1863046 . CLOSED TREE
This commit is contained in:
parent
f50a3674c6
commit
ec5f3a89f8
@ -3010,8 +3010,8 @@ void Document::ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup,
|
||||
// This is asserting that if we previously set mIsInPrivateBrowsing
|
||||
// to true from the channel in Document::Reset, that the loadContext
|
||||
// also believes it to be true.
|
||||
MOZ_ASSERT(!mIsInPrivateBrowsing ||
|
||||
mIsInPrivateBrowsing == loadContext->UsePrivateBrowsing());
|
||||
// MOZ_ASSERT(!mIsInPrivateBrowsing ||
|
||||
// mIsInPrivateBrowsing == loadContext->UsePrivateBrowsing());
|
||||
mIsInPrivateBrowsing = loadContext->UsePrivateBrowsing();
|
||||
}
|
||||
}
|
||||
@ -18564,7 +18564,8 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccessForOrigin(
|
||||
}
|
||||
if (AntiTrackingUtils::CheckStoragePermission(
|
||||
self->NodePrincipal(), type,
|
||||
self->IsInPrivateBrowsing(), nullptr, 0)) {
|
||||
nsContentUtils::IsInPrivateBrowsing(self), nullptr,
|
||||
0)) {
|
||||
return MozPromise<int, bool, true>::CreateAndResolve(
|
||||
true, __func__);
|
||||
}
|
||||
@ -18896,8 +18897,8 @@ already_AddRefed<Promise> Document::CompleteStorageAccessRequestFromSite(
|
||||
false, __func__);
|
||||
}
|
||||
if (AntiTrackingUtils::CheckStoragePermission(
|
||||
self->NodePrincipal(), type, self->IsInPrivateBrowsing(),
|
||||
nullptr, 0)) {
|
||||
self->NodePrincipal(), type,
|
||||
nsContentUtils::IsInPrivateBrowsing(self), nullptr, 0)) {
|
||||
return StorageAccessAPIHelper::
|
||||
StorageAccessPermissionGrantPromise::CreateAndResolve(
|
||||
StorageAccessAPIHelper::eAllowAutoGrant, __func__);
|
||||
|
@ -3943,12 +3943,35 @@ nsPresContext* nsContentUtils::GetContextForContent(
|
||||
return presShell->GetPresContext();
|
||||
}
|
||||
|
||||
// static
|
||||
bool nsContentUtils::IsInPrivateBrowsing(const Document* aDoc) {
|
||||
if (!aDoc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = aDoc->GetDocumentLoadGroup();
|
||||
// See duplicated code below in IsInPrivateBrowsing(nsILoadGroup*)
|
||||
// and Document::Reset/ResetToURI
|
||||
if (loadGroup) {
|
||||
nsCOMPtr<nsIInterfaceRequestor> callbacks;
|
||||
loadGroup->GetNotificationCallbacks(getter_AddRefs(callbacks));
|
||||
if (callbacks) {
|
||||
nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(callbacks);
|
||||
if (loadContext) {
|
||||
return loadContext->UsePrivateBrowsing();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> channel = aDoc->GetChannel();
|
||||
return channel && NS_UsePrivateBrowsing(channel);
|
||||
}
|
||||
|
||||
// static
|
||||
bool nsContentUtils::IsInPrivateBrowsing(nsILoadGroup* aLoadGroup) {
|
||||
if (!aLoadGroup) {
|
||||
return false;
|
||||
}
|
||||
// See duplicated code in Document::Reset/ResetToURI
|
||||
bool isPrivate = false;
|
||||
nsCOMPtr<nsIInterfaceRequestor> callbacks;
|
||||
aLoadGroup->GetNotificationCallbacks(getter_AddRefs(callbacks));
|
||||
@ -3980,7 +4003,7 @@ imgLoader* nsContentUtils::GetImgLoaderForDocument(Document* aDoc) {
|
||||
if (!aDoc) {
|
||||
return imgLoader::NormalLoader();
|
||||
}
|
||||
const bool isPrivate = aDoc->IsInPrivateBrowsing();
|
||||
bool isPrivate = IsInPrivateBrowsing(aDoc);
|
||||
return isPrivate ? imgLoader::PrivateBrowsingLoader()
|
||||
: imgLoader::NormalLoader();
|
||||
}
|
||||
|
@ -1198,6 +1198,11 @@ class nsContentUtils {
|
||||
bool aIsForWindow, uint32_t* aArgCount,
|
||||
const char*** aArgNames);
|
||||
|
||||
/**
|
||||
* Returns true if this document is in a Private Browsing window.
|
||||
*/
|
||||
static bool IsInPrivateBrowsing(const Document* aDoc);
|
||||
|
||||
/**
|
||||
* Returns true if this loadGroup uses Private Browsing.
|
||||
*/
|
||||
|
@ -1982,8 +1982,9 @@ void IMEStateManager::SetIMEState(const IMEState& aState,
|
||||
context.mHasHandledUserInput =
|
||||
aPresContext && aPresContext->PresShell()->HasHandledUserInput();
|
||||
|
||||
context.mInPrivateBrowsing = aPresContext && aPresContext->Document() &&
|
||||
aPresContext->Document()->IsInPrivateBrowsing();
|
||||
context.mInPrivateBrowsing =
|
||||
aPresContext &&
|
||||
nsContentUtils::IsInPrivateBrowsing(aPresContext->Document());
|
||||
|
||||
const RefPtr<Element> focusedElement =
|
||||
aElement ? Element::FromNodeOrNull(
|
||||
|
@ -514,7 +514,7 @@ bool MediaStatusManager::IsInPrivateBrowsing() const {
|
||||
if (!element) {
|
||||
return false;
|
||||
}
|
||||
return element->OwnerDoc()->IsInPrivateBrowsing();
|
||||
return nsContentUtils::IsInPrivateBrowsing(element->OwnerDoc());
|
||||
}
|
||||
|
||||
MediaSessionPlaybackState MediaStatusManager::PlaybackState() const {
|
||||
|
@ -324,7 +324,7 @@ already_AddRefed<Promise> ExecuteOpOnMainOrWorkerThread(
|
||||
new PersistentStoragePermissionRequest(principal, window, promise);
|
||||
|
||||
// In private browsing mode, no permission prompt.
|
||||
if (doc->IsInPrivateBrowsing()) {
|
||||
if (nsContentUtils::IsInPrivateBrowsing(doc)) {
|
||||
aRv = request->Cancel();
|
||||
} else if (!request->CheckPermissionDelegate()) {
|
||||
aRv = request->Cancel();
|
||||
|
@ -153,7 +153,7 @@ void Sanitizer::LogLocalizedString(const char* aName,
|
||||
if (window && window->GetDoc()) {
|
||||
auto* doc = window->GetDoc();
|
||||
innerWindowID = doc->InnerWindowID();
|
||||
isPrivateBrowsing = doc->IsInPrivateBrowsing();
|
||||
isPrivateBrowsing = nsContentUtils::IsInPrivateBrowsing(doc);
|
||||
}
|
||||
nsAutoString logMsg;
|
||||
nsContentUtils::FormatLocalizedString(nsContentUtils::eSECURITY_PROPERTIES,
|
||||
|
@ -2318,7 +2318,7 @@ nsresult imgLoader::LoadImage(
|
||||
bool isPrivate = false;
|
||||
|
||||
if (aLoadingDocument) {
|
||||
isPrivate = aLoadingDocument->IsInPrivateBrowsing();
|
||||
isPrivate = nsContentUtils::IsInPrivateBrowsing(aLoadingDocument);
|
||||
} else if (aLoadGroup) {
|
||||
isPrivate = nsContentUtils::IsInPrivateBrowsing(aLoadGroup);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ static StorageAccess InternalStorageAllowedCheck(
|
||||
}
|
||||
|
||||
// Check if we are in private browsing, and record that fact
|
||||
if (document && document->IsInPrivateBrowsing()) {
|
||||
if (nsContentUtils::IsInPrivateBrowsing(document)) {
|
||||
access = StorageAccess::ePrivateBrowsing;
|
||||
}
|
||||
|
||||
@ -889,6 +889,7 @@ bool ApproximateAllowAccessForWithoutChannel(
|
||||
AntiTrackingUtils::CreateStoragePermissionKey(principal, type);
|
||||
|
||||
return AntiTrackingUtils::CheckStoragePermission(
|
||||
parentPrincipal, type, parentDocument->IsInPrivateBrowsing(), nullptr, 0);
|
||||
parentPrincipal, type,
|
||||
nsContentUtils::IsInPrivateBrowsing(parentDocument), nullptr, 0);
|
||||
}
|
||||
} // namespace mozilla
|
||||
|
Loading…
x
Reference in New Issue
Block a user