views:

323

answers:

2

Hi,

I have an application in which a gecko browser is embedded. The application is crashing when I try to access any https url's because nss is not properly initialised at this point. The crash is in PK11_TokenExists(). I want to block my browser from rendering https sites. If a user clicks on a https link I can block that load in OnStartURI() of nsIURIContentListener.But if the user types in say orkut.com I wont know in OnStartURI() whether its a http url or a https one(i.e. whether it will use SSL or not). I wanted to know how I can block https url's in such cases?

Thanks jbsp72

+1  A: 

I would first try to figure out why your application is crashing on HTTPS/SSL connections. I think it would be better to fix the crash than trying to avoid it.

Otherside
+1  A: 

You can implement this the following way:

Implement the OnStateChange method of the nsIWebProgressListener interface.

Check the parameter aStateFlags: If this parameter contains the flags STATE_IS_DOCUMENT and STATE_START, then a new location is being navigated to.

To find out the URL, use the parameter aRequest. It has type nsIRequest, but cast it to type nsIChannel. Then read the URI property. This contains the URL being navigated to.

In case the URI starts with "https", abort the navigation by calling the cancel method of the parameter aRequest, passing NS_BINDING_ABORTED as a parameter.

NineBerry