I am creating application which gets URL from Firefox on every pageload.
I donít want to use javascript.

For that I took help of WebLock's demo.
for my requirement component should loaded and should start automatically and on every page load it should get url.

For that I refer WebLockís Demo.
In implemented code like WebLock's example using nsContentPolicy
Can my C++ component lonely do get urlís?

Now my application is in stage that it is loaded automatically but ShouldLoad() method is not get called.......

also i have dout with nsIContentPolicy interface.it is not frozen.....

i am using Firefox 3.0 and xulrunner-1.9.0.17.en-US.win32.sdk.

please guide me regarding it.


here is my code ::


#define MOZILLA_STRICT_API

#include "nsIGenericFactory.h"

#include "nsCOMPtr.h"
#include "nsXPCOM.h"
#include "nsIServiceManager.h"
#include "nsICategoryManager.h"
#include "nsMemory.h"
#include "nsEmbedString.h"
#include "nsIDOMWindow.h"
#include "WebDemo.h"
#include "nsIContentPolicy.h"
#include
#include





WebLock::WebLock()
{
NS_INIT_ISUPPORTS();
}

WebLock::~WebLock()
{
}

NS_IMPL_ISUPPORTS3(WebLock, nsIObserver,iWebLock,nsIContentPolicy);


NS_IMETHODIMP WebLock::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
{
return NS_OK;
}

static NS_METHOD WebLockRegistration( nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const char *componentType,
const nsModuleComponentInfo *info)
{
nsresult rv;
nsCOMPtr servman = do_QueryInterface((nsISupports*)aCompMgr, &rv);
if (NS_FAILED(rv))
return rv;

nsCOMPtr catman;
servman->GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACT ID,
NS_GET_IID(nsICategoryManager),
getter_AddRefs(catman));
if (NS_FAILED(rv))
return rv;

char* previous = nsnull;
rv = catman->AddCategoryEntry("xpcom-startup",
"WebLock",
WebLock_ContractID,
PR_TRUE,
PR_TRUE,
&previous);
if (previous)
nsMemory::Free(previous);

rv = catman->AddCategoryEntry("content-policy",
"WebLock",
WebLock_ContractID,
PR_TRUE,
PR_TRUE,
&previous);
if (previous)
nsMemory::Free(previous);
return rv;
}


static NS_METHOD WebLockUnregistration(nsIComponentManager *aCompMgr,nsIFile *aPath,const char *registryLocation,const nsModuleComponentInfo *info)
{
nsresult rv;

nsCOMPtr servman = do_QueryInterface((nsISupports*)aCompMgr, &rv);
if (NS_FAILED(rv))
return rv;

nsCOMPtr catman;
rv = servman->GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACT ID,
NS_GET_IID(nsICategoryManager),
getter_AddRefs(catman));
if (NS_FAILED(rv))
return rv;

rv = catman->DeleteCategoryEntry("xpcom-startup",
"WebLock",
PR_TRUE);
// printf("\n Inside Un-Registration........");

return rv;
}

NS_IMETHODIMP WebLock::ShouldLoad(PRUint32 aContentType,nsIURI *aContentLocation,
nsIURI *aRequestOrigin,
nsISupports *aContext,
const nsACString & aMimeTypeGuess,
nsISupports *aExtra,
PRInt16 *_retval)
{
// get url
// do IPC

MessageBox(NULL,L"inside shouldload ()",L"Success",MB_OK);
return NS_OK;
}

NS_IMETHODIMP WebLock::ShouldProcess(PRUint32 aContentType, nsIURI *aContentLocation, nsIURI *aRequestOrigin, nsISupports *aContext, const nsACString & aMimeType, nsISupports *aExtra, PRInt16 *_retval)
{
return NS_OK;
}

NS_IMETHODIMP WebLock::MyMethod(void)
{
//some code goes here
return NS_OK;
}

NS_GENERIC_FACTORY_CONSTRUCTOR(WebLock)


static const nsModuleComponentInfo components[] =
{
{
"WebLock",
WebLock_CID,
WebLock_ContractID,
WebLockConstructor,
WebLockRegistration,
WebLockUnregistration,
}
};

NS_IMPL_NSGETMODULE(WebLockModule, components)