Bug 1188348 - data manager: domains invisible for Permissions, Preferences, Passowrds. r=KaiRo a=Callek in a CLOSED TREE BETA_BASE_20151029
authorFrank-Rainer Grahl frgrahl@gmx.net
Thu, 29 Oct 2015 10:03:55 +0800
changeset 23359 7c8dd9e1e3aea50e7d8499dbb08a0ead447e2f6d
parent 23358 e768cc217a1a0df1543b27bea68c0753cfc275d9
child 23360 ed09a2f499508f8f41284c2b5974b3b9b7d38b95
push id1510
push usermbanner@mozilla.com
push dateThu, 29 Oct 2015 19:29:37 +0000
treeherdercomm-beta@d1522aaa8689 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersKaiRo, Callek
bugs1188348
Bug 1188348 - data manager: domains invisible for Permissions, Preferences, Passowrds. r=KaiRo a=Callek in a CLOSED TREE
suite/common/dataman/dataman.js
suite/common/permissions/cookieViewer.js
--- a/suite/common/dataman/dataman.js
+++ b/suite/common/dataman/dataman.js
@@ -280,17 +280,17 @@ var gDomains = {
       yield setTimeout(nextStep, 0);
 
       // Add domains for permissions.
       gDataman.debugMsg("Add permissions to domain list: " + Date.now()/1000);
       gDomains.ignoreUpdate = true;
       let enumerator = Services.perms.enumerator;
       while (enumerator.hasMoreElements()) {
         let nextPermission = enumerator.getNext().QueryInterface(Components.interfaces.nsIPermission);
-        gDomains.addDomainOrFlag(nextPermission.host.replace(/^\./, ""), "hasPermissions");
+        gDomains.addDomainOrFlag(nextPermission.principal.URI.host.replace(/^\./, ""), "hasPermissions");
       }
       gDomains.ignoreUpdate = false;
       gDomains.search(gDomains.searchfield.value);
       yield setTimeout(nextStep, 0);
 
       // Add domains for password rejects to permissions.
       gDataman.debugMsg("Add pwd reject permissions to domain list: " + Date.now()/1000);
       gDomains.ignoreUpdate = true;
@@ -1225,21 +1225,21 @@ var gPerms = {
     this.addHost = document.getElementById("permHost");
     this.addType = document.getElementById("permType");
     this.addButton = document.getElementById("permAddButton");
 
     let enumerator = Services.perms.enumerator;
     while (enumerator.hasMoreElements()) {
       let nextPermission = enumerator.getNext();
       nextPermission = nextPermission.QueryInterface(Components.interfaces.nsIPermission);
-      let rawHost = nextPermission.host.replace(/^\./, "");
+      let rawHost = nextPermission.principal.URI.host.replace(/^\./, "");
       if (gDomains.hostMatchesSelected(rawHost)) {
         let permElem = document.createElement("richlistitem");
         permElem.setAttribute("type", nextPermission.type);
-        permElem.setAttribute("host", nextPermission.host);
+        permElem.setAttribute("host", nextPermission.principal.URI.host);
         permElem.setAttribute("rawHost", rawHost);
         permElem.setAttribute("displayHost",
                               gLocSvc.idn.convertToDisplayIDN(rawHost, {}));
         permElem.setAttribute("capability", nextPermission.capability);
         permElem.setAttribute("class", "permission");
         this.list.appendChild(permElem);
       }
     }
@@ -1402,17 +1402,17 @@ var gPerms = {
         }
         else {
           // Only remove if domain is not shown, note that this may leave an empty domain.
           let haveDomainPerms = false;
           let enumerator = Services.perms.enumerator;
           while (enumerator.hasMoreElements()) {
             let nextPermission = enumerator.getNext();
             nextPermission = nextPermission.QueryInterface(Components.interfaces.nsIPermission);
-            if (domain == gDomains.getDomainFromHost(nextPermission.host.replace(/^\./, "")))
+            if (domain == gDomains.getDomainFromHost(nextPermission.principal.URI.host.replace(/^\./, "")))
               haveDomainPerms = true;
           }
           let rejectHosts = Services.logins.getAllDisabledHosts();
           for (let i = 0; i < rejectHosts.length; i++) {
             if (domain == gDomains.getDomainFromHost(rejectHosts[i]))
               haveDomainPerms = true;
           }
           if (!haveDomainPerms)
@@ -1449,17 +1449,17 @@ var gPerms = {
           let dom = gDomains.getDomainFromHost(rejectHosts[i]);
           if (domainList.indexOf(dom) == -1)
             domainList.push(dom);
         }
         gDomains.resetFlagToDomains("hasPermissions", domainList);
         return;
       }
       aSubject.QueryInterface(Components.interfaces.nsIPermission);
-      let rawHost = aSubject.host.replace(/^\./, "");
+      let rawHost = aSubject.principal.URI.host.replace(/^\./, "");
       let domain = gDomains.getDomainFromHost(rawHost);
       // Does change affect possibly loaded Preferences pane?
       let affectsLoaded = this.list && this.list.childElementCount &&
                           gDomains.hostMatchesSelected(rawHost);
       let permElem = null;
       if (affectsLoaded) {
         for (let i = 0; i < this.list.children.length; i++) {
           let elem = this.list.children[i];
@@ -1474,17 +1474,17 @@ var gPerms = {
         }
         else {
           // Only remove if domain is not shown, note that this may leave an empty domain.
           let haveDomainPerms = false;
           let enumerator = Services.perms.enumerator;
           while (enumerator.hasMoreElements()) {
             let nextPermission = enumerator.getNext();
             nextPermission = nextPermission.QueryInterface(Components.interfaces.nsIPermission);
-            if (domain == gDomains.getDomainFromHost(nextPermission.host.replace(/^\./, "")))
+            if (domain == gDomains.getDomainFromHost(nextPermission.principal.URI.host.replace(/^\./, "")))
               haveDomainPerms = true;
           }
           let rejectHosts = Services.logins.getAllDisabledHosts();
           for (let i = 0; i < rejectHosts.length; i++) {
             if (domain == gDomains.getDomainFromHost(rejectHosts[i]))
               haveDomainPerms = true;
           }
           if (!haveDomainPerms)
@@ -1518,24 +1518,24 @@ var gPerms = {
   },
 
   forget: function permissions_forget() {
     let delPerms = [];
     let enumerator = Services.perms.enumerator;
     while (enumerator.hasMoreElements()) {
       let nextPermission = enumerator.getNext();
       nextPermission = nextPermission.QueryInterface(Components.interfaces.nsIPermission);
-      let host = nextPermission.host;
+      let host = nextPermission.principal.URI.host;
       if (gDomains.hostMatchesSelected(host.replace(/^\./, ""))) {
-        delPerms.push({host: host, type: nextPermission.type});
+      delPerms.push({principal: nextPermission.principal, type: nextPermission.type});
       }
     }
     // Loop backwards so later indexes in the list don't change.
     for (let i = delPerms.length - 1; i >= 0; i--) {
-      Services.perms.remove(delPerms[i].host, delPerms[i].type);
+      Services.perms.removeFromPrincipal(delPerms[i].principal, delPerms[i].type);
     }
     // Also remove all password rejects.
     let rejectHosts = Services.logins.getAllDisabledHosts();
     // Loop backwards so later indexes in the list don't change.
     for (let i = rejectHosts.length - 1; i >= 0; i--) {
       if (gDomains.hostMatchesSelected(rejectHosts[i])) {
         Services.logins.setLoginSavingEnabled(rejectHosts[i], true);
       }
--- a/suite/common/permissions/cookieViewer.js
+++ b/suite/common/permissions/cookieViewer.js
@@ -361,50 +361,53 @@ var permissionsTreeView = {
   isContainer : function(index) {return false;},
   cycleHeader : function(aCol) {},
   getRowProperties : function(row) { return ""; },
   getColumnProperties : function(column) { return ""; },
   getCellProperties : function(row, column) { return ""; }
  };
 var permissionsTree;
 
-function Permission(id, host, rawHost, type, capability) {
+function Permission(id, principal, host, rawHost, type, capability) {
   this.id = id;
+  this.principal = principal;
   this.host = host;
   this.rawHost = rawHost;
   this.type = type;
   this.capability = capability;
 }
 
 function loadPermissions() {
   // load permissions into a table
   var enumerator = permissionmanager.enumerator;
   var canStr = cookieBundle.getString("can");
   var canSessionStr = cookieBundle.getString("canSession");
   var cannotStr = cookieBundle.getString("cannot");
   while (enumerator.hasMoreElements()) {
     var nextPermission = enumerator.getNext();
     nextPermission = nextPermission.QueryInterface(Components.interfaces.nsIPermission);
     if (nextPermission.type == "cookie") {
-      var host = nextPermission.host;
+      var host = nextPermission.principal.URI.host;
       var capability;
       switch (nextPermission.capability) {
         case nsIPermissionManager.ALLOW_ACTION:
           capability = canStr;
           break;
         case nsIPermissionManager.DENY_ACTION:
           capability = cannotStr;
           break;
         case nsICookiePermission.ACCESS_SESSION:
           capability = canSessionStr;
           break;
         default:
           continue;
       }
-      permissions.push(new Permission(permissions.length, host,
+      permissions.push(new Permission(permissions.length,
+                                      nextPermission.principal,
+                                      host,
                                       host.replace(/^\./, ""),
                                       nextPermission.type, capability));
     }
   }
   permissionsTreeView.rowCount = permissions.length;
 
   // sort and display the table
   permissionsTree.view = permissionsTreeView;
@@ -490,17 +493,17 @@ function DeleteAllPermissions() {
 }
 
 function FinalizePermissionDeletions() {
   if (!deletedPermissions.length)
     return;
 
   gUpdatingBatch = "perm-changed";
   for (var p = 0; p < deletedPermissions.length; ++p)
-    permissionmanager.remove(deletedPermissions[p].host, deletedPermissions[p].type);
+    permissionmanager.removeFromPrincipal(deletedPermissions[p].principal, deletedPermissions[p].type);
   deletedPermissions.length = 0;
   gUpdatingBatch = "";
 }
 
 function HandlePermissionKeyPress(e) {
   if (e.keyCode == 46) {
     DeletePermission();
   }