From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- browser/components/BrowserGlue.sys.mjs | 242 +++++++++++++++++++++++++-------- 1 file changed, 186 insertions(+), 56 deletions(-) (limited to 'browser/components/BrowserGlue.sys.mjs') diff --git a/browser/components/BrowserGlue.sys.mjs b/browser/components/BrowserGlue.sys.mjs index 52f4a77d82..b6ae665df0 100644 --- a/browser/components/BrowserGlue.sys.mjs +++ b/browser/components/BrowserGlue.sys.mjs @@ -24,6 +24,7 @@ ChromeUtils.defineESModuleGetters(lazy, { BookmarkJSONUtils: "resource://gre/modules/BookmarkJSONUtils.sys.mjs", BrowserSearchTelemetry: "resource:///modules/BrowserSearchTelemetry.sys.mjs", BrowserUIUtils: "resource:///modules/BrowserUIUtils.sys.mjs", + BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs", BrowserUsageTelemetry: "resource:///modules/BrowserUsageTelemetry.sys.mjs", BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs", BuiltInThemes: "resource:///modules/BuiltInThemes.sys.mjs", @@ -42,11 +43,13 @@ ChromeUtils.defineESModuleGetters(lazy, { FeatureGate: "resource://featuregates/FeatureGate.sys.mjs", FirefoxBridgeExtensionUtils: "resource:///modules/FirefoxBridgeExtensionUtils.sys.mjs", + FormAutofillUtils: "resource://gre/modules/shared/FormAutofillUtils.sys.mjs", FxAccounts: "resource://gre/modules/FxAccounts.sys.mjs", HomePage: "resource:///modules/HomePage.sys.mjs", Integration: "resource://gre/modules/Integration.sys.mjs", Interactions: "resource:///modules/Interactions.sys.mjs", LoginBreaches: "resource:///modules/LoginBreaches.sys.mjs", + LoginHelper: "resource://gre/modules/LoginHelper.sys.mjs", MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs", NetUtil: "resource://gre/modules/NetUtil.sys.mjs", NewTabUtils: "resource://gre/modules/NewTabUtils.sys.mjs", @@ -124,11 +127,7 @@ XPCOMUtils.defineLazyServiceGetters(lazy, { ChromeUtils.defineLazyGetter( lazy, "accountsL10n", - () => - new Localization( - ["browser/accounts.ftl", "toolkit/branding/accounts.ftl"], - true - ) + () => new Localization(["browser/accounts.ftl"], true) ); if (AppConstants.ENABLE_WEBDRIVER) { @@ -426,6 +425,20 @@ let JSWINDOWACTORS = { enablePreference: "browser.aboutwelcome.enabled", }, + BackupUI: { + parent: { + esModuleURI: "resource:///actors/BackupUIParent.sys.mjs", + }, + child: { + esModuleURI: "resource:///actors/BackupUIChild.sys.mjs", + events: { + "BackupUI:InitWidget": { wantUntrusted: true }, + }, + }, + matches: ["about:preferences*", "about:settings*"], + enablePreference: "browser.backup.preferences.ui.enabled", + }, + BlockedSite: { parent: { esModuleURI: "resource:///actors/BlockedSiteParent.sys.mjs", @@ -736,6 +749,7 @@ let JSWINDOWACTORS = { "Screenshots:OverlaySelection": {}, "Screenshots:RecordEvent": {}, "Screenshots:ShowPanel": {}, + "Screenshots:FocusPanel": {}, }, }, enablePreference: "screenshots.browser.component.enabled", @@ -1149,6 +1163,9 @@ BrowserGlue.prototype = { case "fxaccounts:commands:open-uri": this._onDisplaySyncURIs(subject); break; + case "fxaccounts:commands:close-uri": + this._onIncomingCloseTabCommand(subject); + break; case "session-save": this._setPrefToSaveSession(true); subject.QueryInterface(Ci.nsISupportsPRBool); @@ -1198,13 +1215,13 @@ BrowserGlue.prototype = { case "initial-migration-did-import-default-bookmarks": this._initPlaces(true); break; - case "handle-xul-text-link": + case "handle-xul-text-link": { let linkHandled = subject.QueryInterface(Ci.nsISupportsPRBool); if (!linkHandled.data) { let win = lazy.BrowserWindowTracker.getTopWindow(); if (win) { data = JSON.parse(data); - let where = win.whereToOpenLink(data); + let where = lazy.BrowserUtils.whereToOpenLink(data); // Preserve legacy behavior of non-modifier left-clicks // opening in a new selected tab. if (where == "current") { @@ -1215,13 +1232,14 @@ BrowserGlue.prototype = { } } break; + } case "profile-before-change": // Any component depending on Places should be finalized in // _onPlacesShutdown. Any component that doesn't need to act after // the UI has gone should be finalized in _onQuitApplicationGranted. this._dispose(); break; - case "keyword-search": + case "keyword-search": { // This notification is broadcast by the docshell when it "fixes up" a // URI that it's been asked to load into a keyword search. let engine = null; @@ -1239,13 +1257,15 @@ BrowserGlue.prototype = { "urlbar" ); break; - case "xpi-signature-changed": + } + case "xpi-signature-changed": { let disabledAddons = JSON.parse(data).disabled; let addons = await lazy.AddonManager.getAddonsByIDs(disabledAddons); if (addons.some(addon => addon)) { this._notifyUnsignedAddonsDisabled(); } break; + } case "sync-ui-state:update": this._updateFxaBadges(lazy.BrowserWindowTracker.getTopWindow()); break; @@ -1263,7 +1283,7 @@ BrowserGlue.prototype = { lazy.DownloadsViewableInternally.register(); break; - case "app-startup": + case "app-startup": { this._earlyBlankFirstPaint(subject); gThisInstanceIsTaskbarTab = subject.handleFlag("taskbar-tab", false); gThisInstanceIsLaunchOnLogin = subject.handleFlag( @@ -1297,6 +1317,7 @@ BrowserGlue.prototype = { await lazy.WindowsLaunchOnLogin.removeLaunchOnLoginRegistryKey(); } break; + } } }, @@ -1316,6 +1337,7 @@ BrowserGlue.prototype = { "fxaccounts:verify_login", "fxaccounts:device_disconnected", "fxaccounts:commands:open-uri", + "fxaccounts:commands:close-uri", "session-save", "places-init-complete", "distribution-customization-complete", @@ -1446,6 +1468,17 @@ BrowserGlue.prototype = { lazy.PdfJs.checkIsDefault(this._isNewProfile); } + if (!AppConstants.NIGHTLY_BUILD && this._isNewProfile) { + lazy.FormAutofillUtils.setOSAuthEnabled( + lazy.FormAutofillUtils.AUTOFILL_CREDITCARDS_REAUTH_PREF, + false + ); + lazy.LoginHelper.setOSAuthEnabled( + lazy.LoginHelper.OS_AUTH_FOR_PASSWORDS_PREF, + false + ); + } + listeners.init(); lazy.SessionStore.init(); @@ -1630,7 +1663,9 @@ BrowserGlue.prototype = { "unsignedAddonsDisabled.learnMore.accesskey" ), callback() { - win.BrowserOpenAddonsMgr("addons://list/extension?unsigned=true"); + win.BrowserAddonUI.openAddonsMgr( + "addons://list/extension?unsigned=true" + ); }, }, ]; @@ -2708,12 +2743,6 @@ BrowserGlue.prototype = { name: "ensurePrivateBrowsingShortcutExists", condition: AppConstants.platform == "win" && - // Pref'ed off until Private Browsing window separation is enabled by default - // to avoid a situation where a user pins the Private Browsing shortcut to - // the Taskbar, which will end up launching into a different Taskbar icon. - lazy.NimbusFeatures.majorRelease2022.getVariable( - "feltPrivacyWindowSeparation" - ) && // We don't want a shortcut if it's been disabled, eg: by enterprise policy. lazy.PrivateBrowsingUtils.enabled && // Private Browsing shortcuts for packaged builds come with the package, @@ -2935,7 +2964,7 @@ BrowserGlue.prototype = { let cfg = lazy.NimbusFeatures.gleanInternalSdk.getVariable( "gleanMetricConfiguration" ); - Services.fog.setMetricsFeatureConfig(JSON.stringify(cfg)); + Services.fog.applyServerKnobsConfig(JSON.stringify(cfg)); }); // Register Glean to listen for experiment updates releated to the @@ -2944,7 +2973,7 @@ BrowserGlue.prototype = { let cfg = lazy.NimbusFeatures.glean.getVariable( "gleanMetricConfiguration" ); - Services.fog.setMetricsFeatureConfig(JSON.stringify(cfg)); + Services.fog.applyServerKnobsConfig(JSON.stringify(cfg)); }); }, }, @@ -3086,11 +3115,9 @@ BrowserGlue.prototype = { { name: "DAPTelemetrySender.startup", - condition: - lazy.TelemetryUtils.isTelemetryEnabled && - lazy.NimbusFeatures.dapTelemetry.getVariable("enabled"), - task: () => { - lazy.DAPTelemetrySender.startup(); + condition: lazy.TelemetryUtils.isTelemetryEnabled, + task: async () => { + await lazy.DAPTelemetrySender.startup(); }, }, @@ -3243,6 +3270,14 @@ BrowserGlue.prototype = { function reportInstallationTelemetry() { lazy.BrowserUsageTelemetry.reportInstallationTelemetry(); }, + + function trustObjectTelemetry() { + let certdb = Cc["@mozilla.org/security/x509certdb;1"].getService( + Ci.nsIX509CertDB + ); + // countTrustObjects also logs the number of trust objects for telemetry purposes + certdb.countTrustObjects(); + }, ]; for (let task of idleTasks) { @@ -3724,7 +3759,7 @@ BrowserGlue.prototype = { _onThisDeviceConnected() { const [title, body] = lazy.accountsL10n.formatValuesSync([ - "account-connection-title", + "account-connection-title-2", "account-connection-connected", ]); @@ -3769,7 +3804,7 @@ BrowserGlue.prototype = { _migrateUI() { // Use an increasing number to keep track of the current migration state. // Completely unrelated to the current Firefox release number. - const UI_VERSION = 144; + const UI_VERSION = 147; const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL; if (!Services.prefs.prefHasUserValue("browser.migration.version")) { @@ -3777,12 +3812,6 @@ BrowserGlue.prototype = { Services.prefs.setIntPref("browser.migration.version", UI_VERSION); this._isNewProfile = true; - if (AppConstants.platform == "win") { - // Ensure that the Firefox Bridge protocols are registered for the new profile. - // No-op if they are registered for the user or the local machine already. - lazy.FirefoxBridgeExtensionUtils.maybeRegisterFirefoxBridgeProtocols(); - } - return; } @@ -4383,24 +4412,7 @@ BrowserGlue.prototype = { } if (currentUIVersion < 143) { - if (AppConstants.platform == "win") { - // In Firefox 122, we enabled the firefox and firefox-private protocols. - // We switched over to using firefox-bridge and firefox-private-bridge, - // but we want to clean up the use of the other protocols. - lazy.FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries(); - - // Register the new firefox bridge related protocols now - lazy.FirefoxBridgeExtensionUtils.maybeRegisterFirefoxBridgeProtocols(); - - // Clean up the old user prefs from FX 122 - Services.prefs.clearUserPref( - "network.protocol-handler.external.firefox" - ); - Services.prefs.clearUserPref( - "network.protocol-handler.external.firefox-private" - ); - Services.prefs.clearUserPref("browser.shell.customProtocolsRegistered"); - } + // Version 143 has been superseded by version 145 below. } if (currentUIVersion < 144) { @@ -4420,6 +4432,99 @@ BrowserGlue.prototype = { } } + if (currentUIVersion < 145) { + if (AppConstants.platform == "win") { + // In Firefox 122, we enabled the firefox and firefox-private protocols. + // We switched over to using firefox-bridge and firefox-private-bridge, + // but we want to clean up the use of the other protocols. + lazy.FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries( + lazy.FirefoxBridgeExtensionUtils.OLD_PUBLIC_PROTOCOL, + lazy.FirefoxBridgeExtensionUtils.OLD_PRIVATE_PROTOCOL + ); + + // Clean up the old user prefs from FX 122 + Services.prefs.clearUserPref( + "network.protocol-handler.external.firefox" + ); + Services.prefs.clearUserPref( + "network.protocol-handler.external.firefox-private" + ); + + // In Firefox 126, we switched over to using native messaging so the + // protocols are no longer necessary even in firefox-bridge and + // firefox-private-bridge form + lazy.FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries( + lazy.FirefoxBridgeExtensionUtils.PUBLIC_PROTOCOL, + lazy.FirefoxBridgeExtensionUtils.PRIVATE_PROTOCOL + ); + Services.prefs.clearUserPref( + "network.protocol-handler.external.firefox-bridge" + ); + Services.prefs.clearUserPref( + "network.protocol-handler.external.firefox-private-bridge" + ); + Services.prefs.clearUserPref("browser.shell.customProtocolsRegistered"); + } + } + + // Version 146 had a typo issue and thus it has been replaced by 147. + + if (currentUIVersion < 147) { + // We're securing the boolean prefs for OS Authentication. + // This is achieved by converting them into a string pref and encrypting the values + // stored inside it. + + if (!AppConstants.NIGHTLY_BUILD) { + const hasRunBetaMigration = Services.prefs + .getCharPref("browser.startup.homepage_override.mstone", "") + .startsWith("127.0"); + + // Version 146 UI migration wrote to a wrong `creditcards` pref when + // the feature was disabled, instead it should have used `creditCards`. + // The correct pref name is in AUTOFILL_CREDITCARDS_REAUTH_PREF. + // Note that we only wrote prefs if the feature was disabled. + let ccTypoDisabled = !lazy.FormAutofillUtils.getOSAuthEnabled( + "extensions.formautofill.creditcards.reauth.optout" + ); + let ccCorrectPrefDisabled = !lazy.FormAutofillUtils.getOSAuthEnabled( + lazy.FormAutofillUtils.AUTOFILL_CREDITCARDS_REAUTH_PREF + ); + let ccPrevReauthPrefValue = Services.prefs.getBoolPref( + "extensions.formautofill.reauth.enabled", + false + ); + + let userHadEnabledCreditCardReauth = + // If we've run beta migration, and neither typo nor correct pref + // indicate disablement, the user enabled the pref: + (hasRunBetaMigration && !ccTypoDisabled && !ccCorrectPrefDisabled) || + // Or if we never ran beta migration and the bool pref is set: + ccPrevReauthPrefValue; + + lazy.FormAutofillUtils.setOSAuthEnabled( + lazy.FormAutofillUtils.AUTOFILL_CREDITCARDS_REAUTH_PREF, + userHadEnabledCreditCardReauth + ); + + if (!hasRunBetaMigration) { + const passwordsPrevReauthPrefValue = Services.prefs.getBoolPref( + "signon.management.page.os-auth.enabled", + false + ); + lazy.LoginHelper.setOSAuthEnabled( + lazy.LoginHelper.OS_AUTH_FOR_PASSWORDS_PREF, + passwordsPrevReauthPrefValue + ); + } + } + + Services.prefs.clearUserPref("extensions.formautofill.reauth.enabled"); + Services.prefs.clearUserPref("signon.management.page.os-auth.enabled"); + Services.prefs.clearUserPref( + "extensions.formautofill.creditcards.reauth.optout" + ); + } + // Update the migration version. Services.prefs.setIntPref("browser.migration.version", UI_VERSION); }, @@ -4515,10 +4620,7 @@ BrowserGlue.prototype = { return "disallow-postUpdate"; } - const useMROnboarding = - lazy.NimbusFeatures.majorRelease2022.getVariable("onboarding"); const showUpgradeDialog = - useMROnboarding ?? lazy.NimbusFeatures.upgradeDialog.getVariable("enabled"); return showUpgradeDialog ? "" : "disabled"; @@ -4774,6 +4876,32 @@ BrowserGlue.prototype = { } }, + async _onIncomingCloseTabCommand(data) { + // The payload is wrapped weirdly because of how Sync does notifications. + const wrappedObj = data.wrappedJSObject.object; + let { urls } = wrappedObj[0]; + let urisToClose = []; + urls.forEach(urlString => { + try { + urisToClose.push(Services.io.newURI(urlString)); + } catch (ex) { + // The url was invalid so we ignore + console.error(ex); + } + }); + for (let win of lazy.BrowserWindowTracker.orderedWindows) { + // Ensure we're operating on fully opened browser windows + if (!win.gBrowser) { + continue; + } + urisToClose = await win.gBrowser.closeTabsByURI(urisToClose); + // If we've successfully closed all the tabs, break early + if (!urisToClose.length) { + break; + } + } + }, + async _onVerifyLoginNotification({ body, title, url }) { let tab; let imageURL; @@ -4812,7 +4940,7 @@ BrowserGlue.prototype = { _onDeviceConnected(deviceName) { const [title, body] = lazy.accountsL10n.formatValuesSync([ - { id: "account-connection-title" }, + { id: "account-connection-title-2" }, deviceName ? { id: "account-connection-connected-with", args: { deviceName } } : { id: "account-connection-connected-with-noname" }, @@ -4849,7 +4977,7 @@ BrowserGlue.prototype = { _onDeviceDisconnected() { const [title, body] = lazy.accountsL10n.formatValuesSync([ - "account-connection-title", + "account-connection-title-2", "account-connection-disconnected", ]); @@ -5732,7 +5860,9 @@ export var AboutHomeStartupCache = { this.setDeferredResult(this.CACHE_RESULT_SCALARS.UNSET); - this._enabled = !!lazy.NimbusFeatures.abouthomecache.getVariable("enabled"); + this._enabled = Services.prefs.getBoolPref( + "browser.startup.homepage.abouthome_cache.enabled" + ); if (!this._enabled) { this.recordResult(this.CACHE_RESULT_SCALARS.DISABLED); -- cgit v1.2.3