aboutDialog.js (4503B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 /* import-globals-from aboutDialog-appUpdater.js */ 8 /* import-globals-from utilityOverlay.js */ 9 10 // Services = object with smart getters for common XPCOM services 11 var { AppConstants } = ChromeUtils.importESModule( 12 "resource://gre/modules/AppConstants.sys.mjs" 13 ); 14 if (AppConstants.MOZ_UPDATER) { 15 Services.scriptloader.loadSubScript( 16 "chrome://browser/content/aboutDialog-appUpdater.js", 17 this 18 ); 19 } 20 21 function init() { 22 let defaults = Services.prefs.getDefaultBranch(null); 23 let distroId = defaults.getCharPref("distribution.id", ""); 24 if (distroId) { 25 let distroAbout = defaults.getStringPref("distribution.about", ""); 26 // If there is about text, we always show it. 27 if (distroAbout) { 28 let distroField = document.getElementById("distribution"); 29 distroField.value = distroAbout; 30 distroField.style.display = "block"; 31 } 32 // If it's not a mozilla distribution, show the rest, 33 // unless about text exists, then we always show. 34 if (!distroId.startsWith("mozilla-") || distroAbout) { 35 let distroVersion = defaults.getCharPref("distribution.version", ""); 36 if (distroVersion) { 37 distroId += " - " + distroVersion; 38 } 39 40 let distroIdField = document.getElementById("distributionId"); 41 distroIdField.value = distroId; 42 distroIdField.style.display = "block"; 43 } 44 } 45 46 // Include the build ID and display warning if this is an "a#" (nightly or aurora) build 47 let versionId = "basebrowser-about-dialog-version"; 48 let versionAttributes = { 49 version: AppConstants.BASE_BROWSER_VERSION, 50 firefoxVersion: AppConstants.MOZ_APP_VERSION_DISPLAY, 51 }; 52 53 let arch = Services.sysinfo.get("arch"); 54 if (["x86", "x86-64"].includes(arch)) { 55 versionAttributes.bits = Services.appinfo.is64Bit ? 64 : 32; 56 } else { 57 versionAttributes.arch = arch; 58 } 59 60 let version = Services.appinfo.version; 61 if (/a\d+$/.test(version)) { 62 document.getElementById("experimental").hidden = false; 63 document.getElementById("communityDesc").hidden = true; 64 } 65 66 // Use Fluent arguments for append version and the architecture of the build 67 let versionField = document.getElementById("version"); 68 69 document.l10n.setAttributes(versionField, versionId, versionAttributes); 70 71 // Show a release notes link if we have a URL. 72 let relNotesLink = document.getElementById("releasenotes"); 73 let relNotesPrefType = Services.prefs.getPrefType( 74 "app.releaseNotesURL.aboutDialog" 75 ); 76 if (relNotesPrefType != Services.prefs.PREF_INVALID) { 77 let relNotesURL = Services.urlFormatter.formatURLPref( 78 "app.releaseNotesURL.aboutDialog" 79 ); 80 if (relNotesURL != "about:blank") { 81 relNotesLink.href = relNotesURL; 82 relNotesLink.hidden = false; 83 } 84 } 85 86 if (AppConstants.MOZ_UPDATER) { 87 gAppUpdater = new appUpdater({ buttonAutoFocus: true }); 88 89 let channelLabel = document.getElementById("currentChannelText"); 90 let channelAttrs = document.l10n.getAttributes(channelLabel); 91 let channel = UpdateUtils.UpdateChannel; 92 document.l10n.setAttributes(channelLabel, channelAttrs.id, { channel }); 93 if ( 94 /^release($|\-)/.test(channel) || 95 Services.sysinfo.getProperty("isPackagedApp") 96 ) { 97 channelLabel.hidden = true; 98 } 99 } 100 101 if (AppConstants.IS_ESR) { 102 document.getElementById("release").hidden = false; 103 } 104 105 document 106 .getElementById("aboutDialogEscapeKey") 107 .addEventListener("command", () => { 108 window.close(); 109 }); 110 if (AppConstants.MOZ_UPDATER) { 111 document 112 .getElementById("aboutDialogHelpLink") 113 .addEventListener("click", () => { 114 openHelpLink("firefox-help"); 115 }); 116 document 117 .getElementById("submit-feedback") 118 .addEventListener("click", openFeedbackPage); 119 document 120 .getElementById("checkForUpdatesButton") 121 .addEventListener("command", () => { 122 gAppUpdater.checkForUpdates(); 123 }); 124 document 125 .getElementById("downloadAndInstallButton") 126 .addEventListener("command", () => { 127 gAppUpdater.startDownload(); 128 }); 129 document.getElementById("updateButton").addEventListener("command", () => { 130 gAppUpdater.buttonRestartAfterDownload(); 131 }); 132 window.addEventListener("unload", e => { 133 onUnload(e); 134 }); 135 } 136 } 137 138 init();