在uninstall
我的引导插件中,我做了一些重要的事情。我删除了它创建的所有文件和所有首选项。但是,这使用了一些服务。
这是我的一个uninstall
程序的示例:
function uninstall(aData, aReason) {
if (aReason == ADDON_UNINSTALL) { //have to put this here because uninstall fires on upgrade/downgrade too
//this is real uninstall
Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://gre/modules/devtools/Console.jsm');
Cu.import('resource://gre/modules/osfile.jsm');
//if custom images were used lets delete them now
var customImgPrefs = ['customImgIdle', 'customImgLoading'];
[].forEach.call(customImgPrefs, function(n) {
//cant check the pref i guess because its probably unintialized or deleted before i used have a `if(prefs[n].value != '') {`
//var normalized = OS.Path.normalize(prefs[n].value);
//var profRootDirLoc = OS.Path.join(OS.Constants.Path.profileDir, OS.Path.basename(normalized));
var profRootDirLoc = OS.Path.join(OS.Constants.Path.profileDir, 'throbber-restored-' + n);
var promiseDelete = OS.File.remove(profRootDirLoc);
console.log('profRootDirLoc', profRootDirLoc)
promiseDelete.then(
function() {
Services.prompt.alert(null, 'deleted', 'success on ' + n);
},
function(aRejReas) {
console.warn('Failed to delete copy of custom throbber ' + n + ' image for reason: ', aRejReas);
Services.prompt.alert(null, 'deleted', 'FAILED on ' + n);
}
);
});
Services.prefs.deleteBranch(prefPrefix);
}
我发布而不是测试的原因是因为我测试并且它有效,但是有什么特殊情况吗?就像插件被禁用,浏览器重新启动,然后用户打开插件管理器然后卸载一样。像这样的特殊情况和其他任何情况?他们是否要求我再次进口我所有的东西?