Index: lib/uninstall.js
diff --git a/lib/uninstall.js b/lib/uninstall.js
new file mode 100644
index 0000000000000000000000000000000000000000..a083dc750378aff730d07531ed05009106f088c7
--- /dev/null
+++ b/lib/uninstall.js
@@ -0,0 +1,56 @@
+/*
+ * This file is part of Adblock Plus ,
+ * Copyright (C) 2006-2015 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see .
+ */
+
+/** @module uninstall */
+
+let info = require("info");
+let {Prefs} = require("prefs");
+let {Utils} = require("utils");
+
+function setUninstallURL()
+{
+ let search = [];
+ let keys = ["addonName", "addonVersion", "application", "applicationVersion",
+ "platform", "platformVersion"];
+ for (let key of keys)
+ search.push(key + "=" + encodeURIComponent(info[key]));
+
+ let downlCount = Prefs.notificationdata.downloadCount || 0;
+ search.push("notificationDownloadCount=" + encodeURIComponent(downlCount));
+
+ chrome.runtime.setUninstallURL(Utils.getDocLink("uninstalled") + "&" +
+ search.join("&"));
+}
+
+function onPrefsLoaded()
+{
+ Prefs.onLoaded.removeListener(onPrefsLoaded);
+ setUninstallURL();
+}
+
+// The uninstall URL contains the notification download count as a parameter,
+// therefore we must wait for preferences to be loaded before generating the
+// URL and we need to re-generate it each time the notification data changes.
+if ("setUninstallURL" in chrome.runtime)
+{
+ Prefs.onLoaded.addListener(onPrefsLoaded);
+ Prefs.onChanged.addListener(function(name)
+ {
+ if (name == "notificationdata")
+ setUninstallURL();
+ });
+}
Index: metadata.common
diff --git a/metadata.common b/metadata.common
index 8d189a516a6332ed402a8d60f20fd986f036d4bd..03e6c4890b7bc1a0410e18358d1610b32eea2bdc 100644
--- a/metadata.common
+++ b/metadata.common
@@ -92,6 +92,7 @@ lib/adblockplus.js = lib/prefs.js
lib/filterComposer.js
lib/icon.js
lib/notificationHelper.js
+ lib/uninstall.js
--arg module=true source_repo=https://hg.adblockplus.org/adblockplus/
ext/common.js = ext/common.js chrome/ext/common.js
ext/background.js = ext/background.js chrome/ext/background.js --arg brace_style=expand
Index: metadata.safari
diff --git a/metadata.safari b/metadata.safari
index 5c7b26691e97fb22a30dc5549507c91cce27ce5f..86c23447fa1f001c873ce146d39c18c81c6b5fbf 100644
--- a/metadata.safari
+++ b/metadata.safari
@@ -19,6 +19,7 @@ Icon.png = adblockplusui/skin/abp-128.png
[convert_js]
ext/common.js = ext/common.js safari/ext/common.js
ext/background.js = ext/background.js safari/ext/background.js --arg brace_style=expand
+lib/adblockplus.js -= lib/uninstall.js
[popovers]
popup_filename = popup.html