Bug 386533 - Mechanism for registering alternative nsILoginManagerStorage implementations. p=sylvain.pasche@gmail.com, r=gavin, a1.9=beltzner
authordolske@mozilla.com
Thu, 21 Feb 2008 17:07:10 -0800
changeset 12059 4bc9eda0f9900ffd90d24b10ab3d706ab6a818a9
parent 12058 b2108d83c12260f085c250641edec3e028c99cea
child 12060 b6a8d54a46dacaeb7ea4ec95ae4374903cfaf2ec
push idunknown
push userunknown
push dateunknown
reviewersgavin
bugs386533
milestone1.9b4pre
Bug 386533 - Mechanism for registering alternative nsILoginManagerStorage implementations. p=sylvain.pasche@gmail.com, r=gavin, a1.9=beltzner
toolkit/components/passwordmgr/src/nsLoginManager.js
--- a/toolkit/components/passwordmgr/src/nsLoginManager.js
+++ b/toolkit/components/passwordmgr/src/nsLoginManager.js
@@ -82,17 +82,30 @@ LoginManager.prototype = {
                             getService(Ci.nsIFormFillController);
         return this.__formFillService;
     },
 
 
     __storage : null, // Storage component which contains the saved logins
     get _storage() {
         if (!this.__storage) {
-            this.__storage = Cc["@mozilla.org/login-manager/storage/legacy;1"].
+
+            var contractID = "@mozilla.org/login-manager/storage/legacy;1";
+            try {
+                var catMan = Cc["@mozilla.org/categorymanager;1"].
+                             getService(Ci.nsICategoryManager);
+                contractID = catMan.getCategoryEntry("login-manager-storage",
+                                                     "nsILoginManagerStorage");
+                this.log("Found alternate nsILoginManagerStorage with " +
+                         "contract ID: " + contractID);
+            } catch (e) {
+                this.log("No alternate nsILoginManagerStorage registered");
+            }
+
+            this.__storage = Cc[contractID].
                              createInstance(Ci.nsILoginManagerStorage);
             try {
                 this.__storage.init();
             } catch (e) {
                 this.log("Initialization of storage component failed: " + e);
                 this.__storage = null;
             }
         }