Bug 1388145 - Make Master Password telemetry only run once per session (and not per window), and run it after an idle period. r=MattN
MozReview-Commit-ID: 1Ecy94TGGar
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1742,31 +1742,16 @@ var gBrowserInit = {
}
// Enable the Restore Last Session command if needed
RestoreLastSessionObserver.init();
SidebarUI.startDelayedLoad();
SocialUI.init();
- // Telemetry for master-password - we do this after 5 seconds as it
- // can cause IO if NSS/PSM has not already initialized.
- setTimeout(() => {
- if (window.closed) {
- return;
- }
- let tokenDB = Cc["@mozilla.org/security/pk11tokendb;1"]
- .getService(Ci.nsIPK11TokenDB);
- let token = tokenDB.getInternalKeyToken();
- let mpEnabled = token.hasPassword;
- if (mpEnabled) {
- Services.telemetry.getHistogramById("MASTER_PASSWORD_ENABLED").add(mpEnabled);
- }
- }, 5000);
-
PanicButtonNotifier.init();
});
gBrowser.tabContainer.addEventListener("TabSelect", function() {
for (let panel of document.querySelectorAll("panel[tabspecific='true']")) {
if (panel.state == "open") {
panel.hidePopup();
}
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1156,16 +1156,28 @@ BrowserGlue.prototype = {
* Note: this function may never be called if the user is never idle for the
* full length of the period of time specified. But given a reasonably low
* value, this is unlikely.
*/
_scheduleArbitrarilyLateIdleTasks() {
Services.tm.idleDispatchToMainThread(() => {
this._sendMediaTelemetry();
});
+
+ Services.tm.idleDispatchToMainThread(() => {
+ // Telemetry for master-password - we do this after a delay as it
+ // can cause IO if NSS/PSM has not already initialized.
+ let tokenDB = Cc["@mozilla.org/security/pk11tokendb;1"]
+ .getService(Ci.nsIPK11TokenDB);
+ let token = tokenDB.getInternalKeyToken();
+ let mpEnabled = token.hasPassword;
+ if (mpEnabled) {
+ Services.telemetry.getHistogramById("MASTER_PASSWORD_ENABLED").add(mpEnabled);
+ }
+ });
},
_createExtraDefaultProfile() {
if (!AppConstants.MOZ_DEV_EDITION) {
return;
}
// If Developer Edition is the only installed Firefox version and no other
// profiles are present, create a second one for use by other versions.