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

Unified Diff: content/child/permissions/permission_dispatcher.cc

Issue 1240783002: content: permissions: add plumbing to request permissions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permissions-content-blink
Patch Set: Fix build Created 5 years, 5 months 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/child/permissions/permission_dispatcher.cc
diff --git a/content/child/permissions/permission_dispatcher.cc b/content/child/permissions/permission_dispatcher.cc
index 4a0957ecb7b8646e95b0a977e96abe921e0c83cd..4fa87ebb30c53c11381c95c935286ddd670f5016 100644
--- a/content/child/permissions/permission_dispatcher.cc
+++ b/content/child/permissions/permission_dispatcher.cc
@@ -9,6 +9,7 @@
#include "content/public/common/service_registry.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/platform/modules/permissions/WebPermissionObserver.h"
+#include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
using blink::WebPermissionObserver;
@@ -113,6 +114,14 @@ void PermissionDispatcher::queryPermission(
type, origin.string().utf8(), callback, kNoWorkerThread);
}
+void PermissionDispatcher::requestPermission(
+ blink::WebPermissionType type,
+ const blink::WebURL& origin,
+ blink::WebPermissionCallback* callback) {
+ RequestPermissionInternal(
+ type, origin.string().utf8(), callback, kNoWorkerThread);
+}
+
void PermissionDispatcher::revokePermission(
blink::WebPermissionType type,
const blink::WebURL& origin,
@@ -154,6 +163,14 @@ void PermissionDispatcher::QueryPermissionForWorker(
QueryPermissionInternal(type, origin, callback, worker_thread_id);
}
+void PermissionDispatcher::RequestPermissionForWorker(
+ blink::WebPermissionType type,
+ const std::string& origin,
+ blink::WebPermissionCallback* callback,
+ int worker_thread_id) {
+ RequestPermissionInternal(type, origin, callback, worker_thread_id);
+}
+
void PermissionDispatcher::RevokePermissionForWorker(
blink::WebPermissionType type,
const std::string& origin,
@@ -232,6 +249,26 @@ void PermissionDispatcher::QueryPermissionInternal(
request_id));
}
+void PermissionDispatcher::RequestPermissionInternal(
+ blink::WebPermissionType type,
+ const std::string& origin,
+ blink::WebPermissionCallback* callback,
+ int worker_thread_id) {
+ // We need to save the |callback| in an IDMap so if |this| gets deleted, the
+ // callback will not leak. In the case of |this| gets deleted, the
+ // |permission_service_| pipe will be destroyed too so OnQueryPermission will
+ // not be called.
+ int request_id = pending_callbacks_.Add(
+ new CallbackInformation(callback, worker_thread_id));
+ GetPermissionServicePtr()->RequestPermission(
+ GetPermissionName(type),
+ origin,
+ blink::WebUserGestureIndicator::isProcessingUserGesture(),
+ base::Bind(&PermissionDispatcher::OnPermissionResponse,
+ base::Unretained(this),
+ request_id));
+}
+
void PermissionDispatcher::RevokePermissionInternal(
blink::WebPermissionType type,
const std::string& origin,
« no previous file with comments | « content/child/permissions/permission_dispatcher.h ('k') | content/child/permissions/permission_dispatcher_thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698