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

Side by Side Diff: templates/bootstrap.js.tmpl

Issue 29397581: Issue 5049 - Allow embedded WebExtensions in gecko packager (Closed) Base URL: https://hg.adblockplus.org/buildtools/
Patch Set: Created March 29, 2017, 9:56 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « packagerGecko.py ('k') | templates/install.rdf.tmpl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 const Cc = Components.classes; 5 const Cc = Components.classes;
6 const Ci = Components.interfaces; 6 const Ci = Components.interfaces;
7 const Cr = Components.results; 7 const Cr = Components.results;
8 const Cu = Components.utils; 8 const Cu = Components.utils;
9 9
10 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); 10 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
11 11
12 Cu.importGlobalProperties(["atob", "btoa", "File", "URL", 12 Cu.importGlobalProperties(["atob", "btoa", "File", "URL",
13 "TextDecoder", "TextEncoder", "XMLHttpRequest"]); 13 "TextDecoder", "TextEncoder", "XMLHttpRequest"]);
14 14
15 let addonData = null; 15 let addonData = null;
16 16
17 function startup(params, reason) 17 function startup(params, reason)
18 { 18 {
19 addonData = params; 19 addonData = params;
20 20
21 {%- if hasChromeRequires %} 21 {%- if hasChromeRequires %}
22 Services.obs.addObserver(RequireObserver, "{{metadata.get('general', 'basename ')}}-require", true); 22 Services.obs.addObserver(RequireObserver, "{{metadata.get('general', 'basename ')}}-require", true);
23 onShutdown.add(function() 23 onShutdown.add(function()
24 { 24 {
25 Services.obs.removeObserver(RequireObserver, "{{metadata.get('general', 'bas ename')}}-require"); 25 Services.obs.removeObserver(RequireObserver, "{{metadata.get('general', 'bas ename')}}-require");
26 }); 26 });
27 {%- set hasShutdownHandlers = True %} 27 {%- set hasShutdownHandlers = True %}
28 {%- endif %} 28 {%- endif %}
29 29
30 {%- if hasWebExtension %}
31 let port = params.webExtension.startup().then(({browser}) =>
32 {
33 return new Promise((resolve, reject) =>
34 {
35 browser.runtime.onConnect.addListener(resolve);
36 });
37 });
38 require.scopes.webextension = {exports: port};
39 {%- endif %}
40
30 require("main"); 41 require("main");
31 } 42 }
32 43
33 function shutdown(params, reason) 44 function shutdown(params, reason)
34 { 45 {
35 {%- if chromeWindows %} 46 {%- if chromeWindows %}
36 let windowNames = {{chromeWindows|json}}; 47 let windowNames = {{chromeWindows|json}};
37 for (let i = 0; i < windowNames.length; i++) 48 for (let i = 0; i < windowNames.length; i++)
38 { 49 {
39 let enumerator = Services.wm.getEnumerator(windowNames[i]); 50 let enumerator = Services.wm.getEnumerator(windowNames[i]);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 { 187 {
177 if (topic == "{{metadata.get('general', 'basename')}}-require") 188 if (topic == "{{metadata.get('general', 'basename')}}-require")
178 { 189 {
179 subject.wrappedJSObject.exports = require(data); 190 subject.wrappedJSObject.exports = require(data);
180 } 191 }
181 }, 192 },
182 193
183 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver]) 194 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver])
184 }; 195 };
185 {%- endif %} 196 {%- endif %}
OLDNEW
« no previous file with comments | « packagerGecko.py ('k') | templates/install.rdf.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld