Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3018)

Unified Diff: content/renderer/geolocation_dispatcher.cc

Issue 722153003: Implement basic mojo Permission service and use it for Geolocation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename HasPermission() to QueryPermission() Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/geolocation_dispatcher.cc
diff --git a/content/renderer/geolocation_dispatcher.cc b/content/renderer/geolocation_dispatcher.cc
index fde4fc98cba9217f6adfb0c669ed1ecf23f69a5e..0a9607561f7c6110e9428ea82dd4bea7d52c93f4 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,38 @@ 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);
+
+ PermissionName permission = PERMISSION_NAME_GEOLOCATION;
+
+ permission_service_->RequestPermission(
+ permission,
+ permissionRequest.securityOrigin().toString().utf8(),
+ base::Bind(&GeolocationDispatcher::OnPermissionSet,
+ weak_ptr_factory_.GetWeakPtr(),
blundell 2014/11/14 12:11:52 This doesn't need to be a weak ptr, as |permission
+ 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) {
« content/common/permission_service.mojom ('K') | « content/renderer/geolocation_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698