summaryrefslogtreecommitdiffstats
path: root/toolkit/components/antitracking/ContentBlockingNotifier.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /toolkit/components/antitracking/ContentBlockingNotifier.h
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/antitracking/ContentBlockingNotifier.h')
-rw-r--r--toolkit/components/antitracking/ContentBlockingNotifier.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/toolkit/components/antitracking/ContentBlockingNotifier.h b/toolkit/components/antitracking/ContentBlockingNotifier.h
new file mode 100644
index 0000000000..20f32d7f94
--- /dev/null
+++ b/toolkit/components/antitracking/ContentBlockingNotifier.h
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_contentblockingnotifier_h
+#define mozilla_contentblockingnotifier_h
+
+#include "nsStringFwd.h"
+#include "mozilla/Maybe.h"
+
+#define ANTITRACKING_CONSOLE_CATEGORY "Content Blocking"_ns
+
+class nsIChannel;
+class nsPIDOMWindowInner;
+class nsPIDOMWindowOuter;
+
+namespace mozilla {
+namespace dom {
+class BrowsingContext;
+} // namespace dom
+
+class ContentBlockingNotifier final {
+ public:
+ enum class BlockingDecision {
+ eBlock,
+ eAllow,
+ };
+ enum StorageAccessPermissionGrantedReason {
+ eStorageAccessAPI,
+ eOpenerAfterUserInteraction,
+ eOpener,
+ ePrivilegeStorageAccessForOriginAPI,
+ };
+
+ // This method can be called on the parent process or on the content process.
+ // The notification is propagated to the child channel if aChannel is a parent
+ // channel proxy.
+ //
+ // aDecision can be eBlock if we have decided to block some content, or eAllow
+ // if we have decided to allow the content through.
+ //
+ // aRejectedReason must be one of these values:
+ // * nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION
+ // * nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER
+ // * nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER
+ // * nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL
+ // * nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN
+ static void OnDecision(nsIChannel* aChannel, BlockingDecision aDecision,
+ uint32_t aRejectedReason);
+
+ static void OnDecision(nsPIDOMWindowInner* aWindow,
+ BlockingDecision aDecision, uint32_t aRejectedReason);
+
+ static void OnDecision(dom::BrowsingContext* aBrowsingContext,
+ BlockingDecision aDecision, uint32_t aRejectedReason);
+
+ static void OnEvent(nsIChannel* aChannel, uint32_t aRejectedReason,
+ bool aBlocked = true);
+
+ static void OnEvent(
+ nsIChannel* aChannel, bool aBlocked, uint32_t aRejectedReason,
+ const nsACString& aTrackingOrigin,
+ const Maybe<StorageAccessPermissionGrantedReason>& aReason = Nothing());
+
+ static void ReportUnblockingToConsole(
+ dom::BrowsingContext* aBrowsingContext, const nsAString& aTrackingOrigin,
+ StorageAccessPermissionGrantedReason aReason);
+};
+
+} // namespace mozilla
+
+#endif // mozilla_contentblockingnotifier_h