michaelbai@google.com | 686190b | 2011-08-03 01:11:16 +0900 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "base/android/path_utils.h" |
| 6 | |
michaelbai@google.com | 686190b | 2011-08-03 01:11:16 +0900 | [diff] [blame] | 7 | #include "base/android/jni_android.h" |
| 8 | #include "base/android/jni_string.h" |
steveblock@google.com | b6cdd98 | 2011-08-11 20:23:52 +0900 | [diff] [blame^] | 9 | #include "base/android/scoped_java_reference.h" |
michaelbai@google.com | 686190b | 2011-08-03 01:11:16 +0900 | [diff] [blame] | 10 | |
| 11 | #include "jni/path_utils_jni.h" |
| 12 | |
| 13 | namespace base { |
| 14 | namespace android { |
| 15 | |
| 16 | std::string GetDataDirectory() { |
| 17 | JNIEnv* env = AttachCurrentThread(); |
steveblock@google.com | b6cdd98 | 2011-08-11 20:23:52 +0900 | [diff] [blame^] | 18 | ScopedJavaReference<jstring> path(env, Java_PathUtils_getDataDirectory( |
| 19 | env, base::android::GetApplicationContext())); |
| 20 | return base::android::ConvertJavaStringToUTF8(env, path.obj()); |
michaelbai@google.com | 686190b | 2011-08-03 01:11:16 +0900 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | std::string GetCacheDirectory() { |
| 24 | JNIEnv* env = AttachCurrentThread(); |
steveblock@google.com | b6cdd98 | 2011-08-11 20:23:52 +0900 | [diff] [blame^] | 25 | ScopedJavaReference<jstring> path(env, Java_PathUtils_getCacheDirectory( |
| 26 | env, base::android::GetApplicationContext())); |
| 27 | return base::android::ConvertJavaStringToUTF8(env, path.obj()); |
michaelbai@google.com | 686190b | 2011-08-03 01:11:16 +0900 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | bool RegisterPathUtils(JNIEnv* env) { |
| 31 | return RegisterNativesImpl(env); |
| 32 | } |
| 33 | |
| 34 | } // namespace android |
| 35 | } // namespace base |