Bug 1338036 - Switch button label from "Remove All" to "Remove All Shown" when filtering by keyword in about:preferences, r=jaws draft
authorFischer.json <fischer.json@gmail.com>
Thu, 09 Feb 2017 12:00:12 +0800
changeset 481606 f95c5ca38e4671d8b53a24fec5b22a9a3fc12213
parent 480952 f505911eb333d5ae8c2bf5c44f7b85add6450b53
child 545243 1d25b3bbc2c3b0d230ee890566acedf851d0f3b9
push id44868
push userbmo:fliu@mozilla.com
push dateFri, 10 Feb 2017 04:36:38 +0000
reviewersjaws
bugs1338036
milestone54.0a1
Bug 1338036 - Switch button label from "Remove All" to "Remove All Shown" when filtering by keyword in about:preferences, r=jaws MozReview-Commit-ID: 8iK6bg8i0uT
browser/components/preferences/cookies.js
browser/components/preferences/cookies.xul
browser/components/preferences/siteDataSettings.js
browser/components/preferences/siteDataSettings.xul
browser/locales/en-US/chrome/browser/preferences/cookies.dtd
browser/locales/en-US/chrome/browser/preferences/preferences.properties
browser/locales/en-US/chrome/browser/preferences/siteDataSettings.dtd
toolkit/components/passwordmgr/content/passwordManager.js
toolkit/components/passwordmgr/content/passwordManager.xul
toolkit/locales/en-US/chrome/passwordmgr/passwordManager.dtd
toolkit/locales/en-US/chrome/passwordmgr/passwordmgr.properties
--- a/browser/components/preferences/cookies.js
+++ b/browser/components/preferences/cookies.js
@@ -27,16 +27,21 @@ var gCookiesWindow = {
     var os = Components.classes["@mozilla.org/observer-service;1"]
                        .getService(Components.interfaces.nsIObserverService);
     os.addObserver(this, "cookie-changed", false);
     os.addObserver(this, "perm-changed", false);
 
     this._bundle = document.getElementById("bundlePreferences");
     this._tree = document.getElementById("cookiesList");
 
+    let removeAllCookies = document.getElementById("removeAllCookies");
+    removeAllCookies.setAttribute("accesskey", this._bundle.getString("removeAllCookies.accesskey"));
+    let removeSelectedCookies = document.getElementById("removeSelectedCookies");
+    removeSelectedCookies.setAttribute("accesskey", this._bundle.getString("removeSelectedCookies.accesskey"));
+
     this._populateList(true);
 
     document.getElementById("filter").focus();
 
     if (!Services.prefs.getBoolPref("privacy.userContext.enabled")) {
       document.getElementById("userContextRow").hidden = true;
     }
   },
@@ -559,17 +564,17 @@ var gCookiesWindow = {
         if (!item) continue;
         if (item.container)
           selectedCookieCount += item.cookies.length;
         else if (!item.container)
           ++selectedCookieCount;
       }
     }
 
-    let buttonLabel = this._bundle.getString("removeSelectedCookies");
+    let buttonLabel = this._bundle.getString("removeSelectedCookies.label");
     let removeSelectedCookies = document.getElementById("removeSelectedCookies");
     removeSelectedCookies.label = PluralForm.get(selectedCookieCount, buttonLabel)
                                             .replace("#1", selectedCookieCount);
 
     removeSelectedCookies.disabled = !(seln.count > 0);
   },
 
   performDeletion: function gCookiesWindow_performDeletion(deleteItems) {
@@ -865,17 +870,21 @@ var gCookiesWindow = {
     for (let i = 0; i < this._view.rowCount; ++i) {
       var item = this._view._getItemAtIndex(i);
       if (item && item.container && item.open)
         this._openIndices.push(i);
     }
   },
 
   _updateRemoveAllButton: function gCookiesWindow__updateRemoveAllButton() {
-    document.getElementById("removeAllCookies").disabled = this._view._rowCount == 0;
+    let removeAllCookies = document.getElementById("removeAllCookies");
+    removeAllCookies.disabled = this._view._rowCount == 0;
+    let label = this._view._filtered ?
+      this._bundle.getString("removeAllShownCookies.label") : this._bundle.getString("removeAllCookies.label");
+    removeAllCookies.setAttribute("label", label);
   },
 
   filter() {
     var filter = document.getElementById("filter").value;
     if (filter == "") {
       gCookiesWindow.clearFilter();
       return;
     }
--- a/browser/components/preferences/cookies.xul
+++ b/browser/components/preferences/cookies.xul
@@ -1,17 +1,17 @@
 <?xml version="1.0"?>
 
 # -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> 
-<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css" type="text/css"?> 
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css" type="text/css"?>
 
 <!DOCTYPE dialog SYSTEM "chrome://browser/locale/preferences/cookies.dtd" >
 
 <window id="CookiesDialog" windowtype="Browser:Cookies"
         class="windowDialog" title="&window.title;"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         style="width: &window.width;;"
         onload="gCookiesWindow.init();"
@@ -92,20 +92,18 @@
           </row>
         </rows>
       </grid>
     </hbox>
   </vbox>
   <hbox align="end">
     <hbox class="actionButtons" flex="1">
       <button id="removeSelectedCookies" disabled="true" icon="clear"
-              accesskey="&button.removeSelectedCookies.accesskey;"
               oncommand="gCookiesWindow.deleteCookie();"/>
       <button id="removeAllCookies" disabled="true" icon="clear"
-              label="&button.removeAllCookies.label;" accesskey="&button.removeAllCookies.accesskey;"
               oncommand="gCookiesWindow.deleteAllCookies();"/>
       <spacer flex="1"/>
 #ifndef XP_MACOSX
       <button oncommand="close();" icon="close"
               label="&button.close.label;" accesskey="&button.close.accesskey;"/>
 #endif
     </hbox>
   </hbox>
--- a/browser/components/preferences/siteDataSettings.js
+++ b/browser/components/preferences/siteDataSettings.js
@@ -21,49 +21,57 @@ let gSiteDataSettings = {
   // - status: persistent-storage permission status
   // - usage: disk usage which site uses
   // - userAction: "remove" or "update-permission"; the action user wants to take.
   //               If not specified, means no action to take
   _sites: null,
 
   _list: null,
   _searchBox: null,
+  _prefStrBundle: null,
 
   init() {
     function setEventListener(id, eventType, callback) {
       document.getElementById(id)
               .addEventListener(eventType, callback.bind(gSiteDataSettings));
     }
 
     this._list = document.getElementById("sitesList");
     this._searchBox = document.getElementById("searchBox");
+    this._prefStrBundle = document.getElementById("bundlePreferences")
     SiteDataManager.getSites().then(sites => {
       this._sites = sites;
       let sortCol = document.getElementById("hostCol");
       this._sortSites(this._sites, sortCol);
       this._buildSitesList(this._sites);
       Services.obs.notifyObservers(null, "sitedata-settings-init", null);
     });
 
+    let removeAllBtn = document.getElementById("removeAll");
+    removeAllBtn.setAttribute("accesskey", this._prefStrBundle.getString("removeAll.accesskey"));
+
     setEventListener("hostCol", "click", this.onClickTreeCol);
     setEventListener("usageCol", "click", this.onClickTreeCol);
     setEventListener("statusCol", "click", this.onClickTreeCol);
     setEventListener("cancel", "command", this.close);
     setEventListener("save", "command", this.saveChanges);
     setEventListener("searchBox", "command", this.onCommandSearch);
     setEventListener("removeAll", "command", this.onClickRemoveAll);
     setEventListener("removeSelected", "command", this.onClickRemoveSelected);
   },
 
   _updateButtonsState() {
     let items = this._list.getElementsByTagName("richlistitem");
     let removeSelectedBtn = document.getElementById("removeSelected");
     let removeAllBtn = document.getElementById("removeAll");
     removeSelectedBtn.disabled = items.length == 0;
     removeAllBtn.disabled = removeSelectedBtn.disabled;
+    let removeAllBtnLabel = this._searchBox.value ?
+      this._prefStrBundle.getString("removeAllShown.label") : this._prefStrBundle.getString("removeAll.label");
+    removeAllBtn.setAttribute("label", removeAllBtnLabel);
   },
 
   /**
    * @param sites {Array}
    * @param col {XULElement} the <treecol> being sorted on
    */
   _sortSites(sites, col) {
     let isCurrentSortCol = col.getAttribute("data-isCurrentSortCol")
@@ -112,35 +120,34 @@ let gSiteDataSettings = {
    */
   _buildSitesList(sites) {
     // Clear old entries.
     let oldItems = this._list.querySelectorAll("richlistitem");
     for (let item of oldItems) {
       item.remove();
     }
 
-    let prefStrBundle = document.getElementById("bundlePreferences");
     let keyword = this._searchBox.value.toLowerCase().trim();
     for (let data of sites) {
       let host = data.uri.host;
       if (keyword && !host.includes(keyword)) {
         continue;
       }
 
       if (data.userAction === "remove") {
         continue;
       }
 
       let statusStrId = data.status === Ci.nsIPermissionManager.ALLOW_ACTION ? "important" : "default";
       let size = DownloadUtils.convertByteUnits(data.usage);
       let item = document.createElement("richlistitem");
       item.setAttribute("data-origin", data.uri.spec);
       item.setAttribute("host", host);
-      item.setAttribute("status", prefStrBundle.getString(statusStrId));
-      item.setAttribute("usage", prefStrBundle.getFormattedString("siteUsage", size));
+      item.setAttribute("status", this._prefStrBundle.getString(statusStrId));
+      item.setAttribute("usage", this._prefStrBundle.getFormattedString("siteUsage", size));
       this._list.appendChild(item);
     }
     this._updateButtonsState();
   },
 
   _removeSiteItems(items) {
     for (let i = items.length - 1; i >= 0; --i) {
       let item = items[i];
--- a/browser/components/preferences/siteDataSettings.xul
+++ b/browser/components/preferences/siteDataSettings.xul
@@ -39,17 +39,17 @@
         <treecol flex="2" width="50" label="&statusCol.label;" id="statusCol"/>
         <treecol flex="1" width="50" label="&usageCol.label;" id="usageCol"/>
       </listheader>
     </richlistbox>
   </vbox>
 
   <hbox align="start">
     <button id="removeSelected" label="&removeSelected.label;" accesskey="&removeSelected.accesskey;"/>
-    <button id="removeAll" label="&removeAll.label;" accesskey="&removeAll.accesskey;"/>
+    <button id="removeAll"/>
   </hbox>
 
   <vbox align="end">
     <hbox>
         <button id="cancel" label="&cancel.label;" accesskey="&cancel.accesskey;"/>
         <button id="save" label="&save.label;" accesskey="&save.accesskey;"/>
     </hbox>
   </vbox>
--- a/browser/locales/en-US/chrome/browser/preferences/cookies.dtd
+++ b/browser/locales/en-US/chrome/browser/preferences/cookies.dtd
@@ -1,24 +1,17 @@
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <!ENTITY window.width                       "36em">
 
 <!ENTITY     cookiesonsystem.label          "The following cookies are stored on your computer:">
 <!ENTITY     cookiename.label               "Cookie Name">
-<!ENTITY     cookiedomain.label             "Site"> 
-<!-- LOCALIZATION NOTE (button.removeSelectedCookies.accesskey):
-  The label associated with this accesskey can be found in 
-  preferences.properties as removeSelectedCookies.
--->
-<!ENTITY     button.removeSelectedCookies.accesskey "R">
-<!ENTITY     button.removeAllCookies.label "Remove All">
-<!ENTITY     button.removeAllCookies.accesskey "A">
+<!ENTITY     cookiedomain.label             "Site">
 
 <!ENTITY     props.name.label               "Name:">
 <!ENTITY     props.value.label              "Content:">
 <!ENTITY     props.domain.label             "Host:">
 <!ENTITY     props.path.label               "Path:">
 <!ENTITY     props.secure.label             "Send For:">
 <!ENTITY     props.expires.label            "Expires:">
 <!ENTITY     props.container.label          "Container:">
--- a/browser/locales/en-US/chrome/browser/preferences/preferences.properties
+++ b/browser/locales/en-US/chrome/browser/preferences/preferences.properties
@@ -118,24 +118,35 @@ forAnyConnection=Any type of connection
 expireAtEndOfSession=At end of session
 can=Allow
 canAccessFirstParty=Allow first party only
 canSession=Allow for Session
 cannot=Block
 noCookieSelected=<no cookie selected>
 cookiesAll=The following cookies are stored on your computer:
 cookiesFiltered=The following cookies match your search:
+
+# LOCALIZATION NOTE (removeAllCookies, removeAllShownCookies):
+# When only partial cookies are shown as a result of keyword search,
+# removeAllShownCookies is displayed as button label.
+# removeAllCookies is displayed when no keyword search and all cookies are shown.
+removeAllCookies.label=Remove All
+removeAllShownCookies.label=Remove All Shown
+removeAllCookies.accesskey=A
+
 # LOCALIZATION NOTE (removeSelectedCookies):
 # Semicolon-separated list of plural forms. See:
 # http://developer.mozilla.org/en/docs/Localization_and_Plurals
 # If you need to display the number of selected elements in your language,
 # you can use #1 in your localization as a placeholder for the number.
 # For example this is the English string with numbers:
 # removeSelectedCookied=Remove #1 Selected;Remove #1 Selected
-removeSelectedCookies=Remove Selected;Remove Selected
+removeSelectedCookies.label=Remove Selected;Remove Selected
+removeSelectedCookies.accesskey=R
+
 defaultUserContextLabel=None
 
 #### Offline apps
 offlineAppsList.height=7em
 offlineAppRemoveTitle=Remove offline website data
 offlineAppRemovePrompt=After removing this data, %S will not be available offline.  Are you sure you want to remove this offline website?
 offlineAppRemoveConfirm=Remove offline data
 
@@ -171,16 +182,23 @@ actualAppCacheSize=Your application cach
 #   %2$S = unit (MB, KB, etc.)
 totalSiteDataSize=Your stored site data is currently using %1$S %2$S of disk space
 clearSiteDataPromptTitle=Clear all cookies and site data
 clearSiteDataPromptText=Selecting ‘Clear Now’ will clear all cookies and site data stored by Firefox. This may sign you out of websites and remove offline web content.
 clearSiteDataNow=Clear Now
 important=Important
 default=Default
 siteUsage=%1$S %2$S
+# LOCALIZATION NOTE (removeAll, removeAllShown):
+# When only partial sites are shown as a result of keyword search,
+# removeAllShown is displayed as button label.
+# removeAll is displayed when no keyword search and all sites are shown.
+removeAll.label=Remove All
+removeAllShown.label=Remove All Shown
+removeAll.accesskey=e
 
 # LOCALIZATION NOTE (featureEnableRequiresRestart, featureDisableRequiresRestart, restartTitle): %S = brandShortName
 featureEnableRequiresRestart=%S must restart to enable this feature.
 featureDisableRequiresRestart=%S must restart to disable this feature.
 shouldRestartTitle=Restart %S
 okToRestartButton=Restart %S now
 revertNoRestartButton=Revert
 
--- a/browser/locales/en-US/chrome/browser/preferences/siteDataSettings.dtd
+++ b/browser/locales/en-US/chrome/browser/preferences/siteDataSettings.dtd
@@ -6,17 +6,15 @@
 <!ENTITY     settings.description          "The following websites asked to store site data in your disk. You can specify which websites are allowed to store site data. Default site data is temporary and could be deleted automatically.">
 <!ENTITY     hostCol.label                 "Site">
 <!ENTITY     statusCol.label               "Status">
 <!ENTITY     usageCol.label                "Storage">
 <!ENTITY     search.label                  "Search:">
 <!ENTITY     search.accesskey              "S">
 <!ENTITY     removeSelected.label          "Remove Selected">
 <!ENTITY     removeSelected.accesskey      "r">
-<!ENTITY     removeAll.label               "Remove All">
-<!ENTITY     removeAll.accesskey           "e">
 <!ENTITY     save.label                    "Save Changes">
 <!ENTITY     save.accesskey                "a">
 <!ENTITY     cancel.label                  "Cancel">
 <!ENTITY     cancel.accesskey              "C">
 <!ENTITY     removingDialog.title          "Removing Site Data">
 <!ENTITY     removingDialog.description    "Removing site data will also remove cookies. This may log you out of websites and remove offline web content. Are you sure you want to make the changes?">
 <!ENTITY     siteTree.label                "The following website cookies will be removed:">
--- a/toolkit/components/passwordmgr/content/passwordManager.js
+++ b/toolkit/components/passwordmgr/content/passwordManager.js
@@ -75,16 +75,18 @@ function Startup() {
   togglePasswordsButton = document.getElementById("togglePasswords");
   signonsIntro = document.getElementById("signonsIntro");
   removeButton = document.getElementById("removeSignon");
   removeAllButton = document.getElementById("removeAllSignons");
 
   togglePasswordsButton.label = kSignonBundle.getString("showPasswords");
   togglePasswordsButton.accessKey = kSignonBundle.getString("showPasswordsAccessKey");
   signonsIntro.textContent = kSignonBundle.getString("loginsDescriptionAll");
+  removeAllButton.setAttribute("label", kSignonBundle.getString("removeAll.label"));
+  removeAllButton.setAttribute("accesskey", kSignonBundle.getString("removeAll.accesskey"));
   document.getElementsByTagName("treecols")[0].addEventListener("click", (event) => {
     let { target, button } = event;
     let sortField = target.getAttribute("data-field-name");
 
     if (target.nodeName != "treecol" || button != 0 || !sortField) {
       return;
     }
 
@@ -551,16 +553,17 @@ function SignonClearFilter() {
       signonsTreeView.selection.rangedSelect(range.min, range.max, true);
     }
   } else {
     signonsTreeView.selection.select(0);
   }
   signonsTreeView._lastSelectedRanges = [];
 
   signonsIntro.textContent = kSignonBundle.getString("loginsDescriptionAll");
+  removeAllButton.setAttribute("label", kSignonBundle.getString("removeAll.label"));
 }
 
 function FocusFilterBox() {
   if (filterField.getAttribute("focused") != "true") {
     filterField.focus();
   }
 }
 
@@ -619,16 +622,17 @@ function FilterPasswords() {
   signonsTreeView.rowCount = signonsTreeView._filterSet.length;
   signonsTree.treeBoxObject.rowCountChanged(0, signonsTreeView.rowCount);
 
   // if the view is not empty then select the first item
   if (signonsTreeView.rowCount > 0)
     signonsTreeView.selection.select(0);
 
   signonsIntro.textContent = kSignonBundle.getString("loginsDescriptionFiltered");
+  removeAllButton.setAttribute("label", kSignonBundle.getString("removeAllShown.label"));
 }
 
 function CopyPassword() {
   // Don't copy passwords if we aren't already showing the passwords & a master
   // password hasn't been entered.
   if (!showingPasswords && !masterPasswordLogin())
     return;
   // Copy selected signon's password to clipboard
--- a/toolkit/components/passwordmgr/content/passwordManager.xul
+++ b/toolkit/components/passwordmgr/content/passwordManager.xul
@@ -106,17 +106,16 @@
       <treechildren/>
     </tree>
     <separator class="thin"/>
     <hbox id="SignonViewerButtons">
       <button id="removeSignon" disabled="true" icon="remove"
               label="&remove.label;" accesskey="&remove.accesskey;"
               oncommand="DeleteSignon();"/>
       <button id="removeAllSignons" icon="clear"
-              label="&removeall.label;" accesskey="&removeall.accesskey;"
               oncommand="DeleteAllSignons();"/>
       <spacer flex="1"/>
 #if defined(MOZ_BUILD_APP_IS_BROWSER) && defined(XP_WIN)
       <button accesskey="&import.accesskey;"
               label="&import.label;"
               oncommand="OpenMigrator();"/>
 #endif
       <button id="togglePasswords"
--- a/toolkit/locales/en-US/chrome/passwordmgr/passwordManager.dtd
+++ b/toolkit/locales/en-US/chrome/passwordmgr/passwordManager.dtd
@@ -12,18 +12,16 @@
 <!ENTITY      treehead.password.label         "Password">
 <!ENTITY      treehead.timeCreated.label         "First Used">
 <!ENTITY      treehead.timeLastUsed.label        "Last Used">
 <!ENTITY      treehead.timePasswordChanged.label "Last Changed">
 <!ENTITY      treehead.timesUsed.label           "Times Used">
 
 <!ENTITY      remove.label                    "Remove">
 <!ENTITY      remove.accesskey                "R">
-<!ENTITY      removeall.label                 "Remove All">
-<!ENTITY      removeall.accesskey             "A">
 
 <!ENTITY      addLogin.label                  "Add Login">
 <!ENTITY      addLogin.accesskey              "L">
 
 <!ENTITY      import.label                    "Import…">
 <!ENTITY      import.accesskey                "I">
 
 <!ENTITY      searchFilter.label              "Search">
--- a/toolkit/locales/en-US/chrome/passwordmgr/passwordmgr.properties
+++ b/toolkit/locales/en-US/chrome/passwordmgr/passwordmgr.properties
@@ -72,8 +72,16 @@ duplicateLoginTitle=Login already exists
 duplicateLogin=A duplicate login already exists.
 
 insecureFieldWarningDescription = This connection is not secure. Logins entered here could be compromised.
 # LOCALIZATION NOTE (insecureFieldWarningDescription2, insecureFieldWarningDescription3):
 # %1$S will contain insecureFieldWarningLearnMore and look like a link to indicate that clicking will open a tab with support information.
 insecureFieldWarningDescription2 = This connection is not secure. Logins entered here could be compromised. %1$S
 insecureFieldWarningDescription3 = Logins entered here could be compromised. %1$S
 insecureFieldWarningLearnMore = Learn More
+
+# LOCALIZATION NOTE (removeAll, removeAllShown):
+# When only partial sites are shown as a result of keyword search,
+# removeAllShown is displayed as button label.
+# removeAll is displayed when no keyword search and all sites are shown.
+removeAll.label=Remove All
+removeAllShown.label=Remove All Shown
+removeAll.accesskey=A