Update on the status of project

So what I have been doing for the past two weeks was to make the extension to work and clean up on the code. In my previous post, I mentioned that the difficulty that I encountered was to retrieve the information (hostname and ActionURL as indicated in Mozilla documentation for findLogins method) of the html form submitted so that I can search for the logins (nsILoginInfo object).

I was kind of stucked until I thought of the way to search for the code that actually saved the login when the form was submitted. This way, I can know how the information was stored and might be able to tell me how to retrieve the information. So, I search for the addLogins method in MXR. It pointed me to two files, nsLoginManager.js and nsLoginManagerPrompter.js. But it was quite difficult to search for which function was called when the login button was clicked. So, I tried to inspect
the notification bar (It contains the prompt “Do you want firefox to remember the password”) that pops up everytime we log in into a website.

So at the location was a button with the value “Remember”. It didn’t help much. I figured that the nsLOginManagerPrompter.js must be in charge of prompting the user, so I tried searching for the “Remember” word in the file. And it brought me to the _showSaveLoginNotification function. After going through the code, I come to the following sequence of function calls:

When a login form is Submitted -> _onFormSubmit() in nsLoginManager.js -> promptToSavePasswords() in nsLoginManagerPrompter.js -> _showSaveLoginNotification() to display the notification bar -> and finally addLogins() in nsLOginManager.js

So I noticed that in the _onFormSubmit function, it retrieves the information from the form submitted by calling the other two functions: _getPasswordOrigin to retrieve the hostname and _getActionOrigin to retrieve the formSubmitURL. I think these two should be the functions that I was looking for. So I extracted from the function, the code that I needed for my extension and it works. I also made use of the _getFormFields() function to get the value of the username field.

So, then I cleaned up the code and added some comments and it is now uploaded to addons.mozilla.org. Please feel free to give your comments and suggestions to me. Thanks.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: