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