- render_process_id, render_frame_id, bridge_id),
- &pending_permissions_.back().cancel);
-}
-
-void GeolocationDispatcherHost::OnCancelPermissionRequest(
- RenderFrameHost* render_frame_host,
- int bridge_id,
- const GURL& requesting_frame) {
- int render_process_id = render_frame_host->GetProcess()->GetID();
- int render_frame_id = render_frame_host->GetRoutingID();
- for (size_t i = 0; i < pending_permissions_.size(); ++i) {
- if (pending_permissions_[i].render_process_id == render_process_id &&
- pending_permissions_[i].render_frame_id == render_frame_id &&
- pending_permissions_[i].bridge_id == bridge_id) {
- if (!pending_permissions_[i].cancel.is_null())
- pending_permissions_[i].cancel.Run();
- pending_permissions_.erase(pending_permissions_.begin() + i);
- return;
- }
- }
-}
-
-void GeolocationDispatcherHost::OnStartUpdating(
- RenderFrameHost* render_frame_host,
- const GURL& requesting_frame,
- bool enable_high_accuracy) {
- // StartUpdating() can be invoked as a result of high-accuracy mode
- // being enabled / disabled. No need to record the dispatcher again.
- UMA_HISTOGRAM_BOOLEAN(
- "Geolocation.GeolocationDispatcherHostImpl.EnableHighAccuracy",
- enable_high_accuracy);
-
- updating_frames_[render_frame_host] = enable_high_accuracy;
- RefreshGeolocationOptions();
-}
-
-void GeolocationDispatcherHost::OnStopUpdating(
- RenderFrameHost* render_frame_host) {
- updating_frames_.erase(render_frame_host);
- RefreshGeolocationOptions();
-}
-
-void GeolocationDispatcherHost::PauseOrResume(bool should_pause) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- paused_ = should_pause;
- RefreshGeolocationOptions();
-}
-
-void GeolocationDispatcherHost::RefreshGeolocationOptions() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- if (updating_frames_.empty() || paused_) {
- geolocation_subscription_.reset();
- return;
- }
-
- bool high_accuracy = false;
- for (std::map<RenderFrameHost*, bool>::iterator i =
- updating_frames_.begin(); i != updating_frames_.end(); ++i) {
- if (i->second) {
- high_accuracy = true;
- break;
- }
- }
- geolocation_subscription_ = GeolocationProvider::GetInstance()->
- AddLocationUpdateCallback(
- base::Bind(&GeolocationDispatcherHost::OnLocationUpdate,
- base::Unretained(this)),
- high_accuracy);