Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/uninstall.js

Issue 29332492: Issue 3269 - Display uninstallation page when uninstalled (Closed)
Patch Set: Addressed further comments Created Dec. 12, 2015, 10:16 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | metadata.common » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/uninstall.js
diff --git a/lib/uninstall.js b/lib/uninstall.js
new file mode 100644
index 0000000000000000000000000000000000000000..ab40d761a5bda0a8fa53beb8d0e5dc9a5c438ef0
--- /dev/null
+++ b/lib/uninstall.js
@@ -0,0 +1,52 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+/** @module uninstall */
+
+let {Prefs} = require("prefs");
+
+function setUninstallURL()
+{
+ let info = require("info");
+ let search = [];
+ for (let key of ["addonName", "addonVersion", "application",
Sebastian Noack 2015/12/12 13:43:27 I just rembered that jshydra generates quite crapp
kzar 2015/12/12 14:13:43 Done.
+ "applicationVersion", "platform", "platformVersion"])
+ search.push(key + "=" + encodeURIComponent(info[key]));
+
+ let downlCount = Prefs.notificationdata.downloadCount || 0;
+ search.push("notificationDownloadCount=" + encodeURIComponent(downlCount));
+
+ chrome.runtime.setUninstallURL(
+ require("utils").Utils.getDocLink("uninstall-abp") + "&" + search.join("&")
Sebastian Noack 2015/12/12 13:43:27 As mentioned in the issue, I think we should just
Sebastian Noack 2015/12/12 13:43:27 I'd rather keep imports at the top, even if only u
kzar 2015/12/12 14:13:43 Done.
kzar 2015/12/12 14:13:43 Done. (Provisionally, if they disagree on the issu
+ );
+}
+
+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.
+Prefs.onLoaded.addListener(onPrefsLoaded);
+Prefs.onChanged.addListener(function(name)
+{
+ if (name == "notificationdata")
+ setUninstallURL();
+});
« no previous file with comments | « no previous file | metadata.common » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld