Re: Javaxpcom: Registering content-policy to category manager
"Grant Gayed" <[email protected]> Wed, 5 May 2010 10:15:21 -0400
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Message-ID | <YYudnbbZY9Xn4HzWnZ2dnUVZ_sGdnZ2d__8755.94497561014$1273069253$gmane$org@mozilla.org> |
You may get more response if you ask this on the mozilla.dev.embedding newsgroup since this isn't a JavaXPCOM-specific question. Grant <[email protected]> wrote in message news:[email protected]... Hi all. I want to register my own ContentPolicy to the category manager. I am able to get the category manager via nsICategoryManager catMang = (nsICategoryManager)servMgr. getServiceByContractID("@mozilla.org/categorymanager;1", nsICategoryManager.NS_ICATEGORYMANAGER_IID); For test purpose, I have implemented the nsIContentPolicy interface by a small testclass called MyContentPolicy. But upto now, I didn't found a hint, how to register an instance of the class or to tell the category manager to instantiate it on himself. I think, I have to use the addCategoryEntry method of the category manager, with "content-policy" as first parameter, which also needs the classpath and the contract id of the xpcom component. Is this right? Can anybody give me a hint, what exactly to do, to register the class below? Do I e.g. have to define an ID or something like that (which are the rules for defining such an ID?) What would be the right parameter for the classname in addCategoryEntry? package test; import org.mozilla.interfaces.*; public class MyContentPolicy implements nsIContentPolicy { public MyContentPolicy () { System.out.println("MyContentPolicy () called"); } public short shouldLoad(long arg0, nsIURI arg1, nsIURI arg2, nsISupports arg3, String arg4, nsISupports arg5) { System.out.println("shouldLoad called"); return nsIContentPolicy.ACCEPT; } public short shouldProcess(long arg0, nsIURI arg1, nsIURI arg2, nsISupports arg3, String arg4, nsISupports arg5) { System.out.println("shouldProcess called"); return nsIContentPolicy.ACCEPT; } public nsISupports queryInterface(String arg0) { // TODO Auto-generated method stub return null; } } Thank you for your advise! Best regards.