[Pale-Moon] Issue #1737 - Part 4: Scope gXPInstallObserver.observe case statements.

This is needed because the large blocks of code otherwise have
redeclarations of let variables.
This commit is contained in:
Pale Moon 2020-03-10 22:32:57 +01:00 • committed by Roy Tam
commit fa4c122fad

View file

@ -74,7 +74,7 @@ const gXPInstallObserver = {
var options = { timeout: Date.now() + 30000 }; var options = { timeout: Date.now() + 30000 };
switch (aTopic) { switch (aTopic) {
case "addon-install-disabled": case "addon-install-disabled": {
notificationID = "xpinstall-disabled" notificationID = "xpinstall-disabled"
if (gPrefService.prefIsLocked("xpinstall.enabled")) { if (gPrefService.prefIsLocked("xpinstall.enabled")) {
@ -95,7 +95,8 @@ const gXPInstallObserver = {
PopupNotifications.show(browser, notificationID, messageString, anchorID, PopupNotifications.show(browser, notificationID, messageString, anchorID,
action, null, options); action, null, options);
break; break;
case "addon-install-origin-blocked": }
case "addon-install-origin-blocked": {
messageString = gNavigatorBundle.getFormattedString("xpinstallPromptWarningOrigin", messageString = gNavigatorBundle.getFormattedString("xpinstallPromptWarningOrigin",
[brandShortName]); [brandShortName]);
@ -104,7 +105,8 @@ const gXPInstallObserver = {
null, null, options); null, null, options);
removeNotificationOnEnd(popup, installInfo.installs); removeNotificationOnEnd(popup, installInfo.installs);
break; break;
case "addon-install-blocked": }
case "addon-install-blocked": {
let originatingHost; let originatingHost;
try { try {
originatingHost = installInfo.originatingURI.host; originatingHost = installInfo.originatingURI.host;
@ -128,7 +130,8 @@ const gXPInstallObserver = {
anchorID, action, null, options); anchorID, action, null, options);
removeNotificationOnEnd(popup, installInfo.installs); removeNotificationOnEnd(popup, installInfo.installs);
break; break;
case "addon-install-started": }
case "addon-install-started": {
var needsDownload = function needsDownload(aInstall) { var needsDownload = function needsDownload(aInstall) {
return aInstall.state != AddonManager.STATE_DOWNLOADED; return aInstall.state != AddonManager.STATE_DOWNLOADED;
} }
@ -153,7 +156,8 @@ const gXPInstallObserver = {
PopupNotifications.show(browser, notificationID, messageString, anchorID, PopupNotifications.show(browser, notificationID, messageString, anchorID,
null, null, options); null, null, options);
break; break;
case "addon-install-failed": }
case "addon-install-failed": {
// TODO This isn't terribly ideal for the multiple failure case // TODO This isn't terribly ideal for the multiple failure case
for (let install of installInfo.installs) { for (let install of installInfo.installs) {
let host = (installInfo.originatingURI instanceof Ci.nsIStandardURL) && let host = (installInfo.originatingURI instanceof Ci.nsIStandardURL) &&
@ -186,7 +190,8 @@ const gXPInstallObserver = {
action, null, options); action, null, options);
} }
break; break;
case "addon-install-complete": }
case "addon-install-complete": {
var needsRestart = installInfo.installs.some(function(i) { var needsRestart = installInfo.installs.some(function(i) {
return i.addon.pendingOperations != AddonManager.PENDING_NONE; return i.addon.pendingOperations != AddonManager.PENDING_NONE;
}); });
@ -218,6 +223,7 @@ const gXPInstallObserver = {
PopupNotifications.show(browser, notificationID, messageString, anchorID, PopupNotifications.show(browser, notificationID, messageString, anchorID,
action, null, options); action, null, options);
break; break;
}
} }
} }
}; };