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

Unified Diff: templates/bootstrap.js.tmpl

Issue 29562599: Issue 5751 - Removing legacy gecko support (Closed)
Patch Set: Rebase against current master ( 489:293593da6033 ) Created Oct. 10, 2017, 9:25 a.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
Index: templates/bootstrap.js.tmpl
diff --git a/templates/bootstrap.js.tmpl b/templates/bootstrap.js.tmpl
deleted file mode 100644
index 42eaef49cefa9bbd87151a4dcc84310bf9b544f7..0000000000000000000000000000000000000000
--- a/templates/bootstrap.js.tmpl
+++ /dev/null
@@ -1,196 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-const Cu = Components.utils;
-
-let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
-
-Cu.importGlobalProperties(["atob", "btoa", "File", "URL",
- "TextDecoder", "TextEncoder", "XMLHttpRequest"]);
-
-let addonData = null;
-
-function startup(params, reason)
-{
- addonData = params;
-
- {%- if hasChromeRequires %}
- Services.obs.addObserver(RequireObserver, "{{metadata.get('general', 'basename')}}-require", true);
- onShutdown.add(function()
- {
- Services.obs.removeObserver(RequireObserver, "{{metadata.get('general', 'basename')}}-require");
- });
- {%- set hasShutdownHandlers = True %}
- {%- endif %}
-
- {%- if hasWebExtension %}
- let port = params.webExtension.startup().then(({browser}) =>
- {
- return new Promise((resolve, reject) =>
- {
- browser.runtime.onConnect.addListener(resolve);
- });
- });
- require.scopes.webextension = {exports: port};
- {%- endif %}
-
- require("main");
-}
-
-function shutdown(params, reason)
-{
- {%- if chromeWindows %}
- let windowNames = {{chromeWindows|json}};
- for (let i = 0; i < windowNames.length; i++)
- {
- let enumerator = Services.wm.getEnumerator(windowNames[i]);
- while (enumerator.hasMoreElements())
- {
- let window = enumerator.getNext().QueryInterface(Ci.nsIDOMWindow);
- window.setTimeout("window.close()", 0); // Closing immediately might not work due to modal windows
- try
- {
- window.close();
- } catch(e) {}
- }
- }
- {%- endif %}
-
- {%- if hasShutdownHandlers %}
- onShutdown.done = true;
- for (let i = shutdownHandlers.length - 1; i >= 0; i --)
- {
- try
- {
- shutdownHandlers[i]();
- }
- catch (e)
- {
- Cu.reportError(e);
- }
- }
- shutdownHandlers = null;
- {%- endif %}
-
- // Make sure to release our ties to the modules even if the sandbox cannot be
- // released for some reason.
- for (let key in require.scopes)
- {
- let scope = require.scopes[key];
- let list = Object.keys(scope);
- for (let i = 0; i < list.length; i++)
- scope[list[i]] = null;
- }
- require.scopes = null;
- addonData = null;
-}
-
-function install(params, reason) {}
-
-function uninstall(params, reason)
-{
- {%- if 'currentVersion' in jsonRequires.get('prefs.json', {}).get('defaults', {}) %}
- const ADDON_UNINSTALL = 6; // https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions#Reason_constants
- if (reason == ADDON_UNINSTALL)
- {
- // Users often uninstall/reinstall extension to "fix" issues. Clear current
- // version number on uninstall to rerun first-run actions in this scenario.
- Services.prefs.clearUserPref("extensions.{{metadata.get('general', 'basename')}}.currentVersion");
- }
- {%- endif %}
-}
-
-{%- if hasShutdownHandlers %}
-let shutdownHandlers = [];
-let onShutdown =
-{
- done: false,
- add: function(handler)
- {
- if (shutdownHandlers.indexOf(handler) < 0)
- shutdownHandlers.push(handler);
- },
- remove: function(handler)
- {
- let index = shutdownHandlers.indexOf(handler);
- if (index >= 0)
- shutdownHandlers.splice(index, 1);
- }
-};
-{%- endif %}
-
-function require(module)
-{
- let scopes = require.scopes;
- if (!(module in scopes))
- {
- {%- if 'info' in requires %}
- if (module == "info")
- {
- let applications = {{applications|json}};
- let appInfo = Services.appinfo;
-
- scopes[module] = {};
- scopes[module].exports =
- {
- addonID: addonData.id,
- addonVersion: addonData.version,
- addonRoot: addonData.resourceURI.spec,
- addonName: "{{metadata.get('general', 'basename')}}",
- application: (appInfo.ID in applications ? applications[appInfo.ID] : "other"),
- applicationVersion: appInfo.version,
- platform: "gecko",
- platformVersion: appInfo.platformVersion
- };
- }
- else
- {
- {%- endif %}
- let url = addonData.resourceURI.spec + "lib/" + module + ".js";
- scopes[module] = {
- Cc, Ci, Cr, Cu, atob, btoa, File, URL, TextDecoder, TextEncoder,
- XMLHttpRequest, require,
- {% if hasShutdownHandlers %}
- onShutdown,
- {% endif %}
- exports: {}};
- {%- if multicompartment %}
- let principal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrincipal);
- scopes[module] = new Cu.Sandbox(principal, {
- sandboxName: url,
- sandboxPrototype: scopes[module],
- wantXrays: false
- });
- {%- endif %}
- Services.scriptloader.loadSubScript(url, scopes[module]);
- {%- if 'info' in requires %}
- }
- {%- endif %}
- }
- return scopes[module].exports;
-}
-require.scopes = Object.create(null);
-{%- for name, data in jsonRequires.iteritems() %}
-require.scopes[{{name|json}}] = {exports: {{data|json}}};
-{%- endfor %}
-
-{%- if hasChromeRequires %}
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-let RequireObserver =
-{
- observe: function(subject, topic, data)
- {
- if (topic == "{{metadata.get('general', 'basename')}}-require")
- {
- subject.wrappedJSObject.exports = require(data);
- }
- },
-
- QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObserver])
-};
-{%- endif %}
« build.py ('K') | « releaseAutomation.py ('k') | templates/install.rdf.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld