OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/geolocation/geolocation_dispatcher_host.h" | 5 #include "content/browser/geolocation/geolocation_dispatcher_host.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 void GeolocationDispatcherHost::UpdateGeoposition( | 161 void GeolocationDispatcherHost::UpdateGeoposition( |
162 RenderFrameHost* frame, | 162 RenderFrameHost* frame, |
163 const Geoposition& geoposition) { | 163 const Geoposition& geoposition) { |
164 RenderFrameHost* top_frame = frame; | 164 RenderFrameHost* top_frame = frame; |
165 while (top_frame->GetParent()) { | 165 while (top_frame->GetParent()) { |
166 top_frame = top_frame->GetParent(); | 166 top_frame = top_frame->GetParent(); |
167 } | 167 } |
168 GetContentClient()->browser()->DidUseGeolocationPermission( | 168 GetContentClient()->browser()->RegisterPermissionUsage( |
| 169 content::PERMISSION_GEOLOCATION, |
169 web_contents(), | 170 web_contents(), |
170 frame->GetLastCommittedURL().GetOrigin(), | 171 frame->GetLastCommittedURL().GetOrigin(), |
171 top_frame->GetLastCommittedURL().GetOrigin()); | 172 top_frame->GetLastCommittedURL().GetOrigin()); |
172 | 173 |
173 frame->Send(new GeolocationMsg_PositionUpdated( | 174 frame->Send(new GeolocationMsg_PositionUpdated( |
174 frame->GetRoutingID(), geoposition)); | 175 frame->GetRoutingID(), geoposition)); |
175 } | 176 } |
176 | 177 |
177 void GeolocationDispatcherHost::OnRequestPermission( | 178 void GeolocationDispatcherHost::OnRequestPermission( |
178 RenderFrameHost* render_frame_host, | 179 RenderFrameHost* render_frame_host, |
179 int bridge_id, | 180 int bridge_id, |
180 const GURL& requesting_origin, | 181 const GURL& requesting_origin, |
181 bool user_gesture) { | 182 bool user_gesture) { |
182 int render_process_id = render_frame_host->GetProcess()->GetID(); | 183 int render_process_id = render_frame_host->GetProcess()->GetID(); |
183 int render_frame_id = render_frame_host->GetRoutingID(); | 184 int render_frame_id = render_frame_host->GetRoutingID(); |
184 | 185 |
185 PendingPermission pending_permission( | 186 PendingPermission pending_permission( |
186 render_frame_id, render_process_id, bridge_id, requesting_origin); | 187 render_frame_id, render_process_id, bridge_id, requesting_origin); |
187 pending_permissions_.push_back(pending_permission); | 188 pending_permissions_.push_back(pending_permission); |
188 | 189 |
189 GetContentClient()->browser()->RequestGeolocationPermission( | 190 GetContentClient()->browser()->RequestPermission( |
| 191 content::PERMISSION_GEOLOCATION, |
190 web_contents(), | 192 web_contents(), |
191 bridge_id, | 193 bridge_id, |
192 requesting_origin, | 194 requesting_origin, |
193 user_gesture, | 195 user_gesture, |
194 base::Bind(&GeolocationDispatcherHost::SendGeolocationPermissionResponse, | 196 base::Bind(&GeolocationDispatcherHost::SendGeolocationPermissionResponse, |
195 weak_factory_.GetWeakPtr(), | 197 weak_factory_.GetWeakPtr(), |
196 render_process_id, render_frame_id, bridge_id)); | 198 render_process_id, render_frame_id, bridge_id)); |
197 } | 199 } |
198 | 200 |
199 void GeolocationDispatcherHost::OnStartUpdating( | 201 void GeolocationDispatcherHost::OnStartUpdating( |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 } | 281 } |
280 | 282 |
281 void GeolocationDispatcherHost::CancelPermissionRequestsForFrame( | 283 void GeolocationDispatcherHost::CancelPermissionRequestsForFrame( |
282 RenderFrameHost* render_frame_host) { | 284 RenderFrameHost* render_frame_host) { |
283 int render_process_id = render_frame_host->GetProcess()->GetID(); | 285 int render_process_id = render_frame_host->GetProcess()->GetID(); |
284 int render_frame_id = render_frame_host->GetRoutingID(); | 286 int render_frame_id = render_frame_host->GetRoutingID(); |
285 | 287 |
286 for (size_t i = 0; i < pending_permissions_.size(); ++i) { | 288 for (size_t i = 0; i < pending_permissions_.size(); ++i) { |
287 if (pending_permissions_[i].render_process_id == render_process_id && | 289 if (pending_permissions_[i].render_process_id == render_process_id && |
288 pending_permissions_[i].render_frame_id == render_frame_id) { | 290 pending_permissions_[i].render_frame_id == render_frame_id) { |
289 GetContentClient()->browser()->CancelGeolocationPermissionRequest( | 291 GetContentClient()->browser()->CancelPermissionRequest( |
| 292 content::PERMISSION_GEOLOCATION, |
290 web_contents(), | 293 web_contents(), |
291 pending_permissions_[i].bridge_id, | 294 pending_permissions_[i].bridge_id, |
292 pending_permissions_[i].origin); | 295 pending_permissions_[i].origin); |
293 pending_permissions_.erase(pending_permissions_.begin() + i); | 296 pending_permissions_.erase(pending_permissions_.begin() + i); |
294 } | 297 } |
295 } | 298 } |
296 } | 299 } |
297 | 300 |
298 } // namespace content | 301 } // namespace content |
OLD | NEW |