我正在做一个配置文件切换插件,偶然发现了nsICategoryManager。
我想知道这是什么?它的一些实际用途是什么?
我读了MDN的文章,但想不出它有什么用
nsICategoryManager
的目的是将条目(通常是XPCOM组件)添加到类别中。管理器本身仅仅提供了注册机制,如何使用类别完全取决于读取类别条目的代码。例如,这里是profile-after-change
类别,用于在Firefox启动时需要激活的组件。
大多数扩展不应该再显式地使用nsICategoryManager
,添加一个类别条目可以在chrome.manifest
:
category profile-after-change MyComponent @foobar/mycomponent;1
这将在扩展被激活时隐式调用nsICategoryManager.addCategoryEntry()
。
Edit:出于好奇,我决定在Firefox源代码中搜索nsCategoryCache
,看看还有什么其他类别。下面是列表:
-
"content-policy"
fornsIContentPolicy
实例 -
"net-content-sniffers"
和"content-sniffing-services"
的nsIContentSniffer
实例。 -
"vacuum-participant"
formozIStorageVacuumParticipant
instances. -
"bookmark-observers"
fornsINavBookmarkObserver
instance . -
"history-observers"
fornsINavHistoryObserver
instances. -
"idle-daily"
用于nsIIdleService
管理的观察者。
这些只是正在缓存和监视更改的类别,完整的列表要长得多。