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

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

Issue 1492703004: Pass method parameters as JavaParamRef in android_webview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: forgot to test compile unit tests before uploading, whoops Created 5 years 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
« no previous file with comments | « android_webview/native/permission/aw_permission_request.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "android_webview/native/permission/aw_permission_request.h" 5 #include "android_webview/native/permission/aw_permission_request.h"
6 6
7 #include "android_webview/native/permission/aw_permission_request_delegate.h" 7 #include "android_webview/native/permission/aw_permission_request_delegate.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "jni/AwPermissionRequest_jni.h" 9 #include "jni/AwPermissionRequest_jni.h"
10 10
(...skipping 28 matching lines...) Expand all
39 env, reinterpret_cast<jlong>(this), 39 env, reinterpret_cast<jlong>(this),
40 ConvertUTF8ToJavaString(env, GetOrigin().spec()).obj(), GetResources()); 40 ConvertUTF8ToJavaString(env, GetOrigin().spec()).obj(), GetResources());
41 java_ref_ = JavaObjectWeakGlobalRef(env, java_peer->obj()); 41 java_ref_ = JavaObjectWeakGlobalRef(env, java_peer->obj());
42 } 42 }
43 43
44 AwPermissionRequest::~AwPermissionRequest() { 44 AwPermissionRequest::~AwPermissionRequest() {
45 OnAcceptInternal(false); 45 OnAcceptInternal(false);
46 } 46 }
47 47
48 void AwPermissionRequest::OnAccept(JNIEnv* env, 48 void AwPermissionRequest::OnAccept(JNIEnv* env,
49 jobject jcaller, 49 const JavaParamRef<jobject>& jcaller,
50 jboolean accept) { 50 jboolean accept) {
51 OnAcceptInternal(accept); 51 OnAcceptInternal(accept);
52 } 52 }
53 53
54 void AwPermissionRequest::OnAcceptInternal(bool accept) { 54 void AwPermissionRequest::OnAcceptInternal(bool accept) {
55 if (!processed_) { 55 if (!processed_) {
56 delegate_->NotifyRequestResult(accept); 56 delegate_->NotifyRequestResult(accept);
57 processed_ = true; 57 processed_ = true;
58 } 58 }
59 } 59 }
60 60
61 void AwPermissionRequest::DeleteThis() { 61 void AwPermissionRequest::DeleteThis() {
62 ScopedJavaLocalRef<jobject> j_request = GetJavaObject(); 62 ScopedJavaLocalRef<jobject> j_request = GetJavaObject();
63 if (j_request.is_null()) 63 if (j_request.is_null())
64 return; 64 return;
65 Java_AwPermissionRequest_destroyNative(AttachCurrentThread(), 65 Java_AwPermissionRequest_destroyNative(AttachCurrentThread(),
66 j_request.obj()); 66 j_request.obj());
67 } 67 }
68 68
69 void AwPermissionRequest::Destroy(JNIEnv* env, jobject obj) { 69 void AwPermissionRequest::Destroy(JNIEnv* env,
70 const JavaParamRef<jobject>& obj) {
70 delete this; 71 delete this;
71 } 72 }
72 73
73 ScopedJavaLocalRef<jobject> AwPermissionRequest::GetJavaObject() { 74 ScopedJavaLocalRef<jobject> AwPermissionRequest::GetJavaObject() {
74 return java_ref_.get(AttachCurrentThread()); 75 return java_ref_.get(AttachCurrentThread());
75 } 76 }
76 77
77 const GURL& AwPermissionRequest::GetOrigin() { 78 const GURL& AwPermissionRequest::GetOrigin() {
78 return delegate_->GetOrigin(); 79 return delegate_->GetOrigin();
79 } 80 }
80 81
81 int64 AwPermissionRequest::GetResources() { 82 int64 AwPermissionRequest::GetResources() {
82 return delegate_->GetResources(); 83 return delegate_->GetResources();
83 } 84 }
84 85
85 void AwPermissionRequest::CancelAndDelete() { 86 void AwPermissionRequest::CancelAndDelete() {
86 processed_ = true; 87 processed_ = true;
87 DeleteThis(); 88 DeleteThis();
88 } 89 }
89 90
90 bool RegisterAwPermissionRequest(JNIEnv* env) { 91 bool RegisterAwPermissionRequest(JNIEnv* env) {
91 return RegisterNativesImpl(env); 92 return RegisterNativesImpl(env);
92 } 93 }
93 94
94 } // namespace android_webivew 95 } // namespace android_webivew
OLDNEW
« no previous file with comments | « android_webview/native/permission/aw_permission_request.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698