Bug 1822393 - Consume GeckoView directly in Android Components for CI builds. r=owlis...
[gecko.git] / browser / actors / AboutPrivateBrowsingChild.sys.mjs
blob277156065c685ce79eba02239c5dabe8d754ca4f
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
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/. */
6 import { RemotePageChild } from "resource://gre/actors/RemotePageChild.sys.mjs";
8 const lazy = {};
10 ChromeUtils.defineESModuleGetters(lazy, {
11   NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
12   ExperimentAPI: "resource://nimbus/ExperimentAPI.sys.mjs",
13 });
15 export class AboutPrivateBrowsingChild extends RemotePageChild {
16   actorCreated() {
17     super.actorCreated();
18     let window = this.contentWindow;
20     Cu.exportFunction(this.PrivateBrowsingRecordClick.bind(this), window, {
21       defineAs: "PrivateBrowsingRecordClick",
22     });
23     Cu.exportFunction(
24       this.PrivateBrowsingShouldHideDefault.bind(this),
25       window,
26       {
27         defineAs: "PrivateBrowsingShouldHideDefault",
28       }
29     );
30     Cu.exportFunction(
31       this.PrivateBrowsingPromoExposureTelemetry.bind(this),
32       window,
33       { defineAs: "PrivateBrowsingPromoExposureTelemetry" }
34     );
35     Cu.exportFunction(this.FeltPrivacyExposureTelemetry.bind(this), window, {
36       defineAs: "FeltPrivacyExposureTelemetry",
37     });
38   }
40   PrivateBrowsingRecordClick(source) {
41     const experiment = lazy.ExperimentAPI.getExperimentMetaData({
42       featureId: "pbNewtab",
43     });
44     if (experiment) {
45       Services.telemetry.recordEvent("aboutprivatebrowsing", "click", source);
46     }
47     return experiment;
48   }
50   PrivateBrowsingShouldHideDefault() {
51     const config = lazy.NimbusFeatures.pbNewtab.getAllVariables() || {};
52     return config?.content?.hideDefault;
53   }
55   PrivateBrowsingPromoExposureTelemetry() {
56     lazy.NimbusFeatures.pbNewtab.recordExposureEvent({ once: false });
57   }
59   FeltPrivacyExposureTelemetry() {
60     lazy.NimbusFeatures.feltPrivacy.recordExposureEvent({ once: true });
61   }