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

Unified Diff: android_webview/native/aw_contents.cc

Issue 239793002: Handle media access permission request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix error, landed it again Created 6 years, 8 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/native/aw_contents.h ('k') | android_webview/native/aw_web_contents_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/native/aw_contents.cc
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc
index ee0e87b96e8245ebd563e08c3103a4fb595fcc38..15296933e6a039374d424f67bbd957fef22c1d4d 100644
--- a/android_webview/native/aw_contents.cc
+++ b/android_webview/native/aw_contents.cc
@@ -24,6 +24,8 @@
#include "android_webview/native/aw_picture.h"
#include "android_webview/native/aw_web_contents_delegate.h"
#include "android_webview/native/java_browser_view_renderer_helper.h"
+#include "android_webview/native/permission/aw_permission_request.h"
+#include "android_webview/native/permission/permission_request_handler.h"
#include "android_webview/native/state_serializer.h"
#include "android_webview/public/browser/draw_gl.h"
#include "base/android/jni_android.h"
@@ -169,6 +171,8 @@ AwContents::AwContents(scoped_ptr<WebContents> web_contents)
render_view_host_ext_.reset(
new AwRenderViewHostExt(this, web_contents_.get()));
+ permission_request_handler_.reset(new PermissionRequestHandler(this));
+
AwAutofillManagerDelegate* autofill_manager_delegate =
AwAutofillManagerDelegate::FromWebContents(web_contents_.get());
if (autofill_manager_delegate)
@@ -518,6 +522,30 @@ void AwContents::HideGeolocationPrompt(const GURL& origin) {
}
}
+void AwContents::OnPermissionRequest(AwPermissionRequest* request) {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> j_request = request->CreateJavaPeer();
+ ScopedJavaLocalRef<jobject> j_ref = java_ref_.get(env);
+ if (j_request.is_null() || j_ref.is_null()) {
+ permission_request_handler_->CancelRequest(
+ request->GetOrigin(), request->GetResources());
+ return;
+ }
+
+ Java_AwContents_onPermissionRequest(env, j_ref.obj(), j_request.obj());
+}
+
+void AwContents::OnPermissionRequestCanceled(AwPermissionRequest* request) {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> j_request = request->GetJavaObject();
+ if (j_request.is_null())
+ return;
+
+ ScopedJavaLocalRef<jobject> j_ref = java_ref_.get(env);
+ Java_AwContents_onPermissionRequestCanceled(
+ env, j_ref.obj(), j_request.obj());
+}
+
void AwContents::FindAllAsync(JNIEnv* env, jobject obj, jstring search_string) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env, search_string));
« no previous file with comments | « android_webview/native/aw_contents.h ('k') | android_webview/native/aw_web_contents_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698