summaryrefslogtreecommitdiffstats
path: root/toolkit/components/resistfingerprinting/nsRFPService.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/resistfingerprinting/nsRFPService.cpp')
-rw-r--r--toolkit/components/resistfingerprinting/nsRFPService.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/toolkit/components/resistfingerprinting/nsRFPService.cpp b/toolkit/components/resistfingerprinting/nsRFPService.cpp
index 8579fe2a3b..643cc2cb7a 100644
--- a/toolkit/components/resistfingerprinting/nsRFPService.cpp
+++ b/toolkit/components/resistfingerprinting/nsRFPService.cpp
@@ -71,6 +71,7 @@
#include "nsTLiteralString.h"
#include "nsTPromiseFlatString.h"
#include "nsTStringRepr.h"
+#include "nsUserCharacteristics.h"
#include "nsXPCOM.h"
#include "nsICookieJarSettings.h"
@@ -100,8 +101,14 @@ static mozilla::LazyLogModule gFingerprinterDetection("FingerprinterDetection");
#define RESIST_FINGERPRINTINGPROTECTION_OVERRIDE_PREF \
"privacy.fingerprintingProtection.overrides"
+#define GLEAN_DATA_SUBMISSION_PREF "datareporting.healthreport.uploadEnabled"
+#define USER_CHARACTERISTICS_UUID_PREF \
+ "toolkit.telemetry.user_characteristics_ping.uuid"
+
#define RFP_TIMER_UNCONDITIONAL_VALUE 20
#define LAST_PB_SESSION_EXITED_TOPIC "last-pb-context-exited"
+#define IDLE_TOPIC "browser-idle-startup-tasks-finished"
+#define GFX_FEATURES "gfx-features-ready"
static constexpr uint32_t kVideoFramesPerSec = 30;
static constexpr uint32_t kVideoDroppedRatio = 5;
@@ -156,6 +163,7 @@ already_AddRefed<nsRFPService> nsRFPService::GetOrCreate() {
static const char* gCallbackPrefs[] = {
RESIST_FINGERPRINTINGPROTECTION_OVERRIDE_PREF,
+ GLEAN_DATA_SUBMISSION_PREF,
nullptr,
};
@@ -176,6 +184,12 @@ nsresult nsRFPService::Init() {
rv = obs->AddObserver(this, OBSERVER_TOPIC_IDLE_DAILY, false);
NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = obs->AddObserver(this, IDLE_TOPIC, false);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = obs->AddObserver(this, GFX_FEATURES, false);
+ NS_ENSURE_SUCCESS(rv, rv);
}
Preferences::RegisterCallbacks(nsRFPService::PrefChanged, gCallbackPrefs,
@@ -273,6 +287,8 @@ void nsRFPService::StartShutdown() {
if (XRE_IsParentProcess()) {
obs->RemoveObserver(this, LAST_PB_SESSION_EXITED_TOPIC);
obs->RemoveObserver(this, OBSERVER_TOPIC_IDLE_DAILY);
+ obs->RemoveObserver(this, IDLE_TOPIC);
+ obs->RemoveObserver(this, GFX_FEATURES);
}
}
@@ -290,16 +306,30 @@ void nsRFPService::PrefChanged(const char* aPref, void* aSelf) {
}
void nsRFPService::PrefChanged(const char* aPref) {
+ MOZ_LOG(gResistFingerprintingLog, LogLevel::Info,
+ ("Pref Changed: %s", aPref));
nsDependentCString pref(aPref);
if (pref.EqualsLiteral(RESIST_FINGERPRINTINGPROTECTION_OVERRIDE_PREF)) {
UpdateFPPOverrideList();
+ } else if (pref.EqualsLiteral(GLEAN_DATA_SUBMISSION_PREF)) {
+ if (XRE_IsParentProcess() &&
+ !Preferences::GetBool(GLEAN_DATA_SUBMISSION_PREF, false)) {
+ MOZ_LOG(gResistFingerprintingLog, LogLevel::Info, ("Clearing UUID"));
+ // If the user has unset the telemetry pref, wipe out the UUID pref value
+ // (The data will also be erased server-side via the "deletion-request"
+ // ping)
+ Preferences::SetCString(USER_CHARACTERISTICS_UUID_PREF, ""_ns);
+ }
}
}
NS_IMETHODIMP
nsRFPService::Observe(nsISupports* aObject, const char* aTopic,
const char16_t* aMessage) {
+ const int kNumTopicsForUserCharacteristics = 2;
+ static int seenTopicsForUserCharacteristics = 0;
+
if (strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, aTopic) == 0) {
StartShutdown();
}
@@ -312,6 +342,14 @@ nsRFPService::Observe(nsISupports* aObject, const char* aTopic,
ClearBrowsingSessionKey(pattern);
}
+ if (!strcmp(IDLE_TOPIC, aTopic) || !strcmp(GFX_FEATURES, aTopic)) {
+ seenTopicsForUserCharacteristics++;
+
+ if (seenTopicsForUserCharacteristics == kNumTopicsForUserCharacteristics) {
+ nsUserCharacteristics::MaybeSubmitPing();
+ }
+ }
+
if (!strcmp(OBSERVER_TOPIC_IDLE_DAILY, aTopic)) {
if (StaticPrefs::
privacy_resistFingerprinting_randomization_daily_reset_enabled()) {