Bug 1520436 - part1 : add another tooltip text for non-promptable permission. r=flod,johannh

As non-promptable permission won't prompt user to ask for their approval, we should use different texts for the cancel button of promptable permissions.

Differential Revision: https://phabricator.services.mozilla.com/D16770

--HG--
extra : moz-landing-system : lando
This commit is contained in:
alwu 2019-01-18 18:54:54 +00:00
parent 4e6082275f
commit db9dcd21c8
3 changed files with 33 additions and 2 deletions

View File

@ -1130,7 +1130,9 @@ var gIdentityHandler = {
let button = document.createXULElement("button");
button.setAttribute("class", "identity-popup-permission-remove-button");
let tooltiptext = gNavigatorBundle.getString("permissions.remove.tooltip");
let tooltiptext = aPermission.isPromptable ?
gNavigatorBundle.getString("permissions.remove.tooltip") :
gNavigatorBundle.getString("permissions.remove.tooltip.noPrompt");
button.setAttribute("tooltiptext", tooltiptext);
button.addEventListener("command", () => {
let browser = gBrowser.selectedBrowser;

View File

@ -974,6 +974,7 @@ captivePortal.infoMessage3 = You must log in to this network before you can acce
captivePortal.showLoginPage2 = Open Network Login Page
permissions.remove.tooltip = Clear this permission and ask again
permissions.remove.tooltip.noPrompt = Clear this permission
# LOCALIZATION NOTE (aboutDialog.architecture.*):
# The sixtyFourBit and thirtyTwoBit strings describe the architecture of the

View File

@ -322,10 +322,11 @@ var SitePermissions = {
* - scope: a constant representing how long the permission will
* be kept.
* - label: the localized label, or null if none is available.
* - isPromptable: would permission prompt user or not
*/
getAllPermissionDetailsForBrowser(browser) {
return this.getAllForBrowser(browser).map(({id, scope, state}) =>
({id, scope, state, label: this.getPermissionLabel(id)}));
({id, scope, state, label: this.getPermissionLabel(id), isPromptable: this.getIsPromptable(id)}));
},
/**
@ -601,6 +602,28 @@ var SitePermissions = {
return gStringBundle.GetStringFromName("permission." + labelID + ".label");
},
/**
* Returns a boolean value which indicates whether this permission would
* prompt user. If permission doesn't mention it explicitly, it would be
* promptable.
*
* @param {string} permissionID
* The permission to get the label for.
*
* @return {boolean} the value of `isPromptable` attribute of permission.
*/
getIsPromptable(permissionID) {
if (!(permissionID in gPermissionObject)) {
// Permission can't be found.
return false;
}
if (!("isPromptable" in gPermissionObject[permissionID])) {
// 'isPromptable' is true by default, if permission doesn't mention it.
return true;
}
return gPermissionObject[permissionID].isPromptable;
},
/**
* Returns the localized label for the given permission state, to be used in
* a UI for managing permissions.
@ -691,10 +714,15 @@ var gPermissionObject = {
* Defaults to ALLOW, BLOCK and the default state (see getDefault).
* The PROMPT_HIDE state is deliberately excluded from "plugin:flash" since we
* don't want to expose a "Hide Prompt" button to the user through pageinfo.
*
* - isPromptable
* indicates whether the permission would prompt user for the approval, it
* would be true by default if permission doesn't explicitly mention.
*/
"autoplay-media": {
exactHostMatch: true,
isPromptable: false,
getDefault() {
let state = Services.prefs.getIntPref("media.autoplay.default",
Ci.nsIAutoplay.BLOCKED);