Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: content/public/common/geoposition.cc

Issue 454253002: Location chooser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Swapping to address InfoBar currying callback case Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/common/geoposition.h" 5 #include "content/public/common/geoposition.h"
6 6
7 namespace { 7 namespace {
8 // Sentinel values to mark invalid data. (WebKit carries companion is_valid 8 // Sentinel values to mark invalid data. (WebKit carries companion is_valid
9 // bools for this purpose; we may eventually follow that approach, but 9 // bools for this purpose; we may eventually follow that approach, but
10 // sentinels worked OK in the Gears code this is based on.) 10 // sentinels worked OK in the Gears code this is based on.)
(...skipping 18 matching lines...) Expand all
29 error_code(ERROR_CODE_NONE) { 29 error_code(ERROR_CODE_NONE) {
30 } 30 }
31 31
32 bool Geoposition::Validate() const { 32 bool Geoposition::Validate() const {
33 return latitude >= -90. && latitude <= 90. && 33 return latitude >= -90. && latitude <= 90. &&
34 longitude >= -180. && longitude <= 180. && 34 longitude >= -180. && longitude <= 180. &&
35 accuracy >= 0. && 35 accuracy >= 0. &&
36 !timestamp.is_null(); 36 !timestamp.is_null();
37 } 37 }
38 38
39 Geoposition Geoposition::ApplyPrecision(const int choice) const {
meacer 2014/08/15 22:20:25 In fact, it looks like Since this method returns
mhm 2014/08/15 23:18:57 Done.
40 Geoposition newGeoposition = *this;
41 switch (choice) {
42 case 1:
43 // City granuality.
44 newGeoposition.latitude =
45 ((int)(newGeoposition.latitude + 0.5 * 10.0)) / 10.0;
46 newGeoposition.longitude =
47 ((int)(newGeoposition.longitude + 0.5 * 10.0)) / 10.0;
48 break;
49 case 2:
50 // State granuality.
51 newGeoposition.latitude = (int)newGeoposition.latitude;
meacer 2014/08/15 22:20:25 May be better: static_cast<int>(std::floor(newGeop
mhm 2014/08/15 23:18:57 Done.
52 newGeoposition.longitude = (int)newGeoposition.longitude;
53 break;
54 case 3:
55 // Country granuality.
56 newGeoposition.latitude = (int)(newGeoposition.latitude / 10.0);
57 newGeoposition.longitude = (int)(newGeoposition.longitude / 10.0);
meacer 2014/08/15 22:20:25 You might want to add that this is a POC, and the
mhm 2014/08/15 23:18:57 Done.
58 break;
59 }
60 return newGeoposition;
61 }
62
39 } // namespace content 63 } // namespace content
OLDNEW
« content/public/common/geoposition.h ('K') | « content/public/common/geoposition.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698