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 feedback Created Dec. 10, 2015, 2:27 p.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 | « chrome/ext/common.js ('k') | metadata.common » ('j') | safari/ext/common.js » ('J')
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..89d6b7d3937e038c6ea538d1b4864d4acd8af9ea
--- /dev/null
+++ b/lib/uninstall.js
@@ -0,0 +1,58 @@
+/*
+ * 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");
+let {Utils} = require("utils");
+
+const uninstallURL = Utils.getDocLink("uninstall-abp");
Sebastian Noack 2015/12/12 00:31:08 IMO, there is no point in caching this into a glob
kzar 2015/12/12 10:25:40 Done.
+
+function setUninstallURL()
+{
+ let info = require("info");
+ let search = [];
+ for (let key of ["addonName", "addonVersion", "application",
+ "applicationVersion", "platform", "platformVersion"])
+ search.push(key + "=" + encodeURIComponent(info[key]));
+
+ search.push("appLocale=" + encodeURIComponent(Utils.appLocale));
Sebastian Noack 2015/12/12 00:31:08 Note that the URL returned by Utils.getDocLink() a
kzar 2015/12/12 10:25:40 OK, updated the issues accordingly and Done.
+
+ let downlCount = Prefs.notificationdata.downloadCount || 0;
+ search.push("notificationDownloadCount=" + encodeURIComponent(downlCount));
+
+ ext.setUninstallURL(uninstallURL + "&" + 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. (But we're not sure if they have already been loaded so we have to do
Sebastian Noack 2015/12/12 00:31:08 Actually we know that prefs haven't been loaded ye
kzar 2015/12/12 10:25:40 Done.
+// it immediately too!) We also need to re-generate the URL each time the
+// notification data changes
+setUninstallURL();
+Prefs.onLoaded.addListener(onPrefsLoaded);
+Prefs.onChanged.addListener(function(name)
+{
+ if (name == "notificationdata")
+ setUninstallURL();
+});
« no previous file with comments | « chrome/ext/common.js ('k') | metadata.common » ('j') | safari/ext/common.js » ('J')

Powered by Google App Engine
This is Rietveld