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

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

Issue 1852513003: Convert //android_webview to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git is hard Created 4 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H 5 #ifndef ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H
6 #define ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H 6 #define ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/android/jni_weak_ref.h" 10 #include "base/android/jni_weak_ref.h"
(...skipping 18 matching lines...) Expand all
29 Geolocation = 1 << 0, 29 Geolocation = 1 << 0,
30 VideoCapture = 1 << 1, 30 VideoCapture = 1 << 1,
31 AudioCapture = 1 << 2, 31 AudioCapture = 1 << 2,
32 ProtectedMediaId = 1 << 3, 32 ProtectedMediaId = 1 << 3,
33 MIDISysex = 1 << 4, 33 MIDISysex = 1 << 4,
34 }; 34 };
35 35
36 // Take the ownership of |delegate|. Returns the native pointer in 36 // Take the ownership of |delegate|. Returns the native pointer in
37 // |weak_ptr|, which is owned by the returned java peer. 37 // |weak_ptr|, which is owned by the returned java peer.
38 static base::android::ScopedJavaLocalRef<jobject> Create( 38 static base::android::ScopedJavaLocalRef<jobject> Create(
39 scoped_ptr<AwPermissionRequestDelegate> delegate, 39 std::unique_ptr<AwPermissionRequestDelegate> delegate,
40 base::WeakPtr<AwPermissionRequest>* weak_ptr); 40 base::WeakPtr<AwPermissionRequest>* weak_ptr);
41 41
42 // Return the Java peer. Must be null-checked. 42 // Return the Java peer. Must be null-checked.
43 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); 43 base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
44 44
45 // Invoked by Java peer when request is processed, |granted| indicates the 45 // Invoked by Java peer when request is processed, |granted| indicates the
46 // request was granted or not. 46 // request was granted or not.
47 void OnAccept(JNIEnv* env, 47 void OnAccept(JNIEnv* env,
48 const base::android::JavaParamRef<jobject>& jcaller, 48 const base::android::JavaParamRef<jobject>& jcaller,
49 jboolean granted); 49 jboolean granted);
50 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); 50 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
51 51
52 // Return the origin which initiated the request. 52 // Return the origin which initiated the request.
53 const GURL& GetOrigin(); 53 const GURL& GetOrigin();
54 54
55 // Return the resources origin requested. 55 // Return the resources origin requested.
56 int64_t GetResources(); 56 int64_t GetResources();
57 57
58 // Cancel this request. Guarantee that 58 // Cancel this request. Guarantee that
59 // AwPermissionRequestDelegate::NotifyRequestResult will not be called after 59 // AwPermissionRequestDelegate::NotifyRequestResult will not be called after
60 // this call. This also deletes this object, so weak pointers are invalidated 60 // this call. This also deletes this object, so weak pointers are invalidated
61 // and raw pointers become dangling pointers. 61 // and raw pointers become dangling pointers.
62 void CancelAndDelete(); 62 void CancelAndDelete();
63 63
64 private: 64 private:
65 friend class TestPermissionRequestHandlerClient; 65 friend class TestPermissionRequestHandlerClient;
66 66
67 AwPermissionRequest(scoped_ptr<AwPermissionRequestDelegate> delegate, 67 AwPermissionRequest(std::unique_ptr<AwPermissionRequestDelegate> delegate,
68 base::android::ScopedJavaLocalRef<jobject>* java_peer); 68 base::android::ScopedJavaLocalRef<jobject>* java_peer);
69 ~AwPermissionRequest(); 69 ~AwPermissionRequest();
70 70
71 void OnAcceptInternal(bool accept); 71 void OnAcceptInternal(bool accept);
72 void DeleteThis(); 72 void DeleteThis();
73 73
74 scoped_ptr<AwPermissionRequestDelegate> delegate_; 74 std::unique_ptr<AwPermissionRequestDelegate> delegate_;
75 JavaObjectWeakGlobalRef java_ref_; 75 JavaObjectWeakGlobalRef java_ref_;
76 76
77 bool processed_; 77 bool processed_;
78 base::WeakPtrFactory<AwPermissionRequest> weak_factory_; 78 base::WeakPtrFactory<AwPermissionRequest> weak_factory_;
79 79
80 DISALLOW_COPY_AND_ASSIGN(AwPermissionRequest); 80 DISALLOW_COPY_AND_ASSIGN(AwPermissionRequest);
81 }; 81 };
82 82
83 bool RegisterAwPermissionRequest(JNIEnv* env); 83 bool RegisterAwPermissionRequest(JNIEnv* env);
84 84
85 } // namespace android_webivew 85 } // namespace android_webivew
86 86
87 #endif // ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H 87 #endif // ANDROID_WEBVIEW_NATIVE_PERMISSION_AW_PERMISSION_REQUEST_H
OLDNEW
« no previous file with comments | « android_webview/native/net_init_native_callback.cc ('k') | android_webview/native/permission/aw_permission_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698