Backed out changeset b3ef06fe604d (bug 1433574) for causing merge conflicts

This commit is contained in:
Margareta Eliza Balazs 2018-04-24 14:47:45 +03:00
parent f96bb4a629
commit 52c01b70d5
12 changed files with 266 additions and 0 deletions

View File

@ -199,6 +199,7 @@ pref("extensions.dss.enabled", false);
pref("extensions.ignoreMTimeChanges", false);
pref("extensions.logging.enabled", false);
pref("extensions.hideInstallButton", true);
pref("extensions.showMismatchUI", false);
pref("extensions.hideUpdateButton", false);
pref("extensions.strictCompatibility", false);
pref("extensions.minCompatibleAppVersion", "11.0");

View File

@ -197,6 +197,8 @@ const RECOMMENDED_PREFS = new Map([
// Should be set in profile.
["extensions.installDistroAddons", false],
["extensions.showMismatchUI", false],
// Turn off extension updates so they do not bother tests
["extensions.update.enabled", false],
["extensions.update.notifyUser", false],

View File

@ -412,6 +412,8 @@ class FirefoxProfile(Profile):
'extensions.getAddons.cache.enabled': False,
# Don't install distribution add-ons from the app folder
'extensions.installDistroAddons': False,
# Dont' run the add-on compatibility check during start-up
'extensions.showMismatchUI': False,
# Don't automatically update add-ons
'extensions.update.enabled': False,
# Don't open a dialog to show available add-on updates

View File

@ -0,0 +1,17 @@
# 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/.
# LOCALIZATION NOTE (addonUpdateTitle)
# %S will be replace with the localized name of the application
addonUpdateTitle=%S Update
# LOCALIZATION NOTE (addonUpdateMessage)
# %S will be replace with the localized name of the application
addonUpdateMessage=%S is updating your extensions…
addonUpdateCancelMessage=Still updating. Want to wait?
# LOCALIZATION NOTE (addonUpdateCancelButton)
# %S will be replace with the localized name of the application
addonUpdateCancelButton=Stop update and launch %S

View File

@ -93,6 +93,7 @@
#ifndef MOZ_FENNEC
locale/@AB_CD@/mozapps/extensions/extensions.properties (%chrome/mozapps/extensions/extensions.properties)
locale/@AB_CD@/mozapps/extensions/blocklist.dtd (%chrome/mozapps/extensions/blocklist.dtd)
locale/@AB_CD@/mozapps/extensions/update.properties (%chrome/mozapps/extensions/update.properties)
#endif
locale/@AB_CD@/mozapps/handling/handling.dtd (%chrome/mozapps/handling/handling.dtd)
locale/@AB_CD@/mozapps/handling/handling.properties (%chrome/mozapps/handling/handling.properties)

View File

@ -0,0 +1,26 @@
body {
font: message-box;
min-width: 480px;
}
#message {
font-size: 14px;
}
#message, #cancel-section {
margin: 10px 5px;
}
#progress {
width: calc(100% - 10px);
margin: 0 5px;
}
#cancel-section {
display: flex;
justify-content: space-between;
}
#cancel-message {
vertical-align: middle;
}

View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="update.js"></script>
<link rel="stylesheet" href="chrome://mozapps/content/extensions/update.css">
</head>
<body>
<div>
<div id="message"></div>
<progress id="progress" val="0" max="1"></progress>
<div id="cancel-section">
<span id="cancel-message"></span>
<button id="cancel-btn"></button>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,24 @@
"use strict";
ChromeUtils.import("resource://gre/modules/Services.jsm");
let BRAND_PROPS = "chrome://branding/locale/brand.properties";
let UPDATE_PROPS = "chrome://mozapps/locale/extensions/update.properties";
let appName = Services.strings.createBundle(BRAND_PROPS)
.GetStringFromName("brandShortName");
let bundle = Services.strings.createBundle(UPDATE_PROPS);
let titleText = bundle.formatStringFromName("addonUpdateTitle", [appName], 1);
let messageText = bundle.formatStringFromName("addonUpdateMessage", [appName], 1);
let cancelText = bundle.GetStringFromName("addonUpdateCancelMessage");
let cancelButtonText = bundle.formatStringFromName("addonUpdateCancelButton", [appName], 1);
document.title = titleText;
window.addEventListener("load", e => {
document.getElementById("message").textContent = messageText;
document.getElementById("cancel-message").textContent = cancelText;
document.getElementById("cancel-btn").textContent = cancelButtonText;
window.sizeToContent();
});

View File

@ -335,6 +335,9 @@ var AddonTestUtils = {
// By default, don't cache add-ons in AddonRepository.jsm
Services.prefs.setBoolPref("extensions.getAddons.cache.enabled", false);
// Disable the compatibility updates window by default
Services.prefs.setBoolPref("extensions.showMismatchUI", false);
// Point update checks to the local machine for fast failures
Services.prefs.setCharPref("extensions.update.url", "http://127.0.0.1/updateURL");
Services.prefs.setCharPref("extensions.update.background.url", "http://127.0.0.1/updateBackgroundURL");

View File

@ -64,6 +64,7 @@ const PREF_PENDING_OPERATIONS = "extensions.pendingOperations";
const PREF_EM_EXTENSION_FORMAT = "extensions.";
const PREF_EM_ENABLED_SCOPES = "extensions.enabledScopes";
const PREF_EM_STARTUP_SCAN_SCOPES = "extensions.startupScanScopes";
const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI";
const PREF_XPI_ENABLED = "xpinstall.enabled";
const PREF_XPI_WHITELIST_REQUIRED = "xpinstall.whitelist.required";
const PREF_XPI_DIRECT_WHITELISTED = "xpinstall.whitelist.directRequest";
@ -1747,6 +1748,9 @@ var XPIProvider = {
activeAddons: new Map(),
// True if the platform could have activated extensions
extensionsActive: false,
// True if all of the add-ons found during startup were installed in the
// application install location
allAppGlobal: true,
// New distribution addons awaiting permissions approval
newDistroAddons: null,
// Keep track of startup phases for telemetry
@ -2034,6 +2038,16 @@ var XPIProvider = {
AddonManagerPrivate.markProviderSafe(this);
if (aAppChanged && !this.allAppGlobal &&
Services.prefs.getBoolPref(PREF_EM_SHOW_MISMATCH_UI, true) &&
AddonManager.updateEnabled) {
let addonsToUpdate = this.shouldForceUpdateCheck(aAppChanged);
if (addonsToUpdate) {
this.noLegacyStartupCheck(addonsToUpdate);
flushCaches = true;
}
}
if (flushCaches) {
Services.obs.notifyObservers(null, "startupcache-invalidate");
// UI displayed early in startup (like the compatibility UI) may have
@ -2264,6 +2278,155 @@ var XPIProvider = {
}
},
/**
* If the application has been upgraded and there are add-ons outside the
* application directory then we may need to synchronize compatibility
* information but only if the mismatch UI isn't disabled.
*
* @returns null if no update check is needed, otherwise an array of add-on
* IDs to check for updates.
*/
shouldForceUpdateCheck(aAppChanged) {
AddonManagerPrivate.recordSimpleMeasure("XPIDB_metadata_age", AddonRepository.metadataAge());
let startupChanges = AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_DISABLED);
logger.debug("shouldForceUpdateCheck startupChanges: " + startupChanges.toSource());
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startup_disabled", startupChanges.length);
let forceUpdate = [];
if (startupChanges.length > 0) {
let addons = XPIDatabase.getAddons();
for (let addon of addons) {
if ((startupChanges.includes(addon.id)) &&
(addon.permissions() & AddonManager.PERM_CAN_UPGRADE) &&
(!addon.isCompatible || isDisabledLegacy(addon))) {
logger.debug("shouldForceUpdateCheck: can upgrade disabled add-on " + addon.id);
forceUpdate.push(addon.id);
}
}
}
if (forceUpdate.length > 0) {
return forceUpdate;
}
return null;
},
/**
* Perform startup check for updates of legacy extensions.
* This runs during startup when an app update has made some add-ons
* incompatible and legacy add-on support is diasabled.
* In this case, we just do a quiet update check.
*
* @param {Array<string>} ids The ids of the addons to check for updates.
*
* @returns {Set<string>} The ids of any addons that were updated. These
* addons will have been started by the update
* process so they should not be started by the
* regular bootstrap startup code.
*/
noLegacyStartupCheck(ids) {
let started = new Set();
const DIALOG = "chrome://mozapps/content/extensions/update.html";
const SHOW_DIALOG_DELAY = 1000;
const SHOW_CANCEL_DELAY = 30000;
// Keep track of a value between 0 and 1 indicating the progress
// for each addon. Just combine these linearly into a single
// value for the progress bar in the update dialog.
let updateProgress = val => {};
let progressByID = new Map();
function setProgress(id, val) {
progressByID.set(id, val);
updateProgress(Array.from(progressByID.values()).reduce((a, b) => a + b) / progressByID.size);
}
// Do an update check for one addon and try to apply the update if
// there is one. Progress for the check is arbitrarily defined as
// 10% done when the update check is done, between 10-90% during the
// download, then 100% when the update has been installed.
let checkOne = async (id) => {
logger.debug(`Checking for updates to disabled addon ${id}\n`);
setProgress(id, 0);
let addon = await AddonManager.getAddonByID(id);
let install = await new Promise(resolve => addon.findUpdates({
onUpdateFinished() { resolve(null); },
onUpdateAvailable(addon, install) { resolve(install); },
}, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED));
if (!install) {
setProgress(id, 1);
return;
}
setProgress(id, 0.1);
let installPromise = new Promise(resolve => {
let finish = () => {
setProgress(id, 1);
resolve();
};
install.addListener({
onDownloadProgress() {
if (install.maxProgress != 0) {
setProgress(id, 0.1 + 0.8 * install.progress / install.maxProgress);
}
},
onDownloadEnded() {
setProgress(id, 0.9);
},
onDownloadFailed: finish,
onInstallFailed: finish,
onInstallEnded() {
started.add(id);
AddonManagerPrivate.addStartupChange(AddonManager.STARTUP_CHANGE_CHANGED, id);
finish();
},
});
});
install.install();
await installPromise;
};
let finished = false;
Promise.all(ids.map(checkOne)).then(() => { finished = true; });
let window;
let timer = setTimeout(() => {
const FEATURES = "chrome,dialog,centerscreen,scrollbars=no";
window = Services.ww.openWindow(null, DIALOG, "", FEATURES, null);
let cancelDiv;
window.addEventListener("DOMContentLoaded", e => {
let progress = window.document.getElementById("progress");
updateProgress = val => { progress.value = val; };
cancelDiv = window.document.getElementById("cancel-section");
cancelDiv.setAttribute("style", "display: none;");
let cancelBtn = window.document.getElementById("cancel-btn");
cancelBtn.addEventListener("click", e => { finished = true; });
});
timer = setTimeout(() => {
cancelDiv.removeAttribute("style");
window.sizeToContent();
}, SHOW_CANCEL_DELAY - SHOW_DIALOG_DELAY);
}, SHOW_DIALOG_DELAY);
Services.tm.spinEventLoopUntil(() => finished);
clearTimeout(timer);
if (window) {
window.close();
}
return started;
},
async updateSystemAddons() {
let systemAddonLocation = XPIProvider.installLocationsByName[KEY_APP_SYSTEM_ADDONS];
if (!systemAddonLocation)

View File

@ -1445,6 +1445,10 @@ this.XPIDatabaseReconcile = {
for (let [id, currentAddon] of currentVisible) {
let previousAddon = previousVisible.get(id);
// Note if any visible add-on is not in the application install location
if (currentAddon._installLocation.name != KEY_APP_GLOBAL)
XPIProvider.allAppGlobal = false;
let isActive = !currentAddon.disabled && !currentAddon.pendingUninstall;
let wasActive = previousAddon ? previousAddon.active : currentAddon.active;

View File

@ -14,6 +14,9 @@ toolkit.jar:
content/mozapps/extensions/blocklist.js (content/blocklist.js)
content/mozapps/extensions/blocklist.css (content/blocklist.css)
content/mozapps/extensions/blocklist.xml (content/blocklist.xml)
content/mozapps/extensions/update.html (content/update.html)
content/mozapps/extensions/update.js (content/update.js)
content/mozapps/extensions/update.css (content/update.css)
content/mozapps/extensions/eula.xul (content/eula.xul)
content/mozapps/extensions/eula.js (content/eula.js)
content/mozapps/extensions/pluginPrefs.xul (content/pluginPrefs.xul)