Updates the mic icon status based on the device's audio state (2nd)
[chromium-blink-merge.git] / chrome / browser / chromeos / geolocation / geoposition.cc
blob6266be2b974a21dee9e27441054a10f4711153dc
1 // Copyright 2014 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.
5 #include "chrome/browser/chromeos/geolocation/geoposition.h"
7 #include "base/strings/stringprintf.h"
9 namespace {
11 // Sentinel values to mark invalid data.
12 const double kBadLatitudeLongitude = 200;
13 const int kBadAccuracy = -1; // Accuracy must be non-negative.
15 } // namespace
17 namespace chromeos {
19 Geoposition::Geoposition()
20 : latitude(kBadLatitudeLongitude),
21 longitude(kBadLatitudeLongitude),
22 accuracy(kBadAccuracy),
23 error_code(0),
24 status(STATUS_NONE) {
27 bool Geoposition::Valid() const {
28 return latitude >= -90. && latitude <= 90. && longitude >= -180. &&
29 longitude <= 180. && accuracy >= 0. && !timestamp.is_null() &&
30 status == STATUS_OK;
33 std::string Geoposition::ToString() const {
34 static const char* const status2string[] = {
35 "NONE",
36 "OK",
37 "SERVER_ERROR",
38 "NETWORK_ERROR",
39 "TIMEOUT"
42 return base::StringPrintf(
43 "latitude=%f, longitude=%f, accuracy=%f, error_code=%u, "
44 "error_message='%s', status=%u (%s)",
45 latitude,
46 longitude,
47 accuracy,
48 error_code,
49 error_message.c_str(),
50 (unsigned)status,
51 (status < arraysize(status2string) ? status2string[status] : "unknown"));
54 } // namespace chromeos