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

Delta Between Two Patch Sets: lib/child/bootstrap.js

Issue 29338425: Issue 3499 - Remove old messaging API (Closed)
Left Patch Set: Created March 16, 2016, 12:33 p.m.
Right Patch Set: Use URLSearchParams Created March 23, 2016, 3:26 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | lib/main.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 (function() 18 (function()
19 { 19 {
20 const Cc = Components.classes; 20 const Cc = Components.classes;
21 const Ci = Components.interfaces; 21 const Ci = Components.interfaces;
22 const Cr = Components.results; 22 const Cr = Components.results;
23 const Cu = Components.utils; 23 const Cu = Components.utils;
24 24
25 let {Loader, main, unload} = Cu.import("resource://gre/modules/commonjs/toolki t/loader.js", {}); 25 let {Loader, main, unload} = Cu.import("resource://gre/modules/commonjs/toolki t/loader.js", {});
26 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); 26 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
27 27
28 Cu.importGlobalProperties(["atob", "btoa", "File", "URL", "URLSearchParams",
29 "TextDecoder", "TextEncoder"]);
Wladimir Palant 2016/03/23 15:29:33 Added quite a few more classes here, for consisten
30
28 let shutdownHandlers = []; 31 let shutdownHandlers = [];
29 let onShutdown = 32 let onShutdown =
30 { 33 {
31 done: false, 34 done: false,
32 add: function(handler) 35 add: function(handler)
33 { 36 {
34 if (shutdownHandlers.indexOf(handler) < 0) 37 if (shutdownHandlers.indexOf(handler) < 0)
35 shutdownHandlers.push(handler); 38 shutdownHandlers.push(handler);
36 }, 39 },
37 remove: function(handler) 40 remove: function(handler)
38 { 41 {
39 let index = shutdownHandlers.indexOf(handler); 42 let index = shutdownHandlers.indexOf(handler);
40 if (index >= 0) 43 if (index >= 0)
41 shutdownHandlers.splice(index, 1); 44 shutdownHandlers.splice(index, 1);
42 } 45 }
43 }; 46 };
44 47
45 function init(info) 48 function init()
46 { 49 {
50 let url = new URL(Components.stack.filename);
51 let params = new URLSearchParams(url.search.substr(1));
52 let info = JSON.parse(params.get("info"));
53
47 let loader = Loader({ 54 let loader = Loader({
48 paths: { 55 paths: {
49 "": info.addonRoot + "lib/" 56 "": info.addonRoot + "lib/"
50 }, 57 },
51 globals: { 58 globals: {
52 Components, Cc, Ci, Cu, Cr, atob, btoa, onShutdown 59 Components, Cc, Ci, Cu, Cr, atob, btoa, File, URL, URLSearchParams,
60 TextDecoder, TextEncoder, onShutdown
53 }, 61 },
54 modules: {"info": info, "messageManager": this}, 62 modules: {"info": info, "messageManager": this},
55 id: info.addonID 63 id: info.addonID
56 }); 64 });
57 onShutdown.add(() => unload(loader, "disable")) 65 onShutdown.add(() => unload(loader, "disable"))
58 66
59 main(loader, "child/main"); 67 main(loader, "child/main");
60 } 68 }
61 69
62 function shutdown(message) 70 function shutdown(message)
(...skipping 15 matching lines...) Expand all
78 shutdownHandlers = null; 86 shutdownHandlers = null;
79 } 87 }
80 } 88 }
81 89
82 addMessageListener("AdblockPlus:Shutdown", shutdown); 90 addMessageListener("AdblockPlus:Shutdown", shutdown);
83 onShutdown.add(() => 91 onShutdown.add(() =>
84 { 92 {
85 removeMessageListener("AdblockPlus:Shutdown", shutdown); 93 removeMessageListener("AdblockPlus:Shutdown", shutdown);
86 }); 94 });
87 95
88 let param = Components.stack.filename.split("#", 2)[1]; 96 init();
89 init(JSON.parse(decodeURIComponent(param)));
90 })(); 97 })();
LEFTRIGHT
« no previous file | lib/main.js » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld