| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ | |
| 6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/scoped_vector.h" | |
| 10 #include "content/browser/geolocation/geolocation_service_impl.h" | |
| 11 #include "third_party/WebKit/public/platform/modules/geolocation/geolocation.moj
om.h" | |
| 12 | |
| 13 namespace content { | |
| 14 | |
| 15 // Provides information to a set of GeolocationServiceImpl instances that are | |
| 16 // associated with a given context. Notably, allows pausing and resuming | |
| 17 // geolocation on these instances. | |
| 18 class GeolocationServiceContext { | |
| 19 public: | |
| 20 GeolocationServiceContext(); | |
| 21 virtual ~GeolocationServiceContext(); | |
| 22 | |
| 23 // Creates a GeolocationServiceImpl that is weakly bound to |request|. | |
| 24 // |update_callback| will be called when services send | |
| 25 // location updates to their clients. | |
| 26 void CreateService( | |
| 27 const base::Closure& update_callback, | |
| 28 mojo::InterfaceRequest<blink::mojom::GeolocationService> request); | |
| 29 | |
| 30 // Called when a service has a connection error. After this call, it is no | |
| 31 // longer safe to access |service|. | |
| 32 void ServiceHadConnectionError(GeolocationServiceImpl* service); | |
| 33 | |
| 34 // Pauses and resumes geolocation. Resuming when nothing is paused is a | |
| 35 // no-op. If a service is added while geolocation is paused, that service | |
| 36 // will not get geolocation updates until geolocation is resumed. | |
| 37 void PauseUpdates(); | |
| 38 void ResumeUpdates(); | |
| 39 | |
| 40 // Returns whether geolocation updates are currently paused. | |
| 41 bool paused() { return paused_; } | |
| 42 | |
| 43 // Enables geolocation override. This method can be used to trigger possible | |
| 44 // location-specific behavior in a particular context. | |
| 45 void SetOverride(std::unique_ptr<Geoposition> geoposition); | |
| 46 | |
| 47 // Disables geolocation override. | |
| 48 void ClearOverride(); | |
| 49 | |
| 50 private: | |
| 51 ScopedVector<GeolocationServiceImpl> services_; | |
| 52 bool paused_; | |
| 53 | |
| 54 std::unique_ptr<Geoposition> geoposition_override_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(GeolocationServiceContext); | |
| 57 }; | |
| 58 | |
| 59 } // namespace content | |
| 60 | |
| 61 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ | |
| OLD | NEW |