| // Copyright 2017 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| module device.mojom; |
| |
| import "mojo/public/mojom/base/time.mojom"; |
| |
| // Sentinel values to mark invalid data. (WebKit carries companion is_valid |
| // bools for this purpose; we may eventually follow that approach, but |
| // sentinels worked OK in the Gears code this is based on.) |
| const double kBadLatitudeLongitude = 200; |
| // Lowest point on land is at approximately -400 meters. |
| const double kBadAltitude = -10000; |
| const double kBadAccuracy = -1; // Accuracy must be non-negative. |
| const double kBadHeading = -1; // Heading must be non-negative. |
| const double kBadSpeed = -1; |
| |
| // A Geoposition represents a position fix. It was originally derived from: |
| // http://gears.googlecode.com/svn/trunk/gears/geolocation/geolocation.h |
| struct Geoposition { |
| // These properties correspond to those of the JavaScript Position object |
| // although their types may differ. |
| // Latitude in decimal degrees north (WGS84 coordinate frame). |
| double latitude = kBadLatitudeLongitude; |
| // Longitude in decimal degrees west (WGS84 coordinate frame). |
| double longitude = kBadLatitudeLongitude; |
| // Altitude in meters (above WGS84 datum). |
| double altitude = kBadAltitude; |
| // Accuracy of horizontal position in meters. |
| double accuracy = kBadAccuracy; |
| // Accuracy of altitude in meters. |
| double altitude_accuracy = kBadAccuracy; |
| // Heading in decimal degrees clockwise from true north. |
| double heading = kBadHeading; |
| // Horizontal component of device velocity in meters per second. |
| double speed = kBadSpeed; |
| // Time of position measurement in seconds since the Windows FILETIME epoch |
| // (1601-01-01 00:00:00 UTC). This is taken from the host computer's system |
| // clock (i.e. from Time::Now(), not the source device's clock). |
| mojo_base.mojom.Time timestamp; |
| }; |
| |
| // These values follow the W3C geolocation specification and can be returned |
| // to JavaScript without the need for a conversion. |
| enum GeopositionErrorCode { |
| kPermissionDenied = 1, |
| kPositionUnavailable = 2 |
| }; |
| |
| // A GeopositionError communicates the reason why the Geolocation service could |
| // not return a position estimate. |
| struct GeopositionError { |
| // Error code, see enum above. |
| GeopositionErrorCode error_code; |
| // Human-readable error message. |
| string error_message; |
| // Technical detail of the error. |
| string error_technical; |
| }; |
| |
| // The result from querying the Geolocation service for the next position |
| // estimate. A GeopositionResult contains either a position estimate or an |
| // error, but not both. |
| union GeopositionResult { |
| Geoposition position; |
| GeopositionError error; |
| }; |