mirror of
https://github.com/zotero/zotero.git
synced 2026-11-27 23:58:57 +00:00
Zotero.Plugins now registers a provider with Blocklist.sys.mjs, via a shim appended by fetch_xulrunner, so the toolkit's own blocklist checks -- on install, update check, and app upgrade -- compute a plugin's state from Zotero's list. Previously, Zotero wrote the blocked state directly into the addon database, and the toolkit's checks reset it, since the RemoteSettings blocklist they consult isn't available in Zotero.
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
// Set via Blocklist.setExtensionBlocklistProvider()
|
|
var zoteroExtensionBlocklistProvider = null;
|
|
|
|
var ZoteroExtensionBlocklist = {
|
|
_initialized: true,
|
|
ensureInitialized() {},
|
|
shutdown() {},
|
|
undoShutdown() {},
|
|
_onUpdate() {},
|
|
async getEntry(addon) {
|
|
if (zoteroExtensionBlocklistProvider) {
|
|
try {
|
|
return await zoteroExtensionBlocklistProvider.getEntry(addon);
|
|
}
|
|
catch (e) {
|
|
console.error(e);
|
|
}
|
|
}
|
|
// Without a provider, echo the addon's current state so that nothing changes before
|
|
// Zotero has registered one (e.g., in the post-upgrade check at AddonManager startup)
|
|
return addon.blocklistState
|
|
&& addon.blocklistState != Ci.nsIBlocklistService.STATE_NOT_BLOCKED
|
|
? { state: addon.blocklistState, url: addon.blocklistURL || null }
|
|
: null;
|
|
},
|
|
async getState(addon) {
|
|
let entry = await this.getEntry(addon);
|
|
return entry ? entry.state : Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
|
|
},
|
|
};
|
|
Blocklist.ExtensionBlocklist = ZoteroExtensionBlocklist;
|
|
Blocklist.setExtensionBlocklistProvider = function (provider) {
|
|
zoteroExtensionBlocklistProvider = provider;
|
|
};
|