1/* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */
2/* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6"use strict";
7
8const { XPCOMUtils } = ChromeUtils.import(
9  "resource://gre/modules/XPCOMUtils.jsm"
10);
11
12XPCOMUtils.defineLazyModuleGetters(this, {
13  Services: "resource://gre/modules/Services.jsm",
14  WindowsInstallsInfo:
15    "resource://gre/modules/components-utils/WindowsInstallsInfo.jsm",
16});
17
18var EXPORTED_SYMBOLS = ["UninstallPing"];
19
20/**
21 * The Windows-only "uninstall" ping, which is saved to disk for the uninstaller to find.
22 * The ping is actually assembled by TelemetryControllerParent.saveUninstallPing().
23 */
24var UninstallPing = {
25  /**
26   * Maximum number of other installs to count (see
27   * toolkit/components/telemetry/docs/data/uninstall-ping.rst for motivation)
28   */
29  MAX_OTHER_INSTALLS: 11,
30
31  /**
32   * Count other installs of this app, based on the values in the TaskBarIDs registry key.
33   *
34   */
35  getOtherInstallsCount() {
36    return WindowsInstallsInfo.getInstallPaths(
37      this.MAX_OTHER_INSTALLS,
38      new Set([Services.dirsvc.get("GreBinD", Ci.nsIFile).path])
39    ).size;
40  },
41};
42