/* -*- 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/. */ "use strict"; var EXPORTED_SYMBOLS = [ "BrowserUsageTelemetry", "getUniqueDomainsVisitedInPast24Hours", "URICountListener", "MINIMUM_TAB_COUNT_INTERVAL_MS", ]; const { XPCOMUtils } = ChromeUtils.import( "resource://gre/modules/XPCOMUtils.jsm" ); XPCOMUtils.defineLazyModuleGetters(this, { AppConstants: "resource://gre/modules/AppConstants.jsm", ClientID: "resource://gre/modules/ClientID.jsm", BrowserTelemetryUtils: "resource://gre/modules/BrowserTelemetryUtils.jsm", CustomizableUI: "resource:///modules/CustomizableUI.jsm", PageActions: "resource:///modules/PageActions.jsm", PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm", SearchSERPTelemetry: "resource:///modules/SearchSERPTelemetry.jsm", Services: "resource://gre/modules/Services.jsm", setTimeout: "resource://gre/modules/Timer.jsm", setInterval: "resource://gre/modules/Timer.jsm", clearTimeout: "resource://gre/modules/Timer.jsm", clearInterval: "resource://gre/modules/Timer.jsm", }); // This pref is in seconds! XPCOMUtils.defineLazyPreferenceGetter( this, "gRecentVisitedOriginsExpiry", "browser.engagement.recent_visited_origins.expiry" ); // 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"; // Probe names. const MAX_TAB_COUNT_SCALAR_NAME = "browser.engagement.max_concurrent_tab_count"; const MAX_WINDOW_COUNT_SCALAR_NAME = "browser.engagement.max_concurrent_window_count"; const TAB_OPEN_EVENT_COUNT_SCALAR_NAME = "browser.engagement.tab_open_event_count"; const MAX_TAB_PINNED_COUNT_SCALAR_NAME = "browser.engagement.max_concurrent_tab_pinned_count"; const TAB_PINNED_EVENT_COUNT_SCALAR_NAME = "browser.engagement.tab_pinned_event_count"; const WINDOW_OPEN_EVENT_COUNT_SCALAR_NAME = "browser.engagement.window_open_event_count"; const UNIQUE_DOMAINS_COUNT_SCALAR_NAME = "browser.engagement.unique_domains_count"; const TOTAL_URI_COUNT_SCALAR_NAME = "browser.engagement.total_uri_count"; const UNFILTERED_URI_COUNT_SCALAR_NAME = "browser.engagement.unfiltered_uri_count"; const TOTAL_URI_COUNT_NORMAL_AND_PRIVATE_MODE_SCALAR_NAME = "browser.engagement.total_uri_count_normal_and_private_mode"; const CONTENT_PROCESS_COUNT = "CONTENT_PROCESS_COUNT"; const MINIMUM_TAB_COUNT_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes, in ms const CONTENT_PROCESS_COUNT_INTERVAL_MS = 5 * 60 * 1000; // The elements we consider to be interactive. const UI_TARGET_ELEMENTS = [ "menuitem", "toolbarbutton", "key", "command", "checkbox", "input", "button", "image", "radio", "richlistitem", ]; // 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", 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", // This should appear last as some of the above are inside the nav bar. "nav-bar": "nav-bar", }; // A list of the expected panes in about:preferences const PREFERENCES_PANES = [ "paneHome", "paneGeneral", "panePrivacy", "paneSearch", "paneSearchResults", "paneSync", "paneContainers", "paneExperimental", ]; 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.