Geolocation in the Browser from Google Gears to Geolocation Sensors
Total Page:16
File Type:pdf, Size:1020Kb
Geolocation in the Browser From Google Gears to Geolocation Sensors Thomas Steiner Anssi Kostiainen Marijn Kruisselbrink Google LLC Intel Corporation Google LLC 20354 Hamburg, Germany 02160 Espoo, Finland San Francisco, CA 94105, USA [email protected] [email protected] [email protected] ABSTRACT 1 HISTORY OF BROWSER GEOLOCATION Geolocation is arguably one of the most powerful capabilities of Geolocation has been available to developers implicitly through smartphones and a lot of attention has been paid to native applica- the mapping of Internet Protocol (ip) addresses or address blocks tions that make use of it. The discontinued Google Gears plugin was to known locations. There are numerous paid subscription and one of the rst approaches to access exact location data on the Web free geolocation databases with varying claims of accuracy that as well, apart from server-side coarse location lookups based on In- range from country level to state or city level, sometimes including ternet Protocol (ip) addresses; and the plugin led directly to the now zip/post code level. A popular free way to obtain ip-based location widely implemented Geolocation api. The World Wide Web Con- data was through Google’s ajax api Loader library [2], which pro- sortium (w3c) Geolocation api specication denes a standard for vided an approximate, region-level estimate of a user’s location accessing location services in the browser via JavaScript. For a long through its google.loader.ClientLocation property. This api time, developers have also demanded more advanced features like did not require users to install any client-side software. Implicit background geolocation tracking and geofencing. The w3c Geolo- geolocation access is not subject of the paper, however, we list it cation and the Devices and Sensors Working Groups, as well as the for the sake of completeness and because it still plays an important Web Incubator Community Group (wicg), have addressed these de- role today, for example, for ip-based regional content blocking. mands with the no longer maintained Geofencing api specication for the former, and—with now (early 2019) resumed eorts—the 1.1 Google Gears Geolocation api in-ight Geolocation Sensors specication for the latter two groups. More accurate location data is available through Wi-Fi access point This paper rst provides an in-depth overview of the historical or cell tower data, as well as through Global Positioning Service development of geolocation in the browser and motivates privacy (gps) data. This data is accessible to native applications, however, decisions that were made at the time, and then gives an outlook initially, not via Web apis. The Google Gears browser plugin [9] on current and future eorts, challenges, and use cases from both for the rst time exposed exact device-based geolocation data a technology as well as from a privacy angle. to the browser. Its Geolocation api had two JavaScript methods: getCurrentPosition() made a single, one-o attempt to get a po- CCS CONCEPTS sition x, while watchPosition() watched the user’s position over • Information systems → Web applications; • Security and time, and provided an update whenever the position changed. Both privacy → Browser security. methods allowed the developer to congure which sources of lo- cation information would be used. As a simple way to get an ap- KEYWORDS proximate position x with low cost in terms of both network and battery resources, Gears also kept track of the best position x ob- Geolocation; Geofencing; Geotracking; Permissions; Privacy tained from these calls and made it available as the lastPosition property. To a contemporary JavaScript developer who may have ACM Reference Format: never used the plugin, the code in Listing 1 still looks very familiar, Thomas Steiner, Anssi Kostiainen, and Marijn Kruisselbrink. 2019. Geoloca- even more than ten years later. tion in the Browser: From Google Gears to Geolocation Sensors. In Com- panion Proceedings of the 2019 World Wide Web Conference (WWW ’19 Companion), May 13–17, 2019, San Francisco, CA, USA. ACM, New York, NY, var geo= google.gears.factory USA, 6 pages. https://doi.org/10.1145/3308560.3316538 .create( 'beta.geolocation '); function updatePosition(position){ alert( 'Current lat/lon is: ' + position.latitude+ ',' + position.longitude); } This paper is published under the Creative Commons Attribution-NonCommercial- function handleError(positionError){ NoDerivs 4.0 International (CC-BY-NC-ND 4.0) license. Authors reserve their rights to alert( 'Attempt to get location failed: ' + disseminate the work on their personal and corporate Web sites with the appropriate positionError.message); attribution. } WWW ’19 Companion, May 13–17, 2019, San Francisco, CA, USA © 2019 IW3C2 (International World Wide Web Conference Committee), published geo.getCurrentPosition(updatePosition, handleError); under Creative Commons CC-BY-NC-ND 4.0 License. ACM ISBN 978-1-4503-6675-5/19/05. Listing 1: Google Gears api (2008) https://doi.org/10.1145/3308560.3316538 From the start, user privacy was a major concern, and the plugin of the device. If the attempt is successful, the successCallback authors wrote in the Wiki [10]: must be invoked with a new Position object, reecting the current “It must be clear to users when an application is using location of the device. If the attempt fails, the errorCallback must the Geolocation api. We could implement one or both be invoked with a new PositionError object, reecting the reason of the following ui elements: for the failure. The watchPosition() method returns an identier (1) A separate dialog from the Gears security dialog that uniquely identies a watch operation and then asynchronously to enable the Geolocation api. If the general-purpose starts that watch operation. This operation must rst attempt to dialog gave access to position data, it would be easy obtain the current location of the device. Similar to the “one-shot” for users to forget they allowed access to Gears, or request, if the attempt is successful, the successCallback must to fail to realize enabling Gears also exposes their be invoked with a new Position object, reecting the current position data. location of the device, else, it must fail as described before. The (2) Some persistent ui that indicates the Geolocation watch operation then must continue to monitor the position of api is being used. For example, there could be a bar the device and invoke the appropriate callback every time this across the bottom of the browser with an icon of position changes. The watch operation must continue until the a globe or map. Perhaps this ui should be ‘active’ clearWatch() method is called with the corresponding identier, somehow, indicating that something is happening, so which immediately stops the watch operation identied by the that the user cannot forget it is being used.” identier. Listing 2 shows all methods in operation (see Listing 1 for comparison). This api is almost universally supported in browsers, In the end, they decided on approach (1), which is still how loca- Figure 1 shows the support situation at the time of writing. tion access is granted today, despite dierent underlying mechanics. The similarity of the code in Listing 1 with code one would write today is no surprise. Gears implemented the at the time current function showMap(pos){ // Showa map centered at editor’s draft of the w3c Geolocation specication, which some of //(pos.coords.latitude, pos.coords.longitude) the authors have helped to dene in collaboration with Microsoft, } Mozilla, and others. The goal for Gears was to advance browser function scrollMap(pos){ capabilities and eventually make itself a relict of time, which is // Scrolls the map so that it is centered at what has happened. //(pos.coords.latitude, pos.coords.longitude) } 1.2 Mozilla Geode function handleError(error){ // Handles the error gracefully. Mozilla Geode [1] was an experimental add-on that appeared slightly } after Gears to explore geolocation in Firefox 3 ahead of the im- plementation of the nal api in a future product release. Geode // One-shot position request navigator.geolocation.getCurrentPosition(showMap, provided an early realization of the w3c Geolocation specica- handleError); tion [14] so that developers could begin experimenting with en- // Request repeated updates abling location-aware experiences. It included a single experimental var watchId= navigator.geolocation.watchPosition( proprietary geolocation service provider called Skyhook to map scrollMap, handleError); Wi-Fi signals to locations, so that any computer with Wi-Fi could function clearPositionWatch(){ get accurate positioning data. An interesting historical fact is that // Cancel the updates when the user clicksa button the ultimate plan for Firefox was that service providers and geoloca- navigator.geolocation.clearWatch(watchId); tion methods would be pluggable [1] to provide users with as many } choices and privacy options as possible, which has not happened. Listing 2: Geolocation api 1.3 w3c Geolocation api The w3c Geolocation api specication [14] denes a high-level interface to location information associated only with the device 1.4 w3c Geofencing api hosting the implementation, such as latitude and longitude. The api The w3c Geofencing api [12] specication dened an api that itself is agnostic of the underlying location information sources, and should let Web applications set up geographic boundaries around no guarantee is given that it returns the device’s actual location. The specic