| 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/memory/weak_ptr.h" | |
| 11 #include "url/gurl.h" | |
| 12 | |
| 13 namespace android_webview { | |
| 14 | |
| 15 class AwPermissionRequestDelegate; | |
| 16 | |
| 17 // This class wraps a permission request, it works with PermissionRequestHandler | |
| 18 // and its' Java peer to represent the request to AwContentsClient. | |
| 19 // The specific permission request should implement the | |
| 20 // AwPermissionRequestDelegate interface, See MediaPermissionRequest. | |
| 21 class AwPermissionRequest { | |
| 22 public: | |
| 23 // The definition must synced with Android's | |
| 24 // android.webkit.PermissionRequest. | |
| 25 enum Resource { | |
| 26 Geolocation = 1 << 0, | |
| 27 VideoCapture = 1 << 1, | |
| 28 AudioCapture = 1 << 2 | |
| 29 }; | |
| 30 | |
| 31 // Take the ownership of |delegate|. | |
| 32 AwPermissionRequest(scoped_ptr<AwPermissionRequestDelegate> delegate); | |
| 33 virtual ~AwPermissionRequest(); | |
| 34 | |
| 35 base::WeakPtr<AwPermissionRequest> GetWeakPtr() { | |
| 36 return weak_factory_.GetWeakPtr(); | |
| 37 } | |
| 38 | |
| 39 // Create and return Java peer. | |
| 40 base::android::ScopedJavaLocalRef<jobject> CreateJavaPeer(); | |
| 41 | |
| 42 // Return the Java peer. | |
| 43 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); | |
| 44 | |
| 45 // Invoked by Java peer when request is processed, |granted| indicates the | |
| 46 // request was granted or not. | |
| 47 void OnAccept(JNIEnv* env, jobject jcaller, jboolean granted); | |
| 48 | |
| 49 // Return the origin which initiated the request. | |
| 50 const GURL& GetOrigin(); | |
| 51 | |
| 52 // Return the resources origin requested. | |
| 53 int64 GetResources(); | |
| 54 | |
| 55 private: | |
| 56 friend class TestAwPermissionRequest; | |
| 57 | |
| 58 scoped_ptr<AwPermissionRequestDelegate> delegate_; | |
| 59 JavaObjectWeakGlobalRef java_ref_; | |
| 60 | |
| 61 base::WeakPtrFactory<AwPermissionRequest> weak_factory_; | |
| 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 | |
| OLD | NEW |