From 58c321dd57a1fc00c2c51b0a8b6e547fdf32aa74 Mon Sep 17 00:00:00 2001 From: "bulach@chromium.org" Date: Fri, 19 Feb 2010 12:11:28 +0000 Subject: Second try for: http://src.chromium.org/viewvc/chrome?view=rev&revision=39374 Initial Geolocation implementation Adds IPC plumbing. Adds Infobar buttons for requesting permission This change specifically: ui_test_utils::WaitForAppModalDialog registers for listening to notifications too late, i.e., after the dialog had been triggered. Exposes AppModalDialogObserver so that we can register, trigger the dialog, then wait for it. Review URL: http://codereview.chromium.org/647048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39435 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/geoposition.cc | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 chrome/common/geoposition.cc (limited to 'chrome/common/geoposition.cc') diff --git a/chrome/common/geoposition.cc b/chrome/common/geoposition.cc new file mode 100644 index 0000000..d4989ed --- /dev/null +++ b/chrome/common/geoposition.cc @@ -0,0 +1,67 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/geoposition.h" + +namespace { +// Sentinel values to mark invalid data. (WebKit carries companion is_valid +// bools for this purpose; we may eventually follow that approach, but +// sentinels worked OK in the gears code this is based on.) +const double kBadLatitudeLongitude = 200; +// Lowest point on land is at approximately -400 meters. +const int kBadAltitude = -10000; +const int kBadAccuracy = -1; // Accuracy must be non-negative. +const int64 kBadTimestamp = kint64min; +const int kBadHeading = -1; // Heading must be non-negative. +const int kBadSpeed = -1; +} + +Geoposition::Geoposition() + : latitude(kBadLatitudeLongitude), + longitude(kBadLatitudeLongitude), + altitude(kBadAltitude), + accuracy(kBadAccuracy), + altitude_accuracy(kBadAccuracy), + heading(kBadHeading), + speed(kBadSpeed), + timestamp(kBadTimestamp), + error_code(ERROR_CODE_NONE) { +} + +bool Geoposition::is_valid_latlong() const { + return latitude >= -90.0 && latitude <= 90.0 && + longitude >= -180.0 && longitude <= 180.0; +} + +bool Geoposition::is_valid_altitude() const { + return altitude > kBadAltitude; +} + +bool Geoposition::is_valid_accuracy() const { + return accuracy >= 0.0; +} + +bool Geoposition::is_valid_altitude_accuracy() const { + return altitude_accuracy >= 0.0; +} + +bool Geoposition::is_valid_heading() const { + return heading >= 0 && heading <= 360; +} + +bool Geoposition::is_valid_speed() const { + return speed >= 0; +} + +bool Geoposition::is_valid_timestamp() const { + return timestamp != kBadTimestamp; +} + +bool Geoposition::IsValidFix() const { + return is_valid_latlong() && is_valid_accuracy() && is_valid_timestamp(); +} + +bool Geoposition::IsInitialized() const { + return error_code != ERROR_CODE_NONE || IsValidFix(); +} -- cgit v1.1