| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 // This file declares the Position structure, which is used to represent a | 5 // This file declares the Geoposition structure, used to represent a position | 
| 6 // position fix. Originally derived from | 6 // fix. It was originally derived from: | 
| 7 // http://gears.googlecode.com/svn/trunk/gears/geolocation/geolocation.h | 7 // http://gears.googlecode.com/svn/trunk/gears/geolocation/geolocation.h | 
| 8 | 8 | 
| 9 #ifndef CONTENT_COMMON_GEOPOSITION_H_ | 9 #ifndef CONTENT_PUBLIC_COMMON_GEOPOSITION_H_ | 
| 10 #define CONTENT_COMMON_GEOPOSITION_H_ | 10 #define CONTENT_PUBLIC_COMMON_GEOPOSITION_H_ | 
| 11 #pragma once | 11 #pragma once | 
| 12 | 12 | 
| 13 #include <string> | 13 #include <string> | 
|  | 14 | 
| 14 #include "base/time.h" | 15 #include "base/time.h" | 
| 15 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" | 
| 16 | 17 | 
| 17 // The internal representation of a geo position. Some properties use different | 18 namespace content { | 
| 18 // types when passed to JavaScript. | 19 | 
| 19 struct CONTENT_EXPORT Geoposition { | 20 struct CONTENT_EXPORT Geoposition { | 
| 20  public: | 21  public: | 
| 21   // Error codes for returning to JavaScript. These values are defined by the | 22   // These values follow the W3C geolocation specification and can be returned | 
| 22   // W3C spec. Note that Gears does not use all of these codes, but we need | 23   // to JavaScript without the need for a conversion. | 
| 23   // values for all of them to allow us to provide the constants on the error |  | 
| 24   // object. |  | 
| 25   enum ErrorCode { | 24   enum ErrorCode { | 
| 26     ERROR_CODE_NONE = 0,               // Chrome addition | 25     ERROR_CODE_NONE = 0,  // Chrome addition. | 
| 27     ERROR_CODE_PERMISSION_DENIED = 1, | 26     ERROR_CODE_PERMISSION_DENIED = 1, | 
| 28     ERROR_CODE_POSITION_UNAVAILABLE = 2, | 27     ERROR_CODE_POSITION_UNAVAILABLE = 2, | 
| 29     ERROR_CODE_TIMEOUT = 3, | 28     ERROR_CODE_TIMEOUT = 3, | 
| 30   }; | 29   }; | 
| 31 | 30 | 
|  | 31   // All fields are initialized to sentinel values marking them as invalid. The | 
|  | 32   // error code is set to ERROR_CODE_NONE. | 
| 32   Geoposition(); | 33   Geoposition(); | 
| 33 | 34 | 
| 34   bool is_valid_latlong() const; | 35   // A valid fix has a valid latitude, longitude, accuracy and timestamp. | 
| 35   bool is_valid_altitude() const; | 36   bool Validate() const; | 
| 36   bool is_valid_accuracy() const; |  | 
| 37   bool is_valid_altitude_accuracy() const; |  | 
| 38   bool is_valid_heading() const; |  | 
| 39   bool is_valid_speed() const; |  | 
| 40   bool is_valid_timestamp() const; |  | 
| 41 | 37 | 
| 42   // A valid fix has a valid latitude, longitude, accuracy and timestamp. | 38   // These properties correspond to those of the JavaScript Position object | 
| 43   bool IsValidFix() const; | 39   // although their types may differ. | 
| 44 | 40   // Latitude in decimal degrees north (WGS84 coordinate frame). | 
| 45   // A position is considered initialized if it has either a valid fix or | 41   double latitude; | 
| 46   // an error code other than NONE. | 42   // Longitude in decimal degrees west (WGS84 coordinate frame). | 
| 47   bool IsInitialized() const; | 43   double longitude; | 
| 48 | 44   // Altitude in meters (above WGS84 datum). | 
| 49   // These properties correspond to the JavaScript Position object. | 45   double altitude; | 
| 50   double latitude;           // In degrees | 46   // Accuracy of horizontal position in meters. | 
| 51   double longitude;          // In degrees | 47   double accuracy; | 
| 52   double altitude;           // In metres | 48   // Accuracy of altitude in meters. | 
| 53   double accuracy;           // In metres | 49   double altitude_accuracy; | 
| 54   double altitude_accuracy;  // In metres | 50   // Heading in decimal degrees clockwise from true north. | 
| 55   double heading;            // In degrees clockwise relative to the true north | 51   double heading; | 
| 56   double speed;              // In meters per second | 52   // Horizontal component of device velocity in meters per second. | 
| 57   // Timestamp for this position fix object taken from the host computer's | 53   double speed; | 
| 58   // system clock (i.e. from Time::Now(), not the source device's clock). | 54   // Time of position measurement in milisecons since Epoch in UTC time. This is | 
|  | 55   // taken from the host computer's system clock (i.e. from Time::Now(), not the | 
|  | 56   // source device's clock). | 
| 59   base::Time timestamp; | 57   base::Time timestamp; | 
| 60 | 58 | 
| 61   // These properties are returned to JavaScript as a PositionError object. | 59   // Error code, see enum above. | 
| 62   ErrorCode error_code; | 60   ErrorCode error_code; | 
| 63   std::string error_message;   // Human-readable error message | 61   // Human-readable error message. | 
|  | 62   std::string error_message; | 
| 64 }; | 63 }; | 
| 65 | 64 | 
|  | 65 }  // namespace content | 
|  | 66 | 
| 66 #endif  // CONTENT_COMMON_GEOPOSITION_H_ | 67 #endif  // CONTENT_COMMON_GEOPOSITION_H_ | 
| OLD | NEW | 
|---|