| 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 <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "content/browser/geolocation/geolocation_provider.h" | 12 #include "content/browser/geolocation/geolocation_provider.h" |
| 13 #include "content/browser/renderer_host/render_message_filter.h" | 13 #include "content/browser/renderer_host/render_message_filter.h" |
| 14 #include "content/browser/renderer_host/render_process_host_impl.h" | 14 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 15 #include "content/browser/renderer_host/render_view_host_impl.h" | 15 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 16 #include "content/public/browser/geolocation_permission_context.h" | 16 #include "content/public/browser/geolocation_permission_context.h" |
| 17 #include "content/common/geolocation_messages.h" | 17 #include "content/common/geolocation_messages.h" |
| 18 #include "content/common/geoposition.h" | 18 #include "content/common/geoposition.h" |
| 19 | 19 |
| 20 using content::BrowserThread; | 20 using content::BrowserThread; |
| 21 using content::GeolocationPermissionContext; | 21 using content::GeolocationPermissionContext; |
| 22 using content::RenderViewHostImpl; | 22 using content::RenderViewHostImpl; |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 void NotifyArbitratorPermissionGranted( | 26 void NotifyArbitratorPermissionGranted() { |
| 27 const GURL& requesting_frame) { | |
| 28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 29 GeolocationProvider::GetInstance()->OnPermissionGranted(requesting_frame); | 28 GeolocationProvider::GetInstance()->OnPermissionGranted(); |
| 30 } | 29 } |
| 31 | 30 |
| 32 void SendGeolocationPermissionResponse( | 31 void SendGeolocationPermissionResponse(int render_process_id, |
| 33 const GURL& requesting_frame, int render_process_id, int render_view_id, | 32 int render_view_id, |
| 34 int bridge_id, bool allowed) { | 33 int bridge_id, |
| 34 bool allowed) { |
| 35 RenderViewHostImpl* r = RenderViewHostImpl::FromID( | 35 RenderViewHostImpl* r = RenderViewHostImpl::FromID( |
| 36 render_process_id, render_view_id); | 36 render_process_id, render_view_id); |
| 37 if (!r) | 37 if (!r) |
| 38 return; | 38 return; |
| 39 r->Send(new GeolocationMsg_PermissionSet(render_view_id, bridge_id, allowed)); | 39 r->Send(new GeolocationMsg_PermissionSet(render_view_id, bridge_id, allowed)); |
| 40 | 40 |
| 41 if (allowed) { | 41 if (allowed) { |
| 42 BrowserThread::PostTask( | 42 BrowserThread::PostTask( |
| 43 BrowserThread::IO, FROM_HERE, | 43 BrowserThread::IO, FROM_HERE, |
| 44 base::Bind(&NotifyArbitratorPermissionGranted, requesting_frame)); | 44 base::Bind(&NotifyArbitratorPermissionGranted)); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 class GeolocationDispatcherHostImpl : public GeolocationDispatcherHost, | 48 class GeolocationDispatcherHostImpl : public GeolocationDispatcherHost, |
| 49 public GeolocationObserver { | 49 public GeolocationObserver { |
| 50 public: | 50 public: |
| 51 GeolocationDispatcherHostImpl( | 51 GeolocationDispatcherHostImpl( |
| 52 int render_process_id, | 52 int render_process_id, |
| 53 GeolocationPermissionContext* geolocation_permission_context); | 53 GeolocationPermissionContext* geolocation_permission_context); |
| 54 | 54 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 int render_view_id, | 137 int render_view_id, |
| 138 int bridge_id, | 138 int bridge_id, |
| 139 const GURL& requesting_frame) { | 139 const GURL& requesting_frame) { |
| 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 141 DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" | 141 DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" |
| 142 << render_view_id << ":" << bridge_id; | 142 << render_view_id << ":" << bridge_id; |
| 143 geolocation_permission_context_->RequestGeolocationPermission( | 143 geolocation_permission_context_->RequestGeolocationPermission( |
| 144 render_process_id_, render_view_id, bridge_id, | 144 render_process_id_, render_view_id, bridge_id, |
| 145 requesting_frame, | 145 requesting_frame, |
| 146 base::Bind( | 146 base::Bind( |
| 147 &SendGeolocationPermissionResponse, requesting_frame, | 147 &SendGeolocationPermissionResponse, |
| 148 render_process_id_, render_view_id, bridge_id)); | 148 render_process_id_, render_view_id, bridge_id)); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void GeolocationDispatcherHostImpl::OnCancelPermissionRequest( | 151 void GeolocationDispatcherHostImpl::OnCancelPermissionRequest( |
| 152 int render_view_id, | 152 int render_view_id, |
| 153 int bridge_id, | 153 int bridge_id, |
| 154 const GURL& requesting_frame) { | 154 const GURL& requesting_frame) { |
| 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 156 DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" | 156 DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" |
| 157 << render_view_id << ":" << bridge_id; | 157 << render_view_id << ":" << bridge_id; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 206 } |
| 207 } // namespace | 207 } // namespace |
| 208 | 208 |
| 209 GeolocationDispatcherHost* GeolocationDispatcherHost::New( | 209 GeolocationDispatcherHost* GeolocationDispatcherHost::New( |
| 210 int render_process_id, | 210 int render_process_id, |
| 211 GeolocationPermissionContext* geolocation_permission_context) { | 211 GeolocationPermissionContext* geolocation_permission_context) { |
| 212 return new GeolocationDispatcherHostImpl( | 212 return new GeolocationDispatcherHostImpl( |
| 213 render_process_id, | 213 render_process_id, |
| 214 geolocation_permission_context); | 214 geolocation_permission_context); |
| 215 } | 215 } |
| OLD | NEW |