| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_OBSERVER_H_ | |
| 6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_OBSERVER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/basictypes.h" | |
| 10 | |
| 11 struct Geoposition; | |
| 12 | |
| 13 // This interface is implemented by observers of GeolocationProvider as | |
| 14 // well as GeolocationProvider itself as an observer of GeolocationArbitrator. | |
| 15 class GeolocationObserver { | |
| 16 public: | |
| 17 // This will be called whenever the 'best available' location is updated, | |
| 18 // or when an error is encountered meaning no location data will be | |
| 19 // available in the forseeable future. | |
| 20 virtual void OnLocationUpdate(const Geoposition& position) = 0; | |
| 21 | |
| 22 protected: | |
| 23 GeolocationObserver() {} | |
| 24 virtual ~GeolocationObserver() {} | |
| 25 | |
| 26 private: | |
| 27 DISALLOW_COPY_AND_ASSIGN(GeolocationObserver); | |
| 28 }; | |
| 29 | |
| 30 struct GeolocationObserverOptions { | |
| 31 GeolocationObserverOptions() : use_high_accuracy(false) {} | |
| 32 explicit GeolocationObserverOptions(bool high_accuracy) | |
| 33 : use_high_accuracy(high_accuracy) {} | |
| 34 | |
| 35 // Given a map<ANYTHING, GeolocationObserverOptions> this function will | |
| 36 // iterate the map and collapse all the options found to a single instance | |
| 37 // that satisfies them all. | |
| 38 template <typename MAP> | |
| 39 static GeolocationObserverOptions Collapse(const MAP& options_map) { | |
| 40 for (typename MAP::const_iterator it = options_map.begin(); | |
| 41 it != options_map.end(); ++it) { | |
| 42 if (it->second.use_high_accuracy) | |
| 43 return GeolocationObserverOptions(true); | |
| 44 } | |
| 45 return GeolocationObserverOptions(false); | |
| 46 } | |
| 47 | |
| 48 bool use_high_accuracy; | |
| 49 }; | |
| 50 | |
| 51 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_OBSERVER_H_ | |
| OLD | NEW |