1 /* vim: set ts=2 sw=2 sts=2 et tw=80: */
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/. */
7 var EXPORTED_SYMBOLS = ["AboutNewTabChild"];
9 const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
10 const { XPCOMUtils } = ChromeUtils.import(
11 "resource://gre/modules/XPCOMUtils.jsm"
13 const { AppConstants } = ChromeUtils.import(
14 "resource://gre/modules/AppConstants.jsm"
16 const { ExperimentAPI } = ChromeUtils.import(
17 "resource://messaging-system/experiments/ExperimentAPI.jsm"
19 const { PrivateBrowsingUtils } = ChromeUtils.import(
20 "resource://gre/modules/PrivateBrowsingUtils.jsm"
23 XPCOMUtils.defineLazyPreferenceGetter(
25 "ACTIVITY_STREAM_DEBUG",
26 "browser.newtabpage.activity-stream.debug",
30 XPCOMUtils.defineLazyPreferenceGetter(
32 "isAboutWelcomePrefEnabled",
33 "browser.aboutwelcome.enabled",
37 class AboutNewTabChild extends JSWindowActorChild {
39 if (event.type == "DOMContentLoaded") {
40 // If the separate about:welcome page is enabled, we can skip all of this,
41 // since that mode doesn't load any of the Activity Stream bits.
43 isAboutWelcomePrefEnabled &&
44 // about:welcome should be enabled by default if no experiment exists.
45 ExperimentAPI.isFeatureEnabled("aboutwelcome", true) &&
46 this.contentWindow.location.pathname.includes("welcome")
51 const debug = !AppConstants.RELEASE_OR_BETA && ACTIVITY_STREAM_DEBUG;
52 const debugString = debug ? "-dev" : "";
54 // This list must match any similar ones in render-activity-stream-html.js.
56 "chrome://browser/content/contentSearchUI.js",
57 "chrome://browser/content/contentSearchHandoffUI.js",
58 "chrome://browser/content/contentTheme.js",
59 `resource://activity-stream/vendor/react${debugString}.js`,
60 `resource://activity-stream/vendor/react-dom${debugString}.js`,
61 "resource://activity-stream/vendor/prop-types.js",
62 "resource://activity-stream/vendor/react-transition-group.js",
63 "resource://activity-stream/vendor/redux.js",
64 "resource://activity-stream/vendor/react-redux.js",
65 "resource://activity-stream/data/content/activity-stream.bundle.js",
66 "resource://activity-stream/data/content/newtab-render.js",
69 for (let script of scripts) {
70 Services.scriptloader.loadSubScript(script, this.contentWindow);
73 (event.type == "pageshow" || event.type == "visibilitychange") &&
74 // The default browser notification shouldn't be shown on about:welcome
75 // since we don't want to distract from the onboarding wizard.
76 !this.contentWindow.location.pathname.includes("welcome")
78 // Don't show the notification in non-permanent private windows
79 // since it is expected to have very little opt-in here.
80 let contentWindowPrivate = PrivateBrowsingUtils.isContentWindowPrivate(
84 this.document.visibilityState == "visible" &&
85 (!contentWindowPrivate ||
86 (contentWindowPrivate &&
87 PrivateBrowsingUtils.permanentPrivateBrowsing))
89 this.sendAsyncMessage("DefaultBrowserNotification");