OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/geolocation/geolocation_dispatcher_host.h" | 5 #include "chrome/browser/geolocation/geolocation_dispatcher_host.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 geolocation_permission_context_->CancelGeolocationPermissionRequest( | 161 geolocation_permission_context_->CancelGeolocationPermissionRequest( |
162 render_process_id_, render_view_id, bridge_id, | 162 render_process_id_, render_view_id, bridge_id, |
163 requesting_frame); | 163 requesting_frame); |
164 } | 164 } |
165 | 165 |
166 void GeolocationDispatcherHostImpl::OnStartUpdating( | 166 void GeolocationDispatcherHostImpl::OnStartUpdating( |
167 int render_view_id, | 167 int render_view_id, |
168 int bridge_id, | 168 int bridge_id, |
169 const GURL& requesting_frame, | 169 const GURL& requesting_frame, |
170 bool enable_high_accuracy) { | 170 bool enable_high_accuracy) { |
171 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
172 // StartUpdating() can be invoked as a result of high-accuracy mode | 171 // StartUpdating() can be invoked as a result of high-accuracy mode |
173 // being enabled / disabled. No need to register the dispatcher again. | 172 // being enabled / disabled. No need to register the dispatcher again. |
174 if (!geolocation_renderer_ids_.count(render_view_id)) | 173 if (!geolocation_renderer_ids_.count(render_view_id)) |
175 OnRegisterDispatcher(render_view_id); | 174 OnRegisterDispatcher(render_view_id); |
176 #endif | |
177 // WebKit sends the startupdating request before checking permissions, to | 175 // WebKit sends the startupdating request before checking permissions, to |
178 // optimize the no-location-available case and reduce latency in the success | 176 // optimize the no-location-available case and reduce latency in the success |
179 // case (location lookup happens in parallel with the permission request). | 177 // case (location lookup happens in parallel with the permission request). |
180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
181 DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" | 179 DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" |
182 << render_view_id << ":" << bridge_id; | 180 << render_view_id << ":" << bridge_id; |
183 bridge_update_options_[std::make_pair(render_view_id, bridge_id)] = | 181 bridge_update_options_[std::make_pair(render_view_id, bridge_id)] = |
184 GeolocationObserverOptions(enable_high_accuracy); | 182 GeolocationObserverOptions(enable_high_accuracy); |
185 geolocation_permission_context_->StartUpdatingRequested( | 183 geolocation_permission_context_->StartUpdatingRequested( |
186 render_process_id_, render_view_id, bridge_id, | 184 render_process_id_, render_view_id, bridge_id, |
187 requesting_frame); | 185 requesting_frame); |
188 RefreshGeolocationObserverOptions(); | 186 RefreshGeolocationObserverOptions(); |
189 } | 187 } |
190 | 188 |
191 void GeolocationDispatcherHostImpl::OnStopUpdating(int render_view_id, | 189 void GeolocationDispatcherHostImpl::OnStopUpdating(int render_view_id, |
192 int bridge_id) { | 190 int bridge_id) { |
193 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
194 DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" | 192 DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" |
195 << render_view_id << ":" << bridge_id; | 193 << render_view_id << ":" << bridge_id; |
196 if (bridge_update_options_.erase(std::make_pair(render_view_id, bridge_id))) | 194 if (bridge_update_options_.erase(std::make_pair(render_view_id, bridge_id))) |
197 RefreshGeolocationObserverOptions(); | 195 RefreshGeolocationObserverOptions(); |
198 geolocation_permission_context_->StopUpdatingRequested( | 196 geolocation_permission_context_->StopUpdatingRequested( |
199 render_process_id_, render_view_id, bridge_id); | 197 render_process_id_, render_view_id, bridge_id); |
200 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
201 OnUnregisterDispatcher(render_view_id); | 198 OnUnregisterDispatcher(render_view_id); |
202 #endif | |
203 } | 199 } |
204 | 200 |
205 void GeolocationDispatcherHostImpl::OnSuspend(int render_view_id, | 201 void GeolocationDispatcherHostImpl::OnSuspend(int render_view_id, |
206 int bridge_id) { | 202 int bridge_id) { |
207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
208 DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" | 204 DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" |
209 << render_view_id << ":" << bridge_id; | 205 << render_view_id << ":" << bridge_id; |
210 // TODO(bulach): connect this with GeolocationArbitrator. | 206 // TODO(bulach): connect this with GeolocationArbitrator. |
211 } | 207 } |
212 | 208 |
(...skipping 23 matching lines...) Expand all Loading... |
236 } | 232 } |
237 } // namespace | 233 } // namespace |
238 | 234 |
239 GeolocationDispatcherHost* GeolocationDispatcherHost::New( | 235 GeolocationDispatcherHost* GeolocationDispatcherHost::New( |
240 int render_process_id, | 236 int render_process_id, |
241 GeolocationPermissionContext* geolocation_permission_context) { | 237 GeolocationPermissionContext* geolocation_permission_context) { |
242 return new GeolocationDispatcherHostImpl( | 238 return new GeolocationDispatcherHostImpl( |
243 render_process_id, | 239 render_process_id, |
244 geolocation_permission_context); | 240 geolocation_permission_context); |
245 } | 241 } |
OLD | NEW |