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 a开发者_JAVA百科nd then choose a random profile (hoping it's only one, or the one I get is the correct one)?
Thanks in advance
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
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.
精彩评论