diff --git a/browser/components/preferences/advanced.js b/browser/components/preferences/advanced.js index 6b5cdd1e0d5..e41921988b7 100644 --- a/browser/components/preferences/advanced.js +++ b/browser/components/preferences/advanced.js @@ -70,6 +70,7 @@ var gAdvancedPane = { #ifdef MOZ_CRASHREPORTER this.initSubmitCrashes(); #endif + this.updateActualCacheSize(); }, /** @@ -190,6 +191,8 @@ var gAdvancedPane = { * * browser.cache.disk.capacity * - the size of the browser cache in KB + * browser.cache.disk.smart_size.enabled + * - If disabled, disk.capacity is used */ /** @@ -200,7 +203,50 @@ var gAdvancedPane = { document.documentElement.openSubDialog("chrome://browser/content/preferences/connection.xul", "", null); }, + + // Retrieves the amount of space currently used by disk cache + updateActualCacheSize: function () + { + var visitor = { + visitDevice: function (deviceID, deviceInfo) + { + if (deviceID == "disk") { + var actualSizeLabel = document.getElementById("actualCacheSize"); + var sizeStrings = DownloadUtils.convertByteUnits(deviceInfo.totalSize); + var prefStrBundle = document.getElementById("bundlePreferences"); + var sizeStr = prefStrBundle.getFormattedString("actualCacheSize", + sizeStrings); + actualSizeLabel.value = sizeStr; + } + // Do not enumerate entries + return false; + }, + visitEntry: function (deviceID, entryInfo) + { + // Do not enumerate entries. + return false; + } + }; + var cacheService = + Components.classes["@mozilla.org/network/cache-service;1"] + .getService(Components.interfaces.nsICacheService); + cacheService.visitEntries(visitor); + }, + + updateCacheSizeUI: function (smartSizeEnabled) + { + document.getElementById("useCacheBefore").disabled = smartSizeEnabled; + document.getElementById("cacheSize").disabled = smartSizeEnabled; + document.getElementById("useCacheAfter").disabled = smartSizeEnabled; + }, + + readSmartSizeEnabled: function () + { + var enabled = document.getElementById("browser.cache.disk.smart_size.enabled").value; + this.updateCacheSizeUI(enabled); + }, + /** * Converts the cache size from units of KB to units of MB and returns that * value. @@ -232,6 +278,7 @@ var gAdvancedPane = { try { cacheService.evictEntries(Components.interfaces.nsICache.STORE_ANYWHERE); } catch(ex) {} + this.updateActualCacheSize(); }, readOfflineNotify: function() diff --git a/browser/components/preferences/advanced.xul b/browser/components/preferences/advanced.xul index fb25989f508..aad310f00b1 100644 --- a/browser/components/preferences/advanced.xul +++ b/browser/components/preferences/advanced.xul @@ -85,8 +85,12 @@ - - + + + + #ifdef MOZ_UPDATER - - - + + + - - &connectionDesc.label; -