Bug 374723: re-design password manager API and implement in JS rather than C++, patch by Justin Dolske <dolske@mozilla.com>, r=mconnor, r=me
authorgavin@gavinsharp.com
Tue, 02 Oct 2007 20:35:36 -0700
changeset 6586 b59d67f74cb9d004d10ae0d90fda6bcc874ec283
parent 6585 8cb4047f92358029e1415010a431478f0e785a65
child 6587 59a3eabee8abcf151d2e9f97c47bbf651d649994
push idunknown
push userunknown
push dateunknown
reviewersmconnor, me
bugs374723
milestone1.9a9pre
Bug 374723: re-design password manager API and implement in JS rather than C++, patch by Justin Dolske <dolske@mozilla.com>, r=mconnor, r=me
browser/modules/Sanitizer.jsm
--- a/browser/modules/Sanitizer.jsm
+++ b/browser/modules/Sanitizer.jsm
@@ -189,34 +189,27 @@ Sanitizer.prototype = {
                               .getService(Components.interfaces.nsIDownloadManager);
         return dlMgr.canCleanUp;
       }
     },
     
     passwords: {
       clear: function ()
       {
-        var pwmgr = Components.classes["@mozilla.org/passwordmanager;1"]
-                              .getService(Components.interfaces.nsIPasswordManager);
-        var e = pwmgr.enumerator;
-        var passwds = [];
-        while (e.hasMoreElements()) {
-          var passwd = e.getNext().QueryInterface(Components.interfaces.nsIPassword);
-          passwds.push(passwd);
-        }
-        
-        for (var i = 0; i < passwds.length; ++i)
-          pwmgr.removeUser(passwds[i].host, passwds[i].user);
+        var pwmgr = Components.classes["@mozilla.org/login-manager;1"]
+                              .getService(Components.interfaces.nsILoginManager);
+        pwmgr.removeAllLogins();
       },
       
       get canClear()
       {
-        var pwmgr = Components.classes["@mozilla.org/passwordmanager;1"]
-                              .getService(Components.interfaces.nsIPasswordManager);
-        return pwmgr.enumerator.hasMoreElements();
+        var pwmgr = Components.classes["@mozilla.org/login-manager;1"]
+                              .getService(Components.interfaces.nsILoginManager);
+        var logins = pwmgr.getAllLogins({});
+        return (logins.length > 0);
       }
     },
     
     sessions: {
       clear: function ()
       {
         // clear all auth tokens
         var sdr = Components.classes["@mozilla.org/security/sdr;1"]