From 06494f307850c576868831bd28a61464eab1f359 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Mon, 16 Dec 2019 13:57:01 -0500 Subject: Remove Basilisk from the Unified XUL Platform repository Development will proceed at https://github.com/MoonchildProductions/Basilisk --- application/basilisk/modules/AboutHome.jsm | 173 --- application/basilisk/modules/AboutNewTab.jsm | 42 - application/basilisk/modules/AttributionCode.jsm | 123 --- .../basilisk/modules/BrowserUsageTelemetry.jsm | 468 -------- application/basilisk/modules/CastingApps.jsm | 164 --- application/basilisk/modules/ContentClick.jsm | 93 -- .../basilisk/modules/ContentCrashHandlers.jsm | 922 ---------------- .../basilisk/modules/ContentLinkHandler.jsm | 147 --- application/basilisk/modules/ContentObservers.jsm | 55 - application/basilisk/modules/ContentSearch.jsm | 566 ---------- application/basilisk/modules/ContentWebRTC.jsm | 393 ------- application/basilisk/modules/E10SUtils.jsm | 128 --- application/basilisk/modules/Feeds.jsm | 104 -- .../basilisk/modules/FormSubmitObserver.jsm | 235 ---- .../basilisk/modules/FormValidationHandler.jsm | 157 --- application/basilisk/modules/HiddenFrame.jsm | 86 -- application/basilisk/modules/LaterRun.jsm | 172 --- .../basilisk/modules/NetworkPrioritizer.jsm | 194 ---- application/basilisk/modules/PermissionUI.jsm | 572 ---------- application/basilisk/modules/PluginContent.jsm | 1132 -------------------- .../basilisk/modules/ProcessHangMonitor.jsm | 387 ------- application/basilisk/modules/ReaderParent.jsm | 102 -- application/basilisk/modules/RecentWindow.jsm | 67 -- application/basilisk/modules/RemotePrompt.jsm | 110 -- application/basilisk/modules/Sanitizer.jsm | 22 - application/basilisk/modules/SitePermissions.jsm | 267 ----- application/basilisk/modules/TransientPrefs.jsm | 24 - application/basilisk/modules/URLBarZoom.jsm | 51 - .../basilisk/modules/Windows8WindowFrameColor.jsm | 53 - application/basilisk/modules/WindowsJumpLists.jsm | 579 ---------- .../basilisk/modules/WindowsPreviewPerTab.jsm | 863 --------------- application/basilisk/modules/moz.build | 45 - application/basilisk/modules/offlineAppCache.jsm | 20 - application/basilisk/modules/webrtcUI.jsm | 969 ----------------- 34 files changed, 9485 deletions(-) delete mode 100644 application/basilisk/modules/AboutHome.jsm delete mode 100644 application/basilisk/modules/AboutNewTab.jsm delete mode 100644 application/basilisk/modules/AttributionCode.jsm delete mode 100644 application/basilisk/modules/BrowserUsageTelemetry.jsm delete mode 100644 application/basilisk/modules/CastingApps.jsm delete mode 100644 application/basilisk/modules/ContentClick.jsm delete mode 100644 application/basilisk/modules/ContentCrashHandlers.jsm delete mode 100644 application/basilisk/modules/ContentLinkHandler.jsm delete mode 100644 application/basilisk/modules/ContentObservers.jsm delete mode 100644 application/basilisk/modules/ContentSearch.jsm delete mode 100644 application/basilisk/modules/ContentWebRTC.jsm delete mode 100644 application/basilisk/modules/E10SUtils.jsm delete mode 100644 application/basilisk/modules/Feeds.jsm delete mode 100644 application/basilisk/modules/FormSubmitObserver.jsm delete mode 100644 application/basilisk/modules/FormValidationHandler.jsm delete mode 100644 application/basilisk/modules/HiddenFrame.jsm delete mode 100644 application/basilisk/modules/LaterRun.jsm delete mode 100644 application/basilisk/modules/NetworkPrioritizer.jsm delete mode 100644 application/basilisk/modules/PermissionUI.jsm delete mode 100644 application/basilisk/modules/PluginContent.jsm delete mode 100644 application/basilisk/modules/ProcessHangMonitor.jsm delete mode 100644 application/basilisk/modules/ReaderParent.jsm delete mode 100644 application/basilisk/modules/RecentWindow.jsm delete mode 100644 application/basilisk/modules/RemotePrompt.jsm delete mode 100644 application/basilisk/modules/Sanitizer.jsm delete mode 100644 application/basilisk/modules/SitePermissions.jsm delete mode 100644 application/basilisk/modules/TransientPrefs.jsm delete mode 100644 application/basilisk/modules/URLBarZoom.jsm delete mode 100644 application/basilisk/modules/Windows8WindowFrameColor.jsm delete mode 100644 application/basilisk/modules/WindowsJumpLists.jsm delete mode 100644 application/basilisk/modules/WindowsPreviewPerTab.jsm delete mode 100644 application/basilisk/modules/moz.build delete mode 100644 application/basilisk/modules/offlineAppCache.jsm delete mode 100644 application/basilisk/modules/webrtcUI.jsm (limited to 'application/basilisk/modules') diff --git a/application/basilisk/modules/AboutHome.jsm b/application/basilisk/modules/AboutHome.jsm deleted file mode 100644 index 671448480..000000000 --- a/application/basilisk/modules/AboutHome.jsm +++ /dev/null @@ -1,173 +0,0 @@ -/* 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 Cc = Components.classes; -var Ci = Components.interfaces; -var Cu = Components.utils; - -this.EXPORTED_SYMBOLS = [ "AboutHomeUtils", "AboutHome" ]; - -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); -Components.utils.import("resource://gre/modules/Services.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "AppConstants", - "resource://gre/modules/AppConstants.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "AutoMigrate", - "resource:///modules/AutoMigrate.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", - "resource://gre/modules/PrivateBrowsingUtils.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Promise", - "resource://gre/modules/Promise.jsm"); - -// Should be bumped up if any data content format changes. -const STARTPAGE_VERSION = 5; - -this.AboutHomeUtils = { - /* - * showKnowYourRights - Determines if the user should be shown the - * about:rights notification. The notification should *not* be shown if - * we've already shown the current version, or if the override pref says to - * never show it. The notification *should* be shown if it's never been seen - * before, if a newer version is available, or if the override pref says to - * always show it. - */ - get showKnowYourRights() { - // Look for an unconditional override pref. If set, do what it says. - // (true --> never show, false --> always show) - try { - return !Services.prefs.getBoolPref("browser.rights.override"); - } catch (e) { } - // Ditto, for the legacy EULA pref. - try { - return !Services.prefs.getBoolPref("browser.EULA.override"); - } catch (e) { } - - if (!AppConstants.MC_OFFICIAL) { - // Non-official builds shouldn't show the notification. - return false; - } - - // Look to see if the user has seen the current version or not. - var currentVersion = Services.prefs.getIntPref("browser.rights.version"); - try { - return !Services.prefs.getBoolPref("browser.rights." + currentVersion + ".shown"); - } catch (e) { } - - // Legacy: If the user accepted a EULA, we won't annoy them with the - // equivalent about:rights page until the version changes. - try { - return !Services.prefs.getBoolPref("browser.EULA." + currentVersion + ".accepted"); - } catch (e) { } - - // We haven't shown the notification before, so do so now. - return true; - } -}; - -/** - * This code provides services to the about:home page. Whenever - * about:home needs to do something chrome-privileged, it sends a - * message that's handled here. - */ -var AboutHome = { - MESSAGES: [ - "AboutHome:RestorePreviousSession", - "AboutHome:Downloads", - "AboutHome:Bookmarks", - "AboutHome:History", - "AboutHome:Addons", - "AboutHome:Sync", - "AboutHome:Settings", - "AboutHome:RequestUpdate", - "AboutHome:MaybeShowAutoMigrationUndoNotification", - ], - - init: function() { - let mm = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager); - - for (let msg of this.MESSAGES) { - mm.addMessageListener(msg, this); - } - }, - - receiveMessage: function(aMessage) { - let window = aMessage.target.ownerGlobal; - - switch (aMessage.name) { - case "AboutHome:RestorePreviousSession": - let ss = Cc["@mozilla.org/browser/sessionstore;1"]. - getService(Ci.nsISessionStore); - if (ss.canRestoreLastSession) { - ss.restoreLastSession(); - } - break; - - case "AboutHome:Downloads": - window.BrowserDownloadsUI(); - break; - - case "AboutHome:Bookmarks": - window.PlacesCommandHook.showPlacesOrganizer("UnfiledBookmarks"); - break; - - case "AboutHome:History": - window.PlacesCommandHook.showPlacesOrganizer("History"); - break; - - case "AboutHome:Addons": - window.BrowserOpenAddonsMgr(); - break; - - case "AboutHome:Sync": - window.openPreferences("paneSync", { urlParams: { entrypoint: "abouthome" } }); - break; - - case "AboutHome:Settings": - window.openPreferences(); - break; - - case "AboutHome:RequestUpdate": - this.sendAboutHomeData(aMessage.target); - break; - - case "AboutHome:MaybeShowAutoMigrationUndoNotification": - AutoMigrate.maybeShowUndoNotification(aMessage.target); - break; - } - }, - - // Send all the chrome-privileged data needed by about:home. This - // gets re-sent when the search engine changes. - sendAboutHomeData: function(target) { - let wrapper = {}; - Components.utils.import("resource:///modules/sessionstore/SessionStore.jsm", - wrapper); - let ss = wrapper.SessionStore; - - ss.promiseInitialized.then(function() { - let data = { - showRestoreLastSession: ss.canRestoreLastSession, - showKnowYourRights: AboutHomeUtils.showKnowYourRights - }; - - if (AboutHomeUtils.showKnowYourRights) { - // Set pref to indicate we've shown the notification. - let currentVersion = Services.prefs.getIntPref("browser.rights.version"); - Services.prefs.setBoolPref("browser.rights." + currentVersion + ".shown", true); - } - - if (target && target.messageManager) { - target.messageManager.sendAsyncMessage("AboutHome:Update", data); - } else { - let mm = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager); - mm.broadcastAsyncMessage("AboutHome:Update", data); - } - }).then(null, function onError(x) { - Cu.reportError("Error in AboutHome.sendAboutHomeData: " + x); - }); - }, - -}; diff --git a/application/basilisk/modules/AboutNewTab.jsm b/application/basilisk/modules/AboutNewTab.jsm deleted file mode 100644 index e170e9c8a..000000000 --- a/application/basilisk/modules/AboutNewTab.jsm +++ /dev/null @@ -1,42 +0,0 @@ -/* 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 Cc = Components.classes; -var Ci = Components.interfaces; -var Cu = Components.utils; - -this.EXPORTED_SYMBOLS = [ "AboutNewTab" ]; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "AutoMigrate", - "resource:///modules/AutoMigrate.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "NewTabUtils", - "resource://gre/modules/NewTabUtils.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "RemotePages", - "resource://gre/modules/RemotePageManager.jsm"); - -var AboutNewTab = { - - pageListener: null, - - init: function() { - this.pageListener = new RemotePages("about:newtab"); - this.pageListener.addMessageListener("NewTab:Customize", this.customize.bind(this)); - this.pageListener.addMessageListener("NewTab:MaybeShowAutoMigrationUndoNotification", - (msg) => AutoMigrate.maybeShowUndoNotification(msg.target.browser)); - }, - - customize: function(message) { - NewTabUtils.allPages.enabled = message.data.enabled; - }, - - uninit: function() { - this.pageListener.destroy(); - this.pageListener = null; - }, -}; diff --git a/application/basilisk/modules/AttributionCode.jsm b/application/basilisk/modules/AttributionCode.jsm deleted file mode 100644 index dc42b2be4..000000000 --- a/application/basilisk/modules/AttributionCode.jsm +++ /dev/null @@ -1,123 +0,0 @@ -/* 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"; - -this.EXPORTED_SYMBOLS = ["AttributionCode"]; - -const {classes: Cc, interfaces: Ci, utils: Cu} = Components; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, 'AppConstants', - 'resource://gre/modules/AppConstants.jsm'); -XPCOMUtils.defineLazyModuleGetter(this, 'OS', - 'resource://gre/modules/osfile.jsm'); -XPCOMUtils.defineLazyModuleGetter(this, 'Services', - 'resource://gre/modules/Services.jsm'); -XPCOMUtils.defineLazyModuleGetter(this, 'Task', - 'resource://gre/modules/Task.jsm'); - -const ATTR_CODE_MAX_LENGTH = 200; -const ATTR_CODE_KEYS_REGEX = /^source|medium|campaign|content$/; -const ATTR_CODE_VALUE_REGEX = /[a-zA-Z0-9_%\\-\\.\\(\\)]*/; -const ATTR_CODE_FIELD_SEPARATOR = "%26"; // URL-encoded & -const ATTR_CODE_KEY_VALUE_SEPARATOR = "%3D"; // URL-encoded = - -let gCachedAttrData = null; - -/** - * Returns an nsIFile for the file containing the attribution data. - */ -function getAttributionFile() { - let file = Services.dirsvc.get("LocalAppData", Ci.nsIFile); - // appinfo does not exist in xpcshell, so we need defaults. - file.append(Services.appinfo.vendor || "mozilla"); - file.append(AppConstants.MOZ_APP_NAME); - file.append("postSigningData"); - return file; -} - -/** - * Returns an object containing a key-value pair for each piece of attribution - * data included in the passed-in attribution code string. - * If the string isn't a valid attribution code, returns an empty object. - */ -function parseAttributionCode(code) { - if (code.length > ATTR_CODE_MAX_LENGTH) { - return {}; - } - - let isValid = true; - let parsed = {}; - for (let param of code.split(ATTR_CODE_FIELD_SEPARATOR)) { - let [key, value] = param.split(ATTR_CODE_KEY_VALUE_SEPARATOR, 2); - if (key && ATTR_CODE_KEYS_REGEX.test(key)) { - if (value && ATTR_CODE_VALUE_REGEX.test(value)) { - parsed[key] = value; - } - } else { - isValid = false; - break; - } - } - return isValid ? parsed : {}; -} - -var AttributionCode = { - /** - * Reads the attribution code, either from disk or a cached version. - * Returns a promise that fulfills with an object containing the parsed - * attribution data if the code could be read and is valid, - * or an empty object otherwise. - */ - getAttrDataAsync() { - return Task.spawn(function*() { - if (gCachedAttrData != null) { - return gCachedAttrData; - } - - let code = ""; - try { - let bytes = yield OS.File.read(getAttributionFile().path); - let decoder = new TextDecoder(); - code = decoder.decode(bytes); - } catch (ex) { - // The attribution file may already have been deleted, - // or it may have never been installed at all; - // failure to open or read it isn't an error. - } - - gCachedAttrData = parseAttributionCode(code); - return gCachedAttrData; - }); - }, - - /** - * Deletes the attribution data file. - * Returns a promise that resolves when the file is deleted, - * or if the file couldn't be deleted (the promise is never rejected). - */ - deleteFileAsync() { - return Task.spawn(function*() { - try { - yield OS.File.remove(getAttributionFile().path); - } catch (ex) { - // The attribution file may already have been deleted, - // or it may have never been installed at all; - // failure to delete it isn't an error. - } - }); - }, - - /** - * Clears the cached attribution code value, if any. - * Does nothing if called from outside of an xpcshell test. - */ - _clearCache() { - let env = Cc["@mozilla.org/process/environment;1"] - .getService(Ci.nsIEnvironment); - if (env.exists("XPCSHELL_TEST_PROFILE_DIR")) { - gCachedAttrData = null; - } - }, -}; diff --git a/application/basilisk/modules/BrowserUsageTelemetry.jsm b/application/basilisk/modules/BrowserUsageTelemetry.jsm deleted file mode 100644 index 39012d2ab..000000000 --- a/application/basilisk/modules/BrowserUsageTelemetry.jsm +++ /dev/null @@ -1,468 +0,0 @@ -/* -*- 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"; - -this.EXPORTED_SYMBOLS = ["BrowserUsageTelemetry"]; - -const {classes: Cc, interfaces: Ci, utils: Cu} = Components; - -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", - "resource://gre/modules/PrivateBrowsingUtils.jsm"); - -// The upper bound for the count of the visited unique domain names. -const MAX_UNIQUE_VISITED_DOMAINS = 100; - -// Observed topic names. -const WINDOWS_RESTORED_TOPIC = "sessionstore-windows-restored"; -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 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"; - -// A list of known search origins. -const KNOWN_SEARCH_SOURCES = [ - "abouthome", - "contextmenu", - "newtab", - "searchbar", - "urlbar", -]; - -const KNOWN_ONEOFF_SOURCES = [ - "oneoff-urlbar", - "oneoff-searchbar", - "unknown", // Edge case: this is the searchbar (see bug 1195733 comment 7). -]; - -function getOpenTabsAndWinsCounts() { - let tabCount = 0; - let winCount = 0; - - let browserEnum = Services.wm.getEnumerator("navigator:browser"); - while (browserEnum.hasMoreElements()) { - let win = browserEnum.getNext(); - winCount++; - tabCount += win.gBrowser.tabs.length; - } - - return { tabCount, winCount }; -} - -function getSearchEngineId(engine) { - if (engine) { - if (engine.identifier) { - return engine.identifier; - } - // Due to bug 1222070, we can't directly check Services.telemetry.canRecordExtended - // here. - const extendedTelemetry = Services.prefs.getBoolPref("toolkit.telemetry.enabled"); - if (engine.name && extendedTelemetry) { - // If it's a custom search engine only report the engine name - // if extended Telemetry is enabled. - return "other-" + engine.name; - } - } - return "other"; -} - -let URICountListener = { - // A set containing the visited domains, see bug 1271310. - _domainSet: new Set(), - // A map to keep track of the URIs loaded from the restored tabs. - _restoredURIsMap: new WeakMap(), - - isHttpURI(uri) { - // Only consider http(s) schemas. - return uri.schemeIs("http") || uri.schemeIs("https"); - }, - - addRestoredURI(browser, uri) { - if (!this.isHttpURI(uri)) { - return; - } - - this._restoredURIsMap.set(browser, uri.spec); - }, - - onLocationChange(browser, webProgress, request, uri, flags) { - // Don't count this URI if it's an error page. - if (flags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE) { - return; - } - - // We only care about top level loads. - if (!webProgress.isTopLevel) { - return; - } - - // The SessionStore sets the URI of a tab first, firing onLocationChange the - // first time, then manages content loading using its scheduler. Once content - // loads, we will hit onLocationChange again. - // We can catch the first case by checking for null requests: be advised that - // this can also happen when navigating page fragments, so account for it. - if (!request && - !(flags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT)) { - return; - } - - // Track URI loads, even if they're not http(s). - let uriSpec = null; - try { - uriSpec = uri.spec; - } catch (e) { - // If we have troubles parsing the spec, still count this as - // an unfiltered URI. - Services.telemetry.scalarAdd(UNFILTERED_URI_COUNT_SCALAR_NAME, 1); - return; - } - - - // Don't count about:blank and similar pages, as they would artificially - // inflate the counts. - if (browser.ownerDocument.defaultView.gInitialPages.includes(uriSpec)) { - return; - } - - // If the URI we're loading is in the _restoredURIsMap, then it comes from a - // restored tab. If so, let's skip it and remove it from the map as we want to - // count page refreshes. - if (this._restoredURIsMap.get(browser) === uriSpec) { - this._restoredURIsMap.delete(browser); - return; - } - - // The URI wasn't from a restored tab. Count it among the unfiltered URIs. - // If this is an http(s) URI, this also gets counted by the "total_uri_count" - // probe. - Services.telemetry.scalarAdd(UNFILTERED_URI_COUNT_SCALAR_NAME, 1); - - if (!this.isHttpURI(uri)) { - return; - } - - // Update the URI counts. - Services.telemetry.scalarAdd(TOTAL_URI_COUNT_SCALAR_NAME, 1); - - // We only want to count the unique domains up to MAX_UNIQUE_VISITED_DOMAINS. - if (this._domainSet.size == MAX_UNIQUE_VISITED_DOMAINS) { - return; - } - - // Unique domains should be aggregated by (eTLD + 1): x.test.com and y.test.com - // are counted once as test.com. - try { - // Even if only considering http(s) URIs, |getBaseDomain| could still throw - // due to the URI containing invalid characters or the domain actually being - // an ipv4 or ipv6 address. - this._domainSet.add(Services.eTLD.getBaseDomain(uri)); - } catch (e) { - return; - } - - Services.telemetry.scalarSet(UNIQUE_DOMAINS_COUNT_SCALAR_NAME, this._domainSet.size); - }, - - /** - * Reset the counts. This should be called when breaking a session in Telemetry. - */ - reset() { - this._domainSet.clear(); - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, - Ci.nsISupportsWeakReference]), -}; - -let BrowserUsageTelemetry = { - init() { - Services.obs.addObserver(this, WINDOWS_RESTORED_TOPIC, false); - }, - - /** - * Handle subsession splits in the parent process. - */ - afterSubsessionSplit() { - // Scalars just got cleared due to a subsession split. We need to set the maximum - // concurrent tab and window counts so that they reflect the correct value for the - // new subsession. - const counts = getOpenTabsAndWinsCounts(); - Services.telemetry.scalarSetMaximum(MAX_TAB_COUNT_SCALAR_NAME, counts.tabCount); - Services.telemetry.scalarSetMaximum(MAX_WINDOW_COUNT_SCALAR_NAME, counts.winCount); - - // Reset the URI counter. - URICountListener.reset(); - }, - - uninit() { - Services.obs.removeObserver(this, DOMWINDOW_OPENED_TOPIC, false); - Services.obs.removeObserver(this, TELEMETRY_SUBSESSIONSPLIT_TOPIC, false); - Services.obs.removeObserver(this, WINDOWS_RESTORED_TOPIC, false); - }, - - observe(subject, topic, data) { - switch (topic) { - case WINDOWS_RESTORED_TOPIC: - this._setupAfterRestore(); - break; - case DOMWINDOW_OPENED_TOPIC: - this._onWindowOpen(subject); - break; - case TELEMETRY_SUBSESSIONSPLIT_TOPIC: - this.afterSubsessionSplit(); - break; - } - }, - - handleEvent(event) { - switch (event.type) { - case "TabOpen": - this._onTabOpen(); - break; - case "unload": - this._unregisterWindow(event.target); - break; - case TAB_RESTORING_TOPIC: - // We're restoring a new tab from a previous or crashed session. - // We don't want to track the URIs from these tabs, so let - // |URICountListener| know about them. - let browser = event.target.linkedBrowser; - URICountListener.addRestoredURI(browser, browser.currentURI); - break; - } - }, - - /** - * The main entry point for recording search related Telemetry. This includes - * search counts and engagement measurements. - * - * Telemetry records only search counts per engine and action origin, but - * nothing pertaining to the search contents themselves. - * - * @param {nsISearchEngine} engine - * The engine handling the search. - * @param {String} source - * Where the search originated from. See KNOWN_SEARCH_SOURCES for allowed - * values. - * @param {Object} [details] Options object. - * @param {Boolean} [details.isOneOff=false] - * true if this event was generated by a one-off search. - * @param {Boolean} [details.isSuggestion=false] - * true if this event was generated by a suggested search. - * @param {Boolean} [details.isAlias=false] - * true if this event was generated by a search using an alias. - * @param {Object} [details.type=null] - * The object describing the event that triggered the search. - * @throws if source is not in the known sources list. - */ - recordSearch(engine, source, details={}) { - const isOneOff = !!details.isOneOff; - const countId = getSearchEngineId(engine) + "." + source; - - if (isOneOff) { - if (!KNOWN_ONEOFF_SOURCES.includes(source)) { - // Silently drop the error if this bogus call - // came from 'urlbar' or 'searchbar'. They're - // calling |recordSearch| twice from two different - // code paths because they want to record the search - // in SEARCH_COUNTS. - if (['urlbar', 'searchbar'].includes(source)) { - Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS").add(countId); - return; - } - throw new Error("Unknown source for one-off search: " + source); - } - } else { - if (!KNOWN_SEARCH_SOURCES.includes(source)) { - throw new Error("Unknown source for search: " + source); - } - Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS").add(countId); - } - - // Dispatch the search signal to other handlers. - this._handleSearchAction(engine, source, details); - }, - - _recordSearch(engine, source, action = null) { - let scalarKey = action ? "search_" + action : "search"; - Services.telemetry.keyedScalarAdd("browser.engagement.navigation." + source, - scalarKey, 1); - Services.telemetry.recordEvent("navigation", "search", source, action, - { engine: getSearchEngineId(engine) }); - }, - - _handleSearchAction(engine, source, details) { - switch (source) { - case "urlbar": - case "oneoff-urlbar": - case "searchbar": - case "oneoff-searchbar": - case "unknown": // Edge case: this is the searchbar (see bug 1195733 comment 7). - this._handleSearchAndUrlbar(engine, source, details); - break; - case "abouthome": - this._recordSearch(engine, "about_home", "enter"); - break; - case "newtab": - this._recordSearch(engine, "about_newtab", "enter"); - break; - case "contextmenu": - this._recordSearch(engine, "contextmenu"); - break; - } - }, - - /** - * This function handles the "urlbar", "urlbar-oneoff", "searchbar" and - * "searchbar-oneoff" sources. - */ - _handleSearchAndUrlbar(engine, source, details) { - // We want "urlbar" and "urlbar-oneoff" (and similar cases) to go in the same - // scalar, but in a different key. - - // When using one-offs in the searchbar we get an "unknown" source. See bug - // 1195733 comment 7 for the context. Fix-up the label here. - const sourceName = - (source === "unknown") ? "searchbar" : source.replace("oneoff-", ""); - - const isOneOff = !!details.isOneOff; - if (isOneOff) { - // We will receive a signal from the "urlbar"/"searchbar" even when the - // search came from "oneoff-urlbar". That's because both signals - // are propagated from search.xml. Skip it if that's the case. - // Moreover, we skip the "unknown" source that comes from the searchbar - // when performing searches from the default search engine. See bug 1195733 - // comment 7 for context. - if (["urlbar", "searchbar", "unknown"].includes(source)) { - return; - } - - // If that's a legit one-off search signal, record it using the relative key. - this._recordSearch(engine, sourceName, "oneoff"); - return; - } - - // The search was not a one-off. It was a search with the default search engine. - if (details.isSuggestion) { - // It came from a suggested search, so count it as such. - this._recordSearch(engine, sourceName, "suggestion"); - return; - } else if (details.isAlias) { - // This one came from a search that used an alias. - this._recordSearch(engine, sourceName, "alias"); - return; - } - - // The search signal was generated by typing something and pressing enter. - this._recordSearch(engine, sourceName, "enter"); - }, - - /** - * This gets called shortly after the SessionStore has finished restoring - * windows and tabs. It counts the open tabs and adds listeners to all the - * windows. - */ - _setupAfterRestore() { - // Make sure to catch new chrome windows and subsession splits. - Services.obs.addObserver(this, DOMWINDOW_OPENED_TOPIC, false); - Services.obs.addObserver(this, TELEMETRY_SUBSESSIONSPLIT_TOPIC, false); - - // Attach the tabopen handlers to the existing Windows. - let browserEnum = Services.wm.getEnumerator("navigator:browser"); - while (browserEnum.hasMoreElements()) { - this._registerWindow(browserEnum.getNext()); - } - - // Get the initial tab and windows max counts. - const counts = getOpenTabsAndWinsCounts(); - Services.telemetry.scalarSetMaximum(MAX_TAB_COUNT_SCALAR_NAME, counts.tabCount); - Services.telemetry.scalarSetMaximum(MAX_WINDOW_COUNT_SCALAR_NAME, counts.winCount); - }, - - /** - * Adds listeners to a single chrome window. - */ - _registerWindow(win) { - win.addEventListener("unload", this); - win.addEventListener("TabOpen", this, true); - - // Don't include URI and domain counts when in private mode. - if (PrivateBrowsingUtils.isWindowPrivate(win)) { - return; - } - win.gBrowser.tabContainer.addEventListener(TAB_RESTORING_TOPIC, this); - win.gBrowser.addTabsProgressListener(URICountListener); - }, - - /** - * Removes listeners from a single chrome window. - */ - _unregisterWindow(win) { - win.removeEventListener("unload", this); - win.removeEventListener("TabOpen", this, true); - - // Don't include URI and domain counts when in private mode. - if (PrivateBrowsingUtils.isWindowPrivate(win.defaultView)) { - return; - } - win.defaultView.gBrowser.tabContainer.removeEventListener(TAB_RESTORING_TOPIC, this); - win.defaultView.gBrowser.removeTabsProgressListener(URICountListener); - }, - - /** - * Updates the tab counts. - * @param {Number} [newTabCount=0] The count of the opened tabs across all windows. This - * is computed manually if not provided. - */ - _onTabOpen(tabCount = 0) { - // Use the provided tab count if available. Otherwise, go on and compute it. - tabCount = tabCount || getOpenTabsAndWinsCounts().tabCount; - // Update the "tab opened" count and its maximum. - Services.telemetry.scalarAdd(TAB_OPEN_EVENT_COUNT_SCALAR_NAME, 1); - Services.telemetry.scalarSetMaximum(MAX_TAB_COUNT_SCALAR_NAME, tabCount); - }, - - /** - * Tracks the window count and registers the listeners for the tab count. - * @param{Object} win The window object. - */ - _onWindowOpen(win) { - // Make sure to have a |nsIDOMWindow|. - if (!(win instanceof Ci.nsIDOMWindow)) { - return; - } - - let onLoad = () => { - win.removeEventListener("load", onLoad, false); - - // Ignore non browser windows. - if (win.document.documentElement.getAttribute("windowtype") != "navigator:browser") { - return; - } - - this._registerWindow(win); - // Track the window open event and check the maximum. - const counts = getOpenTabsAndWinsCounts(); - Services.telemetry.scalarAdd(WINDOW_OPEN_EVENT_COUNT_SCALAR_NAME, 1); - Services.telemetry.scalarSetMaximum(MAX_WINDOW_COUNT_SCALAR_NAME, counts.winCount); - - // We won't receive the "TabOpen" event for the first tab within a new window. - // Account for that. - this._onTabOpen(counts.tabCount); - }; - win.addEventListener("load", onLoad, false); - }, -}; diff --git a/application/basilisk/modules/CastingApps.jsm b/application/basilisk/modules/CastingApps.jsm deleted file mode 100644 index 6f32753e8..000000000 --- a/application/basilisk/modules/CastingApps.jsm +++ /dev/null @@ -1,164 +0,0 @@ -// -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*- -/* 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"; -this.EXPORTED_SYMBOLS = ["CastingApps"]; - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/SimpleServiceDiscovery.jsm"); - - -var CastingApps = { - _sendEventToVideo: function (element, data) { - let event = element.ownerDocument.createEvent("CustomEvent"); - event.initCustomEvent("media-videoCasting", false, true, JSON.stringify(data)); - element.dispatchEvent(event); - }, - - makeURI: function (url, charset, baseURI) { - return Services.io.newURI(url, charset, baseURI); - }, - - getVideo: function (element) { - if (!element) { - return null; - } - - let extensions = SimpleServiceDiscovery.getSupportedExtensions(); - let types = SimpleServiceDiscovery.getSupportedMimeTypes(); - - // Grab the poster attribute from the