Index: content/browser/geolocation/geolocation_dispatcher_host.cc |
diff --git a/content/browser/geolocation/geolocation_dispatcher_host.cc b/content/browser/geolocation/geolocation_dispatcher_host.cc |
index a778dfab2a3092096f9f43514f2c7b0d1475139d..996466f3b56f607be29ddd8cac23cc3696113aa8 100644 |
--- a/content/browser/geolocation/geolocation_dispatcher_host.cc |
+++ b/content/browser/geolocation/geolocation_dispatcher_host.cc |
@@ -91,6 +91,18 @@ GeolocationDispatcherHost::GeolocationDispatcherHost( |
GeolocationDispatcherHost::~GeolocationDispatcherHost() { |
} |
+void GeolocationDispatcherHost::SetOverride( |
+ scoped_ptr<Geoposition> geoposition) { |
+ geoposition_override_.swap(geoposition); |
+ RefreshGeolocationOptions(); |
+ OnLocationUpdate(*geoposition_override_); |
+} |
+ |
+void GeolocationDispatcherHost::ClearOverride() { |
+ geoposition_override_.reset(); |
+ RefreshGeolocationOptions(); |
+} |
+ |
void GeolocationDispatcherHost::RenderFrameDeleted( |
RenderFrameHost* render_frame_host) { |
OnStopUpdating(render_frame_host); |
@@ -130,18 +142,24 @@ void GeolocationDispatcherHost::OnLocationUpdate( |
for (std::map<RenderFrameHost*, bool>::iterator i = updating_frames_.begin(); |
i != updating_frames_.end(); ++i) { |
- RenderFrameHost* top_frame = i->first; |
- while (top_frame->GetParent()) { |
- top_frame = top_frame->GetParent(); |
- } |
- GetContentClient()->browser()->DidUseGeolocationPermission( |
- web_contents(), |
- i->first->GetLastCommittedURL().GetOrigin(), |
- top_frame->GetLastCommittedURL().GetOrigin()); |
+ UpdateGeoposition(i->first, geoposition); |
+ } |
+} |
- i->first->Send(new GeolocationMsg_PositionUpdated( |
- i->first->GetRoutingID(), geoposition)); |
+void GeolocationDispatcherHost::UpdateGeoposition( |
+ RenderFrameHost* frame, |
+ const Geoposition& geoposition) { |
+ RenderFrameHost* top_frame = frame; |
+ while (top_frame->GetParent()) { |
+ top_frame = top_frame->GetParent(); |
} |
+ GetContentClient()->browser()->DidUseGeolocationPermission( |
+ web_contents(), |
+ frame->GetLastCommittedURL().GetOrigin(), |
+ top_frame->GetLastCommittedURL().GetOrigin()); |
+ |
+ frame->Send(new GeolocationMsg_PositionUpdated( |
+ frame->GetRoutingID(), geoposition)); |
} |
void GeolocationDispatcherHost::OnRequestPermission( |
@@ -197,6 +215,8 @@ void GeolocationDispatcherHost::OnStartUpdating( |
updating_frames_[render_frame_host] = enable_high_accuracy; |
RefreshGeolocationOptions(); |
+ if (geoposition_override_.get()) |
+ UpdateGeoposition(render_frame_host, *geoposition_override_); |
} |
void GeolocationDispatcherHost::OnStopUpdating( |
@@ -209,12 +229,14 @@ void GeolocationDispatcherHost::PauseOrResume(bool should_pause) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
paused_ = should_pause; |
RefreshGeolocationOptions(); |
+ if (geoposition_override_.get()) |
blundell
2014/10/21 08:44:20
drive-by: Naively, it seems like the code at lines
vkuzkokov
2014/10/21 11:58:27
There is a check in OnLocationUpdate. This doesn't
blundell
2014/10/21 12:12:44
Ah right, I had forgotten about that. It matters f
|
+ OnLocationUpdate(*geoposition_override_); |
} |
void GeolocationDispatcherHost::RefreshGeolocationOptions() { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- if (updating_frames_.empty() || paused_) { |
+ if (updating_frames_.empty() || paused_ || geoposition_override_.get()) { |
geolocation_subscription_.reset(); |
return; |
} |