/gist:c5c5cd80f27f3158f451 Secret
Last active
December 7, 2018 23:32
-
-
Save mkruisselbrink/c5c5cd80f27f3158f451 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just the new parts for the interface exposed on navigator.geolocation. | |
// In addition there will be two more events, 'regionenter' and 'regionexit'. | |
interface Geolocation : EventTarget { | |
// Registers a Region. If a Region with the same ID has already been | |
// registered the new region will override it. | |
// | |
// The Promise is called with success when the region was successfully | |
// registered, rejected on failure. Possible failure reasons include the | |
// user not accepting the location request, or the Region being invalid. | |
// | |
// Registered regions are scoped to the frame they were registered in, both | |
// with regards to lifetime and for uniqueness of the ID. | |
// Additionally regions can be registered from a ServiceWorker, in which case | |
// they are scoped to (the URL of) that ServiceWorker. | |
// TBD: Should a regular frame somehow be able to directly register a region | |
// which will result in events being send to the ServiceWorker associated | |
// with the frame? | |
// TBD: It would be nice if when a website has registered a region, we could | |
// deliver the regionenter/regionexit events as long as the tab remains | |
// open, even if for example on Android chrome has decided to kill the | |
// associated renderer process (but it is unclear how that would work with | |
// reloading the page). | |
Promise<void> registerRegion(GeolocationRegion region); | |
// Deregisters a Region. The Promise is called with success when the region | |
// was succesfully deregistered, rejected on failure. Possible failure | |
// reasons include a Region with the given ID not existing. | |
Promise<void> deregisterRegion(DOMString regionId); | |
// Returns all registered Regions. Note that regions may automatically be | |
// unregistered; for example, users may revoke, or the device may choose | |
// to forget them (in particular on device restart). | |
// | |
// The Promise is called with the list of Regions on success (which may be | |
// empty), rejected on failure to get regions. Possible failure reasons | |
// are up to the imagination, but do *not* necessarily include simply | |
// having no registered Regions. | |
Promise<GeolocationRegion[]> getRegisteredRegions(); | |
}; | |
interface GeolocationRegion { | |
// All regions may be referred to by a string identifier. Exactly one Region | |
// can be registered per identifier. Region ids are scoped to the frame or | |
// serviceworker they are registered in. | |
readonly attribute DOMString id; | |
}; | |
// Constructor argument for a CircularRegion. | |
dictionary CircularRegionInit { | |
DOMString id; | |
double latitude; | |
double longitude; | |
double radius; | |
}; | |
[Constructor(CircularRegionInit init)] | |
interface CircularRegion : GeolocationRegion { | |
// TODO(mek): What would sensible values be for these? | |
const double MIN_RADIUS; | |
const double MAX_RADIUS; | |
// Latitude in degrees, between -90 and +90 inclusive. | |
readonly attribute double latitude; | |
// Longitude in degree, between -180 and +180 inclusive. | |
readonly attribute double longitude; | |
// Radius of the region in meters. Must be in the range [MIN_RADIUS, | |
// MAX_RADIUS], values are platform dependent. | |
readonly attribute double radius; | |
}; | |
// Constructor argument for a BluetoothLowEnergyRegion. | |
dictionary BluetoothLowEnergyRegionInit { | |
DOMString[] uuids; | |
double radius; | |
}; | |
[Constructor(BluetoothLowEnergyRegionInit init)] | |
interface BluetoothLowEnergyRegion : GeolocationRegion { | |
// TODO(kalman): Is this how to declare these? | |
readonly static attribute double MIN_RADIUS; | |
readonly static attribute double MAX_RADIUS; | |
// TODO(kalman): Do we need some sort of accuracy constant? | |
// List of BLE UUIDs. If any UUID is matched then this region is | |
// considered to be entered. | |
DOMString[] uuids; | |
// Radius. Likely to be a rough estimate. | |
double radius; | |
}; | |
// Registered as 'regionenter' on the Geolocation object. | |
// Fired when a registered region is entered. | |
interface RegionEnterEvent : Event { | |
readonly attribute GeolocationRegion region; | |
}; | |
// Registered as 'regionexit' on the Geolocation object. | |
// Fired when a registered region is exited. | |
interface RegionExitEvent : Event { | |
readonly attribute GeolocationRegion region; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line #38 should use
sequence<…>
, no?