Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the current Firefox profile path from within my applet?

I'm using Network Security Services for Java (JSS) by Mozilla in my applet in order to allow some low-level interaction between my (signed) Java Applet and Mozilla Firefox.

One of the first problem I'm facing is how to find the current Firefox profile path. I need it because I have to call the initialize(String configDir) method of CryptoManager, and the so-called configDir has to be the directory of a Firefox profile.

How can I grab the full path of the current Firefox profile? Is there a clean way or I have to go reading profiles.ini in {$APPDATA}/Firefox, parse it and then choose a random profile (hoping it's only one, or the one I get is the correct one)?

Thanks in advance

like image 806
gd1 Avatar asked Apr 17 '11 17:04

gd1


People also ask

How do I transfer my Firefox profile to a new computer?

The file location is "%APPDATA%\Mozilla\Firefox\Profiles". Simply copy that, throw it on a flash drive, and then move it to the same location on the new machine.

Where are Firefox profiles stored Linux?

In Linux the main Firefox profile folder that stores personal data is in the hidden "~/. mozilla/firefox/" folder. The secondary location in "~/. cache/mozilla/firefox/" is used for the disk cache and isn't important.

Are Firefox profiles separate?

Firefox saves your personal information such as bookmarks, passwords and user preferences in a set of files called your profile, which is stored in a separate location from the Firefox program files. You can have multiple Firefox profiles, each containing a separate set of user information.


2 Answers

In Javascript you can obtain profile and Executable directory:

netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

var profile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile).path

var CurProcD = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("CurProcD", Components.interfaces.nsIFile).path
like image 146
Alfonso Avatar answered Sep 28 '22 03:09

Alfonso


You could try looking at section 1.3.2 here:

http://kb.mozillazine.org/Profile_folder_-_Firefox#Using_the_JavaScript_or_Error_Console

Hope that helps.

like image 23
Ed. Avatar answered Sep 28 '22 02:09

Ed.