diff options
-rw-r--r-- | WebKit/android/jni/WebCoreFrameBridge.cpp | 9 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreJni.cpp | 14 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreJni.h | 2 |
3 files changed, 16 insertions, 9 deletions
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 010c6df..6b3f009 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -1826,15 +1826,6 @@ static void OrientationChanged(JNIEnv *env, jobject obj, int orientation) pFrame->sendOrientationChangeEvent(orientation); } -static std::string jstringToStdString(JNIEnv* env, jstring jstr) { - jsize size = env->GetStringUTFLength(jstr); - jboolean isCopy; - const char* cstr = env->GetStringUTFChars(jstr, &isCopy); - std::string result(cstr, cstr + size); - env->ReleaseStringUTFChars(jstr, cstr); - return result; -} - #if USE(CHROME_NETWORK_STACK) static void AuthenticationProceed(JNIEnv *env, jobject obj, int handle, jstring jUsername, jstring jPassword) diff --git a/WebKit/android/jni/WebCoreJni.cpp b/WebKit/android/jni/WebCoreJni.cpp index 5bcb2e1..1b9619b 100644 --- a/WebKit/android/jni/WebCoreJni.cpp +++ b/WebKit/android/jni/WebCoreJni.cpp @@ -87,4 +87,18 @@ string16 jstringToString16(JNIEnv* env, jstring jstr) } #endif +std::string jstringToStdString(JNIEnv* env, jstring jstr) +{ + if (!jstr || !env) + return std::string(); + + const char* s = env->GetStringUTFChars(jstr, 0); + if (!s) + return std::string(); + std::string str(s); + env->ReleaseStringUTFChars(jstr, s); + checkException(env); + return str; +} + } diff --git a/WebKit/android/jni/WebCoreJni.h b/WebKit/android/jni/WebCoreJni.h index 8bfca7e..d4a9821 100644 --- a/WebKit/android/jni/WebCoreJni.h +++ b/WebKit/android/jni/WebCoreJni.h @@ -77,6 +77,8 @@ WTF::String jstringToWtfString(JNIEnv* env, jstring str); string16 jstringToString16(JNIEnv* env, jstring jstr); #endif +std::string jstringToStdString(JNIEnv* env, jstring jstr); + } #endif |