[Pkg-mozext-commits] [adblock-plus] 240/464: Hack: Clear currentVersion pref on uninstall. This cannot be done in the shutdown handler due to bug 620541, and uninstall handler runs on a new scope which means that handlers registered by modules are no longer available.
David Prévot
taffit at moszumanska.debian.org
Tue Jul 22 20:44:21 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus.
commit 7afcb0bb980a8de24bec1d0374369269b67a3635
Author: Wladimir Palant <trev at adblockplus.org>
Date: Thu Jun 14 16:08:35 2012 +0200
Hack: Clear currentVersion pref on uninstall.
This cannot be done in the shutdown handler due to bug 620541, and uninstall handler runs on a new scope which means that handlers registered by modules are no longer available.
---
bootstrap.js.tmpl | 18 +++++++++++++++---
packager.py | 4 ++++
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/bootstrap.js.tmpl b/bootstrap.js.tmpl
index 33577c9..360a9e7 100644
--- a/bootstrap.js.tmpl
+++ b/bootstrap.js.tmpl
@@ -13,9 +13,6 @@ Cu.import("resource://gre/modules/Services.jsm");
let addonData = null;
-function install(params, reason) {}
-function uninstall(params, reason) {}
-
function startup(params, reason)
{
addonData = params;
@@ -73,6 +70,21 @@ function shutdown(params, reason)
{%- endif %}
}
+function install(params, reason) {}
+
+function uninstall(params, reason)
+{
+ {%- if hasVersionPref %}
+ const ADDON_UNINSTALL = 6; // https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions#Reason_constants
+ if (reason == ADDON_UNINSTALL)
+ {
+ // Users often uninstall/reinstall extension to "fix" issues. Clear current
+ // version number on uninstall to rerun first-run actions in this scenario.
+ Services.prefs.clearUserPref("extensions.{{metadata.get('general', 'basename')}}.currentVersion");
+ }
+ {%- endif %}
+}
+
{%- if hasShutdownHandlers %}
let shutdownHandlers = [];
let onShutdown =
diff --git a/packager.py b/packager.py
index b8a8c72..afc744c 100644
--- a/packager.py
+++ b/packager.py
@@ -225,6 +225,7 @@ def addMissingFiles(baseDir, params, files):
'hasChrome': False,
'hasChromeRequires': False,
'hasShutdownHandlers': False,
+ 'hasVersionPref': False,
'chromeWindows': [],
'requires': {},
'metadata': params['metadata'],
@@ -237,6 +238,9 @@ def addMissingFiles(baseDir, params, files):
templateData['requires'][match.group(1)] = True
if name.startswith('chrome/content/'):
templateData['hasChromeRequires'] = True
+ if name == 'defaults/preferences/prefs.js':
+ if re.search(r'\.currentVersion"', content):
+ templateData['hasVersionPref'] = True
if not '/' in name:
if re.search(r'(?:^|\s)onShutdown\.', content):
templateData['hasShutdownHandlers'] = True
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git
More information about the Pkg-mozext-commits
mailing list