diff options
Diffstat (limited to 'toolkit/mozapps/extensions/content/extensions.js')
-rw-r--r-- | toolkit/mozapps/extensions/content/extensions.js | 1335 |
1 files changed, 500 insertions, 835 deletions
diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index 56158d9c6..6f2a47482 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -4,13 +4,10 @@ "use strict"; -/* import-globals-from ../../../content/contentAreaUtils.js */ -/* globals XMLStylesheetProcessingInstruction*/ - -var Cc = Components.classes; -var Ci = Components.interfaces; -var Cu = Components.utils; -var Cr = Components.results; +const Cc = Components.classes; +const Ci = Components.interfaces; +const Cu = Components.utils; +const Cr = Components.results; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); @@ -18,19 +15,13 @@ Cu.import("resource://gre/modules/DownloadUtils.jsm"); Cu.import("resource://gre/modules/AddonManager.jsm"); Cu.import("resource://gre/modules/addons/AddonRepository.jsm"); -const CONSTANTS = {}; -Cu.import("resource://gre/modules/addons/AddonConstants.jsm", CONSTANTS); -const SIGNING_REQUIRED = CONSTANTS.REQUIRE_SIGNING ? - true : - Services.prefs.getBoolPref("xpinstall.signatures.required"); - XPCOMUtils.defineLazyModuleGetter(this, "PluralForm", "resource://gre/modules/PluralForm.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Preferences", - "resource://gre/modules/Preferences.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Experiments", - "resource:///modules/experiments/Experiments.jsm"); +XPCOMUtils.defineLazyGetter(this, "BrowserToolboxProcess", function () { + return Cu.import("resource://devtools/client/framework/ToolboxProcess.jsm", {}). + BrowserToolboxProcess; +}); const PREF_DISCOVERURL = "extensions.webservice.discoverURL"; const PREF_DISCOVER_ENABLED = "extensions.getAddons.showPane"; @@ -40,6 +31,8 @@ const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled"; const PREF_GETADDONS_CACHE_ID_ENABLED = "extensions.%ID%.getAddons.cache.enabled"; const PREF_UI_TYPE_HIDDEN = "extensions.ui.%TYPE%.hidden"; const PREF_UI_LASTCATEGORY = "extensions.ui.lastCategory"; +const PREF_ADDON_DEBUGGING_ENABLED = "devtools.chrome.enabled"; +const PREF_REMOTE_DEBUGGING_ENABLED = "devtools.debugger.remote-enabled"; const LOADING_MSG_DELAY = 100; @@ -63,103 +56,28 @@ XPCOMUtils.defineLazyServiceGetter(gStrings, "bundleSvc", "@mozilla.org/intl/stringbundle;1", "nsIStringBundleService"); -XPCOMUtils.defineLazyGetter(gStrings, "brand", function() { +XPCOMUtils.defineLazyGetter(gStrings, "brand", function brandLazyGetter() { return this.bundleSvc.createBundle("chrome://branding/locale/brand.properties"); }); -XPCOMUtils.defineLazyGetter(gStrings, "ext", function() { +XPCOMUtils.defineLazyGetter(gStrings, "ext", function extLazyGetter() { return this.bundleSvc.createBundle("chrome://mozapps/locale/extensions/extensions.properties"); }); -XPCOMUtils.defineLazyGetter(gStrings, "dl", function() { +XPCOMUtils.defineLazyGetter(gStrings, "dl", function dlLazyGetter() { return this.bundleSvc.createBundle("chrome://mozapps/locale/downloads/downloads.properties"); }); -XPCOMUtils.defineLazyGetter(gStrings, "brandShortName", function() { +XPCOMUtils.defineLazyGetter(gStrings, "brandShortName", function brandShortNameLazyGetter() { return this.brand.GetStringFromName("brandShortName"); }); -XPCOMUtils.defineLazyGetter(gStrings, "appVersion", function() { +XPCOMUtils.defineLazyGetter(gStrings, "appVersion", function appVersionLazyGetter() { return Services.appinfo.version; }); document.addEventListener("load", initialize, true); window.addEventListener("unload", shutdown, false); -class MessageDispatcher { - constructor(target) { - this.listeners = new Map(); - this.target = target; - } - - addMessageListener(name, handler) { - if (!this.listeners.has(name)) { - this.listeners.set(name, new Set()); - } - - this.listeners.get(name).add(handler); - } - - removeMessageListener(name, handler) { - if (this.listeners.has(name)) { - this.listeners.get(name).delete(handler); - } - } - - sendAsyncMessage(name, data) { - for (let handler of this.listeners.get(name) || new Set()) { - Promise.resolve().then(() => { - handler.receiveMessage({ - name, - data, - target: this.target, - }); - }); - } - } -} - -/** - * A mock FrameMessageManager global to allow frame scripts to run in - * non-top-level, non-remote <browser>s as if they were top-level or - * remote. - * - * @param {Element} browser - * A XUL <browser> element. - */ -class FakeFrameMessageManager { - constructor(browser) { - let dispatcher = new MessageDispatcher(browser); - let frameDispatcher = new MessageDispatcher(null); - - this.sendAsyncMessage = frameDispatcher.sendAsyncMessage.bind(frameDispatcher); - this.addMessageListener = dispatcher.addMessageListener.bind(dispatcher); - this.removeMessageListener = dispatcher.removeMessageListener.bind(dispatcher); - - this.frame = { - get content() { - return browser.contentWindow; - }, - - get docShell() { - return browser.docShell; - }, - - addEventListener: browser.addEventListener.bind(browser), - removeEventListener: browser.removeEventListener.bind(browser), - - sendAsyncMessage: dispatcher.sendAsyncMessage.bind(dispatcher), - addMessageListener: frameDispatcher.addMessageListener.bind(frameDispatcher), - removeMessageListener: frameDispatcher.removeMessageListener.bind(frameDispatcher), - } - } - - loadFrameScript(url) { - Services.scriptloader.loadSubScript(url, Object.create(this.frame)); - } -} - var gPendingInitializations = 1; -Object.defineProperty(this, "gIsInitializing", { - get: () => gPendingInitializations > 0 -}); +this.__defineGetter__("gIsInitializing", function gIsInitializingGetter() gPendingInitializations > 0); function initialize(event) { // XXXbz this listener gets _all_ load events for all nodes in the @@ -236,6 +154,9 @@ function initialize(event) { } gViewController.loadInitialView(view); + + Services.prefs.addObserver(PREF_ADDON_DEBUGGING_ENABLED, debuggingPrefChanged, false); + Services.prefs.addObserver(PREF_REMOTE_DEBUGGING_ENABLED, debuggingPrefChanged, false); } function notifyInitialized() { @@ -256,6 +177,8 @@ function shutdown() { gEventManager.shutdown(); gViewController.shutdown(); Services.obs.removeObserver(sendEMPong, "EM-ping"); + Services.prefs.removeObserver(PREF_ADDON_DEBUGGING_ENABLED, debuggingPrefChanged); + Services.prefs.removeObserver(PREF_REMOTE_DEBUGGING_ENABLED, debuggingPrefChanged); } function sendEMPong(aSubject, aTopic, aData) { @@ -274,12 +197,6 @@ function loadView(aViewId) { } } -function isCorrectlySigned(aAddon) { - // Add-ons without an "isCorrectlySigned" property are correctly signed as - // they aren't the correct type for signing. - return aAddon.isCorrectlySigned !== false; -} - function isDiscoverEnabled() { if (Services.prefs.getPrefType(PREF_DISCOVERURL) == Services.prefs.PREF_INVALID) return false; @@ -297,23 +214,6 @@ function isDiscoverEnabled() { return true; } -function getExperimentEndDate(aAddon) { - if (!("@mozilla.org/browser/experiments-service;1" in Cc)) { - return 0; - } - - if (!aAddon.isActive) { - return aAddon.endDate; - } - - let experiment = Experiments.instance().getActiveExperiment(); - if (!experiment) { - return 0; - } - - return experiment.endDate; -} - /** * Obtain the main DOMWindow for the current context. */ @@ -345,8 +245,9 @@ function getMainWindowWithPreferencesPane() { let mainWindow = getMainWindow(); if (mainWindow && "openAdvancedPreferences" in mainWindow) { return mainWindow; + } else { + return null; } - return null; } /** @@ -372,27 +273,27 @@ var HTML5History = { .canGoForward; }, - back: function() { + back: function HTML5History_back() { window.history.back(); gViewController.updateCommand("cmd_back"); gViewController.updateCommand("cmd_forward"); }, - forward: function() { + forward: function HTML5History_forward() { window.history.forward(); gViewController.updateCommand("cmd_back"); gViewController.updateCommand("cmd_forward"); }, - pushState: function(aState) { + pushState: function HTML5History_pushState(aState) { window.history.pushState(aState, document.title); }, - replaceState: function(aState) { + replaceState: function HTML5History_replaceState(aState) { window.history.replaceState(aState, document.title); }, - popState: function() { + popState: function HTML5History_popState() { function onStatePopped(aEvent) { window.removeEventListener("popstate", onStatePopped, true); // TODO To ensure we can't go forward again we put an additional entry @@ -426,7 +327,7 @@ var FakeHistory = { return (this.pos + 1) < this.states.length; }, - back: function() { + back: function FakeHistory_back() { if (this.pos == 0) throw Components.Exception("Cannot go back from this point"); @@ -436,7 +337,7 @@ var FakeHistory = { gViewController.updateCommand("cmd_forward"); }, - forward: function() { + forward: function FakeHistory_forward() { if ((this.pos + 1) >= this.states.length) throw Components.Exception("Cannot go forward from this point"); @@ -446,17 +347,17 @@ var FakeHistory = { gViewController.updateCommand("cmd_forward"); }, - pushState: function(aState) { + pushState: function FakeHistory_pushState(aState) { this.pos++; this.states.splice(this.pos, this.states.length); this.states.push(aState); }, - replaceState: function(aState) { + replaceState: function FakeHistory_replaceState(aState) { this.states[this.pos] = aState; }, - popState: function() { + popState: function FakeHistory_popState() { if (this.pos == 0) throw Components.Exception("Cannot popState from this view"); @@ -484,7 +385,8 @@ var gEventManager = { _listeners: {}, _installListeners: [], - initialize: function() { + initialize: function gEM_initialize() { + var self = this; const ADDON_EVENTS = ["onEnabling", "onEnabled", "onDisabling", "onDisabled", "onUninstalling", "onUninstalled", "onInstalled", "onOperationCancelled", @@ -493,7 +395,9 @@ var gEventManager = { "onPropertyChanged"]; for (let evt of ADDON_EVENTS) { let event = evt; - this[event] = (...aArgs) => this.delegateAddonEvent(event, aArgs); + self[event] = function initialize_delegateAddonEvent(...aArgs) { + self.delegateAddonEvent(event, aArgs); + }; } const INSTALL_EVENTS = ["onNewInstall", "onDownloadStarted", @@ -504,7 +408,9 @@ var gEventManager = { "onExternalInstall"]; for (let evt of INSTALL_EVENTS) { let event = evt; - this[event] = (...aArgs) => this.delegateInstallEvent(event, aArgs); + self[event] = function initialize_delegateInstallEvent(...aArgs) { + self.delegateInstallEvent(event, aArgs); + }; } AddonManager.addManagerListener(this); @@ -515,7 +421,7 @@ var gEventManager = { this.refreshAutoUpdateDefault(); var contextMenu = document.getElementById("addonitem-popup"); - contextMenu.addEventListener("popupshowing", function() { + contextMenu.addEventListener("popupshowing", function contextMenu_onPopupshowing() { var addon = gViewController.currentViewObj.getSelectedAddon(); contextMenu.setAttribute("addontype", addon.type); @@ -535,39 +441,15 @@ var gEventManager = { menuSep.hidden = (countMenuItemsBeforeSep == 0); }, false); - - let addonTooltip = document.getElementById("addonitem-tooltip"); - addonTooltip.addEventListener("popupshowing", function() { - let addonItem = addonTooltip.triggerNode; - // The way the test triggers the tooltip the richlistitem is the - // tooltipNode but in normal use it is the anonymous node. This allows - // any case - if (addonItem.localName != "richlistitem") - addonItem = document.getBindingParent(addonItem); - - let tiptext = addonItem.getAttribute("name"); - - if (addonItem.mAddon) { - if (shouldShowVersionNumber(addonItem.mAddon)) { - tiptext += " " + (addonItem.hasAttribute("upgrade") ? addonItem.mManualUpdate.version - : addonItem.mAddon.version); - } - } - else if (shouldShowVersionNumber(addonItem.mInstall)) { - tiptext += " " + addonItem.mInstall.version; - } - - addonTooltip.label = tiptext; - }, false); }, - shutdown: function() { + shutdown: function gEM_shutdown() { AddonManager.removeManagerListener(this); AddonManager.removeInstallListener(this); AddonManager.removeAddonListener(this); }, - registerAddonListener: function(aListener, aAddonId) { + registerAddonListener: function gEM_registerAddonListener(aListener, aAddonId) { if (!(aAddonId in this._listeners)) this._listeners[aAddonId] = []; else if (this._listeners[aAddonId].indexOf(aListener) != -1) @@ -575,7 +457,7 @@ var gEventManager = { this._listeners[aAddonId].push(aListener); }, - unregisterAddonListener: function(aListener, aAddonId) { + unregisterAddonListener: function gEM_unregisterAddonListener(aListener, aAddonId) { if (!(aAddonId in this._listeners)) return; var index = this._listeners[aAddonId].indexOf(aListener); @@ -584,20 +466,20 @@ var gEventManager = { this._listeners[aAddonId].splice(index, 1); }, - registerInstallListener: function(aListener) { + registerInstallListener: function gEM_registerInstallListener(aListener) { if (this._installListeners.indexOf(aListener) != -1) return; this._installListeners.push(aListener); }, - unregisterInstallListener: function(aListener) { + unregisterInstallListener: function gEM_unregisterInstallListener(aListener) { var i = this._installListeners.indexOf(aListener); if (i == -1) return; this._installListeners.splice(i, 1); }, - delegateAddonEvent: function(aEvent, aParams) { + delegateAddonEvent: function gEM_delegateAddonEvent(aEvent, aParams) { var addon = aParams.shift(); if (!(addon.id in this._listeners)) return; @@ -608,14 +490,14 @@ var gEventManager = { continue; try { listener[aEvent].apply(listener, aParams); - } catch (e) { + } catch(e) { // this shouldn't be fatal Cu.reportError(e); } } }, - delegateInstallEvent: function(aEvent, aParams) { + delegateInstallEvent: function gEM_delegateInstallEvent(aEvent, aParams) { var existingAddon = aEvent == "onExternalInstall" ? aParams[1] : aParams[0].existingAddon; // If the install is an update then send the event to all listeners // registered for the existing add-on @@ -627,14 +509,14 @@ var gEventManager = { continue; try { listener[aEvent].apply(listener, aParams); - } catch (e) { + } catch(e) { // this shouldn't be fatal Cu.reportError(e); } } }, - refreshGlobalWarning: function() { + refreshGlobalWarning: function gEM_refreshGlobalWarning() { var page = document.getElementById("addons-page"); if (Services.appinfo.inSafeMode) { @@ -656,7 +538,7 @@ var gEventManager = { page.removeAttribute("warning"); }, - refreshAutoUpdateDefault: function() { + refreshAutoUpdateDefault: function gEM_refreshAutoUpdateDefault() { var updateEnabled = AddonManager.updateEnabled; var autoUpdateDefault = AddonManager.autoUpdateDefault; @@ -669,15 +551,15 @@ var gEventManager = { document.getElementById("utils-resetAddonUpdatesToManual").hidden = autoUpdateDefault; }, - onCompatibilityModeChanged: function() { + onCompatibilityModeChanged: function gEM_onCompatibilityModeChanged() { this.refreshGlobalWarning(); }, - onCheckUpdateSecurityChanged: function() { + onCheckUpdateSecurityChanged: function gEM_onCheckUpdateSecurityChanged() { this.refreshGlobalWarning(); }, - onUpdateModeChanged: function() { + onUpdateModeChanged: function gEM_onUpdateModeChanged() { this.refreshAutoUpdateDefault(); } }; @@ -693,10 +575,8 @@ var gViewController = { initialViewSelected: false, lastHistoryIndex: -1, - initialize: function() { + initialize: function gVC_initialize() { this.viewPort = document.getElementById("view-port"); - this.headeredViews = document.getElementById("headered-views"); - this.headeredViewsDeck = document.getElementById("headered-views-content"); this.viewObjects["search"] = gSearchView; this.viewObjects["discover"] = gDiscoverView; @@ -704,30 +584,28 @@ var gViewController = { this.viewObjects["detail"] = gDetailView; this.viewObjects["updates"] = gUpdatesView; - for (let type in this.viewObjects) { - let view = this.viewObjects[type]; + for each (let view in this.viewObjects) view.initialize(); - } window.controllers.appendController(this); - window.addEventListener("popstate", function(e) { + window.addEventListener("popstate", + function window_onStatePopped(e) { gViewController.updateState(e.state); }, false); }, - shutdown: function() { + shutdown: function gVC_shutdown() { if (this.currentViewObj) this.currentViewObj.hide(); this.currentViewRequest = 0; - for (let type in this.viewObjects) { - let view = this.viewObjects[type]; + for each(let view in this.viewObjects) { if ("shutdown" in view) { try { view.shutdown(); - } catch (e) { + } catch(e) { // this shouldn't be fatal Cu.reportError(e); } @@ -737,7 +615,7 @@ var gViewController = { window.controllers.removeController(this); }, - updateState: function(state) { + updateState: function gVC_updateState(state) { try { this.loadViewInternal(state.view, state.previousView, state); this.lastHistoryIndex = gHistory.index; @@ -749,17 +627,18 @@ var gViewController = { gHistory.back(); else gViewController.replaceView(gViewDefault); - } else if (gHistory.canGoForward) { - gHistory.forward(); } else { - gViewController.replaceView(gViewDefault); + if (gHistory.canGoForward) + gHistory.forward(); + else + gViewController.replaceView(gViewDefault); } } }, - parseViewId: function(aViewId) { + parseViewId: function gVC_parseViewId(aViewId) { var matchRegex = /^addons:\/\/([^\/]+)\/(.*)$/; - var [, viewType, viewParam] = aViewId.match(matchRegex) || []; + var [,viewType, viewParam] = aViewId.match(matchRegex) || []; return {type: viewType, param: decodeURIComponent(viewParam)}; }, @@ -767,7 +646,7 @@ var gViewController = { return !this.currentViewObj || this.currentViewObj.node.hasAttribute("loading"); }, - loadView: function(aViewId) { + loadView: function gVC_loadView(aViewId) { var isRefresh = false; if (aViewId == this.currentViewId) { if (this.isLoading) @@ -792,7 +671,7 @@ var gViewController = { // Replaces the existing view with a new one, rewriting the current history // entry to match. - replaceView: function(aViewId) { + replaceView: function gVC_replaceView(aViewId) { if (aViewId == this.currentViewId) return; @@ -804,7 +683,7 @@ var gViewController = { this.loadViewInternal(aViewId, null, state); }, - loadInitialView: function(aViewId) { + loadInitialView: function gVC_loadInitialView(aViewId) { var state = { view: aViewId, previousView: null @@ -816,24 +695,7 @@ var gViewController = { notifyInitialized(); }, - get displayedView() { - if (this.viewPort.selectedPanel == this.headeredViews) { - return this.headeredViewsDeck.selectedPanel; - } - return this.viewPort.selectedPanel; - }, - - set displayedView(view) { - let node = view.node; - if (node.parentNode == this.headeredViewsDeck) { - this.headeredViewsDeck.selectedPanel = node; - this.viewPort.selectedPanel = this.headeredViews; - } else { - this.viewPort.selectedPanel = node; - } - }, - - loadViewInternal: function(aViewId, aPreviousView, aState) { + loadViewInternal: function gVC_loadViewInternal(aViewId, aPreviousView, aState) { var view = this.parseViewId(aViewId); if (!view.type || !(view.type in this.viewObjects)) @@ -848,7 +710,7 @@ var gViewController = { let canHide = this.currentViewObj.hide(); if (canHide === false) return; - this.displayedView.removeAttribute("loading"); + this.viewPort.selectedPanel.removeAttribute("loading"); } catch (e) { // this shouldn't be fatal Cu.reportError(e); @@ -860,8 +722,8 @@ var gViewController = { this.currentViewId = aViewId; this.currentViewObj = viewObj; - this.displayedView = this.currentViewObj; - this.currentViewObj.node.setAttribute("loading", "true"); + this.viewPort.selectedPanel = this.currentViewObj.node; + this.viewPort.selectedPanel.setAttribute("loading", "true"); this.currentViewObj.node.focus(); if (aViewId == aPreviousView) @@ -871,13 +733,13 @@ var gViewController = { }, // Moves back in the document history and removes the current history entry - popState: function(aCallback) { + popState: function gVC_popState(aCallback) { this.viewChangeCallback = aCallback; gHistory.popState(); }, - notifyViewChanged: function() { - this.displayedView.removeAttribute("loading"); + notifyViewChanged: function gVC_notifyViewChanged() { + this.viewPort.selectedPanel.removeAttribute("loading"); if (this.viewChangeCallback) { this.viewChangeCallback(); @@ -891,35 +753,33 @@ var gViewController = { commands: { cmd_back: { - isEnabled: function() { + isEnabled: function cmd_back_isEnabled() { return gHistory.canGoBack; }, - doCommand: function() { + doCommand: function cmd_back_doCommand() { gHistory.back(); } }, cmd_forward: { - isEnabled: function() { + isEnabled: function cmd_forward_isEnabled() { return gHistory.canGoForward; }, - doCommand: function() { + doCommand: function cmd_forward_doCommand() { gHistory.forward(); } }, cmd_focusSearch: { isEnabled: () => true, - doCommand: function() { + doCommand: function cmd_focusSearch_doCommand() { gHeader.focusSearchBox(); } }, cmd_restartApp: { - isEnabled: function() { - return true; - }, - doCommand: function() { + isEnabled: function cmd_restartApp_isEnabled() true, + doCommand: function cmd_restartApp_doCommand() { let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]. createInstance(Ci.nsISupportsPRBool); Services.obs.notifyObservers(cancelQuit, "quit-application-requested", @@ -934,28 +794,31 @@ var gViewController = { }, cmd_enableCheckCompatibility: { - isEnabled: function() { - return true; - }, - doCommand: function() { + isEnabled: function cmd_enableCheckCompatibility_isEnabled() true, + doCommand: function cmd_enableCheckCompatibility_doCommand() { AddonManager.checkCompatibility = true; } }, cmd_enableUpdateSecurity: { - isEnabled: function() { - return true; - }, - doCommand: function() { + isEnabled: function cmd_enableUpdateSecurity_isEnabled() true, + doCommand: function cmd_enableUpdateSecurity_doCommand() { AddonManager.checkUpdateSecurity = true; } }, +/* Plugincheck service is currently N/A for Pale Moon + cmd_pluginCheck: { + isEnabled: function cmd_pluginCheck_isEnabled() true, + doCommand: function cmd_pluginCheck_doCommand() { + openURL(Services.urlFormatter.formatURLPref("plugins.update.url")); + } + }, +*/ + cmd_toggleAutoUpdateDefault: { - isEnabled: function() { - return true; - }, - doCommand: function() { + isEnabled: function cmd_toggleAutoUpdateDefault_isEnabled() true, + doCommand: function cmd_toggleAutoUpdateDefault_doCommand() { if (!AddonManager.updateEnabled || !AddonManager.autoUpdateDefault) { // One or both of the prefs is false, i.e. the checkbox is not checked. // Now toggle both to true. If the user wants us to auto-update @@ -971,11 +834,9 @@ var gViewController = { }, cmd_resetAddonAutoUpdate: { - isEnabled: function() { - return true; - }, - doCommand: function() { - AddonManager.getAllAddons(function(aAddonList) { + isEnabled: function cmd_resetAddonAutoUpdate_isEnabled() true, + doCommand: function cmd_resetAddonAutoUpdate_doCommand() { + AddonManager.getAllAddons(function cmd_resetAddonAutoUpdate_getAllAddons(aAddonList) { for (let addon of aAddonList) { if ("applyBackgroundUpdates" in addon) addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT; @@ -985,37 +846,33 @@ var gViewController = { }, cmd_goToDiscoverPane: { - isEnabled: function() { + isEnabled: function cmd_goToDiscoverPane_isEnabled() { return gDiscoverView.enabled; }, - doCommand: function() { + doCommand: function cmd_goToDiscoverPane_doCommand() { gViewController.loadView("addons://discover/"); } }, cmd_goToRecentUpdates: { - isEnabled: function() { - return true; - }, - doCommand: function() { + isEnabled: function cmd_goToRecentUpdates_isEnabled() true, + doCommand: function cmd_goToRecentUpdates_doCommand() { gViewController.loadView("addons://updates/recent"); } }, cmd_goToAvailableUpdates: { - isEnabled: function() { - return true; - }, - doCommand: function() { + isEnabled: function cmd_goToAvailableUpdates_isEnabled() true, + doCommand: function cmd_goToAvailableUpdates_doCommand() { gViewController.loadView("addons://updates/available"); } }, cmd_showItemDetails: { - isEnabled: function(aAddon) { + isEnabled: function cmd_showItemDetails_isEnabled(aAddon) { return !!aAddon && (gViewController.currentViewObj != gDetailView); }, - doCommand: function(aAddon, aScrollToPreferences) { + doCommand: function cmd_showItemDetails_doCommand(aAddon, aScrollToPreferences) { gViewController.loadView("addons://detail/" + encodeURIComponent(aAddon.id) + (aScrollToPreferences ? "/preferences" : "")); @@ -1024,10 +881,8 @@ var gViewController = { cmd_findAllUpdates: { inProgress: false, - isEnabled: function() { - return !this.inProgress; - }, - doCommand: function() { + isEnabled: function cmd_findAllUpdates_isEnabled() !this.inProgress, + doCommand: function cmd_findAllUpdates_doCommand() { this.inProgress = true; gViewController.updateCommand("cmd_findAllUpdates"); document.getElementById("updates-noneFound").hidden = true; @@ -1038,12 +893,13 @@ var gViewController = { var numUpdated = 0; var numManualUpdates = 0; var restartNeeded = false; + var self = this; - let updateStatus = () => { + function updateStatus() { if (pendingChecks > 0) return; - this.inProgress = false; + self.inProgress = false; gViewController.updateCommand("cmd_findAllUpdates"); document.getElementById("updates-progress").hidden = true; gUpdatesView.maybeRefresh(); @@ -1067,15 +923,15 @@ var gViewController = { } var updateInstallListener = { - onDownloadFailed: function() { + onDownloadFailed: function cmd_findAllUpdates_downloadFailed() { pendingChecks--; updateStatus(); }, - onInstallFailed: function() { + onInstallFailed: function cmd_findAllUpdates_installFailed() { pendingChecks--; updateStatus(); }, - onInstallEnded: function(aInstall, aAddon) { + onInstallEnded: function cmd_findAllUpdates_installEnded(aInstall, aAddon) { pendingChecks--; numUpdated++; if (isPending(aInstall.existingAddon, "upgrade")) @@ -1085,7 +941,7 @@ var gViewController = { }; var updateCheckListener = { - onUpdateAvailable: function(aAddon, aInstall) { + onUpdateAvailable: function cmd_findAllUpdates_updateAvailable(aAddon, aInstall) { gEventManager.delegateAddonEvent("onUpdateAvailable", [aAddon, aInstall]); if (AddonManager.shouldAutoUpdate(aAddon)) { @@ -1097,17 +953,17 @@ var gViewController = { updateStatus(); } }, - onNoUpdateAvailable: function(aAddon) { + onNoUpdateAvailable: function cmd_findAllUpdates_noUpdateAvailable(aAddon) { pendingChecks--; updateStatus(); }, - onUpdateFinished: function(aAddon, aError) { + onUpdateFinished: function cmd_findAllUpdates_updateFinished(aAddon, aError) { gEventManager.delegateAddonEvent("onUpdateFinished", [aAddon, aError]); } }; - AddonManager.getAddonsByTypes(null, function(aAddonList) { + AddonManager.getAddonsByTypes(null, function cmd_findAllUpdates_getAddonsByTypes(aAddonList) { for (let addon of aAddonList) { if (addon.permissions & AddonManager.PERM_CAN_UPGRADE) { pendingChecks++; @@ -1123,20 +979,20 @@ var gViewController = { }, cmd_findItemUpdates: { - isEnabled: function(aAddon) { + isEnabled: function cmd_findItemUpdates_isEnabled(aAddon) { if (!aAddon) return false; return hasPermission(aAddon, "upgrade"); }, - doCommand: function(aAddon) { + doCommand: function cmd_findItemUpdates_doCommand(aAddon) { var listener = { - onUpdateAvailable: function(aAddon, aInstall) { + onUpdateAvailable: function cmd_findItemUpdates_updateAvailable(aAddon, aInstall) { gEventManager.delegateAddonEvent("onUpdateAvailable", [aAddon, aInstall]); if (AddonManager.shouldAutoUpdate(aAddon)) aInstall.install(); }, - onNoUpdateAvailable: function(aAddon) { + onNoUpdateAvailable: function cmd_findItemUpdates_noUpdateAvailable(aAddon) { gEventManager.delegateAddonEvent("onNoUpdateAvailable", [aAddon]); } @@ -1146,24 +1002,37 @@ var gViewController = { } }, + cmd_debugItem: { + doCommand: function cmd_debugItem_doCommand(aAddon) { + BrowserToolboxProcess.init({ addonID: aAddon.id }); + }, + + isEnabled: function cmd_debugItem_isEnabled(aAddon) { + let debuggerEnabled = Services.prefs. + getBoolPref(PREF_ADDON_DEBUGGING_ENABLED); + let remoteEnabled = Services.prefs. + getBoolPref(PREF_REMOTE_DEBUGGING_ENABLED); + return aAddon && aAddon.isDebuggable && debuggerEnabled && remoteEnabled; + } + }, + cmd_showItemPreferences: { - isEnabled: function(aAddon) { + isEnabled: function cmd_showItemPreferences_isEnabled(aAddon) { if (!aAddon || (!aAddon.isActive && !aAddon.isGMPlugin) || !aAddon.optionsURL) { return false; } if (gViewController.currentViewObj == gDetailView && - (aAddon.optionsType == AddonManager.OPTIONS_TYPE_INLINE || - aAddon.optionsType == AddonManager.OPTIONS_TYPE_INLINE_BROWSER)) { + aAddon.optionsType == AddonManager.OPTIONS_TYPE_INLINE) { return false; } if (aAddon.optionsType == AddonManager.OPTIONS_TYPE_INLINE_INFO) return false; return true; }, - doCommand: function(aAddon) { - if (hasInlineOptions(aAddon)) { + doCommand: function cmd_showItemPreferences_doCommand(aAddon) { + if (aAddon.optionsType == AddonManager.OPTIONS_TYPE_INLINE) { gViewController.commands.cmd_showItemDetails.doCommand(aAddon, true); return; } @@ -1195,11 +1064,11 @@ var gViewController = { }, cmd_showItemAbout: { - isEnabled: function(aAddon) { + isEnabled: function cmd_showItemAbout_isEnabled(aAddon) { // XXXunf This may be applicable to install items too. See bug 561260 return !!aAddon; }, - doCommand: function(aAddon) { + doCommand: function cmd_showItemAbout_doCommand(aAddon) { var aboutURL = aAddon.aboutURL; if (aboutURL) openDialog(aboutURL, "", "chrome,centerscreen,modal", aAddon); @@ -1210,17 +1079,17 @@ var gViewController = { }, cmd_enableItem: { - isEnabled: function(aAddon) { + isEnabled: function cmd_enableItem_isEnabled(aAddon) { if (!aAddon) return false; let addonType = AddonManager.addonTypes[aAddon.type]; return (!(addonType.flags & AddonManager.TYPE_SUPPORTS_ASK_TO_ACTIVATE) && hasPermission(aAddon, "enable")); }, - doCommand: function(aAddon) { + doCommand: function cmd_enableItem_doCommand(aAddon) { aAddon.userDisabled = false; }, - getTooltip: function(aAddon) { + getTooltip: function cmd_enableItem_getTooltip(aAddon) { if (!aAddon) return ""; if (aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_ENABLE) @@ -1230,17 +1099,17 @@ var gViewController = { }, cmd_disableItem: { - isEnabled: function(aAddon) { + isEnabled: function cmd_disableItem_isEnabled(aAddon) { if (!aAddon) return false; let addonType = AddonManager.addonTypes[aAddon.type]; return (!(addonType.flags & AddonManager.TYPE_SUPPORTS_ASK_TO_ACTIVATE) && hasPermission(aAddon, "disable")); }, - doCommand: function(aAddon) { + doCommand: function cmd_disableItem_doCommand(aAddon) { aAddon.userDisabled = true; }, - getTooltip: function(aAddon) { + getTooltip: function cmd_disableItem_getTooltip(aAddon) { if (!aAddon) return ""; if (aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_DISABLE) @@ -1250,12 +1119,12 @@ var gViewController = { }, cmd_installItem: { - isEnabled: function(aAddon) { + isEnabled: function cmd_installItem_isEnabled(aAddon) { if (!aAddon) return false; return aAddon.install && aAddon.install.state == AddonManager.STATE_AVAILABLE; }, - doCommand: function(aAddon) { + doCommand: function cmd_installItem_doCommand(aAddon) { function doInstall() { gViewController.currentViewObj.getListItemForID(aAddon.id)._installStatus.installRemote(); } @@ -1268,33 +1137,33 @@ var gViewController = { }, cmd_purchaseItem: { - isEnabled: function(aAddon) { + isEnabled: function cmd_purchaseItem_isEnabled(aAddon) { if (!aAddon) return false; return !!aAddon.purchaseURL; }, - doCommand: function(aAddon) { + doCommand: function cmd_purchaseItem_doCommand(aAddon) { openURL(aAddon.purchaseURL); } }, cmd_uninstallItem: { - isEnabled: function(aAddon) { + isEnabled: function cmd_uninstallItem_isEnabled(aAddon) { if (!aAddon) return false; return hasPermission(aAddon, "uninstall"); }, - doCommand: function(aAddon) { + doCommand: function cmd_uninstallItem_doCommand(aAddon) { if (gViewController.currentViewObj != gDetailView) { aAddon.uninstall(); return; } - gViewController.popState(function() { + gViewController.popState(function cmd_uninstallItem_popState() { gViewController.currentViewObj.getListItemForID(aAddon.id).uninstall(); }); }, - getTooltip: function(aAddon) { + getTooltip: function cmd_uninstallItem_getTooltip(aAddon) { if (!aAddon) return ""; if (aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL) @@ -1304,21 +1173,19 @@ var gViewController = { }, cmd_cancelUninstallItem: { - isEnabled: function(aAddon) { + isEnabled: function cmd_cancelUninstallItem_isEnabled(aAddon) { if (!aAddon) return false; return isPending(aAddon, "uninstall"); }, - doCommand: function(aAddon) { + doCommand: function cmd_cancelUninstallItem_doCommand(aAddon) { aAddon.cancelUninstall(); } }, cmd_installFromFile: { - isEnabled: function() { - return true; - }, - doCommand: function() { + isEnabled: function cmd_installFromFile_isEnabled() true, + doCommand: function cmd_installFromFile_doCommand() { const nsIFilePicker = Ci.nsIFilePicker; var fp = Cc["@mozilla.org/filepicker;1"] .createInstance(nsIFilePicker); @@ -1345,13 +1212,13 @@ var gViewController = { getService(Ci.amIWebInstallListener); webInstaller.onWebInstallRequested(getBrowserElement(), document.documentURIObject, - installs); + installs, installs.length); } return; } var file = files.getNext(); - AddonManager.getInstallForFile(file, function(aInstall) { + AddonManager.getInstallForFile(file, function cmd_installFromFile_getInstallForFile(aInstall) { installs.push(aInstall); buildNextInstall(); }); @@ -1361,25 +1228,13 @@ var gViewController = { } }, - cmd_debugAddons: { - isEnabled: function() { - return true; - }, - doCommand: function() { - let mainWindow = getMainWindow(); - if ("switchToTabHavingURI" in mainWindow) { - mainWindow.switchToTabHavingURI("about:debugging#addons", true); - } - }, - }, - cmd_cancelOperation: { - isEnabled: function(aAddon) { + isEnabled: function cmd_cancelOperation_isEnabled(aAddon) { if (!aAddon) return false; return aAddon.pendingOperations != AddonManager.PENDING_NONE; }, - doCommand: function(aAddon) { + doCommand: function cmd_cancelOperation_doCommand(aAddon) { if (isPending(aAddon, "install")) { aAddon.install.cancel(); } else if (isPending(aAddon, "upgrade")) { @@ -1395,107 +1250,68 @@ var gViewController = { }, cmd_contribute: { - isEnabled: function(aAddon) { + isEnabled: function cmd_contribute_isEnabled(aAddon) { if (!aAddon) return false; return ("contributionURL" in aAddon && aAddon.contributionURL); }, - doCommand: function(aAddon) { + doCommand: function cmd_contribute_doCommand(aAddon) { openURL(aAddon.contributionURL); } }, cmd_askToActivateItem: { - isEnabled: function(aAddon) { + isEnabled: function cmd_askToActivateItem_isEnabled(aAddon) { if (!aAddon) return false; let addonType = AddonManager.addonTypes[aAddon.type]; return ((addonType.flags & AddonManager.TYPE_SUPPORTS_ASK_TO_ACTIVATE) && hasPermission(aAddon, "ask_to_activate")); }, - doCommand: function(aAddon) { + doCommand: function cmd_askToActivateItem_doCommand(aAddon) { aAddon.userDisabled = AddonManager.STATE_ASK_TO_ACTIVATE; } }, cmd_alwaysActivateItem: { - isEnabled: function(aAddon) { + isEnabled: function cmd_alwaysActivateItem_isEnabled(aAddon) { if (!aAddon) return false; let addonType = AddonManager.addonTypes[aAddon.type]; return ((addonType.flags & AddonManager.TYPE_SUPPORTS_ASK_TO_ACTIVATE) && hasPermission(aAddon, "enable")); }, - doCommand: function(aAddon) { + doCommand: function cmd_alwaysActivateItem_doCommand(aAddon) { aAddon.userDisabled = false; } }, cmd_neverActivateItem: { - isEnabled: function(aAddon) { + isEnabled: function cmd_neverActivateItem_isEnabled(aAddon) { if (!aAddon) return false; let addonType = AddonManager.addonTypes[aAddon.type]; return ((addonType.flags & AddonManager.TYPE_SUPPORTS_ASK_TO_ACTIVATE) && hasPermission(aAddon, "disable")); }, - doCommand: function(aAddon) { + doCommand: function cmd_neverActivateItem_doCommand(aAddon) { aAddon.userDisabled = true; } - }, - - cmd_experimentsLearnMore: { - isEnabled: function() { - let mainWindow = getMainWindow(); - return mainWindow && "switchToTabHavingURI" in mainWindow; - }, - doCommand: function() { - let url = Services.prefs.getCharPref("toolkit.telemetry.infoURL"); - openOptionsInTab(url); - }, - }, - - cmd_experimentsOpenTelemetryPreferences: { - isEnabled: function() { - return !!getMainWindowWithPreferencesPane(); - }, - doCommand: function() { - let mainWindow = getMainWindowWithPreferencesPane(); - mainWindow.openAdvancedPreferences("dataChoicesTab"); - }, - }, - - cmd_showUnsignedExtensions: { - isEnabled: function() { - return true; - }, - doCommand: function() { - gViewController.loadView("addons://list/extension?unsigned=true"); - }, - }, - - cmd_showAllExtensions: { - isEnabled: function() { - return true; - }, - doCommand: function() { - gViewController.loadView("addons://list/extension"); - }, - }, + } }, - supportsCommand: function(aCommand) { + supportsCommand: function gVC_supportsCommand(aCommand) { return (aCommand in this.commands); }, - isCommandEnabled: function(aCommand) { + isCommandEnabled: function gVC_isCommandEnabled(aCommand) { if (!this.supportsCommand(aCommand)) return false; var addon = this.currentViewObj.getSelectedAddon(); return this.commands[aCommand].isEnabled(addon); }, - updateCommands: function() { + updateCommands: function gVC_updateCommands() { // wait until the view is initialized if (!this.currentViewObj) return; @@ -1504,7 +1320,7 @@ var gViewController = { this.updateCommand(commandId, addon); }, - updateCommand: function(aCommandId, aAddon) { + updateCommand: function gVC_updateCommand(aCommandId, aAddon) { if (typeof aAddon == "undefined") aAddon = this.currentViewObj.getSelectedAddon(); var cmd = this.commands[aCommandId]; @@ -1519,7 +1335,7 @@ var gViewController = { } }, - doCommand: function(aCommand, aAddon) { + doCommand: function gVC_doCommand(aCommand, aAddon) { if (!this.supportsCommand(aCommand)) return; var cmd = this.commands[aCommand]; @@ -1530,12 +1346,11 @@ var gViewController = { cmd.doCommand(aAddon); }, - onEvent: function() {} + onEvent: function gVC_onEvent() {} }; function hasInlineOptions(aAddon) { return (aAddon.optionsType == AddonManager.OPTIONS_TYPE_INLINE || - aAddon.optionsType == AddonManager.OPTIONS_TYPE_INLINE_BROWSER || aAddon.optionsType == AddonManager.OPTIONS_TYPE_INLINE_INFO); } @@ -1549,11 +1364,14 @@ function openOptionsInTab(optionsURL) { } function formatDate(aDate) { - const locale = Cc["@mozilla.org/chrome/chrome-registry;1"] - .getService(Ci.nsIXULChromeRegistry) - .getSelectedLocale("global", true); - const dtOptions = { year: 'numeric', month: 'long', day: 'numeric' }; - return aDate.toLocaleDateString(locale, dtOptions); + return Cc["@mozilla.org/intl/scriptabledateformat;1"] + .getService(Ci.nsIScriptableDateFormat) + .FormatDate("", + Ci.nsIScriptableDateFormat.dateFormatLong, + aDate.getFullYear(), + aDate.getMonth() + 1, + aDate.getDate() + ); } @@ -1577,10 +1395,6 @@ function shouldShowVersionNumber(aAddon) { if (!aAddon.version) return false; - // The version number is hidden for experiments. - if (aAddon.type == "experiment") - return false; - // The version number is hidden for lightweight themes. if (aAddon.type == "theme") return !/@personas\.mozilla\.org$/.test(aAddon.id); @@ -1614,10 +1428,6 @@ function createItem(aObj, aIsInstall, aIsRemote) { // the binding handles the rest item.setAttribute("value", aObj.id); - if (aObj.type == "experiment") { - item.endDate = getExperimentEndDate(aObj); - } - return item; } @@ -1702,7 +1512,8 @@ function sortElements(aElements, aSortBy, aAscending) { if (addonType && (addonType.flags & AddonManager.TYPE_SUPPORTS_ASK_TO_ACTIVATE) && addon.userDisabled == AddonManager.STATE_ASK_TO_ACTIVATE) return "askToActivate"; - return "enabled"; + else + return "enabled"; } return addon[aKey]; @@ -1726,7 +1537,7 @@ function sortElements(aElements, aSortBy, aAscending) { } - aElements.sort(function(a, b) { + aElements.sort(function elementsSort(a, b) { if (!aAscending) [a, b] = [b, a]; @@ -1771,15 +1582,15 @@ function getAddonsAndInstalls(aType, aCallback) { let addons = null, installs = null; let types = (aType != null) ? [aType] : null; - AddonManager.getAddonsByTypes(types, function(aAddonsList) { - addons = aAddonsList.filter(a => !a.hidden); + AddonManager.getAddonsByTypes(types, function getAddonsAndInstalls_getAddonsByTypes(aAddonsList) { + addons = aAddonsList; if (installs != null) aCallback(addons, installs); }); - AddonManager.getInstallsByTypes(types, function(aInstallsList) { + AddonManager.getInstallsByTypes(types, function getAddonsAndInstalls_getInstallsByTypes(aInstallsList) { // skip over upgrade installs and non-active installs - installs = aInstallsList.filter(function(aInstall) { + installs = aInstallsList.filter(function installsFilter(aInstall) { return !(aInstall.existingAddon || aInstall.state == AddonManager.STATE_AVAILABLE); }); @@ -1796,7 +1607,7 @@ function doPendingUninstalls(aListBox) { var listitem = aListBox.firstChild; while (listitem) { if (listitem.getAttribute("pending") == "uninstall" && - !(listitem.opRequiresRestart("UNINSTALL"))) + !(listitem.opRequiresRestart("uninstall"))) items.push(listitem.mAddon); listitem = listitem.nextSibling; } @@ -1809,7 +1620,7 @@ var gCategories = { node: null, _search: null, - initialize: function() { + initialize: function gCategories_initialize() { this.node = document.getElementById("categories"); this._search = this.get("addons://search/"); @@ -1829,13 +1640,14 @@ var gCategories = { if (!this.node.selectedItem || this.node.selectedItem == this._search) this.node.value = gViewDefault; - this.node.addEventListener("select", () => { - this.maybeHideSearch(); - gViewController.loadView(this.node.selectedItem.value); + var self = this; + this.node.addEventListener("select", function node_onSelected() { + self.maybeHideSearch(); + gViewController.loadView(self.node.selectedItem.value); }, false); - this.node.addEventListener("click", (aEvent) => { - var selectedItem = this.node.selectedItem; + this.node.addEventListener("click", function node_onClicked(aEvent) { + var selectedItem = self.node.selectedItem; if (aEvent.target.localName == "richlistitem" && aEvent.target == selectedItem) { var viewId = selectedItem.value; @@ -1849,11 +1661,11 @@ var gCategories = { }, false); }, - shutdown: function() { + shutdown: function gCategories_shutdown() { AddonManager.removeTypeListener(this); }, - _insertCategory: function(aId, aName, aView, aPriority, aStartHidden) { + _insertCategory: function gCategories_insertCategory(aId, aName, aView, aPriority, aStartHidden) { // If this category already exists then don't re-add it if (document.getElementById("category-" + aId)) return; @@ -1887,7 +1699,7 @@ var gCategories = { this.node.insertBefore(category, node); }, - _removeCategory: function(aId) { + _removeCategory: function gCategories_removeCategory(aId) { var category = document.getElementById("category-" + aId); if (!category) return; @@ -1899,7 +1711,7 @@ var gCategories = { this.node.removeChild(category); }, - onTypeAdded: function(aType) { + onTypeAdded: function gCategories_onTypeAdded(aType) { // Ignore types that we don't have a view object for if (!(aType.viewType in gViewController.viewObjects)) return; @@ -1917,10 +1729,11 @@ var gCategories = { startHidden = true; } + var self = this; gPendingInitializations++; - getAddonsAndInstalls(aType.id, (aAddonsList, aInstallsList) => { + getAddonsAndInstalls(aType.id, function onTypeAdded_getAddonsAndInstalls(aAddonsList, aInstallsList) { var hidden = (aAddonsList.length == 0 && aInstallsList.length == 0); - var item = this.get(aViewId); + var item = self.get(aViewId); // Don't load view that is becoming hidden if (hidden && aViewId == gViewController.currentViewId) @@ -1935,25 +1748,25 @@ var gCategories = { } gEventManager.registerInstallListener({ - onDownloadStarted: function(aInstall) { + onDownloadStarted: function gCategories_onDownloadStarted(aInstall) { this._maybeShowCategory(aInstall); }, - onInstallStarted: function(aInstall) { + onInstallStarted: function gCategories_onInstallStarted(aInstall) { this._maybeShowCategory(aInstall); }, - onInstallEnded: function(aInstall, aAddon) { + onInstallEnded: function gCategories_onInstallEnded(aInstall, aAddon) { this._maybeShowCategory(aAddon); }, - onExternalInstall: function(aAddon, aExistingAddon, aRequiresRestart) { + onExternalInstall: function gCategories_onExternalInstall(aAddon, aExistingAddon, aRequiresRestart) { this._maybeShowCategory(aAddon); }, - _maybeShowCategory: aAddon => { + _maybeShowCategory: function gCategories_maybeShowCategory(aAddon) { if (aType.id == aAddon.type) { - this.get(aViewId).hidden = false; + self.get(aViewId).hidden = false; Services.prefs.setBoolPref(prefName, false); gEventManager.unregisterInstallListener(this); } @@ -1968,7 +1781,7 @@ var gCategories = { startHidden); }, - onTypeRemoved: function(aType) { + onTypeRemoved: function gCategories_onTypeRemoved(aType) { this._removeCategory(aType.id); }, @@ -1976,13 +1789,12 @@ var gCategories = { return this.node.selectedItem ? this.node.selectedItem.value : null; }, - select: function(aId, aPreviousView) { + select: function gCategories_select(aId, aPreviousView) { var view = gViewController.parseViewId(aId); if (view.type == "detail" && aPreviousView) { aId = aPreviousView; view = gViewController.parseViewId(aPreviousView); } - aId = aId.replace(/\?.*/, ""); Services.prefs.setCharPref(PREF_UI_LASTCATEGORY, aId); @@ -1993,11 +1805,10 @@ var gCategories = { return; } - var item; if (view.type == "search") - item = this._search; + var item = this._search; else - item = this.get(aId); + var item = this.get(aId); if (item) { item.hidden = false; @@ -2011,20 +1822,20 @@ var gCategories = { } }, - get: function(aId) { + get: function gCategories_get(aId) { var items = document.getElementsByAttribute("value", aId); if (items.length) return items[0]; return null; }, - setBadge: function(aId, aCount) { + setBadge: function gCategories_setBadge(aId, aCount) { let item = this.get(aId); if (item) item.badgeCount = aCount; }, - maybeHideSearch: function() { + maybeHideSearch: function gCategories_maybeHideSearch() { var view = gViewController.parseViewId(this.node.selectedItem.value); this._search.disabled = view.type != "search"; } @@ -2035,10 +1846,10 @@ var gHeader = { _search: null, _dest: "", - initialize: function() { + initialize: function gHeader_initialize() { this._search = document.getElementById("header-search"); - this._search.addEventListener("command", function(aEvent) { + this._search.addEventListener("command", function search_onCommand(aEvent) { var query = aEvent.target.value; if (query.length == 0) return; @@ -2052,7 +1863,7 @@ var gHeader = { document.getElementById("forward-btn").hidden = !shouldShow; } - window.addEventListener("focus", function(aEvent) { + window.addEventListener("focus", function window_onFocus(aEvent) { if (aEvent.target == window) updateNavButtonVisibility(); }, false); @@ -2060,15 +1871,27 @@ var gHeader = { updateNavButtonVisibility(); }, - focusSearchBox: function() { + focusSearchBox: function gHeader_focusSearchBox() { this._search.focus(); }, - onKeyPress: function(aEvent) { + onKeyPress: function gHeader_onKeyPress(aEvent) { if (String.fromCharCode(aEvent.charCode) == "/") { this.focusSearchBox(); return; } + + // XXXunf Temporary until bug 371900 is fixed. + let key = document.getElementById("focusSearch").getAttribute("key"); +#ifdef XP_MACOSX + let keyModifier = aEvent.metaKey; +#else + let keyModifier = aEvent.ctrlKey; +#endif + if (String.fromCharCode(aEvent.charCode) == key && keyModifier) { + this.focusSearchBox(); + return; + } }, get shouldShowNavButtons() { @@ -2123,9 +1946,8 @@ var gDiscoverView = { _error: null, homepageURL: null, _loadListeners: [], - hideHeader: true, - initialize: function() { + initialize: function gDiscoverView_initialize() { this.enabled = isDiscoverEnabled(); if (!this.enabled) { gCategories.get("addons://discover/").hidden = true; @@ -2147,20 +1969,22 @@ var gDiscoverView = { url = url.replace("%COMPATIBILITY_MODE%", compatMode); url = Services.urlFormatter.formatURL(url); - let setURL = (aURL) => { + var self = this; + + function setURL(aURL) { try { - this.homepageURL = Services.io.newURI(aURL, null, null); + self.homepageURL = Services.io.newURI(aURL, null, null); } catch (e) { - this.showError(); + self.showError(); notifyInitialized(); return; } - this._browser.homePage = this.homepageURL.spec; - this._browser.addProgressListener(this); + self._browser.homePage = self.homepageURL.spec; + self._browser.addProgressListener(self); - if (this.loaded) - this._loadURL(this.homepageURL.spec, false, notifyInitialized); + if (self.loaded) + self._loadURL(self.homepageURL.spec, false, notifyInitialized); else notifyInitialized(); } @@ -2171,7 +1995,7 @@ var gDiscoverView = { } gPendingInitializations++; - AddonManager.getAllAddons(function(aAddons) { + AddonManager.getAllAddons(function initialize_getAllAddons(aAddons) { var list = {}; for (let addon of aAddons) { var prefName = PREF_GETADDONS_CACHE_ID_ENABLED.replace("%ID%", @@ -2194,7 +2018,7 @@ var gDiscoverView = { }); }, - destroy: function() { + destroy: function gDiscoverView_destroy() { try { this._browser.removeProgressListener(this); } @@ -2203,7 +2027,7 @@ var gDiscoverView = { } }, - show: function(aParam, aRequest, aState, aIsRefresh) { + show: function gDiscoverView_show(aParam, aRequest, aState, aIsRefresh) { gViewController.updateCommands(); // If we're being told to load a specific URL then just do that @@ -2234,24 +2058,24 @@ var gDiscoverView = { gViewController.notifyViewChanged.bind(gViewController)); }, - canRefresh: function() { + canRefresh: function gDiscoverView_canRefresh() { if (this._browser.currentURI && this._browser.currentURI.spec == this._browser.homePage) return false; return true; }, - refresh: function(aParam, aRequest, aState) { + refresh: function gDiscoverView_refresh(aParam, aRequest, aState) { this.show(aParam, aRequest, aState, true); }, - hide: function() { }, + hide: function gDiscoverView_hide() { }, - showError: function() { + showError: function gDiscoverView_showError() { this.node.selectedPanel = this._error; }, - _loadURL: function(aURL, aKeepHistory, aCallback) { + _loadURL: function gDiscoverView_loadURL(aURL, aKeepHistory, aCallback) { if (this._browser.currentURI.spec == aURL) { if (aCallback) aCallback(); @@ -2268,7 +2092,7 @@ var gDiscoverView = { this._browser.loadURIWithFlags(aURL, flags); }, - onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) { + onLocationChange: function gDiscoverView_onLocationChange(aWebProgress, aRequest, aLocation, aFlags) { // Ignore the about:blank load if (aLocation.spec == "about:blank") return; @@ -2306,7 +2130,7 @@ var gDiscoverView = { aRequest.cancel(Components.results.NS_BINDING_ABORTED); }, - onSecurityChange: function(aWebProgress, aRequest, aState) { + onSecurityChange: function gDiscoverView_onSecurityChange(aWebProgress, aRequest, aState) { // Don't care about security if the page is not https if (!this.homepageURL.schemeIs("https")) return; @@ -2320,12 +2144,12 @@ var gDiscoverView = { aRequest.cancel(Components.results.NS_BINDING_ABORTED); }, - onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) { + onStateChange: function gDiscoverView_onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) { let transferStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT | Ci.nsIWebProgressListener.STATE_IS_REQUEST | Ci.nsIWebProgressListener.STATE_TRANSFERRING; // Once transferring begins show the content - if ((aStateFlags & transferStart) === transferStart) + if (aStateFlags & transferStart) this.node.selectedPanel = this._browser; // Only care about the network events @@ -2364,15 +2188,13 @@ var gDiscoverView = { listener(); }, - onProgressChange: function() { }, - onStatusChange: function() { }, + onProgressChange: function gDiscoverView_onProgressChange() { }, + onStatusChange: function gDiscoverView_onStatusChange() { }, QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]), - getSelectedAddon: function() { - return null; - } + getSelectedAddon: function gDiscoverView_getSelectedAddon() null }; @@ -2390,7 +2212,7 @@ var gSearchView = { _lastRemoteTotal: 0, _pendingSearches: 0, - initialize: function() { + initialize: function gSearchView_initialize() { this.node = document.getElementById("search-view"); this._filter = document.getElementById("search-filter-radiogroup"); this._sorters = document.getElementById("search-sorters"); @@ -2403,18 +2225,19 @@ var gSearchView = { if (!AddonManager.isInstallEnabled("application/x-xpinstall")) this._filter.hidden = true; - this._listBox.addEventListener("keydown", aEvent => { + var self = this; + this._listBox.addEventListener("keydown", function listbox_onKeydown(aEvent) { if (aEvent.keyCode == aEvent.DOM_VK_RETURN) { - var item = this._listBox.selectedItem; + var item = self._listBox.selectedItem; if (item) item.showInDetailView(); } }, false); - this._filter.addEventListener("command", () => this.updateView(), false); + this._filter.addEventListener("command", function filter_onCommand() self.updateView(), false); }, - shutdown: function() { + shutdown: function gSearchView_shutdown() { if (AddonRepository.isSearching) AddonRepository.cancelSearch(); }, @@ -2423,7 +2246,7 @@ var gSearchView = { return this._pendingSearches > 0; }, - show: function(aQuery, aRequest) { + show: function gSearchView_show(aQuery, aRequest) { gEventManager.registerInstallListener(this); this.showEmptyNotice(false); @@ -2446,18 +2269,19 @@ var gSearchView = { while (this._listBox.firstChild.localName == "richlistitem") this._listBox.removeChild(this._listBox.firstChild); + var self = this; gCachedAddons = {}; this._pendingSearches = 2; this._sorters.setSort("relevancescore", false); var elements = []; - let createSearchResults = (aObjsList, aIsInstall, aIsRemote) => { + function createSearchResults(aObjsList, aIsInstall, aIsRemote) { for (let index in aObjsList) { let obj = aObjsList[index]; let score = aObjsList.length - index; if (!aIsRemote && aQuery.length > 0) { - score = this.getMatchScore(obj, aQuery); + score = self.getMatchScore(obj, aQuery); if (score == 0) continue; } @@ -2467,29 +2291,29 @@ var gSearchView = { if (aIsRemote) { gCachedAddons[obj.id] = obj; if (obj.purchaseURL) - this._sorters.showprice = true; + self._sorters.showprice = true; } elements.push(item); } } - let finishSearch = (createdCount) => { + function finishSearch(createdCount) { if (elements.length > 0) { - sortElements(elements, [this._sorters.sortBy], this._sorters.ascending); + sortElements(elements, [self._sorters.sortBy], self._sorters.ascending); for (let element of elements) - this._listBox.insertBefore(element, this._listBox.lastChild); - this.updateListAttributes(); + self._listBox.insertBefore(element, self._listBox.lastChild); + self.updateListAttributes(); } - this._pendingSearches--; - this.updateView(); + self._pendingSearches--; + self.updateView(); - if (!this.isSearching) + if (!self.isSearching) gViewController.notifyViewChanged(); } - getAddonsAndInstalls(null, function(aAddons, aInstalls) { + getAddonsAndInstalls(null, function show_getAddonsAndInstalls(aAddons, aInstalls) { if (gViewController && aRequest != gViewController.currentViewRequest) return; @@ -2501,7 +2325,7 @@ var gSearchView = { var maxRemoteResults = 0; try { maxRemoteResults = Services.prefs.getIntPref(PREF_MAXRESULTS); - } catch (e) {} + } catch(e) {} if (maxRemoteResults <= 0) { finishSearch(0); @@ -2509,24 +2333,24 @@ var gSearchView = { } AddonRepository.searchAddons(aQuery, maxRemoteResults, { - searchFailed: () => { + searchFailed: function show_SearchFailed() { if (gViewController && aRequest != gViewController.currentViewRequest) return; - this._lastRemoteTotal = 0; + self._lastRemoteTotal = 0; // XXXunf Better handling of AMO search failure. See bug 579502 finishSearch(0); // Silently fail }, - searchSucceeded: (aAddonsList, aAddonCount, aTotalResults) => { + searchSucceeded: function show_SearchSucceeded(aAddonsList, aAddonCount, aTotalResults) { if (gViewController && aRequest != gViewController.currentViewRequest) return; if (aTotalResults > maxRemoteResults) - this._lastRemoteTotal = aTotalResults; + self._lastRemoteTotal = aTotalResults; else - this._lastRemoteTotal = 0; + self._lastRemoteTotal = 0; var createdCount = createSearchResults(aAddonsList, false, true); finishSearch(createdCount); @@ -2534,12 +2358,12 @@ var gSearchView = { }); }, - showLoading: function(aLoading) { + showLoading: function gSearchView_showLoading(aLoading) { this._loading.hidden = !aLoading; this._listBox.hidden = aLoading; }, - updateView: function() { + updateView: function gSearchView_updateView() { var showLocal = this._filter.value == "local"; if (!showLocal && !AddonManager.isInstallEnabled("application/x-xpinstall")) @@ -2567,12 +2391,12 @@ var gSearchView = { gViewController.updateCommands(); }, - hide: function() { + hide: function gSearchView_hide() { gEventManager.unregisterInstallListener(this); doPendingUninstalls(this._listBox); }, - getMatchScore: function(aObj, aQuery) { + getMatchScore: function gSearchView_getMatchScore(aObj, aQuery) { var score = 0; score += this.calculateMatchScore(aObj.name, aQuery, SEARCH_SCORE_MULTIPLIER_NAME); @@ -2581,7 +2405,7 @@ var gSearchView = { return score; }, - calculateMatchScore: function(aStr, aQuery, aMultiplier) { + calculateMatchScore: function gSearchView_calculateMatchScore(aStr, aQuery, aMultiplier) { var score = 0; if (!aStr || aQuery.length == 0) return score; @@ -2613,12 +2437,12 @@ var gSearchView = { return score * aMultiplier; }, - showEmptyNotice: function(aShow) { + showEmptyNotice: function gSearchView_showEmptyNotice(aShow) { this._emptyNotice.hidden = !aShow; this._listBox.hidden = aShow; }, - showAllResultsLink: function(aTotalResults) { + showAllResultsLink: function gSearchView_showAllResultsLink(aTotalResults) { if (aTotalResults == 0) { this._allResultsLink.hidden = true; return; @@ -2634,7 +2458,7 @@ var gSearchView = { this._allResultsLink.hidden = false; }, - updateListAttributes: function() { + updateListAttributes: function gSearchView_updateListAttributes() { var item = this._listBox.querySelector("richlistitem[remote='true'][first]"); if (item) item.removeAttribute("first"); @@ -2661,7 +2485,7 @@ var gSearchView = { }, - onSortChanged: function(aSortBy, aAscending) { + onSortChanged: function gSearchView_onSortChanged(aSortBy, aAscending) { var footer = this._listBox.lastChild; this._listBox.removeChild(footer); @@ -2671,15 +2495,15 @@ var gSearchView = { this._listBox.appendChild(footer); }, - onDownloadCancelled: function(aInstall) { + onDownloadCancelled: function gSearchView_onDownloadCancelled(aInstall) { this.removeInstall(aInstall); }, - onInstallCancelled: function(aInstall) { + onInstallCancelled: function gSearchView_onInstallCancelled(aInstall) { this.removeInstall(aInstall); }, - removeInstall: function(aInstall) { + removeInstall: function gSearchView_removeInstall(aInstall) { for (let item of this._listBox.childNodes) { if (item.mInstall == aInstall) { this._listBox.removeChild(item); @@ -2688,14 +2512,14 @@ var gSearchView = { } }, - getSelectedAddon: function() { + getSelectedAddon: function gSearchView_getSelectedAddon() { var item = this._listBox.selectedItem; if (item) return item.mAddon; return null; }, - getListItemForID: function(aId) { + getListItemForID: function gSearchView_getListItemForID(aId) { var listitem = this._listBox.firstChild; while (listitem) { if (listitem.getAttribute("status") == "installed" && listitem.mAddon.id == aId) @@ -2713,52 +2537,22 @@ var gListView = { _emptyNotice: null, _type: null, - initialize: function() { + initialize: function gListView_initialize() { this.node = document.getElementById("list-view"); this._listBox = document.getElementById("addon-list"); this._emptyNotice = document.getElementById("addon-list-empty"); - this._listBox.addEventListener("keydown", (aEvent) => { + var self = this; + this._listBox.addEventListener("keydown", function listbox_onKeydown(aEvent) { if (aEvent.keyCode == aEvent.DOM_VK_RETURN) { - var item = this._listBox.selectedItem; + var item = self._listBox.selectedItem; if (item) item.showInDetailView(); } }, false); - - document.getElementById("signing-learn-more").setAttribute("href", - Services.urlFormatter.formatURLPref("app.support.baseURL") + "unsigned-addons"); - - let findSignedAddonsLink = document.getElementById("find-alternative-addons"); - try { - findSignedAddonsLink.setAttribute("href", - Services.urlFormatter.formatURLPref("extensions.getAddons.link.url")); - } catch (e) { - findSignedAddonsLink.classList.remove("text-link"); - } - - try { - document.getElementById("signing-dev-manual-link").setAttribute("href", - Services.prefs.getCharPref("xpinstall.signatures.devInfoURL")); - } catch (e) { - document.getElementById("signing-dev-info").hidden = true; - } - - if (Preferences.get("plugin.load_flash_only", true)) { - document.getElementById("plugindeprecation-learnmore-link") - .setAttribute("href", Services.urlFormatter.formatURLPref("app.support.baseURL") + "npapi"); - } else { - document.getElementById("plugindeprecation-notice").hidden = true; - } }, - show: function(aType, aRequest) { - let showOnlyDisabledUnsigned = false; - if (aType.endsWith("?unsigned=true")) { - aType = aType.replace(/\?.*/, ""); - showOnlyDisabledUnsigned = true; - } - + show: function gListView_show(aType, aRequest) { if (!(aType in AddonManager.addonTypes)) throw Components.Exception("Attempting to show unknown type " + aType, Cr.NS_ERROR_INVALID_ARG); @@ -2773,7 +2567,8 @@ var gListView = { navigator.plugins.refresh(false); } - getAddonsAndInstalls(aType, (aAddonsList, aInstallsList) => { + var self = this; + getAddonsAndInstalls(aType, function show_getAddonsAndInstalls(aAddonsList, aInstallsList) { if (gViewController && aRequest != gViewController.currentViewRequest) return; @@ -2785,96 +2580,64 @@ var gListView = { for (let installItem of aInstallsList) elements.push(createItem(installItem, true)); - this.showEmptyNotice(elements.length == 0); + self.showEmptyNotice(elements.length == 0); if (elements.length > 0) { sortElements(elements, ["uiState", "name"], true); for (let element of elements) - this._listBox.appendChild(element); + self._listBox.appendChild(element); } - this.filterDisabledUnsigned(showOnlyDisabledUnsigned); - - gEventManager.registerInstallListener(this); + gEventManager.registerInstallListener(self); gViewController.updateCommands(); gViewController.notifyViewChanged(); }); }, - hide: function() { + hide: function gListView_hide() { gEventManager.unregisterInstallListener(this); doPendingUninstalls(this._listBox); }, - filterDisabledUnsigned: function(aFilter = true) { - let foundDisabledUnsigned = false; - - if (SIGNING_REQUIRED) { - for (let item of this._listBox.childNodes) { - if (!isCorrectlySigned(item.mAddon)) - foundDisabledUnsigned = true; - else - item.hidden = aFilter; - } - } - - document.getElementById("show-disabled-unsigned-extensions").hidden = - aFilter || !foundDisabledUnsigned; - - document.getElementById("show-all-extensions").hidden = !aFilter; - document.getElementById("disabled-unsigned-addons-info").hidden = !aFilter; - }, - - showEmptyNotice: function(aShow) { + showEmptyNotice: function gListView_showEmptyNotice(aShow) { this._emptyNotice.hidden = !aShow; - this._listBox.hidden = aShow; }, - onSortChanged: function(aSortBy, aAscending) { + onSortChanged: function gListView_onSortChanged(aSortBy, aAscending) { sortList(this._listBox, aSortBy, aAscending); }, - onExternalInstall: function(aAddon, aExistingAddon, aRequiresRestart) { + onExternalInstall: function gListView_onExternalInstall(aAddon, aExistingAddon, aRequiresRestart) { // The existing list item will take care of upgrade installs if (aExistingAddon) return; - if (aAddon.hidden) - return; - this.addItem(aAddon); }, - onDownloadStarted: function(aInstall) { + onDownloadStarted: function gListView_onDownloadStarted(aInstall) { this.addItem(aInstall, true); }, - onInstallStarted: function(aInstall) { + onInstallStarted: function gListView_onInstallStarted(aInstall) { this.addItem(aInstall, true); }, - onDownloadCancelled: function(aInstall) { + onDownloadCancelled: function gListView_onDownloadCancelled(aInstall) { this.removeItem(aInstall, true); }, - onInstallCancelled: function(aInstall) { + onInstallCancelled: function gListView_onInstallCancelled(aInstall) { this.removeItem(aInstall, true); }, - onInstallEnded: function(aInstall) { + onInstallEnded: function gListView_onInstallEnded(aInstall) { // Remove any install entries for upgrades, their status will appear against // the existing item if (aInstall.existingAddon) this.removeItem(aInstall, true); - - if (aInstall.addon.type == "experiment") { - let item = this.getListItemForID(aInstall.addon.id); - if (item) { - item.endDate = getExperimentEndDate(aInstall.addon); - } - } }, - addItem: function(aObj, aIsInstall) { + addItem: function gListView_addItem(aObj, aIsInstall) { if (aObj.type != this._type) return; @@ -2892,7 +2655,7 @@ var gListView = { this.showEmptyNotice(false); }, - removeItem: function(aObj, aIsInstall) { + removeItem: function gListView_removeItem(aObj, aIsInstall) { let prop = aIsInstall ? "mInstall" : "mAddon"; for (let item of this._listBox.childNodes) { @@ -2904,14 +2667,14 @@ var gListView = { } }, - getSelectedAddon: function() { + getSelectedAddon: function gListView_getSelectedAddon() { var item = this._listBox.selectedItem; if (item) return item.mAddon; return null; }, - getListItemForID: function(aId) { + getListItemForID: function gListView_getListItemForID(aId) { var listitem = this._listBox.firstChild; while (listitem) { if (listitem.getAttribute("status") == "installed" && listitem.mAddon.id == aId) @@ -2929,25 +2692,26 @@ var gDetailView = { _loadingTimer: null, _autoUpdate: null, - initialize: function() { + initialize: function gDetailView_initialize() { this.node = document.getElementById("detail-view"); this._autoUpdate = document.getElementById("detail-autoUpdate"); - this._autoUpdate.addEventListener("command", () => { - this._addon.applyBackgroundUpdates = this._autoUpdate.value; + var self = this; + this._autoUpdate.addEventListener("command", function autoUpdate_onCommand() { + self._addon.applyBackgroundUpdates = self._autoUpdate.value; }, true); }, - shutdown: function() { + shutdown: function gDetailView_shutdown() { AddonManager.removeManagerListener(this); }, - onUpdateModeChanged: function() { + onUpdateModeChanged: function gDetailView_onUpdateModeChanged() { this.onPropertyChanged(["applyBackgroundUpdates"]); }, - _updateView: function(aAddon, aIsRemote, aScrollToPreferences) { + _updateView: function gDetailView_updateView(aAddon, aIsRemote, aScrollToPreferences) { AddonManager.addManagerListener(this); this.clearLoading(); @@ -2963,9 +2727,10 @@ var gDetailView = { gCategories.select("addons://list/" + aAddon.type); document.getElementById("detail-name").textContent = aAddon.name; - var icon = AddonManager.getPreferredIconURL(aAddon, 64, window); + var icon = aAddon.icon64URL ? aAddon.icon64URL : aAddon.iconURL; document.getElementById("detail-icon").src = icon ? icon : ""; document.getElementById("detail-creator").setCreator(aAddon.creator, aAddon.homepageURL); + document.getElementById("detail-translators").setTranslators(aAddon.translators, aAddon.type); var version = document.getElementById("detail-version"); if (shouldShowVersionNumber(aAddon)) { @@ -2975,7 +2740,6 @@ var gDetailView = { version.hidden = true; } - var screenshotbox = document.getElementById("detail-screenshot-box"); var screenshot = document.getElementById("detail-screenshot"); if (aAddon.screenshots && aAddon.screenshots.length > 0) { if (aAddon.screenshots[0].thumbnailURL) { @@ -2988,9 +2752,9 @@ var gDetailView = { screenshot.height = aAddon.screenshots[0].height; } screenshot.setAttribute("loading", "true"); - screenshotbox.hidden = false; + screenshot.hidden = false; } else { - screenshotbox.hidden = true; + screenshot.hidden = true; } var desc = document.getElementById("detail-desc"); @@ -3103,7 +2867,7 @@ var gDetailView = { downloadsRow.value = null; } - var canUpdate = !aIsRemote && hasPermission(aAddon, "upgrade") && aAddon.id != AddonManager.hotfixID; + var canUpdate = !aIsRemote && hasPermission(aAddon, "upgrade"); document.getElementById("detail-updates-row").hidden = !canUpdate; if ("applyBackgroundUpdates" in aAddon) { @@ -3130,41 +2894,13 @@ var gDetailView = { } } - if (this._addon.type == "experiment") { - let prefix = "details.experiment."; - let active = this._addon.isActive; - - let stateKey = prefix + "state." + (active ? "active" : "complete"); - let node = document.getElementById("detail-experiment-state"); - node.value = gStrings.ext.GetStringFromName(stateKey); - - let now = Date.now(); - let end = getExperimentEndDate(this._addon); - let days = Math.abs(end - now) / (24 * 60 * 60 * 1000); - - let timeKey = prefix + "time."; - let timeMessage; - if (days < 1) { - timeKey += (active ? "endsToday" : "endedToday"); - timeMessage = gStrings.ext.GetStringFromName(timeKey); - } else { - timeKey += (active ? "daysRemaining" : "daysPassed"); - days = Math.round(days); - let timeString = gStrings.ext.GetStringFromName(timeKey); - timeMessage = PluralForm.get(days, timeString) - .replace("#1", days); - } - - document.getElementById("detail-experiment-time").value = timeMessage; - } - - this.fillSettingsRows(aScrollToPreferences, (function() { + this.fillSettingsRows(aScrollToPreferences, (function updateView_fillSettingsRows() { this.updateState(); gViewController.notifyViewChanged(); }).bind(this)); }, - show: function(aAddonId, aRequest) { + show: function gDetailView_show(aAddonId, aRequest) { let index = aAddonId.indexOf("/preferences"); let scrollToPreferences = false; if (index >= 0) { @@ -3172,33 +2908,34 @@ var gDetailView = { scrollToPreferences = true; } - this._loadingTimer = setTimeout(() => { - this.node.setAttribute("loading-extended", true); + var self = this; + this._loadingTimer = setTimeout(function loadTimeOutTimer() { + self.node.setAttribute("loading-extended", true); }, LOADING_MSG_DELAY); var view = gViewController.currentViewId; - AddonManager.getAddonByID(aAddonId, (aAddon) => { + AddonManager.getAddonByID(aAddonId, function show_getAddonByID(aAddon) { if (gViewController && aRequest != gViewController.currentViewRequest) return; if (aAddon) { - this._updateView(aAddon, false, scrollToPreferences); + self._updateView(aAddon, false, scrollToPreferences); return; } // Look for an add-on pending install - AddonManager.getAllInstalls(aInstalls => { + AddonManager.getAllInstalls(function show_getAllInstalls(aInstalls) { for (let install of aInstalls) { if (install.state == AddonManager.STATE_INSTALLED && install.addon.id == aAddonId) { - this._updateView(install.addon, false); + self._updateView(install.addon, false); return; } } if (aAddonId in gCachedAddons) { - this._updateView(gCachedAddons[aAddonId], true); + self._updateView(gCachedAddons[aAddonId], true); return; } @@ -3210,7 +2947,7 @@ var gDetailView = { }); }, - hide: function() { + hide: function gDetailView_hide() { AddonManager.removeManagerListener(this); this.clearLoading(); if (this._addon) { @@ -3230,14 +2967,14 @@ var gDetailView = { } }, - updateState: function() { + updateState: function gDetailView_updateState() { gViewController.updateCommands(); var pending = this._addon.pendingOperations; if (pending != AddonManager.PENDING_NONE) { this.node.removeAttribute("notification"); - pending = null; + var pending = null; const PENDING_OPERATIONS = ["enable", "disable", "install", "uninstall", "upgrade"]; for (let op of PENDING_OPERATIONS) { @@ -3263,15 +3000,6 @@ var gDetailView = { errorLink.value = gStrings.ext.GetStringFromName("details.notification.blocked.link"); errorLink.href = this._addon.blocklistURL; errorLink.hidden = false; - } else if (!isCorrectlySigned(this._addon) && SIGNING_REQUIRED) { - this.node.setAttribute("notification", "error"); - document.getElementById("detail-error").textContent = gStrings.ext.formatStringFromName( - "details.notification.unsignedAndDisabled", [this._addon.name, gStrings.brandShortName], 2 - ); - let errorLink = document.getElementById("detail-error-link"); - errorLink.value = gStrings.ext.GetStringFromName("details.notification.unsigned.link"); - errorLink.href = Services.urlFormatter.formatURLPref("app.support.baseURL") + "unsigned-addons"; - errorLink.hidden = false; } else if (!this._addon.isCompatible && (AddonManager.checkCompatibility || (this._addon.blocklistState != Ci.nsIBlocklistService.STATE_SOFTBLOCKED))) { this.node.setAttribute("notification", "warning"); @@ -3280,22 +3008,13 @@ var gDetailView = { [this._addon.name, gStrings.brandShortName, gStrings.appVersion], 3 ); document.getElementById("detail-warning-link").hidden = true; - } else if (!isCorrectlySigned(this._addon)) { - this.node.setAttribute("notification", "warning"); - document.getElementById("detail-warning").textContent = gStrings.ext.formatStringFromName( - "details.notification.unsigned", [this._addon.name, gStrings.brandShortName], 2 - ); - var warningLink = document.getElementById("detail-warning-link"); - warningLink.value = gStrings.ext.GetStringFromName("details.notification.unsigned.link"); - warningLink.href = Services.urlFormatter.formatURLPref("app.support.baseURL") + "unsigned-addons"; - warningLink.hidden = false; } else if (this._addon.blocklistState == Ci.nsIBlocklistService.STATE_SOFTBLOCKED) { this.node.setAttribute("notification", "warning"); document.getElementById("detail-warning").textContent = gStrings.ext.formatStringFromName( "details.notification.softblocked", [this._addon.name], 1 ); - let warningLink = document.getElementById("detail-warning-link"); + var warningLink = document.getElementById("detail-warning-link"); warningLink.value = gStrings.ext.GetStringFromName("details.notification.softblocked.link"); warningLink.href = this._addon.blocklistURL; warningLink.hidden = false; @@ -3305,9 +3024,9 @@ var gDetailView = { "details.notification.outdated", [this._addon.name], 1 ); - let warningLink = document.getElementById("detail-warning-link"); + var warningLink = document.getElementById("detail-warning-link"); warningLink.value = gStrings.ext.GetStringFromName("details.notification.outdated.link"); - warningLink.href = this._addon.blocklistURL; + warningLink.href = Services.urlFormatter.formatURLPref("plugins.update.url"); warningLink.hidden = false; } else if (this._addon.blocklistState == Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE) { this.node.setAttribute("notification", "error"); @@ -3315,7 +3034,7 @@ var gDetailView = { "details.notification.vulnerableUpdatable", [this._addon.name], 1 ); - let errorLink = document.getElementById("detail-error-link"); + var errorLink = document.getElementById("detail-error-link"); errorLink.value = gStrings.ext.GetStringFromName("details.notification.vulnerableUpdatable.link"); errorLink.href = this._addon.blocklistURL; errorLink.hidden = false; @@ -3325,7 +3044,7 @@ var gDetailView = { "details.notification.vulnerableNoUpdate", [this._addon.name], 1 ); - let errorLink = document.getElementById("detail-error-link"); + var errorLink = document.getElementById("detail-error-link"); errorLink.value = gStrings.ext.GetStringFromName("details.notification.vulnerableNoUpdate.link"); errorLink.href = this._addon.blocklistURL; errorLink.hidden = false; @@ -3368,7 +3087,7 @@ var gDetailView = { this.node.setAttribute("active", this._addon.isActive); }, - clearLoading: function() { + clearLoading: function gDetailView_clearLoading() { if (this._loadingTimer) { clearTimeout(this._loadingTimer); this._loadingTimer = null; @@ -3377,14 +3096,14 @@ var gDetailView = { this.node.removeAttribute("loading-extended"); }, - emptySettingsRows: function() { + emptySettingsRows: function gDetailView_emptySettingsRows() { var lastRow = document.getElementById("detail-downloads"); var rows = lastRow.parentNode; while (lastRow.nextSibling) rows.removeChild(rows.lastChild); }, - fillSettingsRows: function(aScrollToPreferences, aCallback) { + fillSettingsRows: function gDetailView_fillSettingsRows(aScrollToPreferences, aCallback) { this.emptySettingsRows(); if (!hasInlineOptions(this._addon)) { if (aCallback) @@ -3392,34 +3111,6 @@ var gDetailView = { return; } - // We can't use a promise for this, since some code (especially in tests) - // relies on us finishing before the ViewChanged event bubbles up to its - // listeners, and promises resolve asynchronously. - let whenViewLoaded = callback => { - if (gViewController.displayedView.hasAttribute("loading")) { - gDetailView.node.addEventListener("ViewChanged", function viewChangedEventListener() { - gDetailView.node.removeEventListener("ViewChanged", viewChangedEventListener); - callback(); - }); - } else { - callback(); - } - }; - - let finish = (firstSetting) => { - // Ensure the page has loaded and force the XBL bindings to be synchronously applied, - // then notify observers. - whenViewLoaded(() => { - if (firstSetting) - firstSetting.clientTop; - Services.obs.notifyObservers(document, - AddonManager.OPTIONS_NOTIFICATION_DISPLAYED, - this._addon.id); - if (aScrollToPreferences) - gDetailView.scrollToPreferencesRows(); - }); - } - // This function removes and returns the text content of aNode without // removing any child elements. Removing the text nodes ensures any XBL // bindings apply properly. @@ -3439,77 +3130,79 @@ var gDetailView = { var rows = document.getElementById("detail-downloads").parentNode; try { - if (this._addon.optionsType == AddonManager.OPTIONS_TYPE_INLINE_BROWSER) { - whenViewLoaded(() => { - this.createOptionsBrowser(rows).then(browser => { - // Make sure the browser is unloaded as soon as we change views, - // rather than waiting for the next detail view to load. - document.addEventListener("ViewChanged", function viewChangedEventListener() { - document.removeEventListener("ViewChanged", viewChangedEventListener); - browser.remove(); - }); - - finish(browser); - }); - }); - - if (aCallback) - aCallback(); - } else { - var xhr = new XMLHttpRequest(); - xhr.open("GET", this._addon.optionsURL, true); - xhr.responseType = "xml"; - xhr.onload = (function() { - var xml = xhr.responseXML; - var settings = xml.querySelectorAll(":root > setting"); - - var firstSetting = null; - for (var setting of settings) { - - var desc = stripTextNodes(setting).trim(); - if (!setting.hasAttribute("desc")) - setting.setAttribute("desc", desc); - - var type = setting.getAttribute("type"); - if (type == "file" || type == "directory") - setting.setAttribute("fullpath", "true"); - - setting = document.importNode(setting, true); - var style = setting.getAttribute("style"); - if (style) { - setting.removeAttribute("style"); - setting.setAttribute("style", style); - } - - rows.appendChild(setting); - var visible = window.getComputedStyle(setting, null).getPropertyValue("display") != "none"; - if (!firstSetting && visible) { - setting.setAttribute("first-row", true); - firstSetting = setting; - } + var xhr = new XMLHttpRequest(); + xhr.open("GET", this._addon.optionsURL, true); + xhr.responseType = "xml"; + xhr.onload = (function fillSettingsRows_onload() { + var xml = xhr.responseXML; + var settings = xml.querySelectorAll(":root > setting"); + + var firstSetting = null; + for (var setting of settings) { + + var desc = stripTextNodes(setting).trim(); + if (!setting.hasAttribute("desc")) + setting.setAttribute("desc", desc); + + var type = setting.getAttribute("type"); + if (type == "file" || type == "directory") + setting.setAttribute("fullpath", "true"); + + setting = document.importNode(setting, true); + var style = setting.getAttribute("style"); + if (style) { + setting.removeAttribute("style"); + setting.setAttribute("style", style); } - finish(firstSetting); + rows.appendChild(setting); + var visible = window.getComputedStyle(setting, null).getPropertyValue("display") != "none"; + if (!firstSetting && visible) { + setting.setAttribute("first-row", true); + firstSetting = setting; + } + } - if (aCallback) - aCallback(); - }).bind(this); - xhr.onerror = function(aEvent) { - Cu.reportError("Error " + aEvent.target.status + - " occurred while receiving " + this._addon.optionsURL); - if (aCallback) - aCallback(); - }; - xhr.send(); - } - } catch (e) { + // Ensure the page has loaded and force the XBL bindings to be synchronously applied, + // then notify observers. + if (gViewController.viewPort.selectedPanel.hasAttribute("loading")) { + gDetailView.node.addEventListener("ViewChanged", function viewChangedEventListener() { + gDetailView.node.removeEventListener("ViewChanged", viewChangedEventListener, false); + if (firstSetting) + firstSetting.clientTop; + Services.obs.notifyObservers(document, + AddonManager.OPTIONS_NOTIFICATION_DISPLAYED, + gDetailView._addon.id); + if (aScrollToPreferences) + gDetailView.scrollToPreferencesRows(); + }, false); + } else { + if (firstSetting) + firstSetting.clientTop; + Services.obs.notifyObservers(document, + AddonManager.OPTIONS_NOTIFICATION_DISPLAYED, + this._addon.id); + if (aScrollToPreferences) + gDetailView.scrollToPreferencesRows(); + } + if (aCallback) + aCallback(); + }).bind(this); + xhr.onerror = function fillSettingsRows_onerror(aEvent) { + Cu.reportError("Error " + aEvent.target.status + + " occurred while receiving " + this._addon.optionsURL); + if (aCallback) + aCallback(); + }; + xhr.send(); + } catch(e) { Cu.reportError(e); if (aCallback) aCallback(); } }, - scrollToPreferencesRows: function() { + scrollToPreferencesRows: function gDetailView_scrollToPreferencesRows() { // We find this row, rather than remembering it from above, // in case it has been changed by the observers. let firstRow = gDetailView.node.querySelector('setting[first-row="true"]'); @@ -3524,55 +3217,20 @@ var gDetailView = { } }, - createOptionsBrowser: function(parentNode) { - let browser = document.createElement("browser"); - browser.setAttribute("type", "content"); - browser.setAttribute("disableglobalhistory", "true"); - browser.setAttribute("class", "inline-options-browser"); - - return new Promise((resolve, reject) => { - let messageListener = { - receiveMessage({name, data}) { - if (name === "Extension:BrowserResized") - browser.style.height = `${data.height}px`; - else if (name === "Extension:BrowserContentLoaded") - resolve(browser); - }, - }; - - let onload = () => { - browser.removeEventListener("load", onload, true); - - let mm = new FakeFrameMessageManager(browser); - mm.loadFrameScript("chrome://extensions/content/ext-browser-content.js", - false); - mm.addMessageListener("Extension:BrowserContentLoaded", messageListener); - mm.addMessageListener("Extension:BrowserResized", messageListener); - mm.sendAsyncMessage("Extension:InitBrowser", {fixedWidth: true}); - - browser.setAttribute("src", this._addon.optionsURL); - }; - browser.addEventListener("load", onload, true); - browser.addEventListener("error", reject); - - parentNode.appendChild(browser); - }); - }, - - getSelectedAddon: function() { + getSelectedAddon: function gDetailView_getSelectedAddon() { return this._addon; }, - onEnabling: function() { + onEnabling: function gDetailView_onEnabling() { this.updateState(); }, - onEnabled: function() { + onEnabled: function gDetailView_onEnabled() { this.updateState(); this.fillSettingsRows(); }, - onDisabling: function(aNeedsRestart) { + onDisabling: function gDetailView_onDisabling(aNeedsRestart) { this.updateState(); if (!aNeedsRestart && hasInlineOptions(this._addon)) { Services.obs.notifyObservers(document, @@ -3581,24 +3239,24 @@ var gDetailView = { } }, - onDisabled: function() { + onDisabled: function gDetailView_onDisabled() { this.updateState(); this.emptySettingsRows(); }, - onUninstalling: function() { + onUninstalling: function gDetailView_onUninstalling() { this.updateState(); }, - onUninstalled: function() { + onUninstalled: function gDetailView_onUninstalled() { gViewController.popState(); }, - onOperationCancelled: function() { + onOperationCancelled: function gDetailView_onOperationCancelled() { this.updateState(); }, - onPropertyChanged: function(aProperties) { + onPropertyChanged: function gDetailView_onPropertyChanged(aProperties) { if (aProperties.indexOf("applyBackgroundUpdates") != -1) { this._autoUpdate.value = this._addon.applyBackgroundUpdates; let hideFindUpdates = AddonManager.shouldAutoUpdate(this._addon); @@ -3606,12 +3264,11 @@ var gDetailView = { } if (aProperties.indexOf("appDisabled") != -1 || - aProperties.indexOf("signedState") != -1 || aProperties.indexOf("userDisabled") != -1) this.updateState(); }, - onExternalInstall: function(aAddon, aExistingAddon, aNeedsRestart) { + onExternalInstall: function gDetailView_onExternalInstall(aAddon, aExistingAddon, aNeedsRestart) { // Only care about upgrades for the currently displayed add-on if (!aExistingAddon || aExistingAddon.id != this._addon.id) return; @@ -3622,7 +3279,7 @@ var gDetailView = { this.updateState(); }, - onInstallCancelled: function(aInstall) { + onInstallCancelled: function gDetailView_onInstallCancelled(aInstall) { if (aInstall.addon.id == this._addon.id) gViewController.popState(); } @@ -3637,7 +3294,7 @@ var gUpdatesView = { _updateSelected: null, _categoryItem: null, - initialize: function() { + initialize: function gUpdatesView_initialize() { this.node = document.getElementById("updates-view"); this._listBox = document.getElementById("updates-list"); this._emptyNotice = document.getElementById("updates-list-empty"); @@ -3647,7 +3304,7 @@ var gUpdatesView = { this._categoryItem = gCategories.get("addons://updates/available"); this._updateSelected = document.getElementById("update-selected-btn"); - this._updateSelected.addEventListener("command", function() { + this._updateSelected.addEventListener("command", function updateSelected_onCommand() { gUpdatesView.installSelected(); }, false); @@ -3657,12 +3314,12 @@ var gUpdatesView = { AddonManager.addInstallListener(this); }, - shutdown: function() { + shutdown: function gUpdatesView_shutdown() { AddonManager.removeAddonListener(this); AddonManager.removeInstallListener(this); }, - show: function(aType, aRequest) { + show: function gUpdatesView_show(aType, aRequest) { document.getElementById("empty-availableUpdates-msg").hidden = aType != "available"; document.getElementById("empty-recentUpdates-msg").hidden = aType != "recent"; this.showEmptyNotice(false); @@ -3677,91 +3334,92 @@ var gUpdatesView = { this._showAvailableUpdates(false, aRequest); }, - hide: function() { + hide: function gUpdatesView_hide() { this._updateSelected.hidden = true; this._categoryItem.disabled = this._categoryItem.badgeCount == 0; doPendingUninstalls(this._listBox); }, - _showRecentUpdates: function(aRequest) { - AddonManager.getAllAddons((aAddonsList) => { + _showRecentUpdates: function gUpdatesView_showRecentUpdates(aRequest) { + var self = this; + AddonManager.getAllAddons(function showRecentUpdates_getAllAddons(aAddonsList) { if (gViewController && aRequest != gViewController.currentViewRequest) return; var elements = []; let threshold = Date.now() - UPDATES_RECENT_TIMESPAN; for (let addon of aAddonsList) { - if (addon.hidden || !addon.updateDate || addon.updateDate.getTime() < threshold) + if (!addon.updateDate || addon.updateDate.getTime() < threshold) continue; elements.push(createItem(addon)); } - this.showEmptyNotice(elements.length == 0); + self.showEmptyNotice(elements.length == 0); if (elements.length > 0) { - sortElements(elements, [this._sorters.sortBy], this._sorters.ascending); + sortElements(elements, [self._sorters.sortBy], self._sorters.ascending); for (let element of elements) - this._listBox.appendChild(element); + self._listBox.appendChild(element); } gViewController.notifyViewChanged(); }); }, - _showAvailableUpdates: function(aIsRefresh, aRequest) { + _showAvailableUpdates: function gUpdatesView_showAvailableUpdates(aIsRefresh, aRequest) { /* Disable the Update Selected button so it can't get clicked before everything is initialized asynchronously. It will get re-enabled by maybeDisableUpdateSelected(). */ this._updateSelected.disabled = true; - AddonManager.getAllInstalls((aInstallsList) => { + var self = this; + AddonManager.getAllInstalls(function showAvailableUpdates_getAllInstalls(aInstallsList) { if (!aIsRefresh && gViewController && aRequest && aRequest != gViewController.currentViewRequest) return; if (aIsRefresh) { - this.showEmptyNotice(false); - this._updateSelected.hidden = true; + self.showEmptyNotice(false); + self._updateSelected.hidden = true; - while (this._listBox.childNodes.length > 0) - this._listBox.removeChild(this._listBox.firstChild); + while (self._listBox.itemCount > 0) + self._listBox.removeItemAt(0); } var elements = []; for (let install of aInstallsList) { - if (!this.isManualUpdate(install)) + if (!self.isManualUpdate(install)) continue; let item = createItem(install.existingAddon); item.setAttribute("upgrade", true); - item.addEventListener("IncludeUpdateChanged", () => { - this.maybeDisableUpdateSelected(); + item.addEventListener("IncludeUpdateChanged", function item_onIncludeUpdateChanged() { + self.maybeDisableUpdateSelected(); }, false); elements.push(item); } - this.showEmptyNotice(elements.length == 0); + self.showEmptyNotice(elements.length == 0); if (elements.length > 0) { - this._updateSelected.hidden = false; - sortElements(elements, [this._sorters.sortBy], this._sorters.ascending); + self._updateSelected.hidden = false; + sortElements(elements, [self._sorters.sortBy], self._sorters.ascending); for (let element of elements) - this._listBox.appendChild(element); + self._listBox.appendChild(element); } // ensure badge count is in sync - this._categoryItem.badgeCount = this._listBox.itemCount; + self._categoryItem.badgeCount = self._listBox.itemCount; gViewController.notifyViewChanged(); }); }, - showEmptyNotice: function(aShow) { + showEmptyNotice: function gUpdatesView_showEmptyNotice(aShow) { this._emptyNotice.hidden = !aShow; - this._listBox.hidden = aShow; }, - isManualUpdate: function(aInstall, aOnlyAvailable) { + isManualUpdate: function gUpdatesView_isManualUpdate(aInstall, aOnlyAvailable) { var isManual = aInstall.existingAddon && !AddonManager.shouldAutoUpdate(aInstall.existingAddon); if (isManual && aOnlyAvailable) @@ -3769,28 +3427,29 @@ var gUpdatesView = { return isManual; }, - maybeRefresh: function() { + maybeRefresh: function gUpdatesView_maybeRefresh() { if (gViewController.currentViewId == "addons://updates/available") this._showAvailableUpdates(true); this.updateAvailableCount(); }, - updateAvailableCount: function(aInitializing) { + updateAvailableCount: function gUpdatesView_updateAvailableCount(aInitializing) { if (aInitializing) gPendingInitializations++; - AddonManager.getAllInstalls((aInstallsList) => { - var count = aInstallsList.filter(aInstall => { - return this.isManualUpdate(aInstall, true); + var self = this; + AddonManager.getAllInstalls(function updateAvailableCount_getAllInstalls(aInstallsList) { + var count = aInstallsList.filter(function installListFilter(aInstall) { + return self.isManualUpdate(aInstall, true); }).length; - this._categoryItem.disabled = gViewController.currentViewId != "addons://updates/available" && + self._categoryItem.disabled = gViewController.currentViewId != "addons://updates/available" && count == 0; - this._categoryItem.badgeCount = count; + self._categoryItem.badgeCount = count; if (aInitializing) notifyInitialized(); }); }, - maybeDisableUpdateSelected: function() { + maybeDisableUpdateSelected: function gUpdatesView_maybeDisableUpdateSelected() { for (let item of this._listBox.childNodes) { if (item.includeUpdate) { this._updateSelected.disabled = false; @@ -3800,7 +3459,7 @@ var gUpdatesView = { this._updateSelected.disabled = true; }, - installSelected: function() { + installSelected: function gUpdatesView_installSelected() { for (let item of this._listBox.childNodes) { if (item.includeUpdate) item.upgrade(); @@ -3809,14 +3468,14 @@ var gUpdatesView = { this._updateSelected.disabled = true; }, - getSelectedAddon: function() { + getSelectedAddon: function gUpdatesView_getSelectedAddon() { var item = this._listBox.selectedItem; if (item) return item.mAddon; return null; }, - getListItemForID: function(aId) { + getListItemForID: function gUpdatesView_getListItemForID(aId) { var listitem = this._listBox.firstChild; while (listitem) { if (listitem.mAddon.id == aId) @@ -3826,42 +3485,48 @@ var gUpdatesView = { return null; }, - onSortChanged: function(aSortBy, aAscending) { + onSortChanged: function gUpdatesView_onSortChanged(aSortBy, aAscending) { sortList(this._listBox, aSortBy, aAscending); }, - onNewInstall: function(aInstall) { + onNewInstall: function gUpdatesView_onNewInstall(aInstall) { if (!this.isManualUpdate(aInstall)) return; this.maybeRefresh(); }, - onInstallStarted: function(aInstall) { + onInstallStarted: function gUpdatesView_onInstallStarted(aInstall) { this.updateAvailableCount(); }, - onInstallCancelled: function(aInstall) { + onInstallCancelled: function gUpdatesView_onInstallCancelled(aInstall) { if (!this.isManualUpdate(aInstall)) return; this.maybeRefresh(); }, - onPropertyChanged: function(aAddon, aProperties) { + onPropertyChanged: function gUpdatesView_onPropertyChanged(aAddon, aProperties) { if (aProperties.indexOf("applyBackgroundUpdates") != -1) this.updateAvailableCount(); } }; +function debuggingPrefChanged() { + gViewController.updateState(); + gViewController.updateCommands(); + gViewController.notifyViewChanged(); +} + var gDragDrop = { - onDragOver: function(aEvent) { + onDragOver: function gDragDrop_onDragOver(aEvent) { var types = aEvent.dataTransfer.types; - if (types.includes("text/uri-list") || - types.includes("text/x-moz-url") || - types.includes("application/x-moz-file")) + if (types.contains("text/uri-list") || + types.contains("text/x-moz-url") || + types.contains("application/x-moz-file")) aEvent.preventDefault(); }, - onDrop: function(aEvent) { + onDrop: function gDragDrop_onDrop(aEvent) { var dataTransfer = aEvent.dataTransfer; var urls = []; @@ -3897,12 +3562,12 @@ var gDragDrop = { getService(Ci.amIWebInstallListener); webInstaller.onWebInstallRequested(getBrowserElement(), document.documentURIObject, - installs); + installs, installs.length); } return; } - AddonManager.getInstallForURL(urls[pos++], function(aInstall) { + AddonManager.getInstallForURL(urls[pos++], function onDrop_getInstallForURL(aInstall) { installs.push(aInstall); buildNextInstall(); }, "application/x-xpinstall"); |