Bug 1466349 part 1 - Enable passing addonData flags to embedded WE, r=aswan

also fix permission matcher creation in child process

MozReview-Commit-ID: Ht9rEKwaUsp

--HG--
extra : rebase_source : 196f52ca686ddf9e8eb83ad2e20f4dd5ebb8d544
This commit is contained in:
Tomislav Jovanovic 2018-06-05 20:26:24 +02:00
Родитель 3c11fadbc1
Коммит 1a7e5aae66
2 изменённых файлов: 11 добавлений и 4 удалений

Просмотреть файл

@ -127,11 +127,13 @@ class EmbeddedExtension {
*
* @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"));
}
@ -140,8 +142,13 @@ class EmbeddedExtension {
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,

Просмотреть файл

@ -321,6 +321,8 @@ ExtensionManager = {
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);
@ -329,12 +331,10 @@ ExtensionManager = {
} 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,