mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 746908 - Add parameter guards to AddonManager/AddonManagerPrivate API functions. r=dtownsend
This commit is contained in:
parent
bde61972f6
commit
25bea66eda
@ -358,7 +358,7 @@ AddonCompatibilityOverride.prototype = {
|
||||
* A type of add-on, used by the UI to determine how to display different types
|
||||
* of add-ons.
|
||||
*
|
||||
* @param aId
|
||||
* @param aID
|
||||
* The add-on type ID
|
||||
* @param aLocaleURI
|
||||
* The URI of a localized properties file to get the displayable name
|
||||
@ -376,15 +376,15 @@ AddonCompatibilityOverride.prototype = {
|
||||
* An option set of flags that customize the display of the add-on in
|
||||
* the UI.
|
||||
*/
|
||||
function AddonType(aId, aLocaleURI, aLocaleKey, aViewType, aUIPriority, aFlags) {
|
||||
if (!aId)
|
||||
function AddonType(aID, aLocaleURI, aLocaleKey, aViewType, aUIPriority, aFlags) {
|
||||
if (!aID)
|
||||
throw new Error("An AddonType must have an ID");
|
||||
if (aViewType && aUIPriority === undefined)
|
||||
throw new Error("An AddonType with a defined view must have a set UI priority");
|
||||
if (!aLocaleKey)
|
||||
throw new Error("An AddonType must have a displayable name");
|
||||
|
||||
this.id = aId;
|
||||
this.id = aID;
|
||||
this.uiPriority = aUIPriority;
|
||||
this.viewType = aViewType;
|
||||
this.flags = aFlags;
|
||||
@ -393,7 +393,7 @@ function AddonType(aId, aLocaleURI, aLocaleKey, aViewType, aUIPriority, aFlags)
|
||||
this.__defineGetter__("name", function() {
|
||||
delete this.name;
|
||||
let bundle = Services.strings.createBundle(aLocaleURI);
|
||||
this.name = bundle.GetStringFromName(aLocaleKey.replace("%ID%", aId));
|
||||
this.name = bundle.GetStringFromName(aLocaleKey.replace("%ID%", aID));
|
||||
return this.name;
|
||||
});
|
||||
}
|
||||
@ -591,9 +591,17 @@ var AddonManagerInternal = {
|
||||
* @param aProvider
|
||||
* The provider to register
|
||||
* @param aTypes
|
||||
* An array of add-on types
|
||||
* An optional array of add-on types
|
||||
*/
|
||||
registerProvider: function AMI_registerProvider(aProvider, aTypes) {
|
||||
if (!aProvider || typeof aProvider != "object")
|
||||
throw Components.Exception("aProvider must be specified",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (aTypes && !Array.isArray(aTypes))
|
||||
throw Components.Exception("aTypes must be an array or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
this.providers.push(aProvider);
|
||||
|
||||
if (aTypes) {
|
||||
@ -633,6 +641,10 @@ var AddonManagerInternal = {
|
||||
* The provider to unregister
|
||||
*/
|
||||
unregisterProvider: function AMI_unregisterProvider(aProvider) {
|
||||
if (!aProvider || typeof aProvider != "object")
|
||||
throw Components.Exception("aProvider must be specified",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
let pos = 0;
|
||||
while (pos < this.providers.length) {
|
||||
if (this.providers[pos] == aProvider)
|
||||
@ -775,15 +787,27 @@ var AddonManagerInternal = {
|
||||
* appropriate values.
|
||||
*
|
||||
* @param aAddon
|
||||
* The AddonInternal representing the add-on
|
||||
* The Addon representing the add-on
|
||||
* @param aUri
|
||||
* The uri to escape
|
||||
* The string representation of the URI to escape
|
||||
* @param aAppVersion
|
||||
* The optional application version to use for %APP_VERSION%
|
||||
* @return the appropriately escaped uri.
|
||||
* @return The appropriately escaped URI.
|
||||
*/
|
||||
escapeAddonURI: function AMI_escapeAddonURI(aAddon, aUri, aAppVersion)
|
||||
{
|
||||
if (!aAddon || typeof aAddon != "object")
|
||||
throw Components.Exception("aAddon must be an Addon object",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!aUri || typeof aUri != "string")
|
||||
throw Components.Exception("aUri must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (aAppVersion && typeof aAppVersion != "string")
|
||||
throw Components.Exception("aAppVersion must be a string or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
var addonStatus = aAddon.userDisabled || aAddon.softDisabled ? "userDisabled"
|
||||
: "userEnabled";
|
||||
|
||||
@ -1013,6 +1037,14 @@ var AddonManagerInternal = {
|
||||
* The ID of the add-on
|
||||
*/
|
||||
addStartupChange: function AMI_addStartupChange(aType, aID) {
|
||||
if (!aType || typeof aType != "string")
|
||||
throw Components.Exception("aType must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!aID || typeof aID != "string")
|
||||
throw Components.Exception("aID must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (gStarted)
|
||||
return;
|
||||
|
||||
@ -1034,6 +1066,14 @@ var AddonManagerInternal = {
|
||||
* The ID of the add-on
|
||||
*/
|
||||
removeStartupChange: function AMI_removeStartupChange(aType, aID) {
|
||||
if (!aType || typeof aType != "string")
|
||||
throw Components.Exception("aType must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!aID || typeof aID != "string")
|
||||
throw Components.Exception("aID must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (gStarted)
|
||||
return;
|
||||
|
||||
@ -1051,6 +1091,10 @@ var AddonManagerInternal = {
|
||||
* The method on the listeners to call
|
||||
*/
|
||||
callManagerListeners: function AMI_callManagerListeners(aMethod) {
|
||||
if (!aMethod || typeof aMethod != "string")
|
||||
throw Components.Exception("aMethod must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
var args = Array.slice(arguments, 1);
|
||||
this.managerListeners.forEach(function(listener) {
|
||||
try {
|
||||
@ -1070,10 +1114,18 @@ var AddonManagerInternal = {
|
||||
* @param aMethod
|
||||
* The method on the listeners to call
|
||||
* @param aExtraListeners
|
||||
* An array of extra InstallListeners to also call
|
||||
* An optional array of extra InstallListeners to also call
|
||||
* @return false if any of the listeners returned false, true otherwise
|
||||
*/
|
||||
callInstallListeners: function AMI_callInstallListeners(aMethod, aExtraListeners) {
|
||||
if (!aMethod || typeof aMethod != "string")
|
||||
throw Components.Exception("aMethod must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (aExtraListeners && !Array.isArray(aExtraListeners))
|
||||
throw Components.Exception("aExtraListeners must be an array or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
let result = true;
|
||||
let listeners = this.installListeners;
|
||||
if (aExtraListeners)
|
||||
@ -1102,6 +1154,10 @@ var AddonManagerInternal = {
|
||||
* The method on the listeners to call
|
||||
*/
|
||||
callAddonListeners: function AMI_callAddonListeners(aMethod) {
|
||||
if (!aMethod || typeof aMethod != "string")
|
||||
throw Components.Exception("aMethod must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
var args = Array.slice(arguments, 1);
|
||||
this.addonListeners.forEach(function(listener) {
|
||||
try {
|
||||
@ -1119,17 +1175,25 @@ var AddonManagerInternal = {
|
||||
* add-on only supports a single add-on being enabled at a time. This allows
|
||||
* the providers to disable theirs if necessary.
|
||||
*
|
||||
* @param aId
|
||||
* The id of the enabled add-on
|
||||
* @param aID
|
||||
* The ID of the enabled add-on
|
||||
* @param aType
|
||||
* The type of the enabled add-on
|
||||
* @param aPendingRestart
|
||||
* A boolean indicating if the change will only take place the next
|
||||
* time the application is restarted
|
||||
*/
|
||||
notifyAddonChanged: function AMI_notifyAddonChanged(aId, aType, aPendingRestart) {
|
||||
notifyAddonChanged: function AMI_notifyAddonChanged(aID, aType, aPendingRestart) {
|
||||
if (aID && typeof aID != "string")
|
||||
throw Components.Exception("aID must be a string or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!aType || typeof aType != "string")
|
||||
throw Components.Exception("aType must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
this.providers.forEach(function(provider) {
|
||||
callProvider(provider, "addonChanged", null, aId, aType, aPendingRestart);
|
||||
callProvider(provider, "addonChanged", null, aID, aType, aPendingRestart);
|
||||
});
|
||||
},
|
||||
|
||||
@ -1152,8 +1216,8 @@ var AddonManagerInternal = {
|
||||
* Function to call when operation is complete.
|
||||
*/
|
||||
updateAddonRepositoryData: function AMI_updateAddonRepositoryData(aCallback) {
|
||||
if (!aCallback)
|
||||
throw Components.Exception("Must specify aCallback",
|
||||
if (typeof aCallback != "function")
|
||||
throw Components.Exception("aCallback must be a function",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
new AsyncObjectCaller(this.providers, "updateAddonRepositoryData", {
|
||||
@ -1168,11 +1232,12 @@ var AddonManagerInternal = {
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Asynchronously gets an AddonInstall for a URL.
|
||||
*
|
||||
* @param aUrl
|
||||
* The url the add-on is located at
|
||||
* The string represenation of the URL the add-on is located at
|
||||
* @param aCallback
|
||||
* A callback to pass the AddonInstall to
|
||||
* @param aMimetype
|
||||
@ -1192,8 +1257,37 @@ var AddonManagerInternal = {
|
||||
getInstallForURL: function AMI_getInstallForURL(aUrl, aCallback, aMimetype,
|
||||
aHash, aName, aIconURL,
|
||||
aVersion, aLoadGroup) {
|
||||
if (!aUrl || !aMimetype || !aCallback)
|
||||
throw new TypeError("Invalid arguments");
|
||||
if (!aUrl || typeof aUrl != "string")
|
||||
throw Components.Exception("aURL must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (typeof aCallback != "function")
|
||||
throw Components.Exception("aCallback must be a function",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!aMimetype || typeof aMimetype != "string")
|
||||
throw Components.Exception("aMimetype must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (aHash && typeof aHash != "string")
|
||||
throw Components.Exception("aHash must be a string or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (aName && typeof aName != "string")
|
||||
throw Components.Exception("aName must be a string or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (aIconURL && typeof aIconURL != "string")
|
||||
throw Components.Exception("aIconURL must be a string or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (aVersion && typeof aVersion != "string")
|
||||
throw Components.Exception("aVersion must be a string or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (aLoadGroup && (!(aLoadGroup instanceof Ci.nsILoadGroup)))
|
||||
throw Components.Exception("aLoadGroup must be a nsILoadGroup or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
for (let provider of this.providers) {
|
||||
if (callProvider(provider, "supportsMimetype", false, aMimetype)) {
|
||||
@ -1212,7 +1306,7 @@ var AddonManagerInternal = {
|
||||
* Asynchronously gets an AddonInstall for an nsIFile.
|
||||
*
|
||||
* @param aFile
|
||||
* the nsIFile where the add-on is located
|
||||
* The nsIFile where the add-on is located
|
||||
* @param aCallback
|
||||
* A callback to pass the AddonInstall to
|
||||
* @param aMimetype
|
||||
@ -1220,8 +1314,17 @@ var AddonManagerInternal = {
|
||||
* @throws if the aFile or aCallback arguments are not specified
|
||||
*/
|
||||
getInstallForFile: function AMI_getInstallForFile(aFile, aCallback, aMimetype) {
|
||||
if (!aFile || !aCallback)
|
||||
throw Cr.NS_ERROR_INVALID_ARG;
|
||||
if (!(aFile instanceof Ci.nsIFile))
|
||||
throw Components.Exception("aFile must be a nsIFile",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (typeof aCallback != "function")
|
||||
throw Components.Exception("aCallback must be a function",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (aMimetype && typeof aMimetype != "string")
|
||||
throw Components.Exception("aMimetype must be a string or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
new AsyncObjectCaller(this.providers, "getInstallForFile", {
|
||||
nextObject: function(aCaller, aProvider) {
|
||||
@ -1248,11 +1351,16 @@ var AddonManagerInternal = {
|
||||
* An optional array of types to retrieve. Each type is a string name
|
||||
* @param aCallback
|
||||
* A callback which will be passed an array of AddonInstalls
|
||||
* @throws if the aCallback argument is not specified
|
||||
* @throws If the aCallback argument is not specified
|
||||
*/
|
||||
getInstallsByTypes: function AMI_getInstallsByTypes(aTypes, aCallback) {
|
||||
if (!aCallback)
|
||||
throw Cr.NS_ERROR_INVALID_ARG;
|
||||
if (aTypes && !Array.isArray(aTypes))
|
||||
throw Components.Exception("aTypes must be an array or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (typeof aCallback != "function")
|
||||
throw Components.Exception("aCallback must be a function",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
let installs = [];
|
||||
|
||||
@ -1289,6 +1397,10 @@ var AddonManagerInternal = {
|
||||
* @return true if installation is enabled for the mimetype
|
||||
*/
|
||||
isInstallEnabled: function AMI_isInstallEnabled(aMimetype) {
|
||||
if (!aMimetype || typeof aMimetype != "string")
|
||||
throw Components.Exception("aMimetype must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
for (let provider of this.providers) {
|
||||
if (callProvider(provider, "supportsMimetype", false, aMimetype) &&
|
||||
callProvider(provider, "isInstallEnabled"))
|
||||
@ -1304,10 +1416,18 @@ var AddonManagerInternal = {
|
||||
* @param aMimetype
|
||||
* The mimetype of the add-on
|
||||
* @param aURI
|
||||
* The uri of the source, may be null
|
||||
* The optional nsIURI of the source
|
||||
* @return true if the source is allowed to install this mimetype
|
||||
*/
|
||||
isInstallAllowed: function AMI_isInstallAllowed(aMimetype, aURI) {
|
||||
if (!aMimetype || typeof aMimetype != "string")
|
||||
throw Components.Exception("aMimetype must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (aURI && !(aURI instanceof Ci.nsIURI))
|
||||
throw Components.Exception("aURI must be a nsIURI or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
for (let provider of this.providers) {
|
||||
if (callProvider(provider, "supportsMimetype", false, aMimetype) &&
|
||||
callProvider(provider, "isInstallAllowed", null, aURI))
|
||||
@ -1323,9 +1443,9 @@ var AddonManagerInternal = {
|
||||
* @param aMimetype
|
||||
* The mimetype of add-ons being installed
|
||||
* @param aSource
|
||||
* The nsIDOMWindow that started the installs
|
||||
* The optional nsIDOMWindow that started the installs
|
||||
* @param aURI
|
||||
* the nsIURI that started the installs
|
||||
* The optional nsIURI that started the installs
|
||||
* @param aInstalls
|
||||
* The array of AddonInstalls to be installed
|
||||
*/
|
||||
@ -1333,6 +1453,22 @@ var AddonManagerInternal = {
|
||||
aSource,
|
||||
aURI,
|
||||
aInstalls) {
|
||||
if (!aMimetype || typeof aMimetype != "string")
|
||||
throw Components.Exception("aMimetype must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (aSource && !(aSource instanceof Ci.nsIDOMWindow))
|
||||
throw Components.Exception("aSource must be a nsIDOMWindow or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (aURI && !(aURI instanceof Ci.nsIURI))
|
||||
throw Components.Exception("aURI must be a nsIURI or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!Array.isArray(aInstalls))
|
||||
throw Components.Exception("aInstalls must be an array",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!("@mozilla.org/addons/web-install-listener;1" in Cc)) {
|
||||
WARN("No web installer available, cancelling all installs");
|
||||
aInstalls.forEach(function(aInstall) {
|
||||
@ -1382,6 +1518,10 @@ var AddonManagerInternal = {
|
||||
* The InstallListener to add
|
||||
*/
|
||||
addInstallListener: function AMI_addInstallListener(aListener) {
|
||||
if (!aListener || typeof aListener != "object")
|
||||
throw Components.Exception("aListener must be a InstallListener object",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!this.installListeners.some(function(i) { return i == aListener; }))
|
||||
this.installListeners.push(aListener);
|
||||
},
|
||||
@ -1393,6 +1533,10 @@ var AddonManagerInternal = {
|
||||
* The InstallListener to remove
|
||||
*/
|
||||
removeInstallListener: function AMI_removeInstallListener(aListener) {
|
||||
if (!aListener || typeof aListener != "object")
|
||||
throw Components.Exception("aListener must be a InstallListener object",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
let pos = 0;
|
||||
while (pos < this.installListeners.length) {
|
||||
if (this.installListeners[pos] == aListener)
|
||||
@ -1405,19 +1549,24 @@ var AddonManagerInternal = {
|
||||
/**
|
||||
* Asynchronously gets an add-on with a specific ID.
|
||||
*
|
||||
* @param aId
|
||||
* @param aID
|
||||
* The ID of the add-on to retrieve
|
||||
* @param aCallback
|
||||
* The callback to pass the retrieved add-on to
|
||||
* @throws if the aId or aCallback arguments are not specified
|
||||
* @throws if the aID or aCallback arguments are not specified
|
||||
*/
|
||||
getAddonByID: function AMI_getAddonByID(aId, aCallback) {
|
||||
if (!aId || !aCallback)
|
||||
throw Cr.NS_ERROR_INVALID_ARG;
|
||||
getAddonByID: function AMI_getAddonByID(aID, aCallback) {
|
||||
if (!aID || typeof aID != "string")
|
||||
throw Components.Exception("aID must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (typeof aCallback != "function")
|
||||
throw Components.Exception("aCallback must be a function",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
new AsyncObjectCaller(this.providers, "getAddonByID", {
|
||||
nextObject: function(aCaller, aProvider) {
|
||||
callProvider(aProvider, "getAddonByID", null, aId, function(aAddon) {
|
||||
callProvider(aProvider, "getAddonByID", null, aID, function(aAddon) {
|
||||
if (aAddon)
|
||||
safeCall(aCallback, aAddon);
|
||||
else
|
||||
@ -1441,9 +1590,13 @@ var AddonManagerInternal = {
|
||||
* @throws if the aGUID or aCallback arguments are not specified
|
||||
*/
|
||||
getAddonBySyncGUID: function AMI_getAddonBySyncGUID(aGUID, aCallback) {
|
||||
if (!aGUID || !aCallback) {
|
||||
throw Cr.NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
if (!aGUID || typeof aGUID != "string")
|
||||
throw Components.Exception("aGUID must be a non-empty string",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (typeof aCallback != "function")
|
||||
throw Components.Exception("aCallback must be a function",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
new AsyncObjectCaller(this.providers, "getAddonBySyncGUID", {
|
||||
nextObject: function(aCaller, aProvider) {
|
||||
@ -1465,21 +1618,26 @@ var AddonManagerInternal = {
|
||||
/**
|
||||
* Asynchronously gets an array of add-ons.
|
||||
*
|
||||
* @param aIds
|
||||
* @param aIDs
|
||||
* The array of IDs to retrieve
|
||||
* @param aCallback
|
||||
* The callback to pass an array of Addons to
|
||||
* @throws if the aId or aCallback arguments are not specified
|
||||
* @throws if the aID or aCallback arguments are not specified
|
||||
*/
|
||||
getAddonsByIDs: function AMI_getAddonsByIDs(aIds, aCallback) {
|
||||
if (!aIds || !aCallback)
|
||||
throw Cr.NS_ERROR_INVALID_ARG;
|
||||
getAddonsByIDs: function AMI_getAddonsByIDs(aIDs, aCallback) {
|
||||
if (!Array.isArray(aIDs))
|
||||
throw Components.Exception("aIDs must be an array",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (typeof aCallback != "function")
|
||||
throw Components.Exception("aCallback must be a function",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
let addons = [];
|
||||
|
||||
new AsyncObjectCaller(aIds, null, {
|
||||
nextObject: function(aCaller, aId) {
|
||||
AddonManagerInternal.getAddonByID(aId, function(aAddon) {
|
||||
new AsyncObjectCaller(aIDs, null, {
|
||||
nextObject: function(aCaller, aID) {
|
||||
AddonManagerInternal.getAddonByID(aID, function(aAddon) {
|
||||
addons.push(aAddon);
|
||||
aCaller.callNext();
|
||||
});
|
||||
@ -1501,8 +1659,13 @@ var AddonManagerInternal = {
|
||||
* @throws if the aCallback argument is not specified
|
||||
*/
|
||||
getAddonsByTypes: function AMI_getAddonsByTypes(aTypes, aCallback) {
|
||||
if (!aCallback)
|
||||
throw Cr.NS_ERROR_INVALID_ARG;
|
||||
if (aTypes && !Array.isArray(aTypes))
|
||||
throw Components.Exception("aTypes must be an array or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (typeof aCallback != "function")
|
||||
throw Components.Exception("aCallback must be a function",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
let addons = [];
|
||||
|
||||
@ -1543,8 +1706,13 @@ var AddonManagerInternal = {
|
||||
*/
|
||||
getAddonsWithOperationsByTypes:
|
||||
function AMI_getAddonsWithOperationsByTypes(aTypes, aCallback) {
|
||||
if (!aCallback)
|
||||
throw Cr.NS_ERROR_INVALID_ARG;
|
||||
if (aTypes && !Array.isArray(aTypes))
|
||||
throw Components.Exception("aTypes must be an array or null",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (typeof aCallback != "function")
|
||||
throw Components.Exception("aCallback must be a function",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
let addons = [];
|
||||
|
||||
@ -1570,6 +1738,10 @@ var AddonManagerInternal = {
|
||||
* The listener to add
|
||||
*/
|
||||
addManagerListener: function AMI_addManagerListener(aListener) {
|
||||
if (!aListener || typeof aListener != "object")
|
||||
throw Components.Exception("aListener must be an AddonManagerListener object",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!this.managerListeners.some(function(i) { return i == aListener; }))
|
||||
this.managerListeners.push(aListener);
|
||||
},
|
||||
@ -1581,6 +1753,10 @@ var AddonManagerInternal = {
|
||||
* The listener to remove
|
||||
*/
|
||||
removeManagerListener: function AMI_removeManagerListener(aListener) {
|
||||
if (!aListener || typeof aListener != "object")
|
||||
throw Components.Exception("aListener must be an AddonManagerListener object",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
let pos = 0;
|
||||
while (pos < this.managerListeners.length) {
|
||||
if (this.managerListeners[pos] == aListener)
|
||||
@ -1594,9 +1770,13 @@ var AddonManagerInternal = {
|
||||
* Adds a new AddonListener if the listener is not already registered.
|
||||
*
|
||||
* @param aListener
|
||||
* The listener to add
|
||||
* The AddonListener to add
|
||||
*/
|
||||
addAddonListener: function AMI_addAddonListener(aListener) {
|
||||
if (!aListener || typeof aListener != "object")
|
||||
throw Components.Exception("aListener must be an AddonListener object",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!this.addonListeners.some(function(i) { return i == aListener; }))
|
||||
this.addonListeners.push(aListener);
|
||||
},
|
||||
@ -1605,9 +1785,14 @@ var AddonManagerInternal = {
|
||||
* Removes an AddonListener if the listener is registered.
|
||||
*
|
||||
* @param aListener
|
||||
* The listener to remove
|
||||
* The AddonListener to remove
|
||||
*/
|
||||
removeAddonListener: function AMI_removeAddonListener(aListener) {
|
||||
if (!aListener || typeof aListener != "object")
|
||||
throw Components.Exception("aListener must be an AddonListener object",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
|
||||
let pos = 0;
|
||||
while (pos < this.addonListeners.length) {
|
||||
if (this.addonListeners[pos] == aListener)
|
||||
@ -1617,12 +1802,32 @@ var AddonManagerInternal = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a new TypeListener if the listener is not already registered.
|
||||
*
|
||||
* @param aListener
|
||||
* The TypeListener to add
|
||||
*/
|
||||
addTypeListener: function AMI_addTypeListener(aListener) {
|
||||
if (!aListener || typeof aListener != "object")
|
||||
throw Components.Exception("aListener must be a TypeListener object",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!this.typeListeners.some(function(i) { return i == aListener; }))
|
||||
this.typeListeners.push(aListener);
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes an TypeListener if the listener is registered.
|
||||
*
|
||||
* @param aListener
|
||||
* The TypeListener to remove
|
||||
*/
|
||||
removeTypeListener: function AMI_removeTypeListener(aListener) {
|
||||
if (!aListener || typeof aListener != "object")
|
||||
throw Components.Exception("aListener must be a TypeListener object",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
let pos = 0;
|
||||
while (pos < this.typeListeners.length) {
|
||||
if (this.typeListeners[pos] == aListener)
|
||||
@ -1743,8 +1948,8 @@ var AddonManagerPrivate = {
|
||||
AddonManagerInternal.removeStartupChange(aType, aID);
|
||||
},
|
||||
|
||||
notifyAddonChanged: function AMP_notifyAddonChanged(aId, aType, aPendingRestart) {
|
||||
AddonManagerInternal.notifyAddonChanged(aId, aType, aPendingRestart);
|
||||
notifyAddonChanged: function AMP_notifyAddonChanged(aID, aType, aPendingRestart) {
|
||||
AddonManagerInternal.notifyAddonChanged(aID, aType, aPendingRestart);
|
||||
},
|
||||
|
||||
updateAddonAppDisabledStates: function AMP_updateAddonAppDisabledStates() {
|
||||
@ -1949,16 +2154,16 @@ var AddonManager = {
|
||||
return AddonManagerInternal.startupChanges[aType].slice(0);
|
||||
},
|
||||
|
||||
getAddonByID: function AM_getAddonByID(aId, aCallback) {
|
||||
AddonManagerInternal.getAddonByID(aId, aCallback);
|
||||
getAddonByID: function AM_getAddonByID(aID, aCallback) {
|
||||
AddonManagerInternal.getAddonByID(aID, aCallback);
|
||||
},
|
||||
|
||||
getAddonBySyncGUID: function AM_getAddonBySyncGUID(aId, aCallback) {
|
||||
AddonManagerInternal.getAddonBySyncGUID(aId, aCallback);
|
||||
getAddonBySyncGUID: function AM_getAddonBySyncGUID(aGUID, aCallback) {
|
||||
AddonManagerInternal.getAddonBySyncGUID(aGUID, aCallback);
|
||||
},
|
||||
|
||||
getAddonsByIDs: function AM_getAddonsByIDs(aIds, aCallback) {
|
||||
AddonManagerInternal.getAddonsByIDs(aIds, aCallback);
|
||||
getAddonsByIDs: function AM_getAddonsByIDs(aIDs, aCallback) {
|
||||
AddonManagerInternal.getAddonsByIDs(aIDs, aCallback);
|
||||
},
|
||||
|
||||
getAddonsWithOperationsByTypes:
|
||||
@ -2031,7 +2236,18 @@ var AddonManager = {
|
||||
return AddonManagerInternal.addonTypes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Determines whether an Addon should auto-update or not.
|
||||
*
|
||||
* @param aAddon
|
||||
* The Addon representing the add-on
|
||||
* @return true if the addon should auto-update, false otherwise.
|
||||
*/
|
||||
shouldAutoUpdate: function AM_shouldAutoUpdate(aAddon) {
|
||||
if (!aAddon || typeof aAddon != "object")
|
||||
throw Components.Exception("aAddon must be specified",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
|
||||
if (!("applyBackgroundUpdates" in aAddon))
|
||||
return false;
|
||||
if (aAddon.applyBackgroundUpdates == AddonManager.AUTOUPDATE_ENABLE)
|
||||
|
@ -443,10 +443,10 @@ var gInstallingPage = {
|
||||
actionItem.value = label;
|
||||
},
|
||||
|
||||
onInstallEnded: function(aInstall) {
|
||||
onInstallEnded: function(aInstall, aAddon) {
|
||||
// Remember that this add-on was updated during startup
|
||||
AddonManagerPrivate.addStartupChange(AddonManager.STARTUP_CHANGE_CHANGED,
|
||||
aInstall.id);
|
||||
aAddon.id);
|
||||
|
||||
this.startNextInstall();
|
||||
},
|
||||
|
@ -61,7 +61,7 @@ function run_test_1() {
|
||||
var testPlugin = get_test_plugin();
|
||||
do_check_neq(testPlugin, null);
|
||||
|
||||
AddonManager.getAddonsByTypes("plugin", function(addons) {
|
||||
AddonManager.getAddonsByTypes(["plugin"], function(addons) {
|
||||
do_check_true(addons.length > 0);
|
||||
|
||||
addons.forEach(function(p) {
|
||||
|
Loading…
Reference in New Issue
Block a user