| Index: content/browser/geolocation/geolocation_service_context.cc
|
| diff --git a/content/browser/geolocation/geolocation_service_context.cc b/content/browser/geolocation/geolocation_service_context.cc
|
| index 7a250237d872385bda09de3ac0a2f5221e011d65..24f42e5168bc77fc9d96b650a2d8d83bf6f5395c 100644
|
| --- a/content/browser/geolocation/geolocation_service_context.cc
|
| +++ b/content/browser/geolocation/geolocation_service_context.cc
|
| @@ -4,33 +4,48 @@
|
|
|
| #include "content/browser/geolocation/geolocation_service_context.h"
|
|
|
| +#include "content/public/common/geoposition.h"
|
| +
|
| namespace content {
|
|
|
| -GeolocationServiceContext::GeolocationServiceContext() : paused_(false) {
|
| -}
|
| +DEFINE_WEB_CONTENTS_USER_DATA_KEY(GeolocationServiceContext);
|
| +
|
| +GeolocationServiceContext::GeolocationServiceContext(WebContents* web_contents)
|
| + : paused_(false) {}
|
| +
|
| +GeolocationServiceContext::~GeolocationServiceContext() {}
|
|
|
| -GeolocationServiceContext::~GeolocationServiceContext() {
|
| +// static
|
| +GeolocationServiceContext* GeolocationServiceContext::GetOrCreateForWebContents(
|
| + WebContents* web_contents) {
|
| + CreateForWebContents(web_contents);
|
| + return FromWebContents(web_contents);
|
| }
|
|
|
| +// static
|
| void GeolocationServiceContext::CreateService(
|
| - const base::Closure& update_callback,
|
| + RenderFrameHost* render_frame_host,
|
| + mojo::InterfaceRequest<GeolocationService> request) {
|
| + WebContents* web_contents =
|
| + WebContents::FromRenderFrameHost(render_frame_host);
|
| + if (!web_contents)
|
| + return;
|
| +
|
| + GeolocationServiceContext::GetOrCreateForWebContents(web_contents)
|
| + ->CreateServiceImpl(render_frame_host, request.Pass());
|
| +}
|
| +
|
| +void GeolocationServiceContext::CreateServiceImpl(
|
| + RenderFrameHost* render_frame_host,
|
| mojo::InterfaceRequest<GeolocationService> request) {
|
| GeolocationServiceImpl* service =
|
| - new GeolocationServiceImpl(request.Pass(), this, update_callback);
|
| - services_.push_back(service);
|
| + services_.CreateService(request.Pass(), this, render_frame_host);
|
| if (geoposition_override_)
|
| - service->SetOverride(*geoposition_override_.get());
|
| + service->OnOverrideSet();
|
| else
|
| service->StartListeningForUpdates();
|
| }
|
|
|
| -void GeolocationServiceContext::ServiceHadConnectionError(
|
| - GeolocationServiceImpl* service) {
|
| - auto it = std::find(services_.begin(), services_.end(), service);
|
| - DCHECK(it != services_.end());
|
| - services_.erase(it);
|
| -}
|
| -
|
| void GeolocationServiceContext::PauseUpdates() {
|
| paused_ = true;
|
| for (auto* service : services_) {
|
| @@ -45,11 +60,16 @@ void GeolocationServiceContext::ResumeUpdates() {
|
| }
|
| }
|
|
|
| +void GeolocationServiceContext::DestroyService(
|
| + GeolocationServiceImpl* service) {
|
| + services_.DestroyService(service);
|
| +}
|
| +
|
| void GeolocationServiceContext::SetOverride(
|
| scoped_ptr<Geoposition> geoposition) {
|
| geoposition_override_.swap(geoposition);
|
| for (auto* service : services_) {
|
| - service->SetOverride(*geoposition_override_.get());
|
| + service->OnOverrideSet();
|
| }
|
| }
|
|
|
| @@ -57,6 +77,7 @@ void GeolocationServiceContext::ClearOverride() {
|
| for (auto* service : services_) {
|
| service->ClearOverride();
|
| }
|
| + geoposition_override_.reset();
|
| }
|
|
|
| } // namespace content
|
|
|