DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c68fe15a81fc)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";
"use strict";

const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");

/* eslint-disable prettier/prettier */
ChromeUtils.defineModuleGetter(this, "ShellService", "resource:///modules/ShellService.jsm");
ChromeUtils.defineModuleGetter(this, "ShellService", "resource:///modules/ShellService.jsm");
ChromeUtils.defineModuleGetter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm");
ChromeUtils.defineModuleGetter(this, "TelemetryArchive", "resource://gre/modules/TelemetryArchive.jsm");
ChromeUtils.defineModuleGetter(this, "TelemetryController", "resource://gre/modules/TelemetryController.jsm");
ChromeUtils.defineModuleGetter(this, "UpdateUtils", "resource://gre/modules/UpdateUtils.jsm");
ChromeUtils.defineModuleGetter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm");
ChromeUtils.defineModuleGetter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm");
ChromeUtils.defineModuleGetter(this, "AttributionCode", "resource:///modules/AttributionCode.jsm");
ChromeUtils.defineModuleGetter(this, "WindowsVersionInfo", "resource://gre/modules/components-utils/WindowsVersionInfo.jsm");
ChromeUtils.defineModuleGetter(this, "NormandyUtils", "resource://normandy/lib/NormandyUtils.jsm");

var EXPORTED_SYMBOLS = ["ClientEnvironmentBase"];
/* eslint-enable prettier/prettier */

var EXPORTED_SYMBOLS = ["ClientEnvironmentBase"];

/**
 * Components like Normandy RecipeRunner use this as part of the context for filter expressions,
 * Create an object that provides general information about the client application.
 *
 * Components like Normandy RecipeRunner use this as part of the context for filter expressions,
 * so avoid adding non-getter functions as attributes, as filter expressions
 * cannot execute functions.
 * can add getter functions that return promises for async data.
 *
 * Also note that, because filter expressions implicitly resolve promises, you
 * can add getter functions that return promises for async data.
 */
class ClientEnvironmentBase {
  }
  static get distribution() {
    return Services.prefs.getCharPref("distribution.id", "default");
  }

      const pings = await TelemetryArchive.promiseArchivedPingList();
  static get telemetry() {
    return (async () => {
      const pings = await TelemetryArchive.promiseArchivedPingList();

      // get most recent ping per type
        if (ping.type in mostRecentPings) {
      const mostRecentPings = {};
      for (const ping of pings) {
        if (ping.type in mostRecentPings) {
          if (
            mostRecentPings[ping.type].timestampCreated < ping.timestampCreated
          }
          ) {
            mostRecentPings[ping.type] = ping;
          }
        } else {
          mostRecentPings[ping.type] = ping;
        }
      }
      for (const key in mostRecentPings) {

      const telemetry = {};
      for (const key in mostRecentPings) {
        const ping = mostRecentPings[key];
        telemetry[ping.type] = await TelemetryArchive.promiseArchivedPingById(
      }
          ping.id
        );
      }
      return telemetry;
    })();
  static get liveTelemetry() {
  }

  static get liveTelemetry() {
    // Construct a proxy object that forwards access to the main ping, and
    // throws errors for other ping types. The intent is to allow using
    // `telemetry` and `liveTelemetry` in similar ways, but to fail fast if
    let target = {};
    // the wrong telemetry types are accessed.
    let target = {};
    try {
      target.main = TelemetryController.getCurrentPingData();
    } catch (err) {
    }
      Cu.reportError(err);
    }

    return new Proxy(target, {
          return target.main;
      get(target, prop, receiver) {
        if (prop == "main") {
          return target.main;
        }
          `Live telemetry only includes the main ping, not the ${prop} ping`
        throw new Error(
          `Live telemetry only includes the main ping, not the ${prop} ping`
        );
      },
      has(target, prop) {
        return prop == "main";
  }
      },
    });
  }

  // Note that we intend to replace usages of this with client_id in https://bugzilla.mozilla.org/show_bug.cgi?id=1542955
  static get randomizationId() {

    let id = Services.prefs.getCharPref("app.normandy.user_id", "");
    if (!id) {
      id = NormandyUtils.generateUuid();
      Services.prefs.setCharPref("app.normandy.user_id", id);
    }
  static get isDefaultBrowser() {
    return id;
  }

  static get version() {
    return AppConstants.MOZ_APP_VERSION_DISPLAY;
    return (async () => {
  }

  static get channel() {
    return UpdateUtils.getUpdateChannel(false);
  }


  static get isDefaultBrowser() {
  }
    return ShellService.isDefaultBrowser();
  }

  static get searchEngine() {
    return (async () => {
      0
      const defaultEngineInfo = await Services.search.getDefaultEngineInfo();
      return defaultEngineInfo.defaultSearchEngine;
    })();
  }

    return Services.prefs.getIntPref("services.sync.clients.devices.mobile", 0);
  static get syncSetup() {
    return Services.prefs.prefHasUserValue("services.sync.username");
  }

  static get syncDesktopDevices() {
  }
    return Services.prefs.getIntPref(
      "services.sync.clients.devices.desktop",
      0
    );
  }

  static get syncMobileDevices() {
    return Services.prefs.getIntPref("services.sync.clients.devices.mobile", 0);
  }
          name,

  static get syncTotalDevices() {
    return this.syncDesktopDevices + this.syncMobileDevices;
  }

  static get addons() {
        const installDate = new Date(installDateN);
    return (async () => {
        return acc;
      const addons = await AddonManager.getAllAddons();
      return addons.reduce((acc, addon) => {
        const {
          id,
          isActive,
  static get plugins() {
          name,
          type,
          version,
          installDate: installDateN,
        } = addon;
        const installDate = new Date(installDateN);
        acc[id] = { id, isActive, name, type, version, installDate };
        return acc;
      }, {});
      }, {});
    })();
  }

  static get plugins() {
    return Services.locale.appLocaleAsBCP47;
    return (async () => {
      const plugins = await AddonManager.getAddonsByTypes(["plugin"]);
      return plugins.reduce((acc, plugin) => {
        const { name, description, version } = plugin;
        acc[name] = { name, description, version };
      "privacy.donottrackheader.enabled",
        return acc;
      }, {});
    })();
  }

  static get os() {
  static get locale() {
    return Services.locale.appLocaleAsBCP47;
  }

  static get doNotTrack() {
    return Services.prefs.getBoolPref(
      let version = null;
      "privacy.donottrackheader.enabled",
      false
    );
  }

      }
  static get os() {
    function coerceToNumber(version) {
      const parts = version.split(".");
      return parseFloat(parts.slice(0, 2).join("."));
    }
    }

    function getOsVersion() {
      let version = null;
      try {
        version = Services.sysinfo.getProperty("version", null);
      isLinux: AppConstants.platform === "linux",
      } catch (_e) {
        // getProperty can throw if the version does not exist
      }
      if (version) {
        version = coerceToNumber(version);
        }
      }
      return version;
    }

    let osInfo = {
      isWindows: AppConstants.platform == "win",
      isMac: AppConstants.platform === "macosx",
      isLinux: AppConstants.platform === "linux",

      get windowsBuildNumber() {
      get windowsVersion() {
        if (!osInfo.isWindows) {
          return null;
        }
        return getOsVersion();
        return WindowsVersionInfo.get({ throwOnError: false }).buildNumber;
      },

      /**
       * Gets the windows build number by querying the OS directly. The initial
       * version was copied from toolkit/components/telemetry/app/TelemetryEnvironment.jsm
        // Versions of OSX with Darwin < 5 don't follow this pattern
       * @returns {number | null} The build number, or null on non-Windows platform or if there is an error.
       */
      get windowsBuildNumber() {
        if (!osInfo.isWindows) {
          return 10 + 0.1 * (intPart - 4);
          return null;
        }

        return WindowsVersionInfo.get({ throwOnError: false }).buildNumber;
      },
      get darwinVersion() {

      get macVersion() {
        const darwinVersion = osInfo.darwinVersion;
        // Versions of OSX with Darwin < 5 don't follow this pattern
        if (darwinVersion >= 5) {
      },
          // OSX 10.1 used Darwin 5, OSX 10.2 used Darwin 6, and so on.
          const intPart = Math.floor(darwinVersion);
          return 10 + 0.1 * (intPart - 4);
        }
        return null;
      },
    return osInfo;

      get darwinVersion() {
        if (!osInfo.isMac) {
  static get attribution() {
          return null;
    return AttributionCode.getAttrDataAsync();
        }
        return getOsVersion();
      },

  static get appinfo() {
      // Version information on linux is a lot harder and a lot less useful, so
      // don't do anything about it here.
    };

    return osInfo;
}
  }

  static get attribution() {
    return AttributionCode.getAttrDataAsync();
  }

  static get appinfo() {
    Services.appinfo.QueryInterface(Ci.nsIXULAppInfo);
    Services.appinfo.QueryInterface(Ci.nsIPlatformInfo);
    return Services.appinfo;
  }
}