michael@0: // -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // This UI is only opened from the Extension Manager when the app is upgraded. michael@0: michael@0: "use strict"; michael@0: michael@0: const PREF_UPDATE_EXTENSIONS_ENABLED = "extensions.update.enabled"; michael@0: const PREF_XPINSTALL_ENABLED = "xpinstall.enabled"; michael@0: const PREF_EM_HOTFIX_ID = "extensions.hotfix.id"; michael@0: michael@0: // timeout (in milliseconds) to wait for response to the metadata ping michael@0: const METADATA_TIMEOUT = 30000; michael@0: michael@0: Components.utils.import("resource://gre/modules/Services.jsm"); michael@0: Components.utils.import("resource://gre/modules/AddonManager.jsm"); michael@0: Components.utils.import("resource://gre/modules/addons/AddonRepository.jsm"); michael@0: michael@0: Components.utils.import("resource://gre/modules/Log.jsm"); michael@0: let logger = Log.repository.getLogger("addons.update-dialog"); michael@0: michael@0: var gUpdateWizard = { michael@0: // When synchronizing app compatibility info this contains all installed michael@0: // add-ons. When checking for compatible versions this contains only michael@0: // incompatible add-ons. michael@0: addons: [], michael@0: // Contains a list of add-ons that were disabled prior to the application michael@0: // upgrade. michael@0: inactiveAddonIDs: [], michael@0: // The add-ons that we found updates available for michael@0: addonsToUpdate: [], michael@0: shouldSuggestAutoChecking: false, michael@0: shouldAutoCheck: false, michael@0: xpinstallEnabled: true, michael@0: xpinstallLocked: false, michael@0: // cached AddonInstall entries for add-ons we might want to update, michael@0: // keyed by add-on ID michael@0: addonInstalls: new Map(), michael@0: shuttingDown: false, michael@0: // Count the add-ons disabled by this update, enabled/disabled by michael@0: // metadata checks, and upgraded. michael@0: disabled: 0, michael@0: metadataEnabled: 0, michael@0: metadataDisabled: 0, michael@0: upgraded: 0, michael@0: upgradeFailed: 0, michael@0: upgradeDeclined: 0, michael@0: michael@0: init: function gUpdateWizard_init() michael@0: { michael@0: this.inactiveAddonIDs = window.arguments[0]; michael@0: michael@0: try { michael@0: this.shouldSuggestAutoChecking = michael@0: !Services.prefs.getBoolPref(PREF_UPDATE_EXTENSIONS_ENABLED); michael@0: } michael@0: catch (e) { michael@0: } michael@0: michael@0: try { michael@0: this.xpinstallEnabled = Services.prefs.getBoolPref(PREF_XPINSTALL_ENABLED); michael@0: this.xpinstallLocked = Services.prefs.prefIsLocked(PREF_XPINSTALL_ENABLED); michael@0: } michael@0: catch (e) { michael@0: } michael@0: michael@0: if (Services.io.offline) michael@0: document.documentElement.currentPage = document.getElementById("offline"); michael@0: else michael@0: document.documentElement.currentPage = document.getElementById("versioninfo"); michael@0: }, michael@0: michael@0: onWizardFinish: function gUpdateWizard_onWizardFinish () michael@0: { michael@0: if (this.shouldSuggestAutoChecking) michael@0: Services.prefs.setBoolPref(PREF_UPDATE_EXTENSIONS_ENABLED, this.shouldAutoCheck); michael@0: }, michael@0: michael@0: _setUpButton: function gUpdateWizard_setUpButton(aButtonID, aButtonKey, aDisabled) michael@0: { michael@0: var strings = document.getElementById("updateStrings"); michael@0: var button = document.documentElement.getButton(aButtonID); michael@0: if (aButtonKey) { michael@0: button.label = strings.getString(aButtonKey); michael@0: try { michael@0: button.setAttribute("accesskey", strings.getString(aButtonKey + "Accesskey")); michael@0: } michael@0: catch (e) { michael@0: } michael@0: } michael@0: button.disabled = aDisabled; michael@0: }, michael@0: michael@0: setButtonLabels: function gUpdateWizard_setButtonLabels(aBackButton, aBackButtonIsDisabled, michael@0: aNextButton, aNextButtonIsDisabled, michael@0: aCancelButton, aCancelButtonIsDisabled) michael@0: { michael@0: this._setUpButton("back", aBackButton, aBackButtonIsDisabled); michael@0: this._setUpButton("next", aNextButton, aNextButtonIsDisabled); michael@0: this._setUpButton("cancel", aCancelButton, aCancelButtonIsDisabled); michael@0: }, michael@0: michael@0: ///////////////////////////////////////////////////////////////////////////// michael@0: // Update Errors michael@0: errorItems: [], michael@0: michael@0: checkForErrors: function gUpdateWizard_checkForErrors(aElementIDToShow) michael@0: { michael@0: if (this.errorItems.length > 0) michael@0: document.getElementById(aElementIDToShow).hidden = false; michael@0: }, michael@0: michael@0: onWizardClose: function gUpdateWizard_onWizardClose(aEvent) michael@0: { michael@0: return this.onWizardCancel(); michael@0: }, michael@0: michael@0: onWizardCancel: function gUpdateWizard_onWizardCancel() michael@0: { michael@0: gUpdateWizard.shuttingDown = true; michael@0: // Allow add-ons to continue downloading and installing michael@0: // in the background, though some may require a later restart michael@0: // Pages that are waiting for user input go into the background michael@0: // on cancel michael@0: if (gMismatchPage.waiting) { michael@0: logger.info("Dialog closed in mismatch page"); michael@0: if (gUpdateWizard.addonInstalls.size > 0) { michael@0: gInstallingPage.startInstalls([i for ([, i] of gUpdateWizard.addonInstalls)]); michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: // Pages that do asynchronous things will just keep running and check michael@0: // gUpdateWizard.shuttingDown to trigger background behaviour michael@0: if (!gInstallingPage.installing) { michael@0: logger.info("Dialog closed while waiting for updated compatibility information"); michael@0: } michael@0: else { michael@0: logger.info("Dialog closed while downloading and installing updates"); michael@0: } michael@0: return true; michael@0: } michael@0: }; michael@0: michael@0: var gOfflinePage = { michael@0: onPageAdvanced: function gOfflinePage_onPageAdvanced() michael@0: { michael@0: Services.io.offline = false; michael@0: return true; michael@0: }, michael@0: michael@0: toggleOffline: function gOfflinePage_toggleOffline() michael@0: { michael@0: var nextbtn = document.documentElement.getButton("next"); michael@0: nextbtn.disabled = !nextbtn.disabled; michael@0: } michael@0: } michael@0: michael@0: // Addon listener to count addons enabled/disabled by metadata checks michael@0: let listener = { michael@0: onDisabled: function listener_onDisabled(aAddon) { michael@0: logger.debug("onDisabled for ${id}", aAddon); michael@0: gUpdateWizard.metadataDisabled++; michael@0: }, michael@0: onEnabled: function listener_onEnabled(aAddon) { michael@0: logger.debug("onEnabled for ${id}", aAddon); michael@0: gUpdateWizard.metadataEnabled++; michael@0: } michael@0: }; michael@0: michael@0: var gVersionInfoPage = { michael@0: _completeCount: 0, michael@0: _totalCount: 0, michael@0: _versionInfoDone: false, michael@0: onPageShow: function gVersionInfoPage_onPageShow() michael@0: { michael@0: gUpdateWizard.setButtonLabels(null, true, michael@0: "nextButtonText", true, michael@0: "cancelButtonText", false); michael@0: michael@0: try { michael@0: var hotfixID = Services.prefs.getCharPref(PREF_EM_HOTFIX_ID); michael@0: } michael@0: catch (e) { } michael@0: michael@0: // Retrieve all add-ons in order to sync their app compatibility information michael@0: AddonManager.getAllAddons(function gVersionInfoPage_getAllAddons(aAddons) { michael@0: if (gUpdateWizard.shuttingDown) { michael@0: logger.debug("getAllAddons completed after dialog closed"); michael@0: } michael@0: michael@0: gUpdateWizard.addons = [a for (a of aAddons) michael@0: if (a.type != "plugin" && a.id != hotfixID)]; michael@0: michael@0: gVersionInfoPage._totalCount = gUpdateWizard.addons.length; michael@0: michael@0: // Count the add-ons newly disabled by this application update michael@0: for (let addon of gUpdateWizard.addons) { michael@0: if (gUpdateWizard.inactiveAddonIDs.indexOf(addon.id) != -1) { michael@0: gUpdateWizard.disabled++; michael@0: } michael@0: } michael@0: michael@0: // Ensure compatibility overrides are up to date before checking for michael@0: // individual addon updates. michael@0: let ids = [addon.id for (addon of gUpdateWizard.addons)]; michael@0: michael@0: // Do the metadata ping, listening for any newly enabled/disabled add-ons. michael@0: AddonManager.addAddonListener(listener); michael@0: AddonRepository.repopulateCache(ids, function gVersionInfoPage_repopulateCache() { michael@0: michael@0: if (gUpdateWizard.shuttingDown) { michael@0: logger.debug("repopulateCache completed after dialog closed"); michael@0: } michael@0: michael@0: for (let addon of gUpdateWizard.addons) { michael@0: logger.debug("VersionInfo Finding updates for " + addon.id); michael@0: addon.findUpdates(gVersionInfoPage, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED); michael@0: } michael@0: }, METADATA_TIMEOUT); michael@0: }); michael@0: }, michael@0: michael@0: onAllUpdatesFinished: function gVersionInfoPage_onAllUpdatesFinished() { michael@0: AddonManager.removeAddonListener(listener); michael@0: AddonManagerPrivate.recordSimpleMeasure("appUpdate_disabled", michael@0: gUpdateWizard.disabled); michael@0: AddonManagerPrivate.recordSimpleMeasure("appUpdate_metadata_enabled", michael@0: gUpdateWizard.metadataEnabled); michael@0: AddonManagerPrivate.recordSimpleMeasure("appUpdate_metadata_disabled", michael@0: gUpdateWizard.metadataDisabled); michael@0: // Record 0 for these here in case we exit early; values will be replaced michael@0: // later if we actually upgrade any. michael@0: AddonManagerPrivate.recordSimpleMeasure("appUpdate_upgraded", 0); michael@0: AddonManagerPrivate.recordSimpleMeasure("appUpdate_upgradeFailed", 0); michael@0: AddonManagerPrivate.recordSimpleMeasure("appUpdate_upgradeDeclined", 0); michael@0: // Filter out any add-ons that were disabled before the application was michael@0: // upgraded or are already compatible michael@0: logger.debug("VersionInfo updates finished: inactive " + michael@0: gUpdateWizard.inactiveAddonIDs.toSource() + " found " + michael@0: [addon.id + ":" + addon.appDisabled for (addon of gUpdateWizard.addons)].toSource()); michael@0: let filteredAddons = []; michael@0: for (let a of gUpdateWizard.addons) { michael@0: if (a.appDisabled && gUpdateWizard.inactiveAddonIDs.indexOf(a.id) < 0) { michael@0: logger.debug("Continuing with add-on " + a.id); michael@0: filteredAddons.push(a); michael@0: } michael@0: else if (gUpdateWizard.addonInstalls.has(a.id)) { michael@0: gUpdateWizard.addonInstalls.get(a.id).cancel(); michael@0: gUpdateWizard.addonInstalls.delete(a.id); michael@0: } michael@0: } michael@0: gUpdateWizard.addons = filteredAddons; michael@0: michael@0: if (gUpdateWizard.shuttingDown) { michael@0: // jump directly to updating auto-update add-ons in the background michael@0: if (gUpdateWizard.addonInstalls.size > 0) { michael@0: gInstallingPage.startInstalls([i for ([, i] of gUpdateWizard.addonInstalls)]); michael@0: } michael@0: return; michael@0: } michael@0: michael@0: if (filteredAddons.length > 0) { michael@0: if (!gUpdateWizard.xpinstallEnabled && gUpdateWizard.xpinstallLocked) { michael@0: document.documentElement.currentPage = document.getElementById("adminDisabled"); michael@0: return; michael@0: } michael@0: document.documentElement.currentPage = document.getElementById("mismatch"); michael@0: } michael@0: else { michael@0: logger.info("VersionInfo: No updates require further action"); michael@0: // VersionInfo compatibility updates resolved all compatibility problems, michael@0: // close this window and continue starting the application... michael@0: //XXX Bug 314754 - We need to use setTimeout to close the window due to michael@0: // the EM using xmlHttpRequest when checking for updates. michael@0: setTimeout(close, 0); michael@0: } michael@0: }, michael@0: michael@0: ///////////////////////////////////////////////////////////////////////////// michael@0: // UpdateListener michael@0: onUpdateFinished: function gVersionInfoPage_onUpdateFinished(aAddon, status) { michael@0: ++this._completeCount; michael@0: michael@0: if (status != AddonManager.UPDATE_STATUS_NO_ERROR) { michael@0: logger.debug("VersionInfo update " + this._completeCount + " of " + this._totalCount + michael@0: " failed for " + aAddon.id + ": " + status); michael@0: gUpdateWizard.errorItems.push(aAddon); michael@0: } michael@0: else { michael@0: logger.debug("VersionInfo update " + this._completeCount + " of " + this._totalCount + michael@0: " finished for " + aAddon.id); michael@0: } michael@0: michael@0: // If we're not in the background, just make a list of add-ons that have michael@0: // updates available michael@0: if (!gUpdateWizard.shuttingDown) { michael@0: // If we're still in the update check window and the add-on is now active michael@0: // then it won't have been disabled by startup michael@0: if (aAddon.active) { michael@0: AddonManagerPrivate.removeStartupChange("disabled", aAddon.id); michael@0: gUpdateWizard.metadataEnabled++; michael@0: } michael@0: michael@0: // Update the status text and progress bar michael@0: var updateStrings = document.getElementById("updateStrings"); michael@0: var statusElt = document.getElementById("versioninfo.status"); michael@0: var statusString = updateStrings.getFormattedString("statusPrefix", [aAddon.name]); michael@0: statusElt.setAttribute("value", statusString); michael@0: michael@0: // Update the status text and progress bar michael@0: var progress = document.getElementById("versioninfo.progress"); michael@0: progress.mode = "normal"; michael@0: progress.value = Math.ceil((this._completeCount / this._totalCount) * 100); michael@0: } michael@0: michael@0: if (this._completeCount == this._totalCount) michael@0: this.onAllUpdatesFinished(); michael@0: }, michael@0: michael@0: onUpdateAvailable: function gVersionInfoPage_onUpdateAvailable(aAddon, aInstall) { michael@0: logger.debug("VersionInfo got an install for " + aAddon.id + ": " + aAddon.version); michael@0: gUpdateWizard.addonInstalls.set(aAddon.id, aInstall); michael@0: }, michael@0: }; michael@0: michael@0: var gMismatchPage = { michael@0: waiting: false, michael@0: michael@0: onPageShow: function gMismatchPage_onPageShow() michael@0: { michael@0: gMismatchPage.waiting = true; michael@0: gUpdateWizard.setButtonLabels(null, true, michael@0: "mismatchCheckNow", false, michael@0: "mismatchDontCheck", false); michael@0: document.documentElement.getButton("next").focus(); michael@0: michael@0: var incompatible = document.getElementById("mismatch.incompatible"); michael@0: for (let addon of gUpdateWizard.addons) { michael@0: var listitem = document.createElement("listitem"); michael@0: listitem.setAttribute("label", addon.name + " " + addon.version); michael@0: incompatible.appendChild(listitem); michael@0: } michael@0: } michael@0: }; michael@0: michael@0: var gUpdatePage = { michael@0: _totalCount: 0, michael@0: _completeCount: 0, michael@0: onPageShow: function gUpdatePage_onPageShow() michael@0: { michael@0: gMismatchPage.waiting = false; michael@0: gUpdateWizard.setButtonLabels(null, true, michael@0: "nextButtonText", true, michael@0: "cancelButtonText", false); michael@0: document.documentElement.getButton("next").focus(); michael@0: michael@0: gUpdateWizard.errorItems = []; michael@0: michael@0: this._totalCount = gUpdateWizard.addons.length; michael@0: for (let addon of gUpdateWizard.addons) { michael@0: logger.debug("UpdatePage requesting update for " + addon.id); michael@0: // Redundant call to find updates again here when we already got them michael@0: // in the VersionInfo page: https://bugzilla.mozilla.org/show_bug.cgi?id=960597 michael@0: addon.findUpdates(this, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED); michael@0: } michael@0: }, michael@0: michael@0: onAllUpdatesFinished: function gUpdatePage_onAllUpdatesFinished() { michael@0: if (gUpdateWizard.shuttingDown) michael@0: return; michael@0: michael@0: var nextPage = document.getElementById("noupdates"); michael@0: if (gUpdateWizard.addonsToUpdate.length > 0) michael@0: nextPage = document.getElementById("found"); michael@0: document.documentElement.currentPage = nextPage; michael@0: }, michael@0: michael@0: ///////////////////////////////////////////////////////////////////////////// michael@0: // UpdateListener michael@0: onUpdateAvailable: function gUpdatePage_onUpdateAvailable(aAddon, aInstall) { michael@0: logger.debug("UpdatePage got an update for " + aAddon.id + ": " + aAddon.version); michael@0: gUpdateWizard.addonsToUpdate.push(aInstall); michael@0: }, michael@0: michael@0: onUpdateFinished: function gUpdatePage_onUpdateFinished(aAddon, status) { michael@0: if (status != AddonManager.UPDATE_STATUS_NO_ERROR) michael@0: gUpdateWizard.errorItems.push(aAddon); michael@0: michael@0: ++this._completeCount; michael@0: michael@0: if (!gUpdateWizard.shuttingDown) { michael@0: // Update the status text and progress bar michael@0: var updateStrings = document.getElementById("updateStrings"); michael@0: var statusElt = document.getElementById("checking.status"); michael@0: var statusString = updateStrings.getFormattedString("statusPrefix", [aAddon.name]); michael@0: statusElt.setAttribute("value", statusString); michael@0: michael@0: var progress = document.getElementById("checking.progress"); michael@0: progress.value = Math.ceil((this._completeCount / this._totalCount) * 100); michael@0: } michael@0: michael@0: if (this._completeCount == this._totalCount) michael@0: this.onAllUpdatesFinished() michael@0: }, michael@0: }; michael@0: michael@0: var gFoundPage = { michael@0: onPageShow: function gFoundPage_onPageShow() michael@0: { michael@0: gUpdateWizard.setButtonLabels(null, true, michael@0: "installButtonText", false, michael@0: null, false); michael@0: michael@0: var foundUpdates = document.getElementById("found.updates"); michael@0: var itemCount = gUpdateWizard.addonsToUpdate.length; michael@0: for (let install of gUpdateWizard.addonsToUpdate) { michael@0: let listItem = foundUpdates.appendItem(install.name + " " + install.version); michael@0: listItem.setAttribute("type", "checkbox"); michael@0: listItem.setAttribute("checked", "true"); michael@0: listItem.install = install; michael@0: } michael@0: michael@0: if (!gUpdateWizard.xpinstallEnabled) { michael@0: document.getElementById("xpinstallDisabledAlert").hidden = false; michael@0: document.getElementById("enableXPInstall").focus(); michael@0: document.documentElement.getButton("next").disabled = true; michael@0: } michael@0: else { michael@0: document.documentElement.getButton("next").focus(); michael@0: document.documentElement.getButton("next").disabled = false; michael@0: } michael@0: }, michael@0: michael@0: toggleXPInstallEnable: function gFoundPage_toggleXPInstallEnable(aEvent) michael@0: { michael@0: var enabled = aEvent.target.checked; michael@0: gUpdateWizard.xpinstallEnabled = enabled; michael@0: var pref = Components.classes["@mozilla.org/preferences-service;1"] michael@0: .getService(Components.interfaces.nsIPrefBranch); michael@0: pref.setBoolPref(PREF_XPINSTALL_ENABLED, enabled); michael@0: this.updateNextButton(); michael@0: }, michael@0: michael@0: updateNextButton: function gFoundPage_updateNextButton() michael@0: { michael@0: if (!gUpdateWizard.xpinstallEnabled) { michael@0: document.documentElement.getButton("next").disabled = true; michael@0: return; michael@0: } michael@0: michael@0: var oneChecked = false; michael@0: var foundUpdates = document.getElementById("found.updates"); michael@0: var updates = foundUpdates.getElementsByTagName("listitem"); michael@0: for (let update of updates) { michael@0: if (!update.checked) michael@0: continue; michael@0: oneChecked = true; michael@0: break; michael@0: } michael@0: michael@0: gUpdateWizard.setButtonLabels(null, true, michael@0: "installButtonText", true, michael@0: null, false); michael@0: document.getElementById("found").setAttribute("next", "installing"); michael@0: document.documentElement.getButton("next").disabled = !oneChecked; michael@0: } michael@0: }; michael@0: michael@0: var gInstallingPage = { michael@0: _installs : [], michael@0: _errors : [], michael@0: _strings : null, michael@0: _currentInstall : -1, michael@0: _installing : false, michael@0: michael@0: // Initialize fields we need for installing and tracking progress, michael@0: // and start iterating through the installations michael@0: startInstalls: function gInstallingPage_startInstalls(aInstallList) { michael@0: if (!gUpdateWizard.xpinstallEnabled) { michael@0: return; michael@0: } michael@0: michael@0: logger.debug("Start installs for " michael@0: + [i.existingAddon.id for (i of aInstallList)].toSource()); michael@0: this._errors = []; michael@0: this._installs = aInstallList; michael@0: this._installing = true; michael@0: this.startNextInstall(); michael@0: }, michael@0: michael@0: onPageShow: function gInstallingPage_onPageShow() michael@0: { michael@0: gUpdateWizard.setButtonLabels(null, true, michael@0: "nextButtonText", true, michael@0: null, true); michael@0: michael@0: var foundUpdates = document.getElementById("found.updates"); michael@0: var updates = foundUpdates.getElementsByTagName("listitem"); michael@0: let toInstall = []; michael@0: for (let update of updates) { michael@0: if (!update.checked) { michael@0: logger.info("User chose to cancel update of " + update.label); michael@0: gUpdateWizard.upgradeDeclined++; michael@0: update.install.cancel(); michael@0: continue; michael@0: } michael@0: toInstall.push(update.install); michael@0: } michael@0: this._strings = document.getElementById("updateStrings"); michael@0: michael@0: this.startInstalls(toInstall); michael@0: }, michael@0: michael@0: startNextInstall: function gInstallingPage_startNextInstall() { michael@0: if (this._currentInstall >= 0) { michael@0: this._installs[this._currentInstall].removeListener(this); michael@0: } michael@0: michael@0: this._currentInstall++; michael@0: michael@0: if (this._installs.length == this._currentInstall) { michael@0: Services.obs.notifyObservers(null, "TEST:all-updates-done", null); michael@0: AddonManagerPrivate.recordSimpleMeasure("appUpdate_upgraded", michael@0: gUpdateWizard.upgraded); michael@0: AddonManagerPrivate.recordSimpleMeasure("appUpdate_upgradeFailed", michael@0: gUpdateWizard.upgradeFailed); michael@0: AddonManagerPrivate.recordSimpleMeasure("appUpdate_upgradeDeclined", michael@0: gUpdateWizard.upgradeDeclined); michael@0: this._installing = false; michael@0: if (gUpdateWizard.shuttingDown) { michael@0: return; michael@0: } michael@0: var nextPage = this._errors.length > 0 ? "installerrors" : "finished"; michael@0: document.getElementById("installing").setAttribute("next", nextPage); michael@0: document.documentElement.advance(); michael@0: return; michael@0: } michael@0: michael@0: let install = this._installs[this._currentInstall]; michael@0: michael@0: if (gUpdateWizard.shuttingDown && !AddonManager.shouldAutoUpdate(install.existingAddon)) { michael@0: logger.debug("Don't update " + install.existingAddon.id + " in background"); michael@0: gUpdateWizard.upgradeDeclined++; michael@0: install.cancel(); michael@0: this.startNextInstall(); michael@0: return; michael@0: } michael@0: install.addListener(this); michael@0: install.install(); michael@0: }, michael@0: michael@0: ///////////////////////////////////////////////////////////////////////////// michael@0: // InstallListener michael@0: onDownloadStarted: function gInstallingPage_onDownloadStarted(aInstall) { michael@0: if (gUpdateWizard.shuttingDown) { michael@0: return; michael@0: } michael@0: var strings = document.getElementById("updateStrings"); michael@0: var label = strings.getFormattedString("downloadingPrefix", [aInstall.name]); michael@0: var actionItem = document.getElementById("actionItem"); michael@0: actionItem.value = label; michael@0: }, michael@0: michael@0: onDownloadProgress: function gInstallingPage_onDownloadProgress(aInstall) { michael@0: if (gUpdateWizard.shuttingDown) { michael@0: return; michael@0: } michael@0: var downloadProgress = document.getElementById("downloadProgress"); michael@0: downloadProgress.value = Math.ceil(100 * aInstall.progress / aInstall.maxProgress); michael@0: }, michael@0: michael@0: onDownloadEnded: function gInstallingPage_onDownloadEnded(aInstall) { michael@0: }, michael@0: michael@0: onDownloadFailed: function gInstallingPage_onDownloadFailed(aInstall) { michael@0: this._errors.push(aInstall); michael@0: michael@0: gUpdateWizard.upgradeFailed++; michael@0: this.startNextInstall(); michael@0: }, michael@0: michael@0: onInstallStarted: function gInstallingPage_onInstallStarted(aInstall) { michael@0: if (gUpdateWizard.shuttingDown) { michael@0: return; michael@0: } michael@0: var strings = document.getElementById("updateStrings"); michael@0: var label = strings.getFormattedString("installingPrefix", [aInstall.name]); michael@0: var actionItem = document.getElementById("actionItem"); michael@0: actionItem.value = label; michael@0: }, michael@0: michael@0: onInstallEnded: function gInstallingPage_onInstallEnded(aInstall, aAddon) { michael@0: if (!gUpdateWizard.shuttingDown) { michael@0: // Remember that this add-on was updated during startup michael@0: AddonManagerPrivate.addStartupChange(AddonManager.STARTUP_CHANGE_CHANGED, michael@0: aAddon.id); michael@0: } michael@0: michael@0: gUpdateWizard.upgraded++; michael@0: this.startNextInstall(); michael@0: }, michael@0: michael@0: onInstallFailed: function gInstallingPage_onInstallFailed(aInstall) { michael@0: this._errors.push(aInstall); michael@0: michael@0: gUpdateWizard.upgradeFailed++; michael@0: this.startNextInstall(); michael@0: } michael@0: }; michael@0: michael@0: var gInstallErrorsPage = { michael@0: onPageShow: function gInstallErrorsPage_onPageShow() michael@0: { michael@0: gUpdateWizard.setButtonLabels(null, true, null, true, null, true); michael@0: document.documentElement.getButton("finish").focus(); michael@0: }, michael@0: }; michael@0: michael@0: // Displayed when there are incompatible add-ons and the xpinstall.enabled michael@0: // pref is false and locked. michael@0: var gAdminDisabledPage = { michael@0: onPageShow: function gAdminDisabledPage_onPageShow() michael@0: { michael@0: gUpdateWizard.setButtonLabels(null, true, null, true, michael@0: "cancelButtonText", true); michael@0: document.documentElement.getButton("finish").focus(); michael@0: } michael@0: }; michael@0: michael@0: // Displayed when selected add-on updates have been installed without error. michael@0: // There can still be add-ons that are not compatible and don't have an update. michael@0: var gFinishedPage = { michael@0: onPageShow: function gFinishedPage_onPageShow() michael@0: { michael@0: gUpdateWizard.setButtonLabels(null, true, null, true, null, true); michael@0: document.documentElement.getButton("finish").focus(); michael@0: michael@0: if (gUpdateWizard.shouldSuggestAutoChecking) { michael@0: document.getElementById("finishedCheckDisabled").hidden = false; michael@0: gUpdateWizard.shouldAutoCheck = true; michael@0: } michael@0: else michael@0: document.getElementById("finishedCheckEnabled").hidden = false; michael@0: michael@0: document.documentElement.getButton("finish").focus(); michael@0: } michael@0: }; michael@0: michael@0: // Displayed when there are incompatible add-ons and there are no available michael@0: // updates. michael@0: var gNoUpdatesPage = { michael@0: onPageShow: function gNoUpdatesPage_onPageLoad(aEvent) michael@0: { michael@0: gUpdateWizard.setButtonLabels(null, true, null, true, null, true); michael@0: if (gUpdateWizard.shouldSuggestAutoChecking) { michael@0: document.getElementById("noupdatesCheckDisabled").hidden = false; michael@0: gUpdateWizard.shouldAutoCheck = true; michael@0: } michael@0: else michael@0: document.getElementById("noupdatesCheckEnabled").hidden = false; michael@0: michael@0: gUpdateWizard.checkForErrors("updateCheckErrorNotFound"); michael@0: document.documentElement.getButton("finish").focus(); michael@0: } michael@0: };