Bug 1399808 - Remove the offlineGroup UI in about:preferences, r?jaws draft
authorFischer.json <fischer.json@gmail.com>
Mon, 30 Oct 2017 16:16:24 +0800
changeset 688609 cbec1e9efbc1c499042a4fcda19aec10e7c2f634
parent 688337 d3910b7628b8066d3f30d58b17b5824b05768854
child 738124 c72ecbaefe37dc78f0d2ef13c6a73653d3fb0d59
push id86808
push userbmo:fliu@mozilla.com
push dateMon, 30 Oct 2017 10:30:22 +0000
reviewersjaws
bugs1399808
milestone58.0a1
Bug 1399808 - Remove the offlineGroup UI in about:preferences, r?jaws MozReview-Commit-ID: 4JZ62Bg79Zo
browser/app/profile/firefox.js
browser/components/preferences/in-content/privacy.js
browser/components/preferences/in-content/privacy.xul
browser/components/preferences/in-content/tests/browser_bug731866.js
browser/components/preferences/in-content/tests/browser_bug795764_cachedisabled.js
browser/locales/en-US/chrome/browser/preferences/advanced.dtd
browser/locales/en-US/chrome/browser/preferences/preferences.properties
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -734,20 +734,16 @@ pref("plugins.favorfallback.rules", "nos
 pref("browser.preferences.instantApply", false);
 #else
 pref("browser.preferences.instantApply", true);
 #endif
 
 // Toggling Search bar on and off in about:preferences
 pref("browser.preferences.search", true);
 
-// We prefer the storage manager (see browser.storageManager.enabled)
-// over the old offlineGroup UI. Removing the offline group UI is bug 1399808.
-pref("browser.preferences.offlineGroup.enabled", false);
-
 pref("browser.preferences.defaultPerformanceSettings.enabled", true);
 
 pref("browser.download.show_plugins_in_list", true);
 pref("browser.download.hide_plugins_without_extensions", true);
 
 // Backspace and Shift+Backspace behavior
 // 0 goes Back/Forward
 // 1 act like PgUp/PgDown
--- a/browser/components/preferences/in-content/privacy.js
+++ b/browser/components/preferences/in-content/privacy.js
@@ -194,33 +194,16 @@ var gPrivacyPane = {
           document.getElementById("notificationsDoNotDisturb");
         notificationsDoNotDisturb.setAttribute("checked", true);
       }
     }
 
     setEventListener("cacheSize", "change",
       gPrivacyPane.updateCacheSizePref);
 
-    if (Services.prefs.getBoolPref("browser.preferences.offlineGroup.enabled")) {
-      this.updateOfflineApps();
-      this.updateActualAppCacheSize();
-      setEventListener("offlineNotifyExceptions", "command",
-        gPrivacyPane.showOfflineExceptions);
-      setEventListener("offlineAppsList", "select",
-        gPrivacyPane.offlineAppSelected);
-      setEventListener("offlineAppsListRemove", "command",
-        gPrivacyPane.removeOfflineApp);
-      setEventListener("clearOfflineAppCacheButton", "command",
-        gPrivacyPane.clearOfflineAppCache);
-      document.getElementById("offlineAppsList")
-        .style.height = bundlePrefs.getString("offlineAppsList.height");
-      let offlineGroup = document.getElementById("offlineGroup");
-      offlineGroup.removeAttribute("data-hidden-from-search");
-    }
-
     if (Services.prefs.getBoolPref("browser.storageManager.enabled")) {
       Services.obs.addObserver(this, "sitedatamanager:sites-updated");
       Services.obs.addObserver(this, "sitedatamanager:updating-sites");
       let unload = () => {
         window.removeEventListener("unload", unload);
         Services.obs.removeObserver(this, "sitedatamanager:sites-updated");
         Services.obs.removeObserver(this, "sitedatamanager:updating-sites");
       };
@@ -1244,43 +1227,16 @@ var gPrivacyPane = {
    */
   clearCache() {
     try {
       Services.cache2.clear();
     } catch (ex) { }
     this.updateActualCacheSize();
   },
 
-  showOfflineExceptions() {
-    var bundlePreferences = document.getElementById("bundlePreferences");
-    var params = {
-      blockVisible: false,
-      sessionVisible: false,
-      allowVisible: false,
-      prefilledHost: "",
-      permissionType: "offline-app",
-      manageCapability: Components.interfaces.nsIPermissionManager.DENY_ACTION,
-      windowTitle: bundlePreferences.getString("offlinepermissionstitle"),
-      introText: bundlePreferences.getString("offlinepermissionstext")
-    };
-    gSubDialog.open("chrome://browser/content/preferences/permissions.xul",
-      null, params);
-  },
-
-
-  offlineAppSelected() {
-    var removeButton = document.getElementById("offlineAppsListRemove");
-    var list = document.getElementById("offlineAppsList");
-    if (list.selectedItem) {
-      removeButton.setAttribute("disabled", "false");
-    } else {
-      removeButton.setAttribute("disabled", "true");
-    }
-  },
-
   showSiteDataSettings() {
     gSubDialog.open("chrome://browser/content/preferences/siteDataSettings.xul");
   },
 
   toggleSiteData(shouldShow) {
     let clearButton = document.getElementById("clearSiteDataButton");
     let settingsButton = document.getElementById("siteDataSettings");
     clearButton.disabled = !shouldShow;
@@ -1439,165 +1395,16 @@ var gPrivacyPane = {
   /**
    * Update the health report preference with state from checkbox.
    */
   updateSubmitHealthReport() {
     let checkbox = document.getElementById("submitHealthReportBox");
     Services.prefs.setBoolPref(PREF_UPLOAD_ENABLED, checkbox.checked);
   },
 
-  // Methods for Offline Apps (AppCache)
-
-  /**
-   * Clears the application cache.
-   */
-  clearOfflineAppCache() {
-    Components.utils.import("resource:///modules/offlineAppCache.jsm");
-    OfflineAppCacheHelper.clear();
-
-    this.updateActualAppCacheSize();
-    this.updateOfflineApps();
-  },
-
-  // Retrieves the amount of space currently used by offline cache
-  updateActualAppCacheSize() {
-    var visitor = {
-      onCacheStorageInfo(aEntryCount, aConsumption, aCapacity, aDiskDirectory) {
-        var actualSizeLabel = document.getElementById("actualAppCacheSize");
-        var sizeStrings = DownloadUtils.convertByteUnits(aConsumption);
-        var prefStrBundle = document.getElementById("bundlePreferences");
-        // The XBL binding for the string bundle may have been destroyed if
-        // the page was closed before this callback was executed.
-        if (!prefStrBundle.getFormattedString) {
-          return;
-        }
-        var sizeStr = prefStrBundle.getFormattedString("actualAppCacheSize", sizeStrings);
-        actualSizeLabel.value = sizeStr;
-      }
-    };
-
-    try {
-      Services.cache2.asyncVisitStorage(visitor, false);
-    } catch (e) { }
-  },
-
-  readOfflineNotify() {
-    var pref = document.getElementById("browser.offline-apps.notify");
-    var button = document.getElementById("offlineNotifyExceptions");
-    button.disabled = !pref.value;
-    return pref.value;
-  },
-
-  // XXX: duplicated in browser.js
-  _getOfflineAppUsage(perm, groups) {
-    let cacheService = Cc["@mozilla.org/network/application-cache-service;1"].
-      getService(Ci.nsIApplicationCacheService);
-    if (!groups) {
-      try {
-        groups = cacheService.getGroups();
-      } catch (ex) {
-        return 0;
-      }
-    }
-
-    let usage = 0;
-    for (let group of groups) {
-      let uri = Services.io.newURI(group);
-      if (perm.matchesURI(uri, true)) {
-        let cache = cacheService.getActiveCache(group);
-        usage += cache.usage;
-      }
-    }
-
-    return usage;
-  },
-
-  /**
-   * Updates the list of offline applications
-   */
-  updateOfflineApps() {
-    var list = document.getElementById("offlineAppsList");
-    while (list.firstChild) {
-      list.firstChild.remove();
-    }
-
-    var groups;
-    try {
-      var cacheService = Components.classes["@mozilla.org/network/application-cache-service;1"].
-        getService(Components.interfaces.nsIApplicationCacheService);
-      groups = cacheService.getGroups();
-    } catch (e) {
-      return;
-    }
-
-    var bundle = document.getElementById("bundlePreferences");
-
-    var enumerator = Services.perms.enumerator;
-    while (enumerator.hasMoreElements()) {
-      var perm = enumerator.getNext().QueryInterface(Components.interfaces.nsIPermission);
-      if (perm.type == "offline-app" &&
-        perm.capability != Components.interfaces.nsIPermissionManager.DEFAULT_ACTION &&
-        perm.capability != Components.interfaces.nsIPermissionManager.DENY_ACTION) {
-        var row = document.createElement("listitem");
-        row.id = "";
-        row.className = "offlineapp";
-        row.setAttribute("origin", perm.principal.origin);
-        var converted = DownloadUtils.
-          convertByteUnits(this._getOfflineAppUsage(perm, groups));
-        row.setAttribute("usage",
-          bundle.getFormattedString("offlineAppUsage",
-            converted));
-        list.appendChild(row);
-      }
-    }
-  },
-
-  removeOfflineApp() {
-    var list = document.getElementById("offlineAppsList");
-    var item = list.selectedItem;
-    var origin = item.getAttribute("origin");
-    var principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin);
-
-    var flags = Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0 +
-      Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1;
-
-    var bundle = document.getElementById("bundlePreferences");
-    var title = bundle.getString("offlineAppRemoveTitle");
-    var prompt = bundle.getFormattedString("offlineAppRemovePrompt", [principal.URI.prePath]);
-    var confirm = bundle.getString("offlineAppRemoveConfirm");
-    var result = Services.prompt.confirmEx(window, title, prompt, flags, confirm,
-      null, null, null, {});
-    if (result != 0)
-      return;
-
-    // get the permission
-    var perm = Services.perms.getPermissionObject(principal, "offline-app", true);
-    if (perm) {
-      // clear offline cache entries
-      try {
-        var cacheService = Components.classes["@mozilla.org/network/application-cache-service;1"].
-          getService(Components.interfaces.nsIApplicationCacheService);
-        var groups = cacheService.getGroups();
-        for (var i = 0; i < groups.length; i++) {
-          var uri = Services.io.newURI(groups[i]);
-          if (perm.matchesURI(uri, true)) {
-            var cache = cacheService.getActiveCache(groups[i]);
-            cache.discard();
-          }
-        }
-      } catch (e) { }
-
-      Services.perms.removePermission(perm);
-    }
-    list.removeChild(item);
-    gPrivacyPane.offlineAppSelected();
-    this.updateActualAppCacheSize();
-  },
-  // Methods for Offline Apps (AppCache) end
-
   observe(aSubject, aTopic, aData) {
     switch (aTopic) {
       case "sitedatamanager:updating-sites":
         // While updating, we want to disable this section and display loading message until updated
         this.toggleSiteData(false);
         this.updateTotalDataSizeLabel(-1);
         break;
 
--- a/browser/components/preferences/in-content/privacy.xul
+++ b/browser/components/preferences/in-content/privacy.xul
@@ -145,19 +145,16 @@
   <preference id="browser.safebrowsing.downloads.remote.block_uncommon"
               name="browser.safebrowsing.downloads.remote.block_uncommon"
               type="bool"/>
 
   <!-- Network tab -->
   <preference id="browser.cache.disk.capacity"
               name="browser.cache.disk.capacity"
               type="int"/>
-  <preference id="browser.offline-apps.notify"
-              name="browser.offline-apps.notify"
-              type="bool"/>
 
   <preference id="browser.cache.disk.smart_size.enabled"
               name="browser.cache.disk.smart_size.enabled"
               inverted="true"
               type="bool"/>
 
   <!-- Data Choices tab -->
 #ifdef MOZ_CRASHREPORTER
@@ -847,54 +844,8 @@
                                 &devmgr.button.logout.label;
                                 &devmgr.button.changepw.label;
                                 &devmgr.button.load.label;
                                 &devmgr.button.unload.label;"/>
       </hbox>
     </vbox>
   </hbox>
 </groupbox>
-
-<!-- Offline apps -->
-<groupbox id="offlineGroup" data-category="panePrivacy" hidden="true" data-hidden-from-search="true">
-  <caption><label>&offlineStorage2.label;</label></caption>
-
-  <hbox align="center">
-    <label id="actualAppCacheSize" flex="1"/>
-    <!-- Please don't remove the wrapping hbox/vbox/box for these elements. It's used to properly compute the search tooltip position. -->
-    <hbox>
-      <button id="clearOfflineAppCacheButton"
-              class="accessory-button"
-              icon="clear"
-              label="&clearOfflineAppCacheNow.label;" accesskey="&clearOfflineAppCacheNow.accesskey;"/>
-    </hbox>
-  </hbox>
-  <hbox align="center">
-    <checkbox id="offlineNotify"
-              label="&offlineStorageNotify.label;" accesskey="&offlineStorageNotify.accesskey;"
-              preference="browser.offline-apps.notify"
-              onsyncfrompreference="return gPrivacyPane.readOfflineNotify();"
-              flex="1" />
-    <!-- Please don't remove the wrapping hbox/vbox/box for these elements. It's used to properly compute the search tooltip position. -->
-    <hbox>
-      <button id="offlineNotifyExceptions"
-              class="accessory-button"
-              label="&offlineStorageNotifyExceptions.label;"
-              accesskey="&offlineStorageNotifyExceptions.accesskey;"/>
-    </hbox>
-  </hbox>
-  <hbox>
-    <vbox flex="1">
-      <label id="offlineAppsListLabel">&offlineAppsList3.label;</label>
-      <listbox id="offlineAppsList"
-              flex="1"
-              aria-labelledby="offlineAppsListLabel">
-      </listbox>
-    </vbox>
-    <vbox pack="end">
-      <button id="offlineAppsListRemove"
-              class="accessory-button"
-              disabled="true"
-              label="&offlineAppsListRemove.label;"
-              accesskey="&offlineAppsListRemove.accesskey;"/>
-    </vbox>
-  </hbox>
-</groupbox>
--- a/browser/components/preferences/in-content/tests/browser_bug731866.js
+++ b/browser/components/preferences/in-content/tests/browser_bug731866.js
@@ -1,16 +1,15 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
 Components.utils.import("resource://gre/modules/NetUtil.jsm");
 
 const storageManagerDisabled = !SpecialPowers.getBoolPref("browser.storageManager.enabled");
-const offlineGroupDisabled = !SpecialPowers.getBoolPref("browser.preferences.offlineGroup.enabled");
 const browserContainersGroupDisabled = !SpecialPowers.getBoolPref("privacy.userContext.ui.enabled");
 
 function test() {
   waitForExplicitFinish();
   open_preferences(runTest);
 }
 
 var gElements;
@@ -27,23 +26,16 @@ function checkElements(expectedPane) {
     // The siteDataGroup in the Storage Management project is currently only pref-on on Nightly for testing purpose.
     // During the test and the transition period, we have to check the pref to see if the siteDataGroup
     // should be hidden always. This would be a bit bothersome, same as the offlineGroup as below.
     // However, this checking is necessary to make sure we don't leak the siteDataGroup into beta/release build
     if (element.id == "siteDataGroup" && storageManagerDisabled) {
       is_element_hidden(element, "Disabled siteDataGroup should be hidden");
       continue;
     }
-    // The siteDataGroup in the Storage Management project will replace the offlineGroup eventually,
-    // so during the transition period, we have to check the pref to see if the offlineGroup
-    // should be hidden always. See the bug 1354530 for the details.
-    if (element.id == "offlineGroup" && offlineGroupDisabled) {
-      is_element_hidden(element, "Disabled offlineGroup should be hidden");
-      continue;
-    }
     // The browserContainersGroup is still only pref-on on Nightly
     if (element.id == "browserContainersGroup" && browserContainersGroupDisabled) {
       is_element_hidden(element, "Disabled browserContainersGroup should be hidden");
       continue;
     }
 
     let attributeValue = element.getAttribute("data-category");
     let suffix = " (id=" + element.id + ")";
--- a/browser/components/preferences/in-content/tests/browser_bug795764_cachedisabled.js
+++ b/browser/components/preferences/in-content/tests/browser_bug795764_cachedisabled.js
@@ -16,17 +16,16 @@ function test() {
     Services.perms.removeFromPrincipal(principal, "persistent-storage");
   });
 
   SpecialPowers.pushPrefEnv({set: [
     ["browser.cache.offline.enable", false],
     ["browser.cache.disk.enable", false],
     ["browser.cache.memory.enable", false],
     ["browser.storageManager.enabled", true],
-    ["browser.preferences.offlineGroup.enabled", true],
     ["privacy.userContext.ui.enabled", true]
   ]}).then(() => open_preferences(runTest));
 }
 
 function runTest(win) {
   is(gBrowser.currentURI.spec, "about:preferences", "about:preferences loaded");
 
   let tab = win.document;
--- a/browser/locales/en-US/chrome/browser/preferences/advanced.dtd
+++ b/browser/locales/en-US/chrome/browser/preferences/advanced.dtd
@@ -46,18 +46,16 @@ available. -->
 <!ENTITY networkProxy.label              "Network Proxy">
 
 <!ENTITY connectionDesc.label            "Configure how &brandShortName; connects to the Internet">
 <!ENTITY connectionSettings.label        "Settings…">
 <!ENTITY connectionSettings.accesskey    "e">
 
 <!ENTITY httpCache.label                 "Cached Web Content">
 
-<!ENTITY offlineStorage2.label           "Offline Web Content and User Data">
-
 <!--  Site Data section manages sites using Storage API and is under Network -->
 <!ENTITY siteData.label                  "Site Data">
 <!ENTITY clearSiteData.label             "Clear All Data">
 <!ENTITY clearSiteData.accesskey         "l">
 <!ENTITY siteDataSettings.label          "Settings…">
 <!ENTITY siteDataSettings.accesskey      "i">
 <!ENTITY siteDataLearnMoreLink.label     "Learn more">
 
@@ -67,18 +65,16 @@ available. -->
 
   &limitCacheSizeBefore.label [textbox for cache size in MB] &limitCacheSizeAfter.label;
 -->
 <!ENTITY limitCacheSizeBefore.label      "Limit cache to">
 <!ENTITY limitCacheSizeBefore.accesskey  "L">
 <!ENTITY limitCacheSizeAfter.label       "MB of space">
 <!ENTITY clearCacheNow.label             "Clear Now">
 <!ENTITY clearCacheNow.accesskey         "C">
-<!ENTITY clearOfflineAppCacheNow.label   "Clear Now">
-<!ENTITY clearOfflineAppCacheNow.accesskey "N">
 <!ENTITY overrideSmartCacheSize.label    "Override automatic cache management">
 <!ENTITY overrideSmartCacheSize.accesskey "O">
 
 <!ENTITY updateTab.label                 "Update">
 
 <!-- LOCALIZATION NOTE (updateApplication.label):
   Strings from aboutDialog.dtd are displayed in this section of the preferences.
   Please check for possible accesskey conflicts.
@@ -106,27 +102,16 @@ available. -->
 <!ENTITY updateHistory2.accesskey        "p">
 
 <!ENTITY useService.label                "Use a background service to install updates">
 <!ENTITY useService.accesskey            "b">
 
 <!ENTITY enableSearchUpdate2.label       "Automatically update search engines">
 <!ENTITY enableSearchUpdate2.accesskey   "e">
 
-<!ENTITY offlineStorageNotify.label               "Tell you when a website asks to store data for offline use">
-<!ENTITY offlineStorageNotify.accesskey           "T">
-<!ENTITY offlineStorageNotifyExceptions.label     "Exceptions…">
-<!ENTITY offlineStorageNotifyExceptions.accesskey "x">
-
-<!ENTITY offlineAppsList3.label          "The following websites are allowed to store data for offline use">
-<!ENTITY offlineAppsList.height          "7em">
-<!ENTITY offlineAppsListRemove.label     "Remove…">
-<!ENTITY offlineAppsListRemove.accesskey "R">
-<!ENTITY offlineAppRemove.confirm        "Remove offline data">
-
 <!ENTITY certificateTab.label            "Certificates">
 <!ENTITY certPersonal2.description       "When a server requests your personal certificate">
 <!ENTITY selectCerts.auto                "Select one automatically">
 <!ENTITY selectCerts.auto.accesskey      "S">
 <!ENTITY selectCerts.ask                 "Ask you every time">
 <!ENTITY selectCerts.ask.accesskey       "A">
 <!ENTITY enableOCSP.label                "Query OCSP responder servers to confirm the current validity of certificates">
 <!ENTITY enableOCSP.accesskey            "Q">
--- a/browser/locales/en-US/chrome/browser/preferences/preferences.properties
+++ b/browser/locales/en-US/chrome/browser/preferences/preferences.properties
@@ -155,32 +155,16 @@ removeAllShownCookies.accesskey=A
 # 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.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
-
-# LOCALIZATION NOTE: The next string is for the disk usage of the
-# offline application
-#   e.g. offlineAppUsage : "50.23 MB"
-#   %1$S = size (in bytes or megabytes, ...)
-#   %2$S = unit of measure (bytes, KB, MB, ...)
-offlineAppUsage=%1$S %2$S
-
-offlinepermissionstext=The following websites are not allowed to store data for offline use:
-offlinepermissionstitle=Offline Data
-
 ####Preferences::Advanced::Network
 #LOCALIZATION NOTE: The next string is for the disk usage of the web content cache.
 #   e.g., "Your web content cache is currently using 200 MB"
 #   %1$S = size
 #   %2$S = unit (MB, KB, etc.)
 actualDiskCacheSize=Your web content cache is currently using %1$S %2$S of disk space
 actualDiskCacheSizeCalculated=Calculating web content cache size…