/* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */ /* 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/. */ import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { ClientID: "resource://gre/modules/ClientID.sys.mjs", CustomizableUI: "moz-src:///browser/components/customizableui/CustomizableUI.sys.mjs", DeferredTask: "resource://gre/modules/DeferredTask.sys.mjs", NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs", PageActions: "resource:///modules/PageActions.sys.mjs", PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs", SearchSERPTelemetry: "moz-src:///browser/components/search/SearchSERPTelemetry.sys.mjs", SearchSERPTelemetryUtils: "moz-src:///browser/components/search/SearchSERPTelemetry.sys.mjs", SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs", TabMetrics: "moz-src:///browser/components/tabbrowser/TabMetrics.sys.mjs", WindowsInstallsInfo: "resource://gre/modules/components-utils/WindowsInstallsInfo.sys.mjs", clearTimeout: "resource://gre/modules/Timer.sys.mjs", setTimeout: "resource://gre/modules/Timer.sys.mjs", }); // This pref is in seconds! XPCOMUtils.defineLazyPreferenceGetter( lazy, "gRecentVisitedOriginsExpiry", "browser.engagement.recent_visited_origins.expiry" ); XPCOMUtils.defineLazyPreferenceGetter( lazy, "sidebarVerticalTabs", "sidebar.verticalTabs", false, (_aPreference, _previousValue, isVertical) => { let tabCount = getOpenTabsAndWinsCounts().tabCount; BrowserUsageTelemetry.maxTabCount = tabCount; let pinnedTabCount = getPinnedTabsCount(); BrowserUsageTelemetry.maxTabPinnedCount = pinnedTabCount; if (isVertical) { Glean.browserEngagement.maxConcurrentVerticalTabCount.set(tabCount); Glean.browserEngagement.maxConcurrentVerticalTabPinnedCount.set( pinnedTabCount ); } else { Glean.browserEngagement.maxConcurrentTabCount.set(tabCount); Glean.browserEngagement.maxConcurrentTabPinnedCount.set(pinnedTabCount); } BrowserUsageTelemetry.recordPinnedTabsCount(pinnedTabCount); } ); // The upper bound for the count of the visited unique domain names. const MAX_UNIQUE_VISITED_DOMAINS = 100; // Observed topic names. const TAB_RESTORING_TOPIC = "SSTabRestoring"; const TELEMETRY_SUBSESSIONSPLIT_TOPIC = "internal-telemetry-after-subsession-split"; const DOMWINDOW_OPENED_TOPIC = "domwindowopened"; const SESSION_STORE_SAVED_TAB_GROUPS_TOPIC = "sessionstore-saved-tab-groups-changed"; export const MINIMUM_TAB_COUNT_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes, in ms // The elements we consider to be interactive. const UI_TARGET_CHANGE_ELEMENTS = new Set([ "moz-checkbox", "moz-select", "moz-radio", "moz-toggle", "moz-input-folder", "moz-input-password", "moz-input-search", "moz-input-text", "moz-visual-picker-item", ]); const UI_TARGET_COMMAND_ELEMENTS = new Set([ "menuitem", "toolbarbutton", "key", "command", "checkbox", "input", "button", "image", "radio", "richlistitem", "moz-button", "moz-box-button", "moz-box-link", "dialog-button", ]); const UI_TARGET_ELEMENTS = new Map([ ["change", UI_TARGET_CHANGE_ELEMENTS], ["click", UI_TARGET_COMMAND_ELEMENTS], ["command", UI_TARGET_COMMAND_ELEMENTS], ]); // The containers of interactive elements that we care about and their pretty // names. These should be listed in order of most-specific to least-specific, // when iterating JavaScript will guarantee that ordering and so we will find // the most specific area first. const BROWSER_UI_CONTAINER_IDS = { "toolbar-menubar": "menu-bar", TabsToolbar: "tabs-bar", "vertical-tabs": "vertical-tabs-container", PersonalToolbar: "bookmarks-bar", "appMenu-popup": "app-menu", tabContextMenu: "tabs-context", contentAreaContextMenu: "content-context", "widget-overflow-list": "overflow-menu", "widget-overflow-fixed-list": "pinned-overflow-menu", "page-action-buttons": "pageaction-urlbar", pageActionPanel: "pageaction-panel", "unified-extensions-area": "unified-extensions-area", "allTabsMenu-allTabsView": "alltabs-menu", // Historically, panels opened from a button on any toolbar have been // considered part of the nav-bar. Due to a technical change these panels // are no longer descendants of the nav-bar; this entry just preserves // continuity for telemetry. "customizationui-widget-panel": "nav-bar", // This should appear last as some of the above are inside the nav bar. "nav-bar": "nav-bar", }; const ENTRYPOINT_TRACKED_CONTEXT_MENU_IDS = { [BROWSER_UI_CONTAINER_IDS.tabContextMenu]: "tabs-context-entrypoint", }; // A list of the expected panes in about:preferences const PREFERENCES_PANES = [ "paneHome", "paneGeneral", "panePrivacy", "paneSearch", "paneSearchResults", "paneSync", "paneContainers", "paneExperimental", "paneMoreFromMozilla", ]; const IGNORABLE_EVENTS = new WeakMap(); const KNOWN_ADDONS = []; // Buttons that, when clicked, set a preference to true. The convention // is that the preference is named: // // browser.engagement.