| 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_COMMON_GEOPOSITION_H_ | |
| 10 #define CHROME_COMMON_GEOPOSITION_H_ | |
| 11 #pragma once | |
| 12 | |
| 13 #include <string> | |
| 14 #include "base/time.h" | |
| 15 | |
| 16 // The internal representation of a geo position. Some properties use different | |
| 17 // types when passed to JavaScript. | |
| 18 struct Geoposition { | |
| 19 public: | |
| 20 // Error codes for returning to JavaScript. These values are defined by the | |
| 21 // W3C spec. Note that Gears does not use all of these codes, but we need | |
| 22 // values for all of them to allow us to provide the constants on the error | |
| 23 // object. | |
| 24 enum ErrorCode { | |
| 25 ERROR_CODE_NONE = 0, // Chrome addition | |
| 26 ERROR_CODE_PERMISSION_DENIED = 1, | |
| 27 ERROR_CODE_POSITION_UNAVAILABLE = 2, | |
| 28 ERROR_CODE_TIMEOUT = 3, | |
| 29 }; | |
| 30 | |
| 31 Geoposition(); | |
| 32 | |
| 33 bool is_valid_latlong() const; | |
| 34 bool is_valid_altitude() const; | |
| 35 bool is_valid_accuracy() const; | |
| 36 bool is_valid_altitude_accuracy() const; | |
| 37 bool is_valid_heading() const; | |
| 38 bool is_valid_speed() const; | |
| 39 bool is_valid_timestamp() const; | |
| 40 | |
| 41 // A valid fix has a valid latitude, longitude, accuracy and timestamp. | |
| 42 bool IsValidFix() const; | |
| 43 | |
| 44 // A position is considered initialized if it has either a valid fix or | |
| 45 // an error code other than NONE. | |
| 46 bool IsInitialized() const; | |
| 47 | |
| 48 // These properties correspond to the JavaScript Position object. | |
| 49 double latitude; // In degrees | |
| 50 double longitude; // In degrees | |
| 51 double altitude; // In metres | |
| 52 double accuracy; // In metres | |
| 53 double altitude_accuracy; // In metres | |
| 54 double heading; // In degrees clockwise relative to the true north | |
| 55 double speed; // In meters per second | |
| 56 // Timestamp for this position fix object taken from the host computer's | |
| 57 // system clock (i.e. from Time::Now(), not the source device's clock). | |
| 58 base::Time timestamp; | |
| 59 | |
| 60 // These properties are returned to JavaScript as a PositionError object. | |
| 61 ErrorCode error_code; | |
| 62 std::string error_message; // Human-readable error message | |
| 63 }; | |
| 64 | |
| 65 #endif // CHROME_COMMON_GEOPOSITION_H_ | |
| OLD | NEW |