How|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 [color=blue][b]nsIToolkitProfileService [/b][/color]to get current profile by reading the attribute "[color=blue]selectedProfile[/color]". But in some cases, it doesn't work.
For example, we launch XUL as "
xulrunner.exe -no-remote -profile 【How|How to detect current profile for XUL application?】
", you can't get the right profile, it always return the default profile configured in file "
//$USERPROFILE\Application Data\$vendor\$appname\Profiles\$random.default
".
I solved this problem by detecting the folder name of the profile root directory. As for the same reason, you can't get the folder from nsIToolkitProfileService. But, we can get current profile root dir, from the File API. For example,
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;
Simple, but it works well. ; )
推荐阅读
- How|How Fear Works(PartⅡ)
- vue中的条件判断详解v-if|vue中的条件判断详解v-if v-else v-else-if v-show
- HashMap&ConcurrentHashMap&HashTable
- 清晨朗读327(How|清晨朗读327:How Successful People Network with Each Other)
- 90天30个TED演讲|90天30个TED演讲 - Day 25: How to get your ideas to spread
- iOS|iOS -Cannot synthesize weak property because the current deployment target does n
- How|How to make tomato and egg noodles.
- Mixed|Mixed Supervised Object Detection with Robust Objectness Transfer讲解
- jQuery动画
- 你还再说How|你还再说How do you do?快学学外国人地道说法