1 // Copyright (c) 2012 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 #include "android_webview/native/intercepted_request_data.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h"
9 #include "jni/InterceptedRequestData_jni.h"
12 using base::android::ScopedJavaLocalRef
;
14 InterceptedRequestData::InterceptedRequestData(
15 JNIEnv
* env
, base::android::JavaRef
<jobject
> obj
) {
16 java_object_
.Reset(env
, obj
.obj());
19 InterceptedRequestData::~InterceptedRequestData() {
22 ScopedJavaLocalRef
<jobject
>
23 InterceptedRequestData::GetInputStream(JNIEnv
* env
) const {
24 return Java_InterceptedRequestData_getData(env
, java_object_
.obj());
27 bool InterceptedRequestData::GetMimeType(JNIEnv
* env
,
28 string
* mime_type
) const {
29 ScopedJavaLocalRef
<jstring
> jstring_mime_type
=
30 Java_InterceptedRequestData_getMimeType(env
, java_object_
.obj());
31 if (jstring_mime_type
.is_null())
33 *mime_type
= ConvertJavaStringToUTF8(jstring_mime_type
);
37 bool InterceptedRequestData::GetCharset(
38 JNIEnv
* env
, string
* charset
) const {
39 ScopedJavaLocalRef
<jstring
> jstring_charset
=
40 Java_InterceptedRequestData_getCharset(env
, java_object_
.obj());
41 if (jstring_charset
.is_null())
43 *charset
= ConvertJavaStringToUTF8(jstring_charset
);
47 bool RegisterInterceptedRequestData(JNIEnv
* env
) {
48 if (g_InterceptedRequestData_clazz
)
50 if (!base::android::HasClass(env
, kInterceptedRequestDataClassPath
)) {
51 DLOG(ERROR
) << "Unable to find class InterceptedRequestData!";
54 return RegisterNativesImpl(env
);