使用 Mozilla Add-on SDK 中的 XPCOM 组件
我过去曾从事 Mozilla 插件开发(初级水平)。但当遇到 XPCOM 时,我真的很害怕,所以就放弃了。
最近我才遇到了Add-on SDK,发现它真的很酷,而且看到之前花费几个月的工作与SDK的工作时间不超过2天,这真的很令人着迷。现在我又陷入了 XPCOM 模块的困境。
现在我真的很想利用 XPCOM 的强大功能,但是我至少需要一周的时间才能在 SDK 的背景下熟悉 XPCOM。我需要什么代码才能获得我想要的功能?
对于每个用户会话,我想记录一些内容。我能够区分会话。我现在想要的是在用户计算机中创建文件的代码,从加载项打开它并在其中写入一些内容。
用于访问书签和下载并阅读它们的代码。
如果我必须从 SDK 切换回来,那真的会是一个令人心碎的时刻。
I have worked on Mozilla Add-on Development in the past (beginner level). But on encountering XPCOM, I got really scared and left it in the middle.
Recently only I encountered Add-on SDK and found it to be really cool, and it was really fascinating to see that the work that took months before was not more than 2 days work with the SDK. Now again I am stuck on the XPCOM module.
Now I really want to exploit the power of XPCOM but it will take me at least a week to get familiar with XPCOM in the context of SDK. What code do I need to obtain the functionality that I desire?
For each user session, I want to log something. I am able to differentiate sessions. What I want now is the code to create a file in the user's machine, open it from the add-on and write something onto it.
Code to access the bookmarks and downloads and to read them.
It would really be a heart-breaking moment if I would have to switch back from SDK.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
chrome
包 为您提供完整的 XPCOM 访问权限。对于文件访问,最好使用FileUtils
模块:导入模块的语法有些不寻常,这是由于 bug 683217。请注意,
FileUtils.openFileOutputStream()
仅从 Firefox 7 开始可用,如果您想附加到文件,则FileUtils.openSafeFileOutputStream()
不可用。对于书签访问,您可以使用常用的代码片段,开头为:
The
chrome
package gives you full XPCOM access. For file access it is best to use theFileUtils
module:The somewhat unusual syntax to import the module is due to bug 683217. Note that
FileUtils.openFileOutputStream()
is only available starting with Firefox 7 andFileUtils.openSafeFileOutputStream()
isn't usable if you want to append to a file.For bookmark access you use the usual code snippets, starting with: