From 26f9d5efce138040ec1ce1dd448a747eb7e35caf Mon Sep 17 00:00:00 2001 From: JulianWels Date: Thu, 16 Apr 2020 00:33:10 +0000 Subject: [PATCH] Bug 1620244 - Retention telemetry for HTTPS Only Mode. r=ckerschb,jcj Differential Revision: https://phabricator.services.mozilla.com/D69547 --HG-- extra : moz-landing-system : lando --- browser/components/BrowserGlue.jsm | 21 +++++++++++++++++++++ modules/libpref/init/StaticPrefList.yaml | 8 ++++++++ toolkit/components/telemetry/Scalars.yaml | 15 +++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/browser/components/BrowserGlue.jsm b/browser/components/BrowserGlue.jsm index fb9c2c51adbc..024051978565 100644 --- a/browser/components/BrowserGlue.jsm +++ b/browser/components/BrowserGlue.jsm @@ -1970,6 +1970,26 @@ BrowserGlue.prototype = { }); }, + _monitorHTTPSOnlyPref() { + const PREF_ENABLED = "dom.security.https_only_mode"; + const PREF_WAS_ENABLED = "dom.security.https_only_mode_ever_enabled"; + const _checkHTTPSOnlyPref = async () => { + const enabled = Services.prefs.getBoolPref(PREF_ENABLED, false); + const was_enabled = Services.prefs.getBoolPref(PREF_WAS_ENABLED, false); + let value = 0; + if (enabled) { + value = 1; + Services.prefs.setBoolPref(PREF_WAS_ENABLED, true); + } else if (was_enabled) { + value = 2; + } + Services.telemetry.scalarSet("security.https_only_mode_enabled", value); + }; + + Services.prefs.addObserver(PREF_ENABLED, _checkHTTPSOnlyPref); + _checkHTTPSOnlyPref(); + }, + _showNewInstallModal() { // Allow other observers of the same topic to run while we open the dialog. Services.tm.dispatchToMainThread(() => { @@ -2057,6 +2077,7 @@ BrowserGlue.prototype = { this._monitorScreenshotsPref(); this._monitorWebcompatReporterPref(); + this._monitorHTTPSOnlyPref(); let pService = Cc["@mozilla.org/toolkit/profile-service;1"].getService( Ci.nsIToolkitProfileService diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index cb9770db14aa..ccb08c982a0b 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -2454,6 +2454,14 @@ value: false mirror: always +# WARNING: Don't ever update that pref manually! It is only used +# for telemetry purposes and allows to reason about retention of +# the pref dom.security.https_only_mode from above. +- name: dom.security.https_only_mode_ever_enabled + type: RelaxedAtomicBool + value: false + mirror: always + # Is support for selection event APIs enabled? - name: dom.select_events.enabled type: bool diff --git a/toolkit/components/telemetry/Scalars.yaml b/toolkit/components/telemetry/Scalars.yaml index 7fd3819902e6..1cebbc1a9ae1 100644 --- a/toolkit/components/telemetry/Scalars.yaml +++ b/toolkit/components/telemetry/Scalars.yaml @@ -758,6 +758,21 @@ security: - 'geckoview' record_in_processes: - main + https_only_mode_enabled: + bug_numbers: + - 1620244 + description: > + Measures user retention of the HTTPS-Only Mode. + 0 = never enabled, 1 = enabled, 2 = disabled (but was enabled) + expires: never + kind: uint + notification_emails: + - julianwels@mozilla.com + - seceng-telemetry@mozilla.com + products: + - 'firefox' + record_in_processes: + - 'main' pwmgr: potentially_breached_passwords: