Re: simple nsIWebProgressListener question
[email protected] (yueweng)
| Newsgroups | gmane.comp.mozilla.devel.xpinstall |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <bdd3dfe3.0407140202.5a7d5e33__8386.66926506466$1089799679$gmane$org@posting.google.com> |
Christian Biesinger <[email protected]> wrote in message news:<[email protected]>... > On Tue, Jul 13, 2004 at 11:40:42AM +0100, Neil wrote: > > I can't tell you where you would get a document loader from. > > http://lxr.mozilla.org/seamonkey/source/uriloader/base/nsCURILoader.idl#68 > (use do_GetService) > > -- Hi, Thanks for the answers. I have implement the suggestion in the following code, but, I am still not able to capture any browser signal yet. May I know if there is anything I missed out in the following code in order to start receiving Mozilla browser event? I have no compilation error. The following is a summary of my code: HEADER: -------------- class myListener : public nsIWebProgressListener, public nsSupportsWeakReference { public: myListener(); ~myListener(); NS_DECL_ISUPPORTS NS_DECL_NSIWEBPROGRESSLISTENER }; class nsSampleImpl : public nsISample { public: nsSampleImpl(); ......... }; /////////////////////////////////////////////////////////////////////////////////////////////////////////// CPP: -------- static NS_DEFINE_IID(kDocLoaderServiceCID, NS_URI_LOADER_CID); myListener::myListener() { // Register as an observer for the document loader nsCOMPtr<nsIWebProgress> progress(do_GetService(kDocLoaderServiceCID)); if (progress) progress->AddProgressListener(this, nsIWebProgress::NOTIFY_ALL); else printf("myListener(): error->progress is null."); } ........ NS_IMETHODIMP myListener::OnStateChange(nsIWebProgress* aWebProgress, nsIRequest *aRequest, PRUint32 progressStateFlags, nsresult aStatus) { ............ } nsSampleImpl::nsSampleImpl() { printf("nsSampleImpl() enter.\n"); mListener = nsnull; mListener = new myListener(); printf("nsSampleImpl() exit.\n"); } ............. yueweng