2012-05-29 15:52:43 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-04-05 18:09:52 +00:00
|
|
|
|
2011-07-19 20:16:35 +00:00
|
|
|
"use strict";
|
|
|
|
|
2010-04-05 18:09:52 +00:00
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
|
2012-10-31 16:13:28 +00:00
|
|
|
this.EXPORTED_SYMBOLS = [];
|
2010-04-05 18:09:52 +00:00
|
|
|
|
|
|
|
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
2010-04-26 17:48:27 +00:00
|
|
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
2010-04-05 18:09:52 +00:00
|
|
|
|
2011-05-20 17:36:28 +00:00
|
|
|
const URI_EXTENSION_STRINGS = "chrome://mozapps/locale/extensions/extensions.properties";
|
|
|
|
const STRING_TYPE_NAME = "type.%ID%.name";
|
2013-02-15 16:12:44 +00:00
|
|
|
const LIST_UPDATED_TOPIC = "plugins-list-updated";
|
2011-05-20 17:36:28 +00:00
|
|
|
|
2012-09-15 22:17:32 +00:00
|
|
|
for (let name of ["LOG", "WARN", "ERROR"]) {
|
|
|
|
this.__defineGetter__(name, function() {
|
2010-04-26 19:14:19 +00:00
|
|
|
Components.utils.import("resource://gre/modules/AddonLogging.jsm");
|
2010-04-05 18:09:52 +00:00
|
|
|
|
2010-04-26 19:14:19 +00:00
|
|
|
LogManager.getLogger("addons.plugins", this);
|
2012-09-15 22:17:32 +00:00
|
|
|
return this[name];
|
2010-04-26 19:14:19 +00:00
|
|
|
});
|
2012-09-15 22:17:32 +00:00
|
|
|
}
|
2010-04-05 18:09:52 +00:00
|
|
|
|
2011-04-19 21:53:07 +00:00
|
|
|
function getIDHashForString(aStr) {
|
|
|
|
// return the two-digit hexadecimal code for a byte
|
|
|
|
function toHexString(charCode)
|
|
|
|
("0" + charCode.toString(16)).slice(-2);
|
|
|
|
|
|
|
|
let hasher = Cc["@mozilla.org/security/hash;1"].
|
|
|
|
createInstance(Ci.nsICryptoHash);
|
|
|
|
hasher.init(Ci.nsICryptoHash.MD5);
|
|
|
|
let stringStream = Cc["@mozilla.org/io/string-input-stream;1"].
|
|
|
|
createInstance(Ci.nsIStringInputStream);
|
|
|
|
stringStream.data = aStr ? aStr : "null";
|
|
|
|
hasher.updateFromStream(stringStream, -1);
|
|
|
|
|
|
|
|
// convert the binary hash data to a hex string.
|
|
|
|
let binary = hasher.finish(false);
|
|
|
|
let hash = [toHexString(binary.charCodeAt(i)) for (i in binary)].join("").toLowerCase();
|
|
|
|
return "{" + hash.substr(0, 8) + "-" +
|
|
|
|
hash.substr(8, 4) + "-" +
|
|
|
|
hash.substr(12, 4) + "-" +
|
|
|
|
hash.substr(16, 4) + "-" +
|
|
|
|
hash.substr(20) + "}";
|
|
|
|
}
|
|
|
|
|
2010-04-05 18:09:52 +00:00
|
|
|
var PluginProvider = {
|
|
|
|
// A dictionary mapping IDs to names and descriptions
|
|
|
|
plugins: null,
|
|
|
|
|
2012-09-15 22:17:32 +00:00
|
|
|
startup: function PL_startup() {
|
2013-02-15 16:12:44 +00:00
|
|
|
Services.obs.addObserver(this, LIST_UPDATED_TOPIC, false);
|
2012-09-15 22:17:32 +00:00
|
|
|
Services.obs.addObserver(this, AddonManager.OPTIONS_NOTIFICATION_DISPLAYED, false);
|
|
|
|
},
|
|
|
|
|
2011-04-19 21:53:07 +00:00
|
|
|
/**
|
|
|
|
* Called when the application is shutting down. Only necessary for tests
|
|
|
|
* to be able to simulate a shutdown.
|
|
|
|
*/
|
|
|
|
shutdown: function PL_shutdown() {
|
|
|
|
this.plugins = null;
|
2012-09-15 22:17:32 +00:00
|
|
|
Services.obs.removeObserver(this, AddonManager.OPTIONS_NOTIFICATION_DISPLAYED);
|
2013-02-15 16:12:44 +00:00
|
|
|
Services.obs.removeObserver(this, LIST_UPDATED_TOPIC);
|
2012-09-15 22:17:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
observe: function(aSubject, aTopic, aData) {
|
2013-02-15 16:12:44 +00:00
|
|
|
switch (aTopic) {
|
|
|
|
case AddonManager.OPTIONS_NOTIFICATION_DISPLAYED:
|
|
|
|
this.getAddonByID(aData, function PL_displayPluginInfo(plugin) {
|
|
|
|
if (!plugin)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let libLabel = aSubject.getElementById("pluginLibraries");
|
|
|
|
libLabel.textContent = plugin.pluginLibraries.join(", ");
|
|
|
|
|
|
|
|
let typeLabel = aSubject.getElementById("pluginMimeTypes"), types = [];
|
|
|
|
for (let type of plugin.pluginMimeTypes) {
|
|
|
|
let extras = [type.description.trim(), type.suffixes].
|
|
|
|
filter(function(x) x).join(": ");
|
|
|
|
types.push(type.type + (extras ? " (" + extras + ")" : ""));
|
|
|
|
}
|
|
|
|
typeLabel.textContent = types.join(",\n");
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case LIST_UPDATED_TOPIC:
|
|
|
|
if (this.plugins)
|
|
|
|
this.updatePluginList();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a PluginWrapper for a plugin object.
|
|
|
|
*/
|
|
|
|
buildWrapper: function PL_buildWrapper(aPlugin) {
|
|
|
|
return new PluginWrapper(aPlugin.id,
|
|
|
|
aPlugin.name,
|
|
|
|
aPlugin.description,
|
|
|
|
aPlugin.tags);
|
2011-04-19 21:53:07 +00:00
|
|
|
},
|
|
|
|
|
2010-04-05 18:09:52 +00:00
|
|
|
/**
|
|
|
|
* Called to get an Addon with a particular ID.
|
2010-04-28 16:42:07 +00:00
|
|
|
*
|
|
|
|
* @param aId
|
|
|
|
* The ID of the add-on to retrieve
|
|
|
|
* @param aCallback
|
|
|
|
* A callback to pass the Addon to
|
2010-04-05 18:09:52 +00:00
|
|
|
*/
|
2010-04-26 17:49:19 +00:00
|
|
|
getAddonByID: function PL_getAddon(aId, aCallback) {
|
2010-04-05 18:09:52 +00:00
|
|
|
if (!this.plugins)
|
|
|
|
this.buildPluginList();
|
|
|
|
|
2013-02-15 16:12:44 +00:00
|
|
|
if (aId in this.plugins)
|
|
|
|
aCallback(this.buildWrapper(this.plugins[aId]));
|
|
|
|
else
|
2010-04-28 16:42:07 +00:00
|
|
|
aCallback(null);
|
2010-04-05 18:09:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to get Addons of a particular type.
|
2010-04-28 16:42:07 +00:00
|
|
|
*
|
|
|
|
* @param aTypes
|
|
|
|
* An array of types to fetch. Can be null to get all types.
|
|
|
|
* @param callback
|
|
|
|
* A callback to pass an array of Addons to
|
2010-04-05 18:09:52 +00:00
|
|
|
*/
|
2010-04-28 16:42:07 +00:00
|
|
|
getAddonsByTypes: function PL_getAddonsByTypes(aTypes, aCallback) {
|
|
|
|
if (aTypes && aTypes.indexOf("plugin") < 0) {
|
|
|
|
aCallback([]);
|
2010-04-05 18:09:52 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.plugins)
|
|
|
|
this.buildPluginList();
|
|
|
|
|
|
|
|
let results = [];
|
|
|
|
|
|
|
|
for (let id in this.plugins) {
|
2010-04-26 17:49:19 +00:00
|
|
|
this.getAddonByID(id, function(aAddon) {
|
2010-04-28 16:42:07 +00:00
|
|
|
results.push(aAddon);
|
2010-04-05 18:09:52 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2010-04-28 16:42:07 +00:00
|
|
|
aCallback(results);
|
2010-04-05 18:09:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to get Addons that have pending operations.
|
2010-04-28 16:42:07 +00:00
|
|
|
*
|
|
|
|
* @param aTypes
|
|
|
|
* An array of types to fetch. Can be null to get all types
|
|
|
|
* @param aCallback
|
|
|
|
* A callback to pass an array of Addons to
|
2010-04-05 18:09:52 +00:00
|
|
|
*/
|
2010-04-26 17:49:19 +00:00
|
|
|
getAddonsWithOperationsByTypes: function PL_getAddonsWithOperationsByTypes(aTypes, aCallback) {
|
2010-04-28 16:42:07 +00:00
|
|
|
aCallback([]);
|
2010-04-05 18:09:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to get the current AddonInstalls, optionally restricting by type.
|
2010-04-28 16:42:07 +00:00
|
|
|
*
|
|
|
|
* @param aTypes
|
|
|
|
* An array of types or null to get all types
|
|
|
|
* @param aCallback
|
|
|
|
* A callback to pass the array of AddonInstalls to
|
2010-04-05 18:09:52 +00:00
|
|
|
*/
|
2010-04-26 17:49:19 +00:00
|
|
|
getInstallsByTypes: function PL_getInstallsByTypes(aTypes, aCallback) {
|
2010-04-28 16:42:07 +00:00
|
|
|
aCallback([]);
|
2010-04-05 18:09:52 +00:00
|
|
|
},
|
|
|
|
|
2013-02-15 16:12:44 +00:00
|
|
|
/**
|
|
|
|
* Builds a list of the current plugins reported by the plugin host
|
|
|
|
*
|
|
|
|
* @return a dictionary of plugins indexed by our generated ID
|
|
|
|
*/
|
|
|
|
getPluginList: function PL_getPluginList() {
|
2010-04-05 18:09:52 +00:00
|
|
|
let tags = Cc["@mozilla.org/plugin/host;1"].
|
|
|
|
getService(Ci.nsIPluginHost).
|
|
|
|
getPluginTags({});
|
|
|
|
|
2013-02-15 16:12:44 +00:00
|
|
|
let list = {};
|
|
|
|
let seenPlugins = {};
|
2012-09-15 22:17:32 +00:00
|
|
|
for (let tag of tags) {
|
2013-02-15 16:12:44 +00:00
|
|
|
if (!(tag.name in seenPlugins))
|
|
|
|
seenPlugins[tag.name] = {};
|
|
|
|
if (!(tag.description in seenPlugins[tag.name])) {
|
2011-04-19 21:53:07 +00:00
|
|
|
let plugin = {
|
2013-02-15 16:12:44 +00:00
|
|
|
id: getIDHashForString(tag.name + tag.description),
|
2012-09-15 22:17:32 +00:00
|
|
|
name: tag.name,
|
|
|
|
description: tag.description,
|
|
|
|
tags: [tag]
|
2010-04-05 18:09:52 +00:00
|
|
|
};
|
2011-04-19 21:53:07 +00:00
|
|
|
|
2013-02-15 16:12:44 +00:00
|
|
|
seenPlugins[tag.name][tag.description] = plugin;
|
|
|
|
list[plugin.id] = plugin;
|
2011-04-19 21:53:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-02-15 16:12:44 +00:00
|
|
|
seenPlugins[tag.name][tag.description].tags.push(tag);
|
2010-04-05 18:09:52 +00:00
|
|
|
}
|
2012-09-15 22:17:32 +00:00
|
|
|
}
|
2013-02-15 16:12:44 +00:00
|
|
|
|
|
|
|
return list;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds the list of known plugins from the plugin host
|
|
|
|
*/
|
|
|
|
buildPluginList: function PL_buildPluginList() {
|
|
|
|
this.plugins = this.getPluginList();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the plugins from the plugin host by comparing the current plugins
|
|
|
|
* to the last known list sending out any necessary API notifications for
|
|
|
|
* changes.
|
|
|
|
*/
|
|
|
|
updatePluginList: function PL_updatePluginList() {
|
|
|
|
let newList = this.getPluginList();
|
|
|
|
|
|
|
|
let lostPlugins = [this.buildWrapper(this.plugins[id])
|
|
|
|
for each (id in Object.keys(this.plugins)) if (!(id in newList))];
|
|
|
|
let newPlugins = [this.buildWrapper(newList[id])
|
|
|
|
for each (id in Object.keys(newList)) if (!(id in this.plugins))];
|
|
|
|
let matchedIDs = [id for each (id in Object.keys(newList)) if (id in this.plugins)];
|
|
|
|
|
|
|
|
// The plugin host generates new tags for every plugin after a scan and
|
|
|
|
// if the plugin's filename has changed then the disabled state won't have
|
|
|
|
// been carried across, send out notifications for anything that has
|
|
|
|
// changed (see bug 830267).
|
|
|
|
let changedWrappers = [];
|
|
|
|
for (let id of matchedIDs) {
|
|
|
|
let oldWrapper = this.buildWrapper(this.plugins[id]);
|
|
|
|
let newWrapper = this.buildWrapper(newList[id]);
|
|
|
|
|
|
|
|
if (newWrapper.isActive != oldWrapper.isActive) {
|
|
|
|
AddonManagerPrivate.callAddonListeners(newWrapper.isActive ?
|
|
|
|
"onEnabling" : "onDisabling",
|
|
|
|
newWrapper, false);
|
|
|
|
changedWrappers.push(newWrapper);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Notify about new installs
|
|
|
|
for (let plugin of newPlugins) {
|
|
|
|
AddonManagerPrivate.callInstallListeners("onExternalInstall", null,
|
|
|
|
plugin, null, false);
|
|
|
|
AddonManagerPrivate.callAddonListeners("onInstalling", plugin, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Notify for any plugins that have vanished.
|
|
|
|
for (let plugin of lostPlugins)
|
|
|
|
AddonManagerPrivate.callAddonListeners("onUninstalling", plugin, false);
|
|
|
|
|
|
|
|
this.plugins = newList;
|
|
|
|
|
|
|
|
// Signal that new installs are complete
|
|
|
|
for (let plugin of newPlugins)
|
|
|
|
AddonManagerPrivate.callAddonListeners("onInstalled", plugin);
|
|
|
|
|
|
|
|
// Signal that enables/disables are complete
|
|
|
|
for (let wrapper of changedWrappers) {
|
|
|
|
AddonManagerPrivate.callAddonListeners(wrapper.isActive ?
|
|
|
|
"onEnabled" : "onDisabled",
|
|
|
|
wrapper);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Signal that uninstalls are complete
|
|
|
|
for (let plugin of lostPlugins)
|
|
|
|
AddonManagerPrivate.callAddonListeners("onUninstalled", plugin);
|
2010-04-05 18:09:52 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The PluginWrapper wraps a set of nsIPluginTags to provide the data visible to
|
|
|
|
* public callers through the API.
|
|
|
|
*/
|
2010-04-28 16:42:07 +00:00
|
|
|
function PluginWrapper(aId, aName, aDescription, aTags) {
|
|
|
|
let safedesc = aDescription.replace(/<\/?[a-z][^>]*>/gi, " ");
|
2010-04-05 18:09:52 +00:00
|
|
|
let homepageURL = null;
|
2010-04-28 16:42:07 +00:00
|
|
|
if (/<A\s+HREF=[^>]*>/i.test(aDescription))
|
|
|
|
homepageURL = /<A\s+HREF=["']?([^>"'\s]*)/i.exec(aDescription)[1];
|
2010-04-05 18:09:52 +00:00
|
|
|
|
2010-04-28 16:42:07 +00:00
|
|
|
this.__defineGetter__("id", function() aId);
|
2010-04-05 18:09:52 +00:00
|
|
|
this.__defineGetter__("type", function() "plugin");
|
2010-04-28 16:42:07 +00:00
|
|
|
this.__defineGetter__("name", function() aName);
|
2010-08-24 01:04:06 +00:00
|
|
|
this.__defineGetter__("creator", function() null);
|
2010-04-05 18:09:52 +00:00
|
|
|
this.__defineGetter__("description", function() safedesc);
|
2010-04-28 16:42:07 +00:00
|
|
|
this.__defineGetter__("version", function() aTags[0].version);
|
2010-04-05 18:09:52 +00:00
|
|
|
this.__defineGetter__("homepageURL", function() homepageURL);
|
|
|
|
|
2010-04-28 16:42:07 +00:00
|
|
|
this.__defineGetter__("isActive", function() !aTags[0].blocklisted && !aTags[0].disabled);
|
|
|
|
this.__defineGetter__("appDisabled", function() aTags[0].blocklisted);
|
|
|
|
this.__defineGetter__("userDisabled", function() aTags[0].disabled);
|
|
|
|
this.__defineSetter__("userDisabled", function(aVal) {
|
|
|
|
if (aTags[0].disabled == aVal)
|
2010-04-05 18:09:52 +00:00
|
|
|
return;
|
|
|
|
|
2013-04-09 17:45:39 +00:00
|
|
|
for (let tag of aTags)
|
|
|
|
tag.disabled = aVal;
|
2010-04-28 16:42:07 +00:00
|
|
|
AddonManagerPrivate.callAddonListeners(aVal ? "onDisabling" : "onEnabling", this, false);
|
|
|
|
AddonManagerPrivate.callAddonListeners(aVal ? "onDisabled" : "onEnabled", this);
|
|
|
|
return aVal;
|
2010-04-05 18:09:52 +00:00
|
|
|
});
|
|
|
|
|
2010-04-26 17:48:27 +00:00
|
|
|
this.__defineGetter__("blocklistState", function() {
|
|
|
|
let bs = Cc["@mozilla.org/extensions/blocklist;1"].
|
|
|
|
getService(Ci.nsIBlocklistService);
|
|
|
|
return bs.getPluginBlocklistState(aTags[0]);
|
|
|
|
});
|
|
|
|
|
2011-05-25 21:31:56 +00:00
|
|
|
this.__defineGetter__("blocklistURL", function() {
|
|
|
|
let bs = Cc["@mozilla.org/extensions/blocklist;1"].
|
|
|
|
getService(Ci.nsIBlocklistService);
|
|
|
|
return bs.getPluginBlocklistURL(aTags[0]);
|
|
|
|
});
|
|
|
|
|
2010-07-02 14:48:41 +00:00
|
|
|
this.__defineGetter__("size", function() {
|
|
|
|
function getDirectorySize(aFile) {
|
|
|
|
let size = 0;
|
|
|
|
let entries = aFile.directoryEntries.QueryInterface(Ci.nsIDirectoryEnumerator);
|
|
|
|
let entry;
|
2012-12-13 23:23:43 +00:00
|
|
|
while ((entry = entries.nextFile)) {
|
2010-07-02 14:48:41 +00:00
|
|
|
if (entry.isSymlink() || !entry.isDirectory())
|
|
|
|
size += entry.fileSize;
|
|
|
|
else
|
|
|
|
size += getDirectorySize(entry);
|
|
|
|
}
|
|
|
|
entries.close();
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
let size = 0;
|
2012-08-14 04:04:00 +00:00
|
|
|
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
2012-09-15 22:17:32 +00:00
|
|
|
for (let tag of aTags) {
|
|
|
|
file.initWithPath(tag.fullpath);
|
2010-07-02 14:48:41 +00:00
|
|
|
if (file.isDirectory())
|
|
|
|
size += getDirectorySize(file);
|
|
|
|
else
|
|
|
|
size += file.fileSize;
|
2012-09-15 22:17:32 +00:00
|
|
|
}
|
2010-07-02 14:48:41 +00:00
|
|
|
return size;
|
|
|
|
});
|
|
|
|
|
2012-09-15 22:17:32 +00:00
|
|
|
this.__defineGetter__("pluginLibraries", function() {
|
|
|
|
let libs = [];
|
|
|
|
for (let tag of aTags)
|
|
|
|
libs.push(tag.filename);
|
|
|
|
return libs;
|
|
|
|
});
|
|
|
|
|
2013-02-28 12:46:42 +00:00
|
|
|
this.__defineGetter__("pluginFullpath", function() {
|
|
|
|
let paths = [];
|
|
|
|
for (let tag of aTags)
|
|
|
|
paths.push(tag.fullpath);
|
|
|
|
return paths;
|
|
|
|
})
|
|
|
|
|
2012-09-15 22:17:32 +00:00
|
|
|
this.__defineGetter__("pluginMimeTypes", function() {
|
|
|
|
let types = [];
|
|
|
|
for (let tag of aTags)
|
|
|
|
for (let type of tag.getMimeTypes({}))
|
|
|
|
types.push(type);
|
|
|
|
return types;
|
|
|
|
});
|
|
|
|
|
2010-06-29 18:08:44 +00:00
|
|
|
this.__defineGetter__("installDate", function() {
|
|
|
|
let date = 0;
|
2012-08-14 04:04:00 +00:00
|
|
|
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
2012-09-15 22:17:32 +00:00
|
|
|
for (let tag of aTags) {
|
|
|
|
file.initWithPath(tag.fullpath);
|
2010-06-29 18:08:44 +00:00
|
|
|
date = Math.max(date, file.lastModifiedTime);
|
2012-09-15 22:17:32 +00:00
|
|
|
}
|
2010-06-29 18:08:44 +00:00
|
|
|
return new Date(date);
|
|
|
|
});
|
|
|
|
|
2010-04-26 17:48:27 +00:00
|
|
|
this.__defineGetter__("scope", function() {
|
|
|
|
let path = aTags[0].fullpath;
|
|
|
|
// Plugins inside the application directory are in the application scope
|
2012-08-14 04:04:00 +00:00
|
|
|
let dir = Services.dirsvc.get("APlugns", Ci.nsIFile);
|
2010-04-26 17:48:27 +00:00
|
|
|
if (path.substring(0, dir.path.length) == dir.path)
|
|
|
|
return AddonManager.SCOPE_APPLICATION;
|
|
|
|
|
|
|
|
// Plugins inside the profile directory are in the profile scope
|
2012-08-14 04:04:00 +00:00
|
|
|
dir = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
2010-04-26 17:48:27 +00:00
|
|
|
if (path.substring(0, dir.path.length) == dir.path)
|
|
|
|
return AddonManager.SCOPE_PROFILE;
|
|
|
|
|
|
|
|
// Plugins anywhere else in the user's home are in the user scope
|
2012-08-14 04:04:00 +00:00
|
|
|
dir = Services.dirsvc.get("Home", Ci.nsIFile);
|
2010-04-26 17:48:27 +00:00
|
|
|
if (path.substring(0, dir.path.length) == dir.path)
|
|
|
|
return AddonManager.SCOPE_USER;
|
|
|
|
|
|
|
|
// Any other locations are system scope
|
|
|
|
return AddonManager.SCOPE_SYSTEM;
|
|
|
|
});
|
|
|
|
|
2010-04-05 18:09:52 +00:00
|
|
|
this.__defineGetter__("pendingOperations", function() {
|
2010-07-26 17:34:06 +00:00
|
|
|
return AddonManager.PENDING_NONE;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.__defineGetter__("operationsRequiringRestart", function() {
|
|
|
|
return AddonManager.OP_NEEDS_RESTART_NONE;
|
2010-04-05 18:09:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.__defineGetter__("permissions", function() {
|
|
|
|
let permissions = 0;
|
|
|
|
if (!this.appDisabled) {
|
|
|
|
if (this.userDisabled)
|
|
|
|
permissions |= AddonManager.PERM_CAN_ENABLE;
|
|
|
|
else
|
|
|
|
permissions |= AddonManager.PERM_CAN_DISABLE;
|
|
|
|
}
|
|
|
|
return permissions;
|
|
|
|
});
|
2010-04-26 17:48:27 +00:00
|
|
|
}
|
2010-04-05 18:09:52 +00:00
|
|
|
|
2010-04-26 17:48:27 +00:00
|
|
|
PluginWrapper.prototype = {
|
2013-04-01 09:07:23 +00:00
|
|
|
optionsType: AddonManager.OPTIONS_TYPE_INLINE_INFO,
|
2012-09-15 22:17:32 +00:00
|
|
|
optionsURL: "chrome://mozapps/content/extensions/pluginPrefs.xul",
|
|
|
|
|
2010-06-29 18:08:44 +00:00
|
|
|
get updateDate() {
|
|
|
|
return this.installDate;
|
|
|
|
},
|
|
|
|
|
2010-04-26 17:48:27 +00:00
|
|
|
get isCompatible() {
|
|
|
|
return true;
|
|
|
|
},
|
2010-04-05 18:09:52 +00:00
|
|
|
|
2010-07-01 18:37:32 +00:00
|
|
|
get isPlatformCompatible() {
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
2010-04-26 17:48:27 +00:00
|
|
|
get providesUpdatesSecurely() {
|
|
|
|
return true;
|
|
|
|
},
|
2010-04-05 18:09:52 +00:00
|
|
|
|
2011-10-22 18:37:15 +00:00
|
|
|
get foreignInstall() {
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
2010-04-26 17:48:27 +00:00
|
|
|
isCompatibleWith: function(aAppVerison, aPlatformVersion) {
|
|
|
|
return true;
|
2010-04-05 18:09:52 +00:00
|
|
|
},
|
|
|
|
|
2010-04-26 17:48:27 +00:00
|
|
|
findUpdates: function(aListener, aReason, aAppVersion, aPlatformVersion) {
|
|
|
|
if ("onNoCompatibilityUpdateAvailable" in aListener)
|
|
|
|
aListener.onNoCompatibilityUpdateAvailable(this);
|
|
|
|
if ("onNoUpdateAvailable" in aListener)
|
|
|
|
aListener.onNoUpdateAvailable(this);
|
|
|
|
if ("onUpdateFinished" in aListener)
|
|
|
|
aListener.onUpdateFinished(this);
|
2010-04-05 18:09:52 +00:00
|
|
|
}
|
2010-04-26 17:48:27 +00:00
|
|
|
};
|
2010-04-05 18:09:52 +00:00
|
|
|
|
2011-05-20 17:36:28 +00:00
|
|
|
AddonManagerPrivate.registerProvider(PluginProvider, [
|
|
|
|
new AddonManagerPrivate.AddonType("plugin", URI_EXTENSION_STRINGS,
|
|
|
|
STRING_TYPE_NAME,
|
|
|
|
AddonManager.VIEW_TYPE_LIST, 6000)
|
|
|
|
]);
|