Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 /** @module uninstall */ | 18 /** @module uninstall */ |
19 | 19 |
20 let info = require("info"); | |
20 let {Prefs} = require("prefs"); | 21 let {Prefs} = require("prefs"); |
21 let {Utils} = require("utils"); | 22 let {Utils} = require("utils"); |
22 | 23 |
23 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.
| |
24 | |
25 function setUninstallURL() | 24 function setUninstallURL() |
26 { | 25 { |
27 let info = require("info"); | |
28 let search = []; | 26 let search = []; |
29 for (let key of ["addonName", "addonVersion", "application", | 27 let keys = ["addonName", "addonVersion", "application", "applicationVersion", |
30 "applicationVersion", "platform", "platformVersion"]) | 28 "platform", "platformVersion"]; |
29 for (let key of keys) | |
31 search.push(key + "=" + encodeURIComponent(info[key])); | 30 search.push(key + "=" + encodeURIComponent(info[key])); |
32 | |
33 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.
| |
34 | 31 |
35 let downlCount = Prefs.notificationdata.downloadCount || 0; | 32 let downlCount = Prefs.notificationdata.downloadCount || 0; |
36 search.push("notificationDownloadCount=" + encodeURIComponent(downlCount)); | 33 search.push("notificationDownloadCount=" + encodeURIComponent(downlCount)); |
37 | 34 |
38 ext.setUninstallURL(uninstallURL + "&" + search.join("&")); | 35 chrome.runtime.setUninstallURL(Utils.getDocLink("uninstalled") + "&" + |
36 search.join("&")); | |
39 } | 37 } |
40 | 38 |
41 function onPrefsLoaded() | 39 function onPrefsLoaded() |
42 { | 40 { |
43 Prefs.onLoaded.removeListener(onPrefsLoaded); | 41 Prefs.onLoaded.removeListener(onPrefsLoaded); |
44 setUninstallURL(); | 42 setUninstallURL(); |
45 } | 43 } |
46 | 44 |
47 // The uninstall URL contains the notification download count as a parameter, | 45 // The uninstall URL contains the notification download count as a parameter, |
48 // therefore we must wait for preferences to be loaded before generating the | 46 // therefore we must wait for preferences to be loaded before generating the |
49 // URL. (But we're not sure if they have already been loaded so we have to do | 47 // URL and we need to re-generate it each time the notification data changes. |
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.
| |
50 // it immediately too!) We also need to re-generate the URL each time the | 48 if ("setUninstallURL" in chrome.runtime) |
51 // notification data changes | |
52 setUninstallURL(); | |
53 Prefs.onLoaded.addListener(onPrefsLoaded); | |
54 Prefs.onChanged.addListener(function(name) | |
55 { | 49 { |
56 if (name == "notificationdata") | 50 Prefs.onLoaded.addListener(onPrefsLoaded); |
57 setUninstallURL(); | 51 Prefs.onChanged.addListener(function(name) |
58 }); | 52 { |
53 if (name == "notificationdata") | |
54 setUninstallURL(); | |
55 }); | |
56 } | |
LEFT | RIGHT |