Bug 1520436 - part1 : add another tooltip text for non-promptable permission. r=flod,johannh
☠☠ backed out by 1136af68ddae ☠ ☠
authoralwu <alwu@mozilla.com>
Fri, 18 Jan 2019 18:54:54 +0000
changeset 514940 10716b2122dc152763b64e5fccd43ea1bdee239e
parent 514939 cd5c4d799e58dcc745cbab6380f2ea29e4f7d1e7
child 514941 4752a33b4c3ac775977b7e97d992d29c7ce2b110
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflod, johannh
bugs1520436
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
browser/base/content/browser-siteIdentity.js
browser/locales/en-US/chrome/browser/browser.properties
browser/modules/SitePermissions.jsm
--- a/browser/base/content/browser-siteIdentity.js
+++ b/browser/base/content/browser-siteIdentity.js
@@ -1125,17 +1125,19 @@ var gIdentityHandler = {
        SCOPE_POLICY or SCOPE_GLOBAL permission. Policy permissions cannot be
        removed/changed for the duration of the browser session. */
     if (isPolicyPermission) {
       return container;
     }
 
     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;
       this._permissionList.removeChild(container);
       if (aPermission.sharingState &&
           ["camera", "microphone", "screen"].includes(aPermission.id)) {
         let windowId = this._sharingState.windowId;
         if (aPermission.id == "screen") {
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -969,16 +969,17 @@ decoder.decodeWarning.message = A recove
 # and requires the user to log in before browsing.
 captivePortal.infoMessage3 = You must log in to this network before you can access the Internet.
 # LOCALIZATION NOTE (captivePortal.showLoginPage2):
 # The label for a button shown in the info bar in all tabs except the login page tab.
 # The button shows the portal login page tab when clicked.
 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
 # current Firefox build: 32-bit or 64-bit. These strings are used in parentheses
 # between the Firefox version and the "What's new" link in the About dialog,
 # e.g.: "48.0.2 (32-bit) <What's new>" or "51.0a1 (2016-09-05) (64-bit)".
 aboutDialog.architecture.sixtyFourBit = 64-bit
 aboutDialog.architecture.thirtyTwoBit = 32-bit
--- a/browser/modules/SitePermissions.jsm
+++ b/browser/modules/SitePermissions.jsm
@@ -317,20 +317,21 @@ var SitePermissions = {
    *
    * @return {Array<Object>} a list of objects with the keys:
    *           - id: the permissionID of the permission
    *           - state: a constant representing the current permission state
    *             (e.g. SitePermissions.ALLOW)
    *           - 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)}));
   },
 
   /**
    * Checks whether a UI for managing permissions should be exposed for a given
    * URI. This excludes file URIs, for instance, as they don't have a host,
    * even though nsIPermissionManager can still handle them.
    *
    * @param {nsIURI} uri
@@ -597,16 +598,38 @@ var SitePermissions = {
       // Permission doesn't support having a label.
       return null;
     }
     let labelID = gPermissionObject[permissionID].labelID || permissionID;
     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.
    *
    * @param {SitePermissions state} state
    *        The state to get the label for.
    *
    * @return {String|null} the localized label or null if an
    *         unknown state was passed.
@@ -686,20 +709,25 @@ var gPermissionObject = {
    *    Use the given ID instead of the permission name for looking up strings.
    *    e.g. "desktop-notification2" to use permission.desktop-notification2.label
    *
    *  - states
    *    Array of permission states to be exposed to the user.
    *    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);
       if (state == Ci.nsIAutoplay.ALLOWED) {
         return SitePermissions.ALLOW;
       } else if (state == Ci.nsIAutoplay.BLOCKED) {
         return SitePermissions.BLOCK;
       }