Index: content/renderer/geolocation_dispatcher.cc |
diff --git a/content/renderer/geolocation_dispatcher.cc b/content/renderer/geolocation_dispatcher.cc |
index fde4fc98cba9217f6adfb0c669ed1ecf23f69a5e..80ff388ea19c339c7034a43839b90812d312a1f5 100644 |
--- a/content/renderer/geolocation_dispatcher.cc |
+++ b/content/renderer/geolocation_dispatcher.cc |
@@ -4,7 +4,8 @@ |
#include "content/renderer/geolocation_dispatcher.h" |
-#include "content/common/geolocation_messages.h" |
+#include "content/child/child_thread.h" |
+#include "content/public/common/geoposition.h" |
#include "content/renderer/render_view_impl.h" |
#include "third_party/WebKit/public/platform/WebString.h" |
#include "third_party/WebKit/public/web/WebGeolocationPermissionRequest.h" |
@@ -25,20 +26,12 @@ namespace content { |
GeolocationDispatcher::GeolocationDispatcher(RenderFrame* render_frame) |
: RenderFrameObserver(render_frame), |
pending_permissions_(new WebGeolocationPermissionRequestManager()), |
- enable_high_accuracy_(false) { |
+ enable_high_accuracy_(false), |
+ weak_ptr_factory_(this) { |
} |
GeolocationDispatcher::~GeolocationDispatcher() {} |
-bool GeolocationDispatcher::OnMessageReceived(const IPC::Message& message) { |
- bool handled = true; |
- IPC_BEGIN_MESSAGE_MAP(GeolocationDispatcher, message) |
- IPC_MESSAGE_HANDLER(GeolocationMsg_PermissionSet, OnPermissionSet) |
- IPC_MESSAGE_UNHANDLED(handled = false) |
- IPC_END_MESSAGE_MAP() |
- return handled; |
-} |
- |
void GeolocationDispatcher::startUpdating() { |
if (!geolocation_service_.get()) { |
render_frame()->GetServiceRegistry()->ConnectToRemoteService( |
@@ -82,25 +75,39 @@ bool GeolocationDispatcher::lastPosition(WebGeolocationPosition&) { |
// conversion is necessary. |
void GeolocationDispatcher::requestPermission( |
const WebGeolocationPermissionRequest& permissionRequest) { |
- int bridge_id = pending_permissions_->add(permissionRequest); |
- base::string16 origin = permissionRequest.securityOrigin().toString(); |
- Send(new GeolocationHostMsg_RequestPermission( |
- routing_id(), bridge_id, GURL(origin), |
- blink::WebUserGestureIndicator::isProcessingUserGesture())); |
+ if (!permission_service_.get()) { |
+ render_frame()->GetServiceRegistry()->ConnectToRemoteService( |
+ &permission_service_); |
+ } |
+ |
+ int permission_request_id = pending_permissions_->add(permissionRequest); |
+ |
+ PermissionPtr permission = Permission::New(); |
+ permission->name = PERMISSION_NAME_GEOLOCATION; |
+ |
+ permission_service_->RequestPermission( |
+ permission.Clone(), |
qsr
2014/11/14 09:20:26
You should pass the permission, instead of cloning
mlamouri (slow - plz ping)
2014/11/14 11:37:11
For some reasons, I had to Clone(), it wouldn't co
qsr
2014/11/14 11:49:27
When I say pass, I mean calling the Pass() method
|
+ permissionRequest.securityOrigin().toString().utf8(), |
+ base::Bind(&GeolocationDispatcher::OnPermissionSet, |
+ weak_ptr_factory_.GetWeakPtr(), |
+ permission_request_id)); |
} |
void GeolocationDispatcher::cancelPermissionRequest( |
- const WebGeolocationPermissionRequest& permissionRequest) { |
- int bridge_id; |
- pending_permissions_->remove(permissionRequest, bridge_id); |
+ const blink::WebGeolocationPermissionRequest& permissionRequest) { |
+ int permission_request_id; |
+ pending_permissions_->remove(permissionRequest, permission_request_id); |
} |
// Permission for using geolocation has been set. |
-void GeolocationDispatcher::OnPermissionSet(int bridge_id, bool is_allowed) { |
+void GeolocationDispatcher::OnPermissionSet( |
+ int permission_request_id, |
+ PermissionStatus status) { |
WebGeolocationPermissionRequest permissionRequest; |
- if (!pending_permissions_->remove(bridge_id, permissionRequest)) |
+ if (!pending_permissions_->remove(permission_request_id, permissionRequest)) |
return; |
- permissionRequest.setIsAllowed(is_allowed); |
+ |
+ permissionRequest.setIsAllowed(status == PERMISSION_STATUS_GRANTED); |
} |
void GeolocationDispatcher::OnLocationUpdate(MojoGeopositionPtr geoposition) { |