| 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..a2f6a0bda4d1be5e94272f13d82a619c6e08c21c 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(
|
| @@ -214,7 +234,7 @@ void GeolocationDispatcherHost::PauseOrResume(bool should_pause) {
|
| 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;
|
| }
|
|
|