From f15440fc4ad983bf539f00fdd0d648b1a0b046b1 Mon Sep 17 00:00:00 2001 From: Timothy Guan-tin Chien Date: Thu, 27 Apr 2017 19:59:14 +0800 Subject: [PATCH] Bug 1356507 - Show version and updater in the preferences update pane. r=jaws This change includes unmodified aboutDialog-appUpdater.js into preferences.xul, so we could enable the updater UI there. Also, copied code on version/distribution strings from aboutDialog.js. MozReview-Commit-ID: 7o24az7Tn28 --HG-- extra : rebase_source : d3120bfa9d30f0f3fb8a1dad9e5c62427b1e6d62 --- .../base/content/aboutDialog-appUpdater.js | 3 +- .../preferences/in-content/advanced.js | 49 +++++++ .../preferences/in-content/advanced.xul | 130 ++++++++++++++++-- .../preferences/in-content/preferences.xul | 2 + .../en-US/chrome/browser/aboutDialog.dtd | 6 +- .../chrome/browser/preferences/advanced.dtd | 7 + .../shared/incontentprefs/preferences.inc.css | 17 +++ 7 files changed, 198 insertions(+), 16 deletions(-) diff --git a/browser/base/content/aboutDialog-appUpdater.js b/browser/base/content/aboutDialog-appUpdater.js index 3f6dba61258e..3ce4bf8fa49a 100644 --- a/browser/base/content/aboutDialog-appUpdater.js +++ b/browser/base/content/aboutDialog-appUpdater.js @@ -2,7 +2,8 @@ * 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/. */ -// Note: this file is included in aboutDialog.xul if MOZ_UPDATER is defined. +// Note: this file is included in aboutDialog.xul and preferences/advanced.xul +// if MOZ_UPDATER is defined. /* import-globals-from aboutDialog.js */ diff --git a/browser/components/preferences/in-content/advanced.js b/browser/components/preferences/in-content/advanced.js index c4f72088ef93..51f22afcc8b0 100644 --- a/browser/components/preferences/in-content/advanced.js +++ b/browser/components/preferences/in-content/advanced.js @@ -20,7 +20,56 @@ var gAdvancedPane = { this._inited = true; + let version = AppConstants.MOZ_APP_VERSION_DISPLAY; + + // Include the build ID if this is an "a#" (nightly) build + if (/a\d+$/.test(version)) { + let buildID = Services.appinfo.appBuildID; + let year = buildID.slice(0, 4); + let month = buildID.slice(4, 6); + let day = buildID.slice(6, 8); + version += ` (${year}-${month}-${day})`; + } + + // Append "(32-bit)" or "(64-bit)" build architecture to the version number: + let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties"); + let archResource = Services.appinfo.is64Bit + ? "aboutDialog.architecture.sixtyFourBit" + : "aboutDialog.architecture.thirtyTwoBit"; + let arch = bundle.GetStringFromName(archResource); + version += ` (${arch})`; + + document.getElementById("version").textContent = version; + + // Show a release notes link if we have a URL. + let relNotesLink = document.getElementById("releasenotes"); + let relNotesPrefType = Services.prefs.getPrefType("app.releaseNotesURL"); + if (relNotesPrefType != Services.prefs.PREF_INVALID) { + let relNotesURL = Services.urlFormatter.formatURLPref("app.releaseNotesURL"); + if (relNotesURL != "about:blank") { + relNotesLink.href = relNotesURL; + relNotesLink.hidden = false; + } + } + + let distroId = Services.prefs.getCharPref("distribution.id", ""); + if (distroId) { + let distroVersion = Services.prefs.getCharPref("distribution.version"); + + let distroIdField = document.getElementById("distributionId"); + distroIdField.value = distroId + " - " + distroVersion; + distroIdField.hidden = false; + + let distroAbout = Services.prefs.getStringPref("distribution.about", ""); + if (distroAbout) { + let distroField = document.getElementById("distribution"); + distroField.value = distroAbout; + distroField.hidden = false; + } + } + if (AppConstants.MOZ_UPDATER) { + gAppUpdater = new appUpdater(); let onUnload = () => { window.removeEventListener("unload", onUnload); Services.prefs.removeObserver("app.update.", this); diff --git a/browser/components/preferences/in-content/advanced.xul b/browser/components/preferences/in-content/advanced.xul index 97dd5cb0c29a..d760676307ae 100644 --- a/browser/components/preferences/in-content/advanced.xul +++ b/browser/components/preferences/in-content/advanced.xul @@ -4,6 +4,10 @@ +#ifdef MOZ_UPDATER +