ProfilePolicyConnectorFactory: Refactoring from Profile to BrowserContext.
[chromium-blink-merge.git] / android_webview / native / permission / aw_permission_request.h
blobb3a3589dd03eb7f565e45b68d4e7733576f5cde3
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.
5 #ifndef ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H
6 #define ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H
8 #include "base/android/jni_weak_ref.h"
9 #include "base/android/scoped_java_ref.h"
10 #include "base/memory/weak_ptr.h"
11 #include "url/gurl.h"
13 namespace android_webview {
15 class AwPermissionRequestDelegate;
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 ProtectedMediaId = 1 << 3,
32 // Take the ownership of |delegate|.
33 AwPermissionRequest(scoped_ptr<AwPermissionRequestDelegate> delegate);
34 virtual ~AwPermissionRequest();
36 base::WeakPtr<AwPermissionRequest> GetWeakPtr() {
37 return weak_factory_.GetWeakPtr();
40 // Create and return Java peer.
41 base::android::ScopedJavaLocalRef<jobject> CreateJavaPeer();
43 // Return the Java peer.
44 base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
46 // Invoked by Java peer when request is processed, |granted| indicates the
47 // request was granted or not.
48 void OnAccept(JNIEnv* env, jobject jcaller, jboolean granted);
50 // Return the origin which initiated the request.
51 const GURL& GetOrigin();
53 // Return the resources origin requested.
54 int64 GetResources();
56 private:
57 friend class TestAwPermissionRequest;
59 scoped_ptr<AwPermissionRequestDelegate> delegate_;
60 JavaObjectWeakGlobalRef java_ref_;
62 base::WeakPtrFactory<AwPermissionRequest> weak_factory_;
64 DISALLOW_COPY_AND_ASSIGN(AwPermissionRequest);
67 bool RegisterAwPermissionRequest(JNIEnv* env);
69 } // namespace android_webivew
71 #endif // ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H