Bug 1466349 part 1 - Enable passing addonData flags to embedded WE,
also fix permission matcher creation in child process
MozReview-Commit-ID: Ht9rEKwaUsp
--- a/toolkit/components/extensions/LegacyExtensionsUtils.jsm
+++ b/toolkit/components/extensions/LegacyExtensionsUtils.jsm
@@ -122,31 +122,38 @@ class EmbeddedExtension {
this.started = false;
}
/**
* Start the embedded webextension.
*
* @param {number} reason
* The add-on startup bootstrap reason received from the XPIProvider.
+ * @param {object} [addonData]
+ * Additional data to pass to the Extension constructor.
*
* @returns {Promise<LegacyContextAPI>} A promise which resolve to the API exposed to the
* legacy context.
*/
- startup(reason) {
+ startup(reason, addonData = {}) {
if (this.started) {
return Promise.reject(new Error("This embedded extension has already been started"));
}
// Setup the startup promise.
this.startupPromise = new Promise((resolve, reject) => {
let embeddedExtensionURI = Services.io.newURI("webextension/", null, this.resourceURI);
+ let {builtIn, signedState, temporarilyInstalled} = addonData;
+
// This is the instance of the WebExtension embedded in the hybrid add-on.
this.extension = new Extension({
+ builtIn,
+ signedState,
+ temporarilyInstalled,
id: this.addonId,
resourceURI: embeddedExtensionURI,
version: this.version,
});
this.extension.isEmbedded = true;
// This callback is register to the "startup" event, emitted by the Extension instance
--- a/toolkit/components/extensions/extension-process-script.js
+++ b/toolkit/components/extensions/extension-process-script.js
@@ -316,30 +316,30 @@ ExtensionManager = {
Services.cpmm.addMessageListener("Schema:Add", this);
}
},
initExtensionPolicy(extension) {
let policy = WebExtensionPolicy.getByID(extension.id);
if (!policy) {
let localizeCallback, allowedOrigins, webAccessibleResources;
+ let restrictSchemes = !extension.permissions.has("mozillaAddons");
+
if (extension.localize) {
// We have a real Extension object.
localizeCallback = extension.localize.bind(extension);
allowedOrigins = extension.whiteListedHosts;
webAccessibleResources = extension.webAccessibleResources;
} else {
// We have serialized extension data;
localizeCallback = str => extensions.get(policy).localize(str);
- allowedOrigins = new MatchPatternSet(extension.whiteListedHosts);
+ allowedOrigins = new MatchPatternSet(extension.whiteListedHosts, {restrictSchemes});
webAccessibleResources = extension.webAccessibleResources.map(host => new MatchGlob(host));
}
- let restrictSchemes = !extension.permissions.has("mozillaAddons");
-
policy = new WebExtensionPolicy({
id: extension.id,
mozExtensionHostname: extension.uuid,
name: extension.name,
baseURL: extension.resourceURL,
permissions: Array.from(extension.permissions),
allowedOrigins,