зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1599046 - P1. Remove ContentBlockingLog from the child r=timhuang,Ehsan
At this point, there is no consumer that uses ContentBlockingLog stored in the child. This patch removes the following code: 1. Removing nsGlobalWindowOuter::NotifyContentBlockingEvent 2. Removing nsDocLoader::OnContentBlockingEvent 3. Removing contentBlockingEvent in nsISecureBrowserUI.idl 4. Removing mContentBlockingLog from Document.cpp and APIs related to it. Differential Revision: https://phabricator.services.mozilla.com/D56874 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
6b1a075865
Коммит
ffdfd5d51a
|
@ -14135,8 +14135,6 @@ void Document::DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const {
|
|||
mql->SizeOfExcludingThis(aWindowSizes.mState.mMallocSizeOf);
|
||||
}
|
||||
|
||||
mContentBlockingLog.AddSizeOfExcludingThis(aWindowSizes);
|
||||
|
||||
DocumentOrShadowRoot::AddSizeOfExcludingThis(aWindowSizes);
|
||||
|
||||
for (auto& sheetArray : mAdditionalSheets) {
|
||||
|
|
|
@ -1120,327 +1120,6 @@ class Document : public nsINode,
|
|||
MOZ_MUST_USE RefPtr<GetContentBlockingEventsPromise>
|
||||
GetContentBlockingEvents();
|
||||
|
||||
/**
|
||||
* Get tracking content blocked flag for this document.
|
||||
*/
|
||||
bool GetHasTrackingContentBlocked() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fingerprinting content blocked flag for this document.
|
||||
*/
|
||||
bool GetHasFingerprintingContentBlocked() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_BLOCKED_FINGERPRINTING_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cryptomining content blocked flag for this document.
|
||||
*/
|
||||
bool GetHasCryptominingContentBlocked() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_BLOCKED_CRYPTOMINING_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get socialtracking content blocked flag for this document.
|
||||
*/
|
||||
bool GetHasSocialTrackingContentBlocked() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_BLOCKED_SOCIALTRACKING_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all cookies blocked flag for this document.
|
||||
*/
|
||||
bool GetHasAllCookiesBlocked() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tracking cookies blocked flag for this document.
|
||||
*/
|
||||
bool GetHasTrackingCookiesBlocked() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get social tracking cookies blocked flag for this document.
|
||||
*/
|
||||
bool GetHasSocialTrackingCookiesBlocked() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get third-party cookies blocked flag for this document.
|
||||
*/
|
||||
bool GetHasForeignCookiesBlocked() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cookies blocked by site permission flag for this document.
|
||||
*/
|
||||
bool GetHasCookiesBlockedByPermission() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tracking content blocked flag for this document.
|
||||
*/
|
||||
void SetHasTrackingContentBlocked(bool aHasTrackingContentBlocked,
|
||||
const nsACString& aOriginBlocked) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginBlocked, nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT,
|
||||
aHasTrackingContentBlocked);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fingerprinting content blocked flag for this document.
|
||||
*/
|
||||
void SetHasFingerprintingContentBlocked(bool aHasFingerprintingContentBlocked,
|
||||
const nsACString& aOriginBlocked) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_BLOCKED_FINGERPRINTING_CONTENT,
|
||||
aHasFingerprintingContentBlocked);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cryptomining content blocked flag for this document.
|
||||
*/
|
||||
void SetHasCryptominingContentBlocked(bool aHasCryptominingContentBlocked,
|
||||
const nsACString& aOriginBlocked) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_BLOCKED_CRYPTOMINING_CONTENT,
|
||||
aHasCryptominingContentBlocked);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the socialtracking content blocked flag for this document.
|
||||
*/
|
||||
void SetHasSocialTrackingContentBlocked(bool aHasSocialTrackingContentBlocked,
|
||||
const nsACString& aOriginBlocked) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_BLOCKED_SOCIALTRACKING_CONTENT,
|
||||
aHasSocialTrackingContentBlocked);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the all cookies blocked flag for this document.
|
||||
*/
|
||||
void SetHasAllCookiesBlocked(bool aHasAllCookiesBlocked,
|
||||
const nsACString& aOriginBlocked) {
|
||||
RecordContentBlockingLog(aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL,
|
||||
aHasAllCookiesBlocked);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tracking cookies blocked flag for this document.
|
||||
*/
|
||||
void SetHasTrackingCookiesBlocked(
|
||||
bool aHasTrackingCookiesBlocked, const nsACString& aOriginBlocked,
|
||||
const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason,
|
||||
const nsTArray<nsCString>& aTrackingFullHashes) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginBlocked, nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER,
|
||||
aHasTrackingCookiesBlocked, aReason, aTrackingFullHashes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the social tracking cookies blocked flag for this document.
|
||||
*/
|
||||
void SetHasSocialTrackingCookiesBlocked(
|
||||
bool aHasSocialTrackingCookiesBlocked, const nsACString& aOriginBlocked,
|
||||
const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason,
|
||||
const nsTArray<nsCString>& aTrackingFullHashes) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER,
|
||||
aHasSocialTrackingCookiesBlocked, aReason, aTrackingFullHashes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the third-party cookies blocked flag for this document.
|
||||
*/
|
||||
void SetHasForeignCookiesBlocked(bool aHasForeignCookiesBlocked,
|
||||
const nsACString& aOriginBlocked) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginBlocked, nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN,
|
||||
aHasForeignCookiesBlocked);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cookies blocked by site permission flag for this document.
|
||||
*/
|
||||
void SetHasCookiesBlockedByPermission(bool aHasCookiesBlockedByPermission,
|
||||
const nsACString& aOriginBlocked) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION,
|
||||
aHasCookiesBlockedByPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cookies loaded flag for this document.
|
||||
*/
|
||||
void SetHasCookiesLoaded(bool aHasCookiesLoaded,
|
||||
const nsACString& aOriginLoaded) {
|
||||
RecordContentBlockingLog(aOriginLoaded,
|
||||
nsIWebProgressListener::STATE_COOKIES_LOADED,
|
||||
aHasCookiesLoaded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cookies loaded flag for this document.
|
||||
*/
|
||||
bool GetHasCookiesLoaded() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_COOKIES_LOADED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tracker cookies loaded flag for this document.
|
||||
*/
|
||||
void SetHasTrackerCookiesLoaded(bool aHasTrackerCookiesLoaded,
|
||||
const nsACString& aOriginLoaded) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginLoaded, nsIWebProgressListener::STATE_COOKIES_LOADED_TRACKER,
|
||||
aHasTrackerCookiesLoaded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tracker cookies loaded flag for this document.
|
||||
*/
|
||||
bool GetHasTrackerCookiesLoaded() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_COOKIES_LOADED_TRACKER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the social tracker cookies loaded flag for this document.
|
||||
*/
|
||||
void SetHasSocialTrackerCookiesLoaded(bool aHasSocialTrackerCookiesLoaded,
|
||||
const nsACString& aOriginLoaded) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginLoaded,
|
||||
nsIWebProgressListener::STATE_COOKIES_LOADED_SOCIALTRACKER,
|
||||
aHasSocialTrackerCookiesLoaded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the social tracker cookies loaded flag for this document.
|
||||
*/
|
||||
bool GetHasSocialTrackerCookiesLoaded() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_COOKIES_LOADED_SOCIALTRACKER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get level 1 tracking content loaded flag for this document.
|
||||
*/
|
||||
bool GetHasLevel1TrackingContentLoaded() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_LOADED_LEVEL_1_TRACKING_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the level 1 tracking content loaded flag for this document.
|
||||
*/
|
||||
void SetHasLevel1TrackingContentLoaded(bool aHasTrackingContentLoaded,
|
||||
const nsACString& aOriginBlocked) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_LOADED_LEVEL_1_TRACKING_CONTENT,
|
||||
aHasTrackingContentLoaded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get level 2 tracking content loaded flag for this document.
|
||||
*/
|
||||
bool GetHasLevel2TrackingContentLoaded() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_LOADED_LEVEL_2_TRACKING_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the level 2 tracking content loaded flag for this document.
|
||||
*/
|
||||
void SetHasLevel2TrackingContentLoaded(bool aHasTrackingContentLoaded,
|
||||
const nsACString& aOriginBlocked) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_LOADED_LEVEL_2_TRACKING_CONTENT,
|
||||
aHasTrackingContentLoaded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fingerprinting content loaded flag for this document.
|
||||
*/
|
||||
bool GetHasFingerprintingContentLoaded() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_LOADED_FINGERPRINTING_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fingerprinting content loaded flag for this document.
|
||||
*/
|
||||
void SetHasFingerprintingContentLoaded(bool aHasFingerprintingContentLoaded,
|
||||
const nsACString& aOriginBlocked) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_LOADED_FINGERPRINTING_CONTENT,
|
||||
aHasFingerprintingContentLoaded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cryptomining content loaded flag for this document.
|
||||
*/
|
||||
bool GetHasCryptominingContentLoaded() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_LOADED_CRYPTOMINING_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cryptomining content loaded flag for this document.
|
||||
*/
|
||||
void SetHasCryptominingContentLoaded(bool aHasCryptominingContentLoaded,
|
||||
const nsACString& aOriginBlocked) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_LOADED_CRYPTOMINING_CONTENT,
|
||||
aHasCryptominingContentLoaded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get socialtracking content loaded flag for this document.
|
||||
*/
|
||||
bool GetHasSocialTrackingContentLoaded() {
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_LOADED_SOCIALTRACKING_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the socialtracking content loaded flag for this document.
|
||||
*/
|
||||
void SetHasSocialTrackingContentLoaded(bool aHasSocialTrackingContentLoaded,
|
||||
const nsACString& aOriginBlocked) {
|
||||
RecordContentBlockingLog(
|
||||
aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_LOADED_SOCIALTRACKING_CONTENT,
|
||||
aHasSocialTrackingContentLoaded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sandbox flags for this document.
|
||||
* @see nsSandboxFlags.h for the possible flags
|
||||
|
@ -4383,15 +4062,6 @@ class Document : public nsINode,
|
|||
InternalCommandDataHashtable;
|
||||
static InternalCommandDataHashtable* sInternalCommandDataHashtable;
|
||||
|
||||
void RecordContentBlockingLog(
|
||||
const nsACString& aOrigin, uint32_t aType, bool aBlocked,
|
||||
const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason =
|
||||
Nothing(),
|
||||
const nsTArray<nsCString>& aTrackingFullHashes = nsTArray<nsCString>()) {
|
||||
mContentBlockingLog.RecordLog(aOrigin, aType, aBlocked, aReason,
|
||||
aTrackingFullHashes);
|
||||
}
|
||||
|
||||
mutable std::bitset<eDeprecatedOperationCount> mDeprecationWarnedAbout;
|
||||
mutable std::bitset<eDocumentWarningCount> mDocWarningWarnedAbout;
|
||||
|
||||
|
@ -5128,11 +4798,6 @@ class Document : public nsINode,
|
|||
// existing in the set means the corresponding script isn't a tracking script.
|
||||
nsTHashtable<nsCStringHashKey> mTrackingScripts;
|
||||
|
||||
// The log of all content blocking actions taken on this document. This is
|
||||
// only stored on top-level documents and includes the activity log for all of
|
||||
// the nested subdocuments as well.
|
||||
ContentBlockingLog mContentBlockingLog;
|
||||
|
||||
// List of ancestor principals. This is set at the point a document
|
||||
// is connected to a docshell and not mutated thereafter.
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>> mAncestorPrincipals;
|
||||
|
|
|
@ -5330,168 +5330,7 @@ void nsGlobalWindowOuter::NotifyContentBlockingEvent(
|
|||
nsIChannel* aTrackingChannel,
|
||||
const mozilla::Maybe<AntiTrackingCommon::StorageAccessGrantedReason>&
|
||||
aReason) {
|
||||
MOZ_ASSERT(aURIHint);
|
||||
DebugOnly<bool> isCookiesBlockedTracker =
|
||||
aEvent == nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
|
||||
aEvent == nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER;
|
||||
MOZ_ASSERT_IF(aBlocked, aReason.isNothing());
|
||||
MOZ_ASSERT_IF(!isCookiesBlockedTracker, aReason.isNothing());
|
||||
MOZ_ASSERT_IF(isCookiesBlockedTracker && !aBlocked, aReason.isSome());
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell = GetDocShell();
|
||||
if (!docShell) {
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<Document> doc = GetExtantDoc();
|
||||
NS_ENSURE_TRUE_VOID(doc);
|
||||
|
||||
nsCOMPtr<nsIURI> uri(aURIHint);
|
||||
nsCOMPtr<nsIChannel> channel(aChannel);
|
||||
nsCOMPtr<nsIClassifiedChannel> trackingChannel =
|
||||
do_QueryInterface(aTrackingChannel);
|
||||
|
||||
nsCOMPtr<nsIRunnable> func = NS_NewRunnableFunction(
|
||||
"NotifyContentBlockingEventDelayed",
|
||||
[doc, docShell, uri, channel, aEvent, aBlocked, aReason,
|
||||
trackingChannel]() {
|
||||
// This event might come after the user has navigated to another
|
||||
// page. To prevent showing the TrackingProtection UI on the wrong
|
||||
// page, we need to check that the loading URI for the channel is
|
||||
// the same as the URI currently loaded in the document.
|
||||
if (!SameLoadingURI(doc, channel) &&
|
||||
aEvent == nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Notify nsIWebProgressListeners of this content blocking event.
|
||||
// Can be used to change the UI state.
|
||||
uint32_t event = 0;
|
||||
nsCOMPtr<nsISecureBrowserUI> securityUI;
|
||||
docShell->GetSecurityUI(getter_AddRefs(securityUI));
|
||||
if (!securityUI) {
|
||||
return;
|
||||
}
|
||||
securityUI->GetContentBlockingEvent(&event);
|
||||
nsAutoCString origin;
|
||||
nsContentUtils::GetASCIIOrigin(uri, origin);
|
||||
|
||||
bool blockedValue = aBlocked;
|
||||
if (aEvent == nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT) {
|
||||
doc->SetHasTrackingContentBlocked(aBlocked, origin);
|
||||
} else if (aEvent == nsIWebProgressListener::
|
||||
STATE_LOADED_LEVEL_1_TRACKING_CONTENT) {
|
||||
doc->SetHasLevel1TrackingContentLoaded(aBlocked, origin);
|
||||
} else if (aEvent == nsIWebProgressListener::
|
||||
STATE_LOADED_LEVEL_2_TRACKING_CONTENT) {
|
||||
doc->SetHasLevel2TrackingContentLoaded(aBlocked, origin);
|
||||
} else if (aEvent == nsIWebProgressListener::
|
||||
STATE_BLOCKED_FINGERPRINTING_CONTENT) {
|
||||
doc->SetHasFingerprintingContentBlocked(aBlocked, origin);
|
||||
} else if (aEvent == nsIWebProgressListener::
|
||||
STATE_LOADED_FINGERPRINTING_CONTENT) {
|
||||
doc->SetHasFingerprintingContentLoaded(aBlocked, origin);
|
||||
} else if (aEvent ==
|
||||
nsIWebProgressListener::STATE_BLOCKED_CRYPTOMINING_CONTENT) {
|
||||
doc->SetHasCryptominingContentBlocked(aBlocked, origin);
|
||||
} else if (aEvent ==
|
||||
nsIWebProgressListener::STATE_LOADED_CRYPTOMINING_CONTENT) {
|
||||
doc->SetHasCryptominingContentLoaded(aBlocked, origin);
|
||||
} else if (aEvent == nsIWebProgressListener::
|
||||
STATE_BLOCKED_SOCIALTRACKING_CONTENT) {
|
||||
doc->SetHasSocialTrackingContentBlocked(aBlocked, origin);
|
||||
} else if (aEvent == nsIWebProgressListener::
|
||||
STATE_LOADED_SOCIALTRACKING_CONTENT) {
|
||||
doc->SetHasSocialTrackingContentLoaded(aBlocked, origin);
|
||||
} else if (aEvent == nsIWebProgressListener::
|
||||
STATE_COOKIES_BLOCKED_BY_PERMISSION) {
|
||||
doc->SetHasCookiesBlockedByPermission(aBlocked, origin);
|
||||
} else if (aEvent ==
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER) {
|
||||
nsTArray<nsCString> trackingFullHashes;
|
||||
if (trackingChannel) {
|
||||
Unused << trackingChannel->GetMatchedTrackingFullHashes(
|
||||
trackingFullHashes);
|
||||
}
|
||||
doc->SetHasTrackingCookiesBlocked(aBlocked, origin, aReason,
|
||||
trackingFullHashes);
|
||||
} else if (aEvent == nsIWebProgressListener::
|
||||
STATE_COOKIES_BLOCKED_SOCIALTRACKER) {
|
||||
nsTArray<nsCString> trackingFullHashes;
|
||||
if (trackingChannel) {
|
||||
Unused << trackingChannel->GetMatchedTrackingFullHashes(
|
||||
trackingFullHashes);
|
||||
}
|
||||
doc->SetHasSocialTrackingCookiesBlocked(aBlocked, origin, aReason,
|
||||
trackingFullHashes);
|
||||
} else if (aEvent ==
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL) {
|
||||
doc->SetHasAllCookiesBlocked(aBlocked, origin);
|
||||
} else if (aEvent ==
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN) {
|
||||
doc->SetHasForeignCookiesBlocked(aBlocked, origin);
|
||||
} else if (aEvent == nsIWebProgressListener::STATE_COOKIES_LOADED) {
|
||||
MOZ_ASSERT(!aBlocked,
|
||||
"We don't expected to see blocked STATE_COOKIES_LOADED");
|
||||
// Note that the logic in this branch is the logical negation of
|
||||
// the logic in other branches, since the Document API we have is
|
||||
// phrased in "loaded" terms as opposed to "blocked" terms.
|
||||
blockedValue = !aBlocked;
|
||||
doc->SetHasCookiesLoaded(blockedValue, origin);
|
||||
} else if (aEvent ==
|
||||
nsIWebProgressListener::STATE_COOKIES_LOADED_TRACKER) {
|
||||
MOZ_ASSERT(
|
||||
!aBlocked,
|
||||
"We don't expected to see blocked STATE_COOKIES_LOADED_TRACKER");
|
||||
// Note that the logic in this branch is the logical negation of the
|
||||
// logic in other branches, since the Document API we have is phrased
|
||||
// in "loaded" terms as opposed to "blocked" terms.
|
||||
blockedValue = !aBlocked;
|
||||
doc->SetHasTrackerCookiesLoaded(blockedValue, origin);
|
||||
} else if (aEvent ==
|
||||
nsIWebProgressListener::STATE_COOKIES_LOADED_SOCIALTRACKER) {
|
||||
MOZ_ASSERT(!aBlocked,
|
||||
"We don't expected to see blocked "
|
||||
"STATE_COOKIES_LOADED_SOCIALTRACKER");
|
||||
// Note that the logic in this branch is the logical negation of
|
||||
// the logic in other branches, since the Document API we have is
|
||||
// phrased in "loaded" terms as opposed to "blocked" terms.
|
||||
blockedValue = !aBlocked;
|
||||
doc->SetHasSocialTrackerCookiesLoaded(blockedValue, origin);
|
||||
} else {
|
||||
// Ignore nsIWebProgressListener::STATE_BLOCKED_UNSAFE_CONTENT;
|
||||
}
|
||||
});
|
||||
nsresult rv;
|
||||
if (StaticPrefs::dom_testing_sync_content_blocking_notifications()) {
|
||||
rv = func->Run();
|
||||
} else {
|
||||
rv = NS_DispatchToCurrentThreadQueue(func.forget(), 100,
|
||||
EventQueuePriority::Idle);
|
||||
}
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
bool nsGlobalWindowOuter::SameLoadingURI(Document* aDoc, nsIChannel* aChannel) {
|
||||
nsCOMPtr<nsIURI> docURI = aDoc->GetDocumentURI();
|
||||
if (!docURI) {
|
||||
return false;
|
||||
}
|
||||
nsCOMPtr<nsILoadInfo> channelLoadInfo = aChannel->LoadInfo();
|
||||
nsCOMPtr<nsIPrincipal> channelLoadingPrincipal =
|
||||
channelLoadInfo->LoadingPrincipal();
|
||||
if (!channelLoadingPrincipal) {
|
||||
// TYPE_DOCUMENT loads will not have a channelLoadingPrincipal. But top
|
||||
// level loads should not be blocked by Tracking Protection, so we will
|
||||
// return false
|
||||
return false;
|
||||
}
|
||||
bool equals = false;
|
||||
nsresult rv = channelLoadingPrincipal->EqualsURI(docURI, &equals);
|
||||
|
||||
return NS_SUCCEEDED(rv) && equals;
|
||||
// TODO: This function will be removed in the next patch
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -816,9 +816,6 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
|
|||
nsDocShellLoadState* aLoadState, bool aForceNoOpener,
|
||||
mozilla::dom::BrowsingContext** aReturn);
|
||||
|
||||
// Checks that the channel was loaded by the URI currently loaded in aDoc
|
||||
static bool SameLoadingURI(Document* aDoc, nsIChannel* aChannel);
|
||||
|
||||
public:
|
||||
// Helper Functions
|
||||
already_AddRefed<nsIDocShellTreeOwner> GetTreeOwner();
|
||||
|
|
|
@ -15,7 +15,6 @@ interface nsISecureBrowserUI : nsISupports
|
|||
void init(in nsIDocShell docShell);
|
||||
|
||||
readonly attribute unsigned long state;
|
||||
readonly attribute unsigned long contentBlockingEvent;
|
||||
readonly attribute bool isSecureContext;
|
||||
readonly attribute nsITransportSecurityInfo secInfo;
|
||||
};
|
||||
|
|
|
@ -84,23 +84,6 @@ nsSecureBrowserUIImpl::GetIsSecureContext(bool* aIsSecureContext) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSecureBrowserUIImpl::GetContentBlockingEvent(uint32_t* aEvent) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_ENSURE_ARG(aEvent);
|
||||
|
||||
MOZ_LOG(gSecureBrowserUILog, LogLevel::Debug,
|
||||
("GetContentBlockingEvent %p", this));
|
||||
// With respect to mixed content and tracking protection, we won't know when
|
||||
// the state of our document (or a subdocument) has changed, so we ask the
|
||||
// docShell.
|
||||
CheckForContentBlockingEvents();
|
||||
MOZ_LOG(gSecureBrowserUILog, LogLevel::Debug, (" mEvent: %x", mEvent));
|
||||
|
||||
*aEvent = mEvent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSecureBrowserUIImpl::GetSecInfo(nsITransportSecurityInfo** result) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -172,88 +155,6 @@ void nsSecureBrowserUIImpl::CheckForMixedContent() {
|
|||
}
|
||||
}
|
||||
|
||||
// Ask the docShell if we have any content blocking events.
|
||||
void nsSecureBrowserUIImpl::CheckForContentBlockingEvents() {
|
||||
RefPtr<dom::Document> doc = PrepareForContentChecks();
|
||||
if (!doc) {
|
||||
// If the docshell has no document, then there is no need to update mState.
|
||||
return;
|
||||
}
|
||||
|
||||
// Has tracking content been blocked or loaded?
|
||||
if (doc->GetHasTrackingContentBlocked()) {
|
||||
mEvent |= STATE_BLOCKED_TRACKING_CONTENT;
|
||||
}
|
||||
|
||||
if (doc->GetHasLevel1TrackingContentLoaded()) {
|
||||
mEvent |= STATE_LOADED_LEVEL_1_TRACKING_CONTENT;
|
||||
}
|
||||
|
||||
if (doc->GetHasLevel2TrackingContentLoaded()) {
|
||||
mEvent |= STATE_LOADED_LEVEL_2_TRACKING_CONTENT;
|
||||
}
|
||||
|
||||
// Has fingerprinting content been blocked or loaded?
|
||||
if (doc->GetHasFingerprintingContentBlocked()) {
|
||||
mEvent |= STATE_BLOCKED_FINGERPRINTING_CONTENT;
|
||||
}
|
||||
|
||||
if (doc->GetHasFingerprintingContentLoaded()) {
|
||||
mEvent |= STATE_LOADED_FINGERPRINTING_CONTENT;
|
||||
}
|
||||
|
||||
// Has cryptomining content been blocked or loaded?
|
||||
if (doc->GetHasCryptominingContentBlocked()) {
|
||||
mEvent |= STATE_BLOCKED_CRYPTOMINING_CONTENT;
|
||||
}
|
||||
|
||||
if (doc->GetHasCryptominingContentLoaded()) {
|
||||
mEvent |= STATE_LOADED_CRYPTOMINING_CONTENT;
|
||||
}
|
||||
|
||||
// Has socialtracking content been blocked or loaded?
|
||||
if (doc->GetHasSocialTrackingContentBlocked()) {
|
||||
mEvent |= STATE_BLOCKED_SOCIALTRACKING_CONTENT;
|
||||
}
|
||||
|
||||
if (doc->GetHasSocialTrackingContentLoaded()) {
|
||||
mEvent |= STATE_LOADED_SOCIALTRACKING_CONTENT;
|
||||
}
|
||||
|
||||
// Other block types.
|
||||
if (doc->GetHasCookiesBlockedByPermission()) {
|
||||
mEvent |= STATE_COOKIES_BLOCKED_BY_PERMISSION;
|
||||
}
|
||||
|
||||
if (doc->GetHasTrackingCookiesBlocked()) {
|
||||
mEvent |= STATE_COOKIES_BLOCKED_TRACKER;
|
||||
}
|
||||
|
||||
if (doc->GetHasSocialTrackingCookiesBlocked()) {
|
||||
mEvent |= STATE_COOKIES_BLOCKED_SOCIALTRACKER;
|
||||
}
|
||||
|
||||
if (doc->GetHasForeignCookiesBlocked()) {
|
||||
mEvent |= STATE_COOKIES_BLOCKED_FOREIGN;
|
||||
}
|
||||
|
||||
if (doc->GetHasAllCookiesBlocked()) {
|
||||
mEvent |= STATE_COOKIES_BLOCKED_ALL;
|
||||
}
|
||||
|
||||
if (doc->GetHasCookiesLoaded()) {
|
||||
mEvent |= STATE_COOKIES_LOADED;
|
||||
}
|
||||
|
||||
if (doc->GetHasTrackerCookiesLoaded()) {
|
||||
mEvent |= STATE_COOKIES_LOADED_TRACKER;
|
||||
}
|
||||
|
||||
if (doc->GetHasSocialTrackerCookiesLoaded()) {
|
||||
mEvent |= STATE_COOKIES_LOADED_SOCIALTRACKER;
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to determine if the given URI can be considered secure.
|
||||
// Essentially, only "https" URIs can be considered secure. However, the URI we
|
||||
// have may be e.g. view-source:https://example.com, in which case we have to
|
||||
|
|
|
@ -44,8 +44,6 @@ class nsSecureBrowserUIImpl : public nsISecureBrowserUI,
|
|||
already_AddRefed<mozilla::dom::Document> PrepareForContentChecks();
|
||||
// Do mixed content checks. May update mState.
|
||||
void CheckForMixedContent();
|
||||
// Do Content Blocking checks. May update mEvent.
|
||||
void CheckForContentBlockingEvents();
|
||||
// Given some information about a request from an OnLocationChange event,
|
||||
// update mState and mTopLevelSecurityInfo.
|
||||
nsresult UpdateStateAndSecurityInfo(nsIChannel* channel, nsIURI* uri);
|
||||
|
|
|
@ -18,11 +18,6 @@ RemoteSecurityUI.prototype = {
|
|||
get state() {
|
||||
return this._state;
|
||||
},
|
||||
// TODO: This API will be removed when we remove contentBlockingEvent
|
||||
// from nsISecureBrowserUI.idl
|
||||
get contentBlockingEvent() {
|
||||
return 0;
|
||||
},
|
||||
get secInfo() {
|
||||
return this._secInfo;
|
||||
},
|
||||
|
|
|
@ -1525,25 +1525,6 @@ void nsDocLoader::OnSecurityChange(nsISupports* aContext, uint32_t aState) {
|
|||
}
|
||||
}
|
||||
|
||||
void nsDocLoader::OnContentBlockingEvent(nsISupports* aContext,
|
||||
uint32_t aEvent) {
|
||||
//
|
||||
// Fire progress notifications out to any registered nsIWebProgressListeners.
|
||||
//
|
||||
|
||||
nsCOMPtr<nsIRequest> request = do_QueryInterface(aContext);
|
||||
nsIWebProgress* webProgress = static_cast<nsIWebProgress*>(this);
|
||||
|
||||
NOTIFY_LISTENERS(
|
||||
nsIWebProgress::NOTIFY_CONTENT_BLOCKING,
|
||||
listener->OnContentBlockingEvent(webProgress, request, aEvent););
|
||||
|
||||
// Pass the notification up to the parent...
|
||||
if (mParent) {
|
||||
mParent->OnContentBlockingEvent(aContext, aEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation of nsISupportsPriority methods...
|
||||
*
|
||||
|
|
|
@ -120,14 +120,6 @@ class nsDocLoader : public nsIDocumentLoader,
|
|||
* changed. State flags are in nsIWebProgressListener.idl
|
||||
*/
|
||||
void OnSecurityChange(nsISupports* aContext, uint32_t aState);
|
||||
/**
|
||||
* Fired when a content blocking event occurs during the time
|
||||
* when a document is alive. This interface should be called
|
||||
* by Gecko to notify nsIWebProgressListeners that there is a
|
||||
* new content blocking event. Content blocking events are in
|
||||
* nsIWebProgressListeners.idl.
|
||||
*/
|
||||
void OnContentBlockingEvent(nsISupports* aContext, uint32_t aEvent);
|
||||
|
||||
void SetDocumentOpenedButNotLoaded() { mDocumentOpenedButNotLoaded = true; }
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче