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

Side by Side Diff: android_webview/native/permission/aw_permission_request.h

Issue 239793002: Handle media access permission request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments, added unittests 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H
6 #define ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H
7
8 #include "base/android/jni_helper.h"
9 #include "base/android/scoped_java_ref.h"
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "url/gurl.h"
13
14 namespace android_webview {
15
16 class AwPermissionRequestDelegate;
17
18 // This class wraps a permission request, it works with PermissionRequestHandler
19 // and its' Java peer to represent the request to AwContentsClient.
20 // The specific permission request should implement the
21 // AwPermissionRequestDelegate interface, See MediaPermissionRequest.
22 class AwPermissionRequest : public base::RefCounted<AwPermissionRequest> {
23 public:
24 // The definition must synced with Android's
25 // android.webkit.PermissionRequest.
26 enum Resource {
27 Geolocation = 1 << 0,
28 VideoCapture = 1 << 1,
29 AudioCapture = 1 << 2
30 };
31
32 // Take the ownership of |delegate|.
33 AwPermissionRequest(scoped_ptr<AwPermissionRequestDelegate> delegate);
34
35 // Create and return Java peer, |callback| is invoked after request result
36 // is returned from Java peer and notified to delegate.
37 base::android::ScopedJavaLocalRef<jobject> CreateJavaPeer(
38 base::Callback<void(scoped_refptr<AwPermissionRequest>)> callback);
39
40 // Return the Java peer.
41 base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
42
43 // Invoked by Java peer when request is processed, |granted| indicates the
44 // request was granted or not.
45 void OnAccept(JNIEnv* env, jobject jcaller, jboolean granted);
46
47 // Return the origin which initiated the request.
48 const GURL& GetOrigin();
49
50 // Return the resources origin requested.
51 int64 GetResources();
52
53 private:
54 friend class base::RefCounted<AwPermissionRequest>;
55 friend class TestAwPermissionRequest;
56
57 virtual ~AwPermissionRequest();
58
59 scoped_ptr<AwPermissionRequestDelegate> delegate_;
60 base::Callback<void(scoped_refptr<AwPermissionRequest>)> callback_;
61 JavaObjectWeakGlobalRef java_ref_;
62
63 DISALLOW_COPY_AND_ASSIGN(AwPermissionRequest);
64 };
65
66 bool RegisterAwPermissionRequest(JNIEnv* env);
67
68 } // namespace android_webivew
69
70 #endif // ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698