summaryrefslogtreecommitdiffstats
path: root/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingState.h
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingState.h')
-rw-r--r--toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingState.h39
1 files changed, 22 insertions, 17 deletions
diff --git a/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingState.h b/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingState.h
index 17d324bda9..a9e186206a 100644
--- a/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingState.h
+++ b/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingState.h
@@ -45,7 +45,7 @@ class BounceTrackingState : public nsIWebProgressListener,
// return nullptr if the given web progress / browsing context is not suitable
// (see ShouldCreateBounceTrackingStateForWebProgress).
static already_AddRefed<BounceTrackingState> GetOrCreate(
- dom::BrowsingContextWebProgress* aWebProgress);
+ dom::BrowsingContextWebProgress* aWebProgress, nsresult& aRv);
// Reset state for all BounceTrackingState instances this includes resetting
// BounceTrackingRecords and cancelling any running timers.
@@ -62,31 +62,35 @@ class BounceTrackingState : public nsIWebProgressListener,
// Callback for when we received a response from the server and are about to
// create a document for the response. Calls into
// BounceTrackingState::OnResponseReceived.
- nsresult OnDocumentStartRequest(nsIChannel* aChannel);
+ [[nodiscard]] nsresult OnDocumentStartRequest(nsIChannel* aChannel);
// At the start of a navigation, either initialize a new bounce tracking
// record, or append a client-side redirect to the current bounce tracking
// record.
// Should only be called for top level content navigations.
- nsresult OnStartNavigation(nsIPrincipal* aTriggeringPrincipal,
- const bool aHasValidUserGestureActivation);
+ [[nodiscard]] nsresult OnStartNavigation(
+ nsIPrincipal* aTriggeringPrincipal,
+ const bool aHasValidUserGestureActivation);
// Record sites which have written cookies in the current extended
// navigation.
- nsresult OnCookieWrite(const nsACString& aSiteHost);
+ [[nodiscard]] nsresult OnCookieWrite(const nsACString& aSiteHost);
// Whether the given BrowsingContext should hold a BounceTrackingState
// instance to monitor bounce tracking navigations.
static bool ShouldCreateBounceTrackingStateForBC(
dom::CanonicalBrowsingContext* aBrowsingContext);
+ // Whether the given principal should be tracked for bounce tracking.
+ static bool ShouldTrackPrincipal(nsIPrincipal* aPrincipal);
+
// Check if there is a BounceTrackingState which current browsing context is
// associated with aSiteHost.
// This is an approximation for checking if a given site is currently loaded
// in the top level context, e.g. in a tab. See Bug 1842047 for adding a more
// accurate check that calls into the browser implementations.
- static nsresult HasBounceTrackingStateForSite(const nsACString& aSiteHost,
- bool& aResult);
+ [[nodiscard]] static nsresult HasBounceTrackingStateForSite(
+ const nsACString& aSiteHost, bool& aResult);
// Get the currently associated BrowsingContext. Returns nullptr if it has not
// been attached yet.
@@ -99,10 +103,16 @@ class BounceTrackingState : public nsIWebProgressListener,
// Create a string that describes this object. Used for logging.
nsCString Describe();
+ // Record sites which have accessed storage in the current extended
+ // navigation.
+ [[nodiscard]] nsresult OnStorageAccess(nsIPrincipal* aPrincipal);
+
private:
explicit BounceTrackingState();
virtual ~BounceTrackingState();
+ bool mIsInitialized{false};
+
uint64_t mBrowserId{};
// OriginAttributes associated with the browser this state is attached to.
@@ -130,25 +140,20 @@ class BounceTrackingState : public nsIWebProgressListener,
dom::BrowsingContextWebProgress* aWebProgress);
// Init to be called after creation, attaches nsIWebProgressListener.
- nsresult Init(dom::BrowsingContextWebProgress* aWebProgress);
+ [[nodiscard]] nsresult Init(dom::BrowsingContextWebProgress* aWebProgress);
// When the response is received at the end of a navigation, fill the
// bounce set.
- nsresult OnResponseReceived(const nsTArray<nsCString>& aSiteList);
+ [[nodiscard]] nsresult OnResponseReceived(
+ const nsTArray<nsCString>& aSiteList);
// When the document is loaded at the end of a navigation, update the
// final host.
- nsresult OnDocumentLoaded(nsIPrincipal* aDocumentPrincipal);
-
- // TODO: Bug 1839918: Detection of stateful bounces.
-
- // Record sites which have accessed storage in the current extended
- // navigation.
- nsresult OnStorageAccess();
+ [[nodiscard]] nsresult OnDocumentLoaded(nsIPrincipal* aDocumentPrincipal);
// Record sites which have activated service workers in the current
// extended navigation.
- nsresult OnServiceWorkerActivation();
+ [[nodiscard]] nsresult OnServiceWorkerActivation();
};
} // namespace mozilla