summaryrefslogtreecommitdiffstats
path: root/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingProtection.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingProtection.h27
1 files changed, 22 insertions, 5 deletions
diff --git a/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingProtection.h b/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingProtection.h
index e99cf895be..98b235ead1 100644
--- a/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingProtection.h
+++ b/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingProtection.h
@@ -6,8 +6,10 @@
#include "mozilla/Logging.h"
#include "mozilla/MozPromise.h"
+#include "mozilla/glean/GleanMetrics.h"
#include "nsIBounceTrackingProtection.h"
#include "nsIClearDataService.h"
+#include "mozilla/Maybe.h"
class nsIPrincipal;
class nsITimer;
@@ -37,8 +39,11 @@ class BounceTrackingProtection final : public nsIBounceTrackingProtection {
[[nodiscard]] nsresult RecordStatefulBounces(
BounceTrackingState* aBounceTrackingState);
- // Stores a user activation flag with a timestamp for the given principal.
- [[nodiscard]] nsresult RecordUserActivation(nsIPrincipal* aPrincipal);
+ // Stores a user activation flag with a timestamp for the given principal. The
+ // timestamp defaults to the current time, but can be overridden via
+ // aActivationTime.
+ [[nodiscard]] nsresult RecordUserActivation(
+ nsIPrincipal* aPrincipal, Maybe<PRTime> aActivationTime = Nothing());
// Clears expired user interaction flags for the given state global. If
// aStateGlobal == nullptr, clears expired user interaction flags for all
@@ -50,6 +55,10 @@ class BounceTrackingProtection final : public nsIBounceTrackingProtection {
BounceTrackingProtection();
~BounceTrackingProtection() = default;
+ // Keeps track of whether the feature is enabled based on pref state.
+ // Initialized on first call of GetSingleton.
+ static Maybe<bool> sFeatureIsEnabled;
+
// Timer which periodically runs PurgeBounceTrackers.
nsCOMPtr<nsITimer> mBounceTrackingPurgeTimer;
@@ -82,15 +91,23 @@ class BounceTrackingProtection final : public nsIBounceTrackingProtection {
NS_DECL_NSICLEARDATACALLBACK
explicit ClearDataCallback(ClearDataMozPromise::Private* aPromise,
- const nsACString& aHost)
- : mHost(aHost), mPromise(aPromise){};
+ const nsACString& aHost);
private:
- virtual ~ClearDataCallback() { mPromise->Reject(0, __func__); }
+ virtual ~ClearDataCallback();
nsCString mHost;
+
+ void RecordClearDurationTelemetry();
+
+ glean::TimerId mClearDurationTimer;
RefPtr<ClearDataMozPromise::Private> mPromise;
};
+
+ // Imports user activation permissions from permission manager if needed. This
+ // is important so we don't purge data for sites the user has interacted with
+ // before the feature was enabled.
+ [[nodiscard]] nsresult MaybeMigrateUserInteractionPermissions();
};
} // namespace mozilla