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