How to detect current profile for XUL application?
标题: 如何获得XUL应用的当前profile,希望这篇英文日志能够帮到惯用英语搜索的人
When we launch our XUL application in multiple profiles mode, we may need to know which profile it works on.
Mozilla provides the interfaces as nsIToolkitProfileService to get current profile by reading the attribute "selectedProfile". But in some cases, it doesn't work.
For example, we launch XUL as "
xulrunner.exe -no-remote -profile <profile path or name>", you can't get the right profile, it always return the default profile configured in file "
//$USERPROFILE\Application Data\$vendor\$appname\Profiles\$random.default".
var dirService = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);var profDir = dirService.get("ProfD", Components.interfaces.nsIFile);var profName = profDir.leafName;