From 27d64093adffeeb5d4cd8acf8a5ae428a9ad989a Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Thu, 9 Apr 2015 17:30:29 +0200 Subject: [PATCH] * initialize and terminate have to return a Promise * use this.log instead of log * in findLogins rename the variable httpRealm in the loop to itemHttpRealm to avoid name clash with the httpRealm argument * bump versions --- components/loginManagerStorage.js | 23 +++++++++++++++-------- install.rdf | 6 +++--- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/components/loginManagerStorage.js b/components/loginManagerStorage.js index 83f4566..43aeaab 100644 --- a/components/loginManagerStorage.js +++ b/components/loginManagerStorage.js @@ -2,6 +2,7 @@ const Cc = Components.classes; const Ci = Components.interfaces; Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); +Components.utils.import("resource://gre/modules/Promise.jsm"); var keyring = {}; Components.utils.import("chrome://gnome-keyring/content/gnome-keyring.js", keyring); @@ -55,7 +56,7 @@ GnomeKeyringLoginManagerStorage.prototype = { this.log("Called " + arguments.callee.name + "(" + args.join(",") + ")"); }, - initialize: function() { + init: function() { var prefBranch = Cc["@mozilla.org/preferences-service;1"] .getService(Ci.nsIPrefService) .getBranch(this.prefBranch); @@ -75,19 +76,25 @@ GnomeKeyringLoginManagerStorage.prototype = { try { keyring.create(this.keyringName, null); } catch(e) { - log("Exception: " + e + " in " + e.stack); + this.log("Exception: " + e + " in " + e.stack); } } try { keyring.unlock(this.keyringName, null); } catch(e) { - log("Exception: " + e + " in " + e.stack); + this.log("Exception: " + e + " in " + e.stack); } }, - init: function() { this.initialize(); }, + initialize: function() { + this.init(); + return new Promise(function (resolve) { resolve(); }); + }, initWithFile: function(aInputFile, aOutputFile) { this.init(); }, + terminate: function() { + return new Promise(function (resolve) { resolve(); }); + }, addLogin: function(login) { var attr = {}; attr[this.attributeHostname] = login.hostname; @@ -194,16 +201,16 @@ GnomeKeyringLoginManagerStorage.prototype = { /** * The HttpRealm must be either a non empty string or null */ - var httpRealm = item.attributes[this.attributeHttpRealm]; - if(httpRealm == "") { - httpRealm = null; + var itemHttpRealm = item.attributes[this.attributeHttpRealm]; + if(itemHttpRealm == "") { + itemHttpRealm = null; } var login = Components.classes["@mozilla.org/login-manager/loginInfo;1"] .createInstance(Components.interfaces.nsILoginInfo); login.init(item.attributes[this.attributeHostname], item.attributes[this.attributeFormSubmitURL], - httpRealm, + itemHttpRealm, item.attributes[this.attributeUsername], item.secret, item.attributes[this.attributeUsernameField], diff --git a/install.rdf b/install.rdf index f1613b8..3a727b3 100644 --- a/install.rdf +++ b/install.rdf @@ -7,7 +7,7 @@ gnome-keyring-integration@sebastianwick.net GNOME Keyring integration GNOME Keyring integration - 0.6 + 0.7 Sebastian Wick https://github.com/swick/moz-gnome-keyring-integration 2 @@ -17,7 +17,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 4.0 - 32.* + 39.* @@ -26,7 +26,7 @@ {3550f703-e582-4d05-9a08-453d09bdfdc6} 5.* - 32.* + 39.*