"Arun" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am trying to write a componant which will be used to block sites. I
> derived my componant from nsIContentPolicy Interface and registerd the
> "content-policy" category during the registration process. It should
> call ShouldLoad function of nsIContentPolicy when I visit a web site
> but it is not doing so.
>
> This is done in the registration function
>
> nsCOMPtr<nsICategoryManager> catman;
> rv =
servman->GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACTID,NS_GET_IID(nsI
CategoryManager), getter_AddRefs(catman));
>
> rv = catman->AddCategoryEntry("xpcom-startup","WebLock",
> WebLock_ContractID,PR_TRUE,PR_TRUE,&previous);
>
>
> rv = catman->AddCategoryEntry("content-policy","WebLock",
> WebLock_ContractID,PR_TRUE,PR_TRUE,&previous);
>
> and then I have ShouldLoad function. but it never gets executed.
>
> any ideas why it does not work?
>
> It however works for the "xpcom-startup" category and I am getting the
> notifications when I start the browser.
> I am using netscape 7.1 which is build on Mozilla 1.4
Hi Arun,
First take it from me - you should use Mozilla build 1.02 with Netscape 7.x.
You will pull your hair out if you do not ,as there are many version
mismatch problems - believe me when I say that.
I have had problems with the "AddCategoryEntry" method on Netscape 7.x. Are
you checking the result (rv) after you add the category? Also I would make
sure that you are utilizing a try-catch block. I would bet my pay check
that "AddCategoryEntry" is failing.
This is the only way I got my registration functionality to work for
Netscape 7.x - regardless of whatever you read in any book.
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPinpointCitationToolbar)
static NS_METHOD nsSagebrushToolbarRegistration(nsIComponentManager
*aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const char *componentType,
const nsModuleComponentInfo
*info)
{
return NS_OK;
}
static NS_METHOD nsSagebrushToolbarUnregistration(nsIComponentManager
*aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const nsModuleComponentInfo
*info)
{
return NS_OK;
}
NS_DECL_CLASSINFO(nsPinpointCitationToolbar)
static const nsModuleComponentInfo components[] =
{
{ "Pinpoint Citation Toolbar",
NS_SAGEBRUSH_CID,
sagebrush_ContractID,
nsPinpointCitationToolbarConstructor,
nsSagebrushToolbarRegistration,
nsSagebrushToolbarUnregistration
}
};
NS_IMPL_NSGETMODULE(nsPinpointCitationToolbar, components)