From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../BounceTrackingProtection.h | 27 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingProtection.h') 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 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 sFeatureIsEnabled; + // Timer which periodically runs PurgeBounceTrackers. nsCOMPtr 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 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 -- cgit v1.2.3