[email protected] | 61c86c6 | 2011-08-02 16:11:16 | [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 | |
| 7 | #include "base/android/auto_jobject.h" |
| 8 | #include "base/android/jni_android.h" |
| 9 | #include "base/android/jni_string.h" |
| 10 | |
| 11 | #include "jni/path_utils_jni.h" |
| 12 | |
| 13 | namespace base { |
| 14 | namespace android { |
| 15 | |
| 16 | std::string GetDataDirectory() { |
| 17 | JNIEnv* env = AttachCurrentThread(); |
| 18 | AutoJObject path = AutoJObject::FromLocalRef( |
| 19 | env, Java_PathUtils_getDataDirectory( |
| 20 | env, base::android::GetApplicationContext())); |
| 21 | return base::android::ConvertJavaStringToUTF8( |
| 22 | env, static_cast<jstring>(path.obj())); |
| 23 | } |
| 24 | |
| 25 | std::string GetCacheDirectory() { |
| 26 | JNIEnv* env = AttachCurrentThread(); |
| 27 | AutoJObject path = AutoJObject::FromLocalRef( |
| 28 | env, Java_PathUtils_getCacheDirectory( |
| 29 | env, base::android::GetApplicationContext())); |
| 30 | return base::android::ConvertJavaStringToUTF8( |
| 31 | env, static_cast<jstring>(path.obj())); |
| 32 | } |
| 33 | |
| 34 | bool RegisterPathUtils(JNIEnv* env) { |
| 35 | return RegisterNativesImpl(env); |
| 36 | } |
| 37 | |
| 38 | } // namespace android |
| 39 | } // namespace base |