Skip to content

Commit

Permalink
* initialize and terminate have to return a Promise
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
swick committed Apr 9, 2015
1 parent 15c0619 commit 27d6409
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
23 changes: 15 additions & 8 deletions components/loginManagerStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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],
Expand Down
6 changes: 3 additions & 3 deletions install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<em:id>gnome-keyring-integration@sebastianwick.net</em:id>
<em:name>GNOME Keyring integration</em:name>
<em:description>GNOME Keyring integration</em:description>
<em:version>0.6</em:version>
<em:version>0.7</em:version>
<em:creator>Sebastian Wick</em:creator>
<em:homepageURL>https://github.com/swick/moz-gnome-keyring-integration</em:homepageURL>
<em:type>2</em:type>
Expand All @@ -17,7 +17,7 @@
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>4.0</em:minVersion>
<em:maxVersion>32.*</em:maxVersion>
<em:maxVersion>39.*</em:maxVersion>
</Description>
</em:targetApplication>

Expand All @@ -26,7 +26,7 @@
<Description>
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
<em:minVersion>5.*</em:minVersion>
<em:maxVersion>32.*</em:maxVersion>
<em:maxVersion>39.*</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
Expand Down

0 comments on commit 27d6409

Please sign in to comment.