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

Unified Diff: android_webview/browser/aw_permission_manager.cc

Issue 1316863010: browser: implement multiple permission requesting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@request-multiple-content
Patch Set: Rebase on master Created 5 years, 2 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
« no previous file with comments | « android_webview/browser/aw_permission_manager.h ('k') | chrome/browser/permissions/permission_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/browser/aw_permission_manager.cc
diff --git a/android_webview/browser/aw_permission_manager.cc b/android_webview/browser/aw_permission_manager.cc
index 6474513250f667796a3513b10f31d50da4fb91b3..d2a6233e18a9a1222768f23aa33aedc5ce10f4dc 100644
--- a/android_webview/browser/aw_permission_manager.cc
+++ b/android_webview/browser/aw_permission_manager.cc
@@ -258,6 +258,26 @@ int AwPermissionManager::RequestPermission(
return request_id;
}
+int AwPermissionManager::RequestPermissions(
+ const std::vector<PermissionType>& permissions,
+ content::RenderFrameHost* render_frame_host,
+ const GURL& requesting_origin,
+ bool user_gesture,
+ const base::Callback<void(
+ const std::vector<PermissionStatus>&)>& callback) {
+ NOTIMPLEMENTED() << "RequestPermissions has not been implemented in WebView";
+
+ std::vector<PermissionStatus> result;
+ const GURL& embedding_origin =
+ content::WebContents::FromRenderFrameHost(render_frame_host)
+ ->GetLastCommittedURL().GetOrigin();
+ for (PermissionType type : permissions) {
+ result.push_back(GetPermissionStatus(
+ type, requesting_origin, embedding_origin));
+ }
+ return kNoPendingOperation;
+}
+
// static
void AwPermissionManager::OnRequestResponse(
const base::WeakPtr<AwPermissionManager>& manager,
@@ -290,42 +310,49 @@ void AwPermissionManager::OnRequestResponse(
callback.Run(status);
}
-void AwPermissionManager::CancelPermissionRequest(
- PermissionType permission,
- content::RenderFrameHost* render_frame_host,
- int request_id,
- const GURL& origin) {
+void AwPermissionManager::CancelPermissionRequest(int request_id) {
PendingRequest* pending_request = pending_requests_.Lookup(request_id);
if (!pending_request)
return;
+ content::RenderFrameHost* render_frame_host =
+ content::RenderFrameHost::FromID(pending_request->render_process_id,
+ pending_request->render_frame_id);
+ content::WebContents* web_contents =
+ content::WebContents::FromRenderFrameHost(render_frame_host);
+ DCHECK(web_contents);
+
// The caller is canceling (presumably) the most recent request. Assuming the
// request did not complete, the user did not respond to the requset.
// Thus, assume we do not know the result.
- const GURL& embedding_origin =
- content::WebContents::FromRenderFrameHost(render_frame_host)
+ const GURL& embedding_origin = web_contents
->GetLastCommittedURL().GetOrigin();
- result_cache_->ClearResult(permission, origin, embedding_origin);
+ result_cache_->ClearResult(
+ pending_request->permission,
+ pending_request->requesting_origin,
+ embedding_origin);
- int render_process_id = render_frame_host->GetProcess()->GetID();
- int render_frame_id = render_frame_host->GetRoutingID();
AwBrowserPermissionRequestDelegate* delegate =
- AwBrowserPermissionRequestDelegate::FromID(render_process_id,
- render_frame_id);
+ AwBrowserPermissionRequestDelegate::FromID(
+ pending_request->render_process_id,
+ pending_request->render_frame_id);
if (!delegate) {
pending_requests_.Remove(request_id);
return;
}
- switch (permission) {
+ switch (pending_request->permission) {
case PermissionType::GEOLOCATION:
- delegate->CancelGeolocationPermissionRequests(origin);
+ delegate->CancelGeolocationPermissionRequests(
+ pending_request->requesting_origin);
break;
case PermissionType::PROTECTED_MEDIA_IDENTIFIER:
- delegate->CancelProtectedMediaIdentifierPermissionRequests(origin);
+ delegate->CancelProtectedMediaIdentifierPermissionRequests(
+ pending_request->requesting_origin);
break;
case PermissionType::MIDI_SYSEX:
- delegate->CancelMIDISysexPermissionRequests(origin);
+ delegate->CancelMIDISysexPermissionRequests(
+ pending_request->requesting_origin);
break;
case PermissionType::NOTIFICATIONS:
case PermissionType::PUSH_MESSAGING:
@@ -333,7 +360,7 @@ void AwPermissionManager::CancelPermissionRequest(
case PermissionType::AUDIO_CAPTURE:
case PermissionType::VIDEO_CAPTURE:
NOTIMPLEMENTED() << "CancelPermission not implemented for "
- << static_cast<int>(permission);
+ << static_cast<int>(pending_request->permission);
break;
case PermissionType::MIDI:
// There is nothing to cancel so this is simply ignored.
« no previous file with comments | « android_webview/browser/aw_permission_manager.h ('k') | chrome/browser/permissions/permission_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698