3

I wanted to implement a web browser control to Geo-location enable my WinForm desktop application.

I have successfully implemented the GeckoFX web browser in my WinForm project. The problem is when visiting a HTML5 Gelocation enabled website/address the "Allow/Deny access" popup does not appear.

As a result the Geo-location does not work. I have confirmed that Geo-location is enabled in preferences and have tested my WinForm using http://html5test.com and the control is listed as supporting Geo-location.

I have already tried to set permissions via the XPCom API for a specific domain so that the pop-up asking for permission would not be needed:

   //CREATE nsSTRING
            nsAUTF8String i = new nsAUTF8String("http://html5demos.com");

            //CREATE NEW URI
            var nsII = Xpcom.CreateInstance<nsIIOService>("@mozilla.org/network/io-service;1");
            nsIURI uri = nsII.NewURI(i, "Unicode", null);

            //CREATE PERMISSION MANAGER
            var instancePM = Xpcom.CreateInstance<nsIPermissionManager>("@mozilla.org/permissionmanager;1");

            //GEO PERMISSION SETTINGS
            uint permission = Convert.ToUInt32(1);
            uint expiretype = Convert.ToUInt32(0);
            long expireTime = (long)0;

            //ADD GEO PERMISSION SETTINGS  (THIS SHOULD ALLOW GEO LOCATION TO JUST RUN WITH NO PROMPT)
            instancePM.Add(uri, "geo", permission, expiretype, expireTime);

            //TEST PERMISSIONS http://html5demos.com 
            uint testResult = instancePM.TestExactPermission(uri, "geo"); //RETURN SCORRECT SETTING OF 1 = OK

This did return a tested value of 1 but still the Geo-location does not work.

I have already seen this stackoverflow question: Gecko for windows forms and geolocation. How to accept request for share my location?, but not really sure where to go from there.

I am sure I need to implement the call myself as the control is just the browser window and not all the other bits n bobs that make up a browser application. Does anyone have any suggestions or perhaps have already implemented Geo-location in GeckoFX using WinForms and C#?

Thanks Andre

Community
  • 1
  • 1
user2876638
  • 31
  • 1
  • 2

0 Answers0