Bug 1308295 part 1: rename permHandler -> promptHandler r=rhelmer

MozReview-Commit-ID: 7IJaxeLXqBb

--HG--
extra : rebase_source : c81ffc5b0c30d999a45fd3c9d4792927b036a94f
This commit is contained in:
Andrew Swan 2016-12-30 07:52:23 -08:00
Родитель 810d3afda5
Коммит e0d3b0aa71
3 изменённых файлов: 21 добавлений и 21 удалений

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

@ -3016,7 +3016,7 @@ var AddonManagerInternal = {
return AddonManagerInternal.getInstallForURL(options.url, "application/x-xpinstall",
options.hash).then(install => {
if (Preferences.get(PREF_WEBEXT_PREF_PROMPTS, false)) {
install._permHandler = info => new Promise((resolve, reject) => {
install.promptHandler = info => new Promise((resolve, reject) => {
const observer = {
observe(subject, topic, data) {
if (topic == "webextension-permission-response" &&
@ -3308,10 +3308,10 @@ this.AddonManager = {
["STATE_DOWNLOADED", 3],
// The download failed.
["STATE_DOWNLOAD_FAILED", 4],
// The install may not proceed until the user accepts permissions
["STATE_AWAITING_PERMISSIONS", 5],
// Any permission prompts are done
["STATE_PERMISSION_GRANTED", 6],
// The install may not proceed until the user accepts a prompt
["STATE_AWAITING_PROMPT", 5],
// Any prompts are done
["STATE_PROMPTS_DONE", 6],
// The install has been postponed.
["STATE_POSTPONED", 7],
// The install is ready to be applied.

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

@ -5294,8 +5294,8 @@ class AddonInstall {
* Optional icons for the add-on
* @param options.version
* An optional version for the add-on
* @param options.permHandler
* A callback to present permissions to the user before installing.
* @param options.promptHandler
* A callback to prompt the user before installing.
*/
constructor(installLocation, url, options = {}) {
this.wrapper = new AddonInstallWrapper(this);
@ -5311,7 +5311,7 @@ class AddonInstall {
}
this.hash = this.originalHash;
this.existingAddon = options.existingAddon || null;
this.permHandler = options.permHandler || (() => Promise.resolve());
this.promptHandler = options.promptHandler || (() => Promise.resolve());
this.releaseNotesURI = null;
this.listeners = [];
@ -5351,9 +5351,9 @@ class AddonInstall {
install() {
switch (this.state) {
case AddonManager.STATE_DOWNLOADED:
this.checkPermissions();
this.checkPrompt();
break;
case AddonManager.STATE_PERMISSION_GRANTED:
case AddonManager.STATE_PROMPTS_DONE:
this.checkForBlockers();
break;
case AddonManager.STATE_READY:
@ -5619,9 +5619,9 @@ class AddonInstall {
* STATE_DOWNLOADED (which actually means that the file is available
* and has been verified).
*/
checkPermissions() {
checkPrompt() {
Task.spawn((function*() {
if (this.permHandler) {
if (this.promptHandler) {
let info = {
existingAddon: this.existingAddon ? this.existingAddon.wrapper : null,
addon: this.addon.wrapper,
@ -5629,9 +5629,9 @@ class AddonInstall {
};
try {
yield this.permHandler(info);
yield this.promptHandler(info);
} catch (err) {
logger.info(`Install of ${this.addon.id} cancelled since user declined permissions`);
logger.info(`Install of ${this.addon.id} cancelled by user`);
this.state = AddonManager.STATE_CANCELLED;
XPIProvider.removeActiveInstall(this);
AddonManagerPrivate.callInstallListeners("onInstallCancelled",
@ -5639,7 +5639,7 @@ class AddonInstall {
return;
}
}
this.state = AddonManager.STATE_PERMISSION_GRANTED;
this.state = AddonManager.STATE_PROMPTS_DONE;
this.install();
}).bind(this));
}
@ -6091,8 +6091,8 @@ class DownloadAddonInstall extends AddonInstall {
* Optional icons for the add-on
* @param options.version
* An optional version for the add-on
* @param options.permHandler
* A callback to present permissions to the user before installing.
* @param options.promptHandler
* A callback to prompt the user before installing.
*/
constructor(installLocation, url, options = {}) {
super(installLocation, url, options);
@ -6607,8 +6607,8 @@ AddonInstallWrapper.prototype = {
return installFor(this).sourceURI;
},
set _permHandler(handler) {
installFor(this).permHandler = handler;
set promptHandler(handler) {
installFor(this).promptHandler = handler;
},
install() {

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

@ -492,7 +492,7 @@ add_task(function* test_permissions() {
let install = yield AddonManager.getInstallForFile(xpi);
let perminfo;
install._permHandler = info => {
install.promptHandler = info => {
perminfo = info;
return Promise.resolve();
};
@ -530,7 +530,7 @@ add_task(function* test_permissions() {
let install = yield AddonManager.getInstallForFile(xpi);
let perminfo;
install._permHandler = info => {
install.promptHandler = info => {
perminfo = info;
return Promise.reject();
};