| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This file declares the Position structure, which is used to represent a |
| 6 // position fix. Originally derived from |
| 7 // http://gears.googlecode.com/svn/trunk/gears/geolocation/geolocation.h |
| 8 |
| 9 #ifndef CHROME_BROWSER_GEOLOCATION_GEOPOSITION_H_ |
| 10 #define CHROME_BROWSER_GEOLOCATION_GEOPOSITION_H_ |
| 11 |
| 12 #include "base/string16.h" |
| 13 |
| 14 // The internal representation of a position. Some properties use different |
| 15 // types when passed to JavaScript. |
| 16 struct Position { |
| 17 public: |
| 18 // Error codes for returning to JavaScript. These values are defined by the |
| 19 // W3C spec. Note that Gears does not use all of these codes, but we need |
| 20 // values for all of them to allow us to provide the constants on the error |
| 21 // object. |
| 22 enum ErrorCode { |
| 23 ERROR_CODE_NONE = -1, // Gears addition |
| 24 ERROR_CODE_UNKNOWN_ERROR = 0, // Not used by Gears |
| 25 ERROR_CODE_PERMISSION_DENIED = 1, // Not used by Gears - Geolocation |
| 26 // methods throw an exception if |
| 27 // permission has not been granted. |
| 28 ERROR_CODE_POSITION_UNAVAILABLE = 2, |
| 29 ERROR_CODE_TIMEOUT = 3, |
| 30 }; |
| 31 |
| 32 Position(); |
| 33 |
| 34 bool is_valid_latlong() const; |
| 35 bool is_valid_altitude() const; |
| 36 bool is_valid_accuracy() const; |
| 37 bool is_valid_altitude_accuracy() const; |
| 38 bool is_valid_timestamp() const; |
| 39 |
| 40 // A valid fix has a valid latitude, longitude, accuracy and timestamp. |
| 41 bool IsValidFix() const; |
| 42 |
| 43 // A position is considered initialized if it has either a valid fix or |
| 44 // an error code other than NONE. |
| 45 bool IsInitialized() const; |
| 46 |
| 47 // These properties correspond to the JavaScript Position object. |
| 48 double latitude; // In degrees |
| 49 double longitude; // In degrees |
| 50 double altitude; // In metres |
| 51 double accuracy; // In metres |
| 52 double altitude_accuracy; // In metres |
| 53 int64 timestamp; // Milliseconds since 1st Jan 1970 |
| 54 |
| 55 // These properties are returned to JavaScript as a PositionError object. |
| 56 ErrorCode error_code; |
| 57 std::wstring error_message; // Human-readable error message |
| 58 }; |
| 59 |
| 60 #endif // CHROME_BROWSER_GEOLOCATION_GEOPOSITION_H_ |
| OLD | NEW |