Restore app.update.url.override preference.

This commit is contained in:
wolfbeast 2019-02-12 16:33:11 +01:00 committed by Roy Tam
commit 87624b25ff
2 changed files with 34 additions and 7 deletions

View file

@ -141,6 +141,9 @@ pref("app.update.url", "https://aus5.mozilla.org/update/6/%PRODUCT%/%VERSION%/%B
// app.update.url.manual is in branding section
// app.update.url.details is in branding section
// User-settable override to app.update.url for testing purposes.
//pref("app.update.url.override", "");
// app.update.interval is in branding section
// app.update.promptWaitTime is in branding section

View file

@ -44,6 +44,7 @@ const PREF_APP_UPDATE_SOCKET_RETRYTIMEOUT = "app.update.socket.retryTimeout";
const PREF_APP_UPDATE_STAGING_ENABLED = "app.update.staging.enabled";
const PREF_APP_UPDATE_URL = "app.update.url";
const PREF_APP_UPDATE_URL_DETAILS = "app.update.url.details";
const PREF_APP_UPDATE_URL_OVERRIDE = "app.update.url.override";
const PREFBRANCH_APP_UPDATE_NEVER = "app.update.never.";
@ -2143,6 +2144,14 @@ UpdateService.prototype = {
}
}
let prefType = Services.prefs.getPrefType(PREF_APP_UPDATE_URL_OVERRIDE);
let overridePrefHasValue = prefType != Ci.nsIPrefBranch.PREF_INVALID;
// Histogram IDs:
// UPDATE_HAS_PREF_URL_OVERRIDE_EXTERNAL
// UPDATE_HAS_PREF_URL_OVERRIDE_NOTIFY
AUSTLMY.pingGeneric("UPDATE_HAS_PREF_URL_OVERRIDE_" + this._pingSuffix,
overridePrefHasValue, false);
// If a download is in progress or the patch has been staged do nothing.
if (this.isDownloading) {
AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_IS_DOWNLOADING);
@ -2173,8 +2182,18 @@ UpdateService.prototype = {
} else if (!UpdateUtils.ABI) {
AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_NO_OS_ABI);
} else if (!validUpdateURL) {
AUSTLMY.pingCheckCode(this._pingSuffix,
AUSTLMY.CHK_INVALID_DEFAULT_URL);
if (overridePrefHasValue) {
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_URL_OVERRIDE)) {
AUSTLMY.pingCheckCode(this._pingSuffix,
AUSTLMY.CHK_INVALID_USER_OVERRIDE_URL);
} else {
AUSTLMY.pingCheckCode(this._pingSuffix,
AUSTLMY.CHK_INVALID_DEFAULT_OVERRIDE_URL);
}
} else {
AUSTLMY.pingCheckCode(this._pingSuffix,
AUSTLMY.CHK_INVALID_DEFAULT_URL);
}
} else if (!getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true)) {
AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_PREF_DISABLED);
} else if (!hasUpdateMutex()) {
@ -3023,11 +3042,16 @@ Checker.prototype = {
getUpdateURL: function UC_getUpdateURL(force) {
this._forced = force;
let url;
try {
url = Services.prefs.getDefaultBranch(null).
getCharPref(PREF_APP_UPDATE_URL);
} catch (e) {
// Use the override URL if specified.
let url = getPref("getCharPref", PREF_APP_UPDATE_URL_OVERRIDE, null);
// Otherwise, construct the update URL from component parts.
if (!url) {
try {
url = Services.prefs.getDefaultBranch(null).
getCharPref(PREF_APP_UPDATE_URL);
} catch (e) {
}
}
if (!url || url == "") {