firefox插件- nsICategoryManager的实际使用



我正在做一个配置文件切换插件,偶然发现了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" for nsIContentPolicy实例
  • "net-content-sniffers""content-sniffing-services"nsIContentSniffer实例。
  • "vacuum-participant" for mozIStorageVacuumParticipant instances.
  • "bookmark-observers" for nsINavBookmarkObserver instance .
  • "history-observers" for nsINavHistoryObserver instances.
  • "idle-daily"用于nsIIdleService管理的观察者。

这些只是正在缓存和监视更改的类别,完整的列表要长得多。

最新更新