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

Unified 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 side-by-side diff with in-line comments
Download patch
« content/public/common/geoposition.h ('K') | « content/public/common/geoposition.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/common/geoposition.cc
diff --git a/content/public/common/geoposition.cc b/content/public/common/geoposition.cc
index 3a0f1f08b1847e4e6b616a38b7e7813bc99f4446..775dd7b17f75f6e52a88a47997863bf8485ca770 100644
--- a/content/public/common/geoposition.cc
+++ b/content/public/common/geoposition.cc
@@ -36,4 +36,28 @@ bool Geoposition::Validate() const {
!timestamp.is_null();
}
+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.
+ Geoposition newGeoposition = *this;
+ switch (choice) {
+ case 1:
+ // City granuality.
+ newGeoposition.latitude =
+ ((int)(newGeoposition.latitude + 0.5 * 10.0)) / 10.0;
+ newGeoposition.longitude =
+ ((int)(newGeoposition.longitude + 0.5 * 10.0)) / 10.0;
+ break;
+ case 2:
+ // State granuality.
+ 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.
+ newGeoposition.longitude = (int)newGeoposition.longitude;
+ break;
+ case 3:
+ // Country granuality.
+ newGeoposition.latitude = (int)(newGeoposition.latitude / 10.0);
+ 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.
+ break;
+ }
+ return newGeoposition;
+}
+
} // namespace content
« 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