How to enable Location access · cefsharp/CefSharp · Discussion #3719 (original) (raw)
Another option is to mock the relevant geolocation APIs in JavaScript yourself like mentioned in https://magpcss.org/ceforum/viewtopic.php?f=6&t=17432
Here is an example, Google Earth uses watchPosition
whereas Google Maps uses getCurrentPosition
:
browser.ExecuteScriptAsyncWhenPageLoaded(@" navigator.permissions.query = options => { return Promise.resolve({ state: 'granted' }); }; navigator.geolocation.getCurrentPosition = (success, error, options) => { success({ coords: { latitude: -33.854477, longitude: 151.234738, accuracy: 10, altitude: null, altitudeAccuracy: null, heading: null, speed: null }, timestamp: Date.now() }); }; navigator.geolocation.watchPosition = (success, error, options) => { success({ coords: { latitude: -33.854477, longitude: 151.234738, accuracy: 49, altitude: null, altitudeAccuracy: null, heading: null, speed: null }, timestamp: Date.now() }); return 0; }; ", oneTime: false);
See https://developer.mozilla.org/docs/Web/API/Geolocation for the JavaScript APIs..
Cef references to removed geolocation APIs:
https://bitbucket.org/chromiumembedded/cef/commits/ac86b61
https://bitbucket.org/chromiumembedded/cef/issues/2380/geolocation-can-not-work-after-branch-3239