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

Unified Diff: chrome/ext/uninstall.js

Issue 29332492: Issue 3269 - Display uninstallation page when uninstalled (Closed)
Patch Set: Create ext.setUninstallURL abstraction Created Dec. 9, 2015, 3:36 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') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/ext/uninstall.js
diff --git a/chrome/ext/uninstall.js b/chrome/ext/uninstall.js
new file mode 100644
index 0000000000000000000000000000000000000000..b402c7d6b8c2b2a2d5e40106726120d31cc87221
--- /dev/null
+++ b/chrome/ext/uninstall.js
@@ -0,0 +1,57 @@
+/*
+ * 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/>.
+ */
+
+(function()
Sebastian Noack 2015/12/09 17:37:31 Once you made this a proper module the IIFE will b
kzar 2015/12/10 14:28:20 Done.
+{
+ "use strict";
+
+ let prefs = require("prefs");
Sebastian Noack 2015/12/09 17:37:31 Nit: let {Prefs} = require("prefs");
kzar 2015/12/10 14:28:20 Done.
+
+ function setUninstallURL()
+ {
+ let uninstall_url = "https://adblockplus.org/en/uninstall-abp";
Sebastian Noack 2015/12/09 17:37:31 Please use camel-case consistently.
Sebastian Noack 2015/12/09 17:37:31 Please don't hard code the language part of the UR
kzar 2015/12/10 14:28:20 Done. (Opened issue 3403 for the redirection)
kzar 2015/12/10 14:28:20 Done.
+ let module_keys = [
+ [require("info"), ["addonName", "addonVersion", "application",
+ "applicationVersion", "platform", "platformVersion"]],
+ [require("utils").Utils, ["appLocale"]]
+ ];
+
+ let search = [];
+ for (let module_key of module_keys)
+ for (let key of module_key[1])
+ if (key in module_key[0])
Sebastian Noack 2015/12/09 17:37:31 I don't see why that check would be necessary.
kzar 2015/12/10 14:28:20 Done.
+ search.push(key + "=" + encodeURIComponent(module_key[0][key]));
+
+ let downlCount = prefs.Prefs.notificationdata.downloadCount || 0;
+ search.push("notificationDownloadCount=" + encodeURIComponent(downlCount));
Sebastian Noack 2015/12/09 17:37:31 You could simplify the loop above if you just hand
kzar 2015/12/10 14:28:20 Done.
+
+ ext.setUninstallURL(uninstall_url + "?" + search.join("&"));
+ }
+
+ // 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
+ // it immediately too!) We also need to re-generate the URL each time the
+ // notification data changes
+ setUninstallURL();
+ prefs.Prefs.onLoaded.addListener(setUninstallURL);
Sebastian Noack 2015/12/09 17:37:31 You should remove the listener once it has been ca
kzar 2015/12/10 14:28:20 Done.
+ prefs.Prefs.onChanged.addListener(function(name)
+ {
+ if (name == "notificationdata")
+ setUninstallURL();
+ });
+}());
« no previous file with comments | « chrome/ext/common.js ('k') | metadata.common » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld