diff options
author | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-19 12:11:28 +0000 |
---|---|---|
committer | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-19 12:11:28 +0000 |
commit | 58c321dd57a1fc00c2c51b0a8b6e547fdf32aa74 (patch) | |
tree | cdd273a38ba1b449952d5701e6ceb6f46142c073 /chrome/common/geoposition.cc | |
parent | 2375d294b30e5d0b0bc63d26a417203959ef32af (diff) | |
download | chromium_src-58c321dd57a1fc00c2c51b0a8b6e547fdf32aa74.zip chromium_src-58c321dd57a1fc00c2c51b0a8b6e547fdf32aa74.tar.gz chromium_src-58c321dd57a1fc00c2c51b0a8b6e547fdf32aa74.tar.bz2 |
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
Diffstat (limited to 'chrome/common/geoposition.cc')
-rw-r--r-- | chrome/common/geoposition.cc | 67 |
1 files changed, 67 insertions, 0 deletions
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(); +} |