summaryrefslogtreecommitdiffstats
path: root/application/palemoon/components/preferences/advanced.js
diff options
context:
space:
mode:
Diffstat (limited to 'application/palemoon/components/preferences/advanced.js')
-rw-r--r--application/palemoon/components/preferences/advanced.js49
1 files changed, 25 insertions, 24 deletions
diff --git a/application/palemoon/components/preferences/advanced.js b/application/palemoon/components/preferences/advanced.js
index 429a0c419..0803496fe 100644
--- a/application/palemoon/components/preferences/advanced.js
+++ b/application/palemoon/components/preferences/advanced.js
@@ -8,6 +8,7 @@ Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
Components.utils.import("resource://gre/modules/ctypes.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/LoadContextInfo.jsm");
+Components.utils.import("resource://gre/modules/BrowserUtils.jsm");
var gAdvancedPane = {
_inited: false,
@@ -377,7 +378,7 @@ var gAdvancedPane = {
},
// XXX: duplicated in browser.js
- _getOfflineAppUsage: function (host, groups)
+ _getOfflineAppUsage: function (perm, groups)
{
var cacheService = Components.classes["@mozilla.org/network/application-cache-service;1"].
getService(Components.interfaces.nsIApplicationCacheService);
@@ -390,7 +391,7 @@ var gAdvancedPane = {
var usage = 0;
for (var i = 0; i < groups.length; i++) {
var uri = ios.newURI(groups[i], null, null);
- if (uri.asciiHost == host) {
+ if (perm.matchesURI(uri, true)) {
var cache = cacheService.getActiveCache(groups[i]);
usage += cache.usage;
}
@@ -427,9 +428,9 @@ var gAdvancedPane = {
var row = document.createElement("listitem");
row.id = "";
row.className = "offlineapp";
- row.setAttribute("host", perm.host);
+ row.setAttribute("origin", perm.principal.origin);
var converted = DownloadUtils.
- convertByteUnits(this._getOfflineAppUsage(perm.host, groups));
+ convertByteUnits(this._getOfflineAppUsage(perm, groups));
row.setAttribute("usage",
bundle.getFormattedString("offlineAppUsage",
converted));
@@ -453,7 +454,8 @@ var gAdvancedPane = {
{
var list = document.getElementById("offlineAppsList");
var item = list.selectedItem;
- var host = item.getAttribute("host");
+ var origin = item.getAttribute("origin");
+ var principal = BrowserUtils.principalFromOrigin(origin);
var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
@@ -462,35 +464,34 @@ var gAdvancedPane = {
var bundle = document.getElementById("bundlePreferences");
var title = bundle.getString("offlineAppRemoveTitle");
- var prompt = bundle.getFormattedString("offlineAppRemovePrompt", [host]);
+ var prompt = bundle.getFormattedString("offlineAppRemovePrompt", [principal.URI.prePath]);
var confirm = bundle.getString("offlineAppRemoveConfirm");
var result = prompts.confirmEx(window, title, prompt, flags, confirm,
null, null, null, {});
if (result != 0)
return;
- // clear offline cache entries
- var cacheService = Components.classes["@mozilla.org/network/application-cache-service;1"].
- getService(Components.interfaces.nsIApplicationCacheService);
- var ios = Components.classes["@mozilla.org/network/io-service;1"].
- getService(Components.interfaces.nsIIOService);
- var groups = cacheService.getGroups();
- for (var i = 0; i < groups.length; i++) {
- var uri = ios.newURI(groups[i], null, null);
- if (uri.asciiHost == host) {
+ // get the permission
+ var pm = Components.classes["@mozilla.org/permissionmanager;1"]
+ .getService(Components.interfaces.nsIPermissionManager);
+ var perm = pm.getPermissionObject(principal, "offline-app");
+ 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], null, null);
+ if (perm.matchesURI(uri, true)) {
var cache = cacheService.getActiveCache(groups[i]);
cache.discard();
+ }
}
- }
-
- // remove the permission
- var pm = Components.classes["@mozilla.org/permissionmanager;1"]
- .getService(Components.interfaces.nsIPermissionManager);
- pm.remove(host, "offline-app",
- Components.interfaces.nsIPermissionManager.ALLOW_ACTION);
- pm.remove(host, "offline-app",
- Components.interfaces.nsIOfflineCacheUpdateService.ALLOW_NO_WARN);
+ } catch (e) {}
+ pm.removePermission(perm);
+ }
list.removeChild(item);
gAdvancedPane.offlineAppSelected();
this.updateActualAppCacheSize();