OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef BASE_ANDROID_JNI_STRING_H_ | 5 #ifndef BASE_ANDROID_JNI_STRING_H_ |
6 #define BASE_ANDROID_JNI_STRING_H_ | 6 #define BASE_ANDROID_JNI_STRING_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
12 #include "base/string16.h" | |
13 #include "base/string_piece.h" | 12 #include "base/string_piece.h" |
14 | 13 |
15 namespace base { | 14 namespace base { |
16 namespace android { | 15 namespace android { |
17 | 16 |
18 // Convert a Java string to UTF8. Returns a std string. | 17 // Convert a Java string to UTF8. Returns a std string. |
19 std::string ConvertJavaStringToUTF8(JNIEnv* env, jstring str); | 18 std::string ConvertJavaStringToUTF8(JNIEnv* env, jstring str); |
20 std::string ConvertJavaStringToUTF8(const JavaRef<jstring>& str); | 19 std::string ConvertJavaStringToUTF8(const JavaRef<jstring>& str); |
21 | 20 |
22 // Convert a std string to Java string. | 21 // Convert a std string to Java string. |
23 ScopedJavaLocalRef<jstring> ConvertUTF8ToJavaString( | 22 ScopedJavaLocalRef<jstring> ConvertUTF8ToJavaString( |
24 JNIEnv* env, const base::StringPiece& str); | 23 JNIEnv* env, |
| 24 const base::StringPiece& str); |
25 | 25 |
26 // Convert a Java string to UTF16. Returns a string16. | 26 // Convert a Java string to UTF16. Returns a string16. |
27 string16 ConvertJavaStringToUTF16(JNIEnv* env, jstring str); | 27 string16 ConvertJavaStringToUTF16(JNIEnv* env, jstring str); |
28 string16 ConvertJavaStringToUTF16(const JavaRef<jstring>& str); | 28 string16 ConvertJavaStringToUTF16(const JavaRef<jstring>& str); |
29 | 29 |
30 // Convert a string16 to a Java string. | 30 // Convert a string16 to a Java string. |
31 ScopedJavaLocalRef<jstring> ConvertUTF16ToJavaString( | 31 ScopedJavaLocalRef<jstring> ConvertUTF16ToJavaString( |
32 JNIEnv* env, const string16& str); | 32 JNIEnv* env, |
| 33 const base::StringPiece16& str); |
33 | 34 |
34 } // namespace android | 35 } // namespace android |
35 } // namespace base | 36 } // namespace base |
36 | 37 |
37 #endif // BASE_ANDROID_JNI_STRING_H_ | 38 #endif // BASE_ANDROID_JNI_STRING_H_ |
OLD | NEW |