Chromium Code Reviews| Index: android_webview/native/permission/aw_permission_request.h |
| diff --git a/android_webview/native/permission/aw_permission_request.h b/android_webview/native/permission/aw_permission_request.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a7e7d9c655c2e836a7983c53f055ba81f8ff0a5a |
| --- /dev/null |
| +++ b/android_webview/native/permission/aw_permission_request.h |
| @@ -0,0 +1,75 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H |
| +#define ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H |
| + |
| +#include "base/android/jni_helper.h" |
| +#include "base/android/scoped_java_ref.h" |
| +#include "base/callback.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "url/gurl.h" |
| + |
| +namespace android_webview { |
| + |
| +class AwPermissionRequestDelegate; |
| + |
| +// This class wraps a permission request, it works with PermissionRequestHandler |
| +// and its' Java peer to represent the request to AwContentsClient. |
| +// The specific permission request should implement the |
| +// AwPermissionRequestDelegate interface, See MediaPermissionRequest. |
| +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!
|
| + public: |
| + // The definition must synced with Android's |
| + // 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
|
| + enum Resource { |
| + GeoLocation = 1 << 0, |
|
benm (inactive)
2014/04/16 14:51:10
nit s/L/l/
michaelbai
2014/04/22 20:53:51
Done.
|
| + VideoCapture = 1 << 1, |
| + AudioCapture = 1 << 2 |
| + }; |
| + |
| + // Take the ownership of |delegate|. |
| + 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.
|
| + |
| + // Create and return Java peer, |callback| is invoked after request result |
| + // is returned from Java peer and notified to delegate. |
| + base::android::ScopedJavaLocalRef<jobject> CreateJavaPeer( |
| + base::Callback<void(scoped_refptr<AwPermissionRequest>)> callback); |
| + |
| + // Return the Java peer. |
| + base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); |
| + |
| + // Invoked by Java peer when request is processed, |granted| indicates the |
| + // request was granted or not. |
| + void OnAccept(JNIEnv* env, jobject jcaller, jboolean granted); |
| + |
| + // Called by Java peer to get the origin which initiated the request. |
| + base::android::ScopedJavaLocalRef<jstring> GetOrigin(JNIEnv* env, |
| + jobject jcaller); |
| + |
| + // Called by Java peer to get the resoures requested by origin. |
| + jlong GetResources(JNIEnv* env, jobject jcaller); |
| + |
| + // Return the origin which initiated the request. |
| + const GURL& GetOrigin(); |
| + |
| + // 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.
|
| + int64 GetResources(); |
| + |
| + private: |
| + friend class base::RefCounted<AwPermissionRequest>; |
| + virtual ~AwPermissionRequest(); |
| + |
| + scoped_ptr<AwPermissionRequestDelegate> delegate_; |
| + base::Callback<void(scoped_refptr<AwPermissionRequest>)> callback_; |
| + JavaObjectWeakGlobalRef java_ref_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AwPermissionRequest); |
| +}; |
| + |
| +bool RegisterAwPermissionRequest(JNIEnv* env); |
| + |
| +} // namespace android_webivew |
| + |
| +#endif // ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H |