diff --git a/browser/base/content/sanitize.js b/browser/base/content/sanitize.js index 54bf72f131c..31f22438a61 100644 --- a/browser/base/content/sanitize.js +++ b/browser/base/content/sanitize.js @@ -204,24 +204,13 @@ Sanitizer.prototype = { offlineApps: { clear: function () { - const Cc = Components.classes; - const Ci = Components.interfaces; - var cacheService = Cc["@mozilla.org/network/cache-service;1"]. - getService(Ci.nsICacheService); - try { - // Offline app data is "timeless", and doesn't respect - // the setting of timespan, it always clears everything - cacheService.evictEntries(Ci.nsICache.STORE_OFFLINE); - } catch(er) {} - - var storageManagerService = Cc["@mozilla.org/dom/storagemanager;1"]. - getService(Ci.nsIDOMStorageManager); - storageManagerService.clearOfflineApps(); + Components.utils.import("resource:///modules/offlineAppCache.jsm"); + OfflineAppCacheHelper.clear(); }, get canClear() { - return true; + return true; } }, diff --git a/browser/components/preferences/advanced.js b/browser/components/preferences/advanced.js index 3d2c0f1750e..c12ec4b4a81 100644 --- a/browser/components/preferences/advanced.js +++ b/browser/components/preferences/advanced.js @@ -68,7 +68,8 @@ var gAdvancedPane = { #ifdef MOZ_CRASHREPORTER this.initSubmitCrashes(); #endif - this.updateActualCacheSize(); + this.updateActualCacheSize("disk"); + this.updateActualCacheSize("offline"); }, /** @@ -202,18 +203,22 @@ var gAdvancedPane = { "", null); }, - // Retrieves the amount of space currently used by disk cache - updateActualCacheSize: function () + // Retrieves the amount of space currently used by disk or offline cache + updateActualCacheSize: function (device) { var visitor = { visitDevice: function (deviceID, deviceInfo) { - if (deviceID == "disk") { - var actualSizeLabel = document.getElementById("actualCacheSize"); + if (deviceID == device) { + var actualSizeLabel = document.getElementById(device == "disk" ? + "actualDiskCacheSize" : + "actualAppCacheSize"); var sizeStrings = DownloadUtils.convertByteUnits(deviceInfo.totalSize); var prefStrBundle = document.getElementById("bundlePreferences"); - var sizeStr = prefStrBundle.getFormattedString("actualCacheSize", - sizeStrings); + var sizeStr = prefStrBundle.getFormattedString(device == "disk" ? + "actualDiskCacheSize" : + "actualAppCacheSize", + sizeStrings); actualSizeLabel.value = sizeStr; } // Do not enumerate entries @@ -226,6 +231,7 @@ var gAdvancedPane = { return false; } }; + var cacheService = Components.classes["@mozilla.org/network/cache-service;1"] .getService(Components.interfaces.nsICacheService); @@ -274,11 +280,23 @@ var gAdvancedPane = { clearCache: function () { var cacheService = Components.classes["@mozilla.org/network/cache-service;1"] - .getService(Components.interfaces.nsICacheService); + .getService(Components.interfaces.nsICacheService); try { cacheService.evictEntries(Components.interfaces.nsICache.STORE_ANYWHERE); } catch(ex) {} - this.updateActualCacheSize(); + this.updateActualCacheSize("disk"); + }, + + /** + * Clears the application cache. + */ + clearOfflineAppCache: function () + { + Components.utils.import("resource:///modules/offlineAppCache.jsm"); + OfflineAppCacheHelper.clear(); + + this.updateActualCacheSize("offline"); + this.updateOfflineApps(); }, readOfflineNotify: function() @@ -432,6 +450,7 @@ var gAdvancedPane = { list.removeChild(item); gAdvancedPane.offlineAppSelected(); + this.updateActualCacheSize("offline"); }, // UPDATE TAB diff --git a/browser/components/preferences/advanced.xul b/browser/components/preferences/advanced.xul index 27f756fb76e..8d3c5b3db4c 100644 --- a/browser/components/preferences/advanced.xul +++ b/browser/components/preferences/advanced.xul @@ -234,12 +234,12 @@ - - - - + + + + -