| 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..bb917306580c80f0548192f1451fdeceec78d1b1 100644
|
| --- a/content/browser/geolocation/geolocation_dispatcher_host.cc
|
| +++ b/content/browser/geolocation/geolocation_dispatcher_host.cc
|
| @@ -69,10 +69,12 @@ void RecordGeopositionErrorCode(Geoposition::ErrorCode error_code) {
|
| GeolocationDispatcherHost::PendingPermission::PendingPermission(
|
| int render_frame_id,
|
| int render_process_id,
|
| - int bridge_id)
|
| + int bridge_id,
|
| + const GURL& origin)
|
| : render_frame_id(render_frame_id),
|
| render_process_id(render_process_id),
|
| - bridge_id(bridge_id) {
|
| + bridge_id(bridge_id),
|
| + origin(origin) {
|
| }
|
|
|
| GeolocationDispatcherHost::PendingPermission::~PendingPermission() {
|
| @@ -94,6 +96,8 @@ GeolocationDispatcherHost::~GeolocationDispatcherHost() {
|
| void GeolocationDispatcherHost::RenderFrameDeleted(
|
| RenderFrameHost* render_frame_host) {
|
| OnStopUpdating(render_frame_host);
|
| +
|
| + CancelPermissionRequestsForFrame(render_frame_host);
|
| }
|
|
|
| void GeolocationDispatcherHost::RenderViewHostChanged(
|
| @@ -104,6 +108,16 @@ void GeolocationDispatcherHost::RenderViewHostChanged(
|
| geolocation_subscription_.reset();
|
| }
|
|
|
| +void GeolocationDispatcherHost::DidNavigateAnyFrame(
|
| + RenderFrameHost* render_frame_host,
|
| + const LoadCommittedDetails& details,
|
| + const FrameNavigateParams& params) {
|
| + if (details.is_in_page)
|
| + return;
|
| +
|
| + CancelPermissionRequestsForFrame(render_frame_host);
|
| +}
|
| +
|
| bool GeolocationDispatcherHost::OnMessageReceived(
|
| const IPC::Message& msg, RenderFrameHost* render_frame_host) {
|
| bool handled = true;
|
| @@ -111,8 +125,6 @@ bool GeolocationDispatcherHost::OnMessageReceived(
|
| render_frame_host)
|
| IPC_MESSAGE_HANDLER(GeolocationHostMsg_RequestPermission,
|
| OnRequestPermission)
|
| - IPC_MESSAGE_HANDLER(GeolocationHostMsg_CancelPermissionRequest,
|
| - OnCancelPermissionRequest)
|
| IPC_MESSAGE_HANDLER(GeolocationHostMsg_StartUpdating, OnStartUpdating)
|
| IPC_MESSAGE_HANDLER(GeolocationHostMsg_StopUpdating, OnStopUpdating)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| @@ -147,47 +159,28 @@ void GeolocationDispatcherHost::OnLocationUpdate(
|
| void GeolocationDispatcherHost::OnRequestPermission(
|
| RenderFrameHost* render_frame_host,
|
| int bridge_id,
|
| - const GURL& requesting_frame,
|
| + const GURL& requesting_origin,
|
| bool user_gesture) {
|
| int render_process_id = render_frame_host->GetProcess()->GetID();
|
| int render_frame_id = render_frame_host->GetRoutingID();
|
|
|
| PendingPermission pending_permission(
|
| - render_frame_id, render_process_id, bridge_id);
|
| + render_frame_id, render_process_id, bridge_id, requesting_origin);
|
| pending_permissions_.push_back(pending_permission);
|
|
|
| GetContentClient()->browser()->RequestGeolocationPermission(
|
| web_contents(),
|
| bridge_id,
|
| - requesting_frame,
|
| + requesting_origin,
|
| user_gesture,
|
| base::Bind(&GeolocationDispatcherHost::SendGeolocationPermissionResponse,
|
| weak_factory_.GetWeakPtr(),
|
| render_process_id, render_frame_id, bridge_id));
|
| }
|
|
|
| -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) {
|
| - GetContentClient()->browser()->CancelGeolocationPermissionRequest(
|
| - web_contents(), bridge_id, requesting_frame);
|
| -
|
| - pending_permissions_.erase(pending_permissions_.begin() + i);
|
| - return;
|
| - }
|
| - }
|
| -}
|
| -
|
| void GeolocationDispatcherHost::OnStartUpdating(
|
| RenderFrameHost* render_frame_host,
|
| - const GURL& requesting_frame,
|
| + const GURL& requesting_origin,
|
| 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.
|
| @@ -263,4 +256,21 @@ void GeolocationDispatcherHost::SendGeolocationPermissionResponse(
|
| NOTREACHED();
|
| }
|
|
|
| +void GeolocationDispatcherHost::CancelPermissionRequestsForFrame(
|
| + RenderFrameHost* render_frame_host) {
|
| + 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) {
|
| + GetContentClient()->browser()->CancelGeolocationPermissionRequest(
|
| + web_contents(),
|
| + pending_permissions_[i].bridge_id,
|
| + pending_permissions_[i].origin);
|
| + pending_permissions_.erase(pending_permissions_.begin() + i);
|
| + }
|
| + }
|
| +}
|
| +
|
| } // namespace content
|
|
|