Hello,
I created an XPCOM component to listen to some events from Mozilla (1.7). The component was successfully hooked into Mozilla and it get launched everytime Mozilla is started. The problem is that even this component implements the nsIWebProgressListener interface, it still cannot catch any progress event (when I get into the code, I found out that everything was ok, including the AddProgressListener method). The same thing happens when I place this registration code in the Observe method as someone here suggested. Part of the code is presented in the following. I would appricate very much if anyone could help me to figure out what's still missing?
-------- The header (.h)
class GNPMozilla: public INPMozilla, public nsIObserver, public nsIWebProgressListener, public nsSupportsWeakReference
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_INPMOZILLA
GNPMozilla();
private:
virtual ~GNPMozilla();protected: };
-------- The implementation (.cpp)
GNPMozilla::GNPMozilla()
{
nsresult rv;
nsCOMPtr<nsIServiceManager> pSvcMgr;
// get the global service manager.
rv = NS_GetServiceManager(getter_AddRefs(pSvcMgr));
if (NS_FAILED(rv))
return;
nsCOMPtr<nsIWebProgress> pWebProgress;
rv = pSvcMgr->GetServiceByContractID(
"@mozilla.org/appshell/component/browser-status-filter;1", NS_GET_IID(nsIWebProgress), getter_AddRefs(pWebProgress));
if (NS_FAILED(rv))
return;
// add me as a progress listener.
rv = pWebProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_ALL);
if (NS_FAILED(rv))
return;
}
NS_IMETHODIMP GNPMozilla::OnLocationChange( nsIWebProgress* aWebProgress, nsIRequest* aRequest, nsIURI* aLocation ) { return NS_OK; }
NS_IMETHODIMP
GNPMozilla::OnProgressChange(
nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
PRInt32 aCurSelfProgress,
PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress,
PRInt32 aMaxTotalProgress
)
{
return NS_OK;
}NS_IMETHODIMP
GNPMozilla::OnSecurityChange(
nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
PRUint32 aState
)
{
return NS_OK;
}NS_IMETHODIMP
GNPMozilla::OnStateChange(
nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
PRUint32 aStateFlags,
nsresult aStatus
)
{
return NS_OK;
}NS_IMETHODIMP
GNPMozilla::OnStatusChange(
nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsresult aStatus,
const PRUnichar* aMessage
)
{
return NS_OK;
}_______________________________________________ Mozilla-xpcom mailing list [email protected] http://mail.mozilla.org/listinfo/mozilla-xpcom
