зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1197420 Part 2 Extension cleanups for optional permissions r=kmag
- Convert the object used to represent permissions to the format used in the optional permissions UI (property hosts becomes origins) - Turn Extension.userPermissions into a getter MozReview-Commit-ID: Dc44DMfKjG --HG-- extra : rebase_source : e24e1b52edd3ddcd353a6407497ec4076039af03
This commit is contained in:
Родитель
f1085e3c9d
Коммит
0672fec97c
|
@ -95,7 +95,7 @@ add_task(function* () {
|
||||||
seen: false,
|
seen: false,
|
||||||
userPermissions: {
|
userPermissions: {
|
||||||
permissions: ["history"],
|
permissions: ["history"],
|
||||||
hosts: ["https://*/*"],
|
origins: ["https://*/*"],
|
||||||
},
|
},
|
||||||
iconURL: ICON_URL,
|
iconURL: ICON_URL,
|
||||||
});
|
});
|
||||||
|
@ -108,7 +108,7 @@ add_task(function* () {
|
||||||
seen: false,
|
seen: false,
|
||||||
userPermissions: {
|
userPermissions: {
|
||||||
permissions: [],
|
permissions: [],
|
||||||
hosts: [],
|
origins: [],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ add_task(function* () {
|
||||||
seen: false,
|
seen: false,
|
||||||
userPermissions: {
|
userPermissions: {
|
||||||
permissions: [],
|
permissions: [],
|
||||||
hosts: ["<all_urls>"],
|
origins: ["<all_urls>"],
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ add_task(function* () {
|
||||||
seen: false,
|
seen: false,
|
||||||
userPermissions: {
|
userPermissions: {
|
||||||
permissions: [],
|
permissions: [],
|
||||||
hosts: ["<all_urls>"],
|
origins: ["<all_urls>"],
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -220,11 +220,11 @@ this.ExtensionsUI = {
|
||||||
|
|
||||||
let bundle = Services.strings.createBundle(BROWSER_PROPERTIES);
|
let bundle = Services.strings.createBundle(BROWSER_PROPERTIES);
|
||||||
|
|
||||||
let perms = info.permissions || {hosts: [], permissions: []};
|
let perms = info.permissions || {origins: [], permissions: []};
|
||||||
|
|
||||||
// First classify our host permissions
|
// First classify our host permissions
|
||||||
let allUrls = false, wildcards = [], sites = [];
|
let allUrls = false, wildcards = [], sites = [];
|
||||||
for (let permission of perms.hosts) {
|
for (let permission of perms.origins) {
|
||||||
if (permission == "<all_urls>") {
|
if (permission == "<all_urls>") {
|
||||||
allUrls = true;
|
allUrls = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -375,20 +375,20 @@ this.ExtensionData = class {
|
||||||
// manifest. The current implementation just returns the contents
|
// manifest. The current implementation just returns the contents
|
||||||
// of the permissions attribute, if we add things like url_overrides,
|
// of the permissions attribute, if we add things like url_overrides,
|
||||||
// they should also be added here.
|
// they should also be added here.
|
||||||
userPermissions() {
|
get userPermissions() {
|
||||||
let result = {
|
let result = {
|
||||||
hosts: this.whiteListedHosts.pat,
|
origins: this.whiteListedHosts.pat,
|
||||||
apis: [...this.apiNames],
|
apis: [...this.apiNames],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Array.isArray(this.manifest.content_scripts)) {
|
if (Array.isArray(this.manifest.content_scripts)) {
|
||||||
for (let entry of this.manifest.content_scripts) {
|
for (let entry of this.manifest.content_scripts) {
|
||||||
result.hosts.push(...entry.matches);
|
result.origins.push(...entry.matches);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const EXP_PATTERN = /^experiments\.\w+/;
|
const EXP_PATTERN = /^experiments\.\w+/;
|
||||||
result.permissions = [...this.permissions]
|
result.permissions = [...this.permissions]
|
||||||
.filter(p => !result.hosts.includes(p) && !EXP_PATTERN.test(p));
|
.filter(p => !result.origins.includes(p) && !EXP_PATTERN.test(p));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,7 +401,7 @@ this.ExtensionData = class {
|
||||||
// a *.domain.com to specific-host.domain.com that's actually a
|
// a *.domain.com to specific-host.domain.com that's actually a
|
||||||
// drop in permissions but the simple test below will cause a prompt.
|
// drop in permissions but the simple test below will cause a prompt.
|
||||||
return {
|
return {
|
||||||
hosts: newPermissions.hosts.filter(perm => !oldPermissions.hosts.includes(perm)),
|
origins: newPermissions.origins.filter(perm => !oldPermissions.origins.includes(perm)),
|
||||||
permissions: newPermissions.permissions.filter(perm => !oldPermissions.permissions.includes(perm)),
|
permissions: newPermissions.permissions.filter(perm => !oldPermissions.permissions.includes(perm)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1348,7 +1348,7 @@ var AddonManagerInternal = {
|
||||||
let difference = Extension.comparePermissions(oldPerms, newPerms);
|
let difference = Extension.comparePermissions(oldPerms, newPerms);
|
||||||
|
|
||||||
// If there are no new permissions, just go ahead with the update
|
// If there are no new permissions, just go ahead with the update
|
||||||
if (difference.hosts.length == 0 && difference.permissions.length == 0) {
|
if (difference.origins.length == 0 && difference.permissions.length == 0) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -725,7 +725,7 @@ function attachUpdateHandler(install) {
|
||||||
let difference = Extension.comparePermissions(oldPerms, newPerms);
|
let difference = Extension.comparePermissions(oldPerms, newPerms);
|
||||||
|
|
||||||
// If there are no new permissions, just proceed
|
// If there are no new permissions, just proceed
|
||||||
if (difference.hosts.length == 0 && difference.permissions.length == 0) {
|
if (difference.origins.length == 0 && difference.permissions.length == 0) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1291,7 +1291,7 @@ var gViewController = {
|
||||||
doCommand(aAddon) {
|
doCommand(aAddon) {
|
||||||
if (aAddon.isWebExtension && !aAddon.seen && WEBEXT_PERMISSION_PROMPTS) {
|
if (aAddon.isWebExtension && !aAddon.seen && WEBEXT_PERMISSION_PROMPTS) {
|
||||||
let perms = aAddon.userPermissions;
|
let perms = aAddon.userPermissions;
|
||||||
if (perms.hosts.length > 0 || perms.permissions.length > 0) {
|
if (perms.origins.length > 0 || perms.permissions.length > 0) {
|
||||||
let subject = {
|
let subject = {
|
||||||
wrappedJSObject: {
|
wrappedJSObject: {
|
||||||
target: getBrowserElement(),
|
target: getBrowserElement(),
|
||||||
|
|
|
@ -1022,7 +1022,7 @@ var loadManifestFromWebManifest = Task.async(function*(aUri) {
|
||||||
addon.iconURL = null;
|
addon.iconURL = null;
|
||||||
addon.icon64URL = null;
|
addon.icon64URL = null;
|
||||||
addon.icons = manifest.icons || {};
|
addon.icons = manifest.icons || {};
|
||||||
addon.userPermissions = extension.userPermissions();
|
addon.userPermissions = extension.userPermissions;
|
||||||
|
|
||||||
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT;
|
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT;
|
||||||
|
|
||||||
|
|
|
@ -520,7 +520,7 @@ add_task(function* test_permissions_prompt() {
|
||||||
notEqual(perminfo.addon, null, "Permission info includes the new addon");
|
notEqual(perminfo.addon, null, "Permission info includes the new addon");
|
||||||
let perms = perminfo.addon.userPermissions;
|
let perms = perminfo.addon.userPermissions;
|
||||||
deepEqual(perms.permissions, ["tabs", "storage"], "API permissions are correct");
|
deepEqual(perms.permissions, ["tabs", "storage"], "API permissions are correct");
|
||||||
deepEqual(perms.hosts, ["https://*.example.com/*", "<all_urls>"], "Host permissions are correct");
|
deepEqual(perms.origins, ["https://*.example.com/*", "<all_urls>"], "Host permissions are correct");
|
||||||
deepEqual(perms.apis, ["test"], "Experiments permissions are correct");
|
deepEqual(perms.apis, ["test"], "Experiments permissions are correct");
|
||||||
|
|
||||||
let addon = yield promiseAddonByID(perminfo.addon.id);
|
let addon = yield promiseAddonByID(perminfo.addon.id);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче