Index: content/browser/geolocation/geolocation_service_context.h |
diff --git a/content/browser/geolocation/geolocation_service_context.h b/content/browser/geolocation/geolocation_service_context.h |
index 453c8b0dce2862ef600ea20b8ca4b1c3ecd0578c..9bf78fa0cdd11dde1b0aa5b7bb208edcd02a26ff 100644 |
--- a/content/browser/geolocation/geolocation_service_context.h |
+++ b/content/browser/geolocation/geolocation_service_context.h |
@@ -5,28 +5,26 @@ |
#ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ |
#define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ |
-#include "base/memory/scoped_vector.h" |
#include "content/browser/geolocation/geolocation_service_impl.h" |
+#include "content/common/geolocation_service.mojom.h" |
+#include "content/public/browser/web_contents_user_data.h" |
+#include "mojo/common/service_set.h" |
namespace content { |
+struct Geoposition; |
// Provides information to a set of GeolocationServiceImpl instances that are |
// associated with a given context. Notably, allows pausing and resuming |
// geolocation on these instances. |
-class GeolocationServiceContext { |
+class GeolocationServiceContext |
+ : public WebContentsUserData<GeolocationServiceContext> { |
public: |
- GeolocationServiceContext(); |
- virtual ~GeolocationServiceContext(); |
+ static GeolocationServiceContext* GetOrCreateForWebContents( |
+ WebContents* web_contents); |
- // Creates a GeolocationServiceImpl that is weakly bound to |request|. |
- // |update_callback| will be called when services send |
- // location updates to their clients. |
- void CreateService(const base::Closure& update_callback, |
- mojo::InterfaceRequest<GeolocationService> request); |
- |
- // Called when a service has a connection error. After this call, it is no |
- // longer safe to access |service|. |
- void ServiceHadConnectionError(GeolocationServiceImpl* service); |
+ // Creates a GeolocationServiceImpl that is bound to |request|. |
+ static void CreateService(RenderFrameHost* render_frame_host, |
+ mojo::InterfaceRequest<GeolocationService> request); |
// Pauses and resumes geolocation. Resuming when nothing is paused is a |
// no-op. If a service is added while geolocation is paused, that service |
@@ -35,7 +33,14 @@ class GeolocationServiceContext { |
void ResumeUpdates(); |
// Returns whether geolocation updates are currently paused. |
- bool paused() { return paused_; } |
+ bool paused() const { return paused_; } |
+ |
+ // Returns the current position override, or nullptr if there isn't one. |
+ const Geoposition* position_override() const { |
+ return geoposition_override_.get(); |
+ } |
+ |
+ void DestroyService(GeolocationServiceImpl* service); |
// Enables geolocation override. This method can be used to trigger possible |
// location-specific behavior in a particular context. |
@@ -45,7 +50,15 @@ class GeolocationServiceContext { |
void ClearOverride(); |
private: |
- ScopedVector<GeolocationServiceImpl> services_; |
+ friend class WebContentsUserData<GeolocationServiceContext>; |
+ |
+ explicit GeolocationServiceContext(WebContents* web_contents); |
+ ~GeolocationServiceContext() override; |
+ |
+ void CreateServiceImpl(RenderFrameHost* render_frame_host, |
+ mojo::InterfaceRequest<GeolocationService> request); |
+ |
+ mojo::ServiceSet<GeolocationService, GeolocationServiceImpl> services_; |
bool paused_; |
scoped_ptr<Geoposition> geoposition_override_; |