15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This file declares the Geoposition structure, used to represent a position 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// fix. It was originally derived from: 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// http://gears.googlecode.com/svn/trunk/gears/geolocation/geolocation.h 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_PUBLIC_COMMON_GEOPOSITION_H_ 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_PUBLIC_COMMON_GEOPOSITION_H_ 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 14eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/time/time.h" 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h" 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content { 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct CONTENT_EXPORT Geoposition { 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // These values follow the W3C geolocation specification and can be returned 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // to JavaScript without the need for a conversion. 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum ErrorCode { 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_CODE_NONE = 0, // Chrome addition. 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_CODE_PERMISSION_DENIED = 1, 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_CODE_POSITION_UNAVAILABLE = 2, 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_CODE_TIMEOUT = 3, 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // All fields are initialized to sentinel values marking them as invalid. The 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // error code is set to ERROR_CODE_NONE. 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Geoposition(); 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A valid fix has a valid latitude, longitude, accuracy and timestamp. 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool Validate() const; 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // These properties correspond to those of the JavaScript Position object 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // although their types may differ. 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Latitude in decimal degrees north (WGS84 coordinate frame). 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double latitude; 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Longitude in decimal degrees west (WGS84 coordinate frame). 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double longitude; 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Altitude in meters (above WGS84 datum). 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double altitude; 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Accuracy of horizontal position in meters. 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double accuracy; 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Accuracy of altitude in meters. 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double altitude_accuracy; 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Heading in decimal degrees clockwise from true north. 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double heading; 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Horizontal component of device velocity in meters per second. 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double speed; 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Time of position measurement in milisecons since Epoch in UTC time. This is 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // taken from the host computer's system clock (i.e. from Time::Now(), not the 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // source device's clock). 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::Time timestamp; 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Error code, see enum above. 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ErrorCode error_code; 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Human-readable error message. 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string error_message; 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace content 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CONTENT_COMMON_GEOPOSITION_H_ 67