summaryrefslogtreecommitdiffstats
path: root/application/palemoon/components/preferences
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-26 12:29:03 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-26 12:29:03 +0200
commit0638a11fc4ac96d6f56e0038d140b32906fa5d82 (patch)
treebeca3a943342e5eb802663324e6bcfc8426272f0 /application/palemoon/components/preferences
parent33377b3a9efd171f020fc84dc86d9c36b513887b (diff)
downloadUXP-0638a11fc4ac96d6f56e0038d140b32906fa5d82.tar
UXP-0638a11fc4ac96d6f56e0038d140b32906fa5d82.tar.gz
UXP-0638a11fc4ac96d6f56e0038d140b32906fa5d82.tar.lz
UXP-0638a11fc4ac96d6f56e0038d140b32906fa5d82.tar.xz
UXP-0638a11fc4ac96d6f56e0038d140b32906fa5d82.zip
Bug 1173523 - Part 7: Update advanced.js to use new API for nsIPermission
Diffstat (limited to 'application/palemoon/components/preferences')
-rw-r--r--application/palemoon/components/preferences/advanced.js32
1 files changed, 14 insertions, 18 deletions
diff --git a/application/palemoon/components/preferences/advanced.js b/application/palemoon/components/preferences/advanced.js
index 902a0e3a8..451af6f78 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,
@@ -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 == perm.host) {
+ if (perm.matchesURI(uri, true)) {
var cache = cacheService.getActiveCache(groups[i]);
usage += cache.usage;
}
@@ -427,7 +428,7 @@ 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, groups));
row.setAttribute("usage",
@@ -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,13 +464,18 @@ 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;
+ // get the permission
+ var pm = Components.classes["@mozilla.org/permissionmanager;1"]
+ .getService(Components.interfaces.nsIPermissionManager);
+ var perm = pm.getPermissionObject(principal, "offline-app");
+
// clear offline cache entries
var cacheService = Components.classes["@mozilla.org/network/application-cache-service;1"].
getService(Components.interfaces.nsIApplicationCacheService);
@@ -476,25 +483,14 @@ var gAdvancedPane = {
getService(Components.interfaces.nsIIOService);
var groups = cacheService.getGroups();
for (var i = 0; i < groups.length; i++) {
- let uri = ios.newURI(groups[i], null, null);
- if (uri.asciiHost == host) {
+ var uri = ios.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);
- let uri;
- try {
- // file:// URIs are stored with their scheme. We try to parse them first, as
- // URIs like http://file:///foo/bar/baz.html will parse as HTTP URIs.
- uri = ios.newURI(host, null, null);
- } catch (e) {
- uri = ios.newURI("http://" + host, null, null);
- }
- pm.remove(uri, "offline-app");
+ pm.removePermission(perm);
list.removeChild(item);
gAdvancedPane.offlineAppSelected();