Chromium Code Reviews| OLD | NEW |
|---|---|
| (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> { | |
|
mkosiba (inactive)
2014/04/17 10:34:06
do these need to be refcounted? could PermissionRe
michaelbai
2014/04/22 20:53:51
Yes, PermissionRequestHandler will hold the AwPerm
mkosiba (inactive)
2014/04/23 18:04:40
Why does the AwPermissionRequest need to "hold its
michaelbai
2014/04/24 00:56:43
Sorry, I didn't explain it clearly in the first ha
mkosiba (inactive)
2014/04/24 09:24:58
I don't quite understand how having a new permissi
michaelbai
2014/04/25 01:06:09
The AwPermissionRequestDelegate is owned by AwPerm
mkosiba (inactive)
2014/04/28 15:35:36
Thanks!
| |
| 23 public: | |
| 24 // The definition must synced with Android's | |
| 25 // android.webkit.PermissionRequest.java. | |
|
mkosiba (inactive)
2014/04/17 10:34:06
nit: android.webkit.PermissionRequest (drop .java)
michaelbai
2014/04/22 20:53:51
Right, there is no good solution here.
On 2014/04
| |
| 26 enum Resource { | |
| 27 GeoLocation = 1 << 0, | |
|
benm (inactive)
2014/04/16 14:51:10
nit s/L/l/
michaelbai
2014/04/22 20:53:51
Done.
| |
| 28 VideoCapture = 1 << 1, | |
| 29 AudioCapture = 1 << 2 | |
| 30 }; | |
| 31 | |
| 32 // Take the ownership of |delegate|. | |
| 33 AwPermissionRequest(AwPermissionRequestDelegate* delegate); | |
|
mkosiba (inactive)
2014/04/17 10:34:06
if takes ownership then should take scoped_ptr<AwP
michaelbai
2014/04/22 20:53:51
Done.
| |
| 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 // Called by Java peer to get the origin which initiated the request. | |
| 48 base::android::ScopedJavaLocalRef<jstring> GetOrigin(JNIEnv* env, | |
| 49 jobject jcaller); | |
| 50 | |
| 51 // Called by Java peer to get the resoures requested by origin. | |
| 52 jlong GetResources(JNIEnv* env, jobject jcaller); | |
| 53 | |
| 54 // Return the origin which initiated the request. | |
| 55 const GURL& GetOrigin(); | |
| 56 | |
| 57 // Return the origin which initiated the request. | |
|
benm (inactive)
2014/04/16 14:51:10
wrong comment.
michaelbai
2014/04/22 20:53:51
Done.
| |
| 58 int64 GetResources(); | |
| 59 | |
| 60 private: | |
| 61 friend class base::RefCounted<AwPermissionRequest>; | |
| 62 virtual ~AwPermissionRequest(); | |
| 63 | |
| 64 scoped_ptr<AwPermissionRequestDelegate> delegate_; | |
| 65 base::Callback<void(scoped_refptr<AwPermissionRequest>)> callback_; | |
| 66 JavaObjectWeakGlobalRef java_ref_; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(AwPermissionRequest); | |
| 69 }; | |
| 70 | |
| 71 bool RegisterAwPermissionRequest(JNIEnv* env); | |
| 72 | |
| 73 } // namespace android_webivew | |
| 74 | |
| 75 #endif // ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H | |
| OLD | NEW |