summaryrefslogtreecommitdiffstats
path: root/WebKit/android/jni/WebCoreJni.cpp
diff options
context:
space:
mode:
authorIain Merrick <husky@google.com>2010-10-21 17:56:42 +0100
committerIain Merrick <husky@google.com>2010-10-21 17:59:16 +0100
commit5b7723d28caa3e8a979bcd40a9d634b410c23ec2 (patch)
treea9efeb8cd9dd1af1982380e9ba5f8d6e7388db2a /WebKit/android/jni/WebCoreJni.cpp
parent583f3b2e7b569ec9f88e9c481db1eb86a8c0224b (diff)
downloadexternal_webkit-5b7723d28caa3e8a979bcd40a9d634b410c23ec2.zip
external_webkit-5b7723d28caa3e8a979bcd40a9d634b410c23ec2.tar.gz
external_webkit-5b7723d28caa3e8a979bcd40a9d634b410c23ec2.tar.bz2
Move jstringToStdString into WebCoreJni.h
Also tweaked the implementation slightly to match jstringToString16, which is more robust. Change-Id: I614576615a6f429ea1632c395d5bc4e068c32cfb
Diffstat (limited to 'WebKit/android/jni/WebCoreJni.cpp')
-rw-r--r--WebKit/android/jni/WebCoreJni.cpp14
1 files changed, 14 insertions, 0 deletions
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;
+}
+
}