OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "android_webview/native/intercepted_request_data.h" |
| 6 |
| 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" |
| 9 #include "jni/InterceptedRequestData_jni.h" |
| 10 |
| 11 using std::string; |
| 12 using base::android::ScopedJavaLocalRef; |
| 13 |
| 14 InterceptedRequestData::InterceptedRequestData( |
| 15 JNIEnv* env, base::android::JavaRef<jobject> obj) { |
| 16 java_object_.Reset(env, obj.obj()); |
| 17 } |
| 18 |
| 19 InterceptedRequestData::~InterceptedRequestData() { |
| 20 } |
| 21 |
| 22 ScopedJavaLocalRef<jobject> |
| 23 InterceptedRequestData::GetInputStream(JNIEnv* env) const { |
| 24 return Java_InterceptedRequestData_getData(env, java_object_.obj()); |
| 25 } |
| 26 |
| 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()) |
| 32 return false; |
| 33 *mime_type = ConvertJavaStringToUTF8(jstring_mime_type); |
| 34 return true; |
| 35 } |
| 36 |
| 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()) |
| 42 return false; |
| 43 *charset = ConvertJavaStringToUTF8(jstring_charset); |
| 44 return true; |
| 45 } |
| 46 |
| 47 bool RegisterInterceptedRequestData(JNIEnv* env) { |
| 48 if (g_InterceptedRequestData_clazz) |
| 49 return true; |
| 50 if (!base::android::HasClass(env, kInterceptedRequestDataClassPath)) { |
| 51 DLOG(ERROR) << "Unable to find class InterceptedRequestData!"; |
| 52 return false; |
| 53 } |
| 54 return RegisterNativesImpl(env); |
| 55 } |
OLD | NEW |