[email protected] | 6fa1e7ef | 2012-03-14 11:24:04 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 61c86c6 | 2011-08-02 16:11:16 | [diff] [blame] | 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 | |||||
[email protected] | 61c86c6 | 2011-08-02 16:11:16 | [diff] [blame] | 7 | #include "base/android/jni_android.h" |
8 | #include "base/android/jni_string.h" | ||||
[email protected] | f98d7b9 | 2011-09-09 10:17:35 | [diff] [blame] | 9 | #include "base/android/scoped_java_ref.h" |
[email protected] | 61c86c6 | 2011-08-02 16:11:16 | [diff] [blame] | 10 | |
[email protected] | e46f6615 | 2012-07-19 20:02:55 | [diff] [blame^] | 11 | #include "jni/PathUtils_jni.h" |
[email protected] | 61c86c6 | 2011-08-02 16:11:16 | [diff] [blame] | 12 | |
13 | namespace base { | ||||
14 | namespace android { | ||||
15 | |||||
16 | std::string GetDataDirectory() { | ||||
17 | JNIEnv* env = AttachCurrentThread(); | ||||
[email protected] | 6fa1e7ef | 2012-03-14 11:24:04 | [diff] [blame] | 18 | ScopedJavaLocalRef<jstring> path = |
19 | Java_PathUtils_getDataDirectory(env, GetApplicationContext()); | ||||
20 | return ConvertJavaStringToUTF8(path); | ||||
[email protected] | 61c86c6 | 2011-08-02 16:11:16 | [diff] [blame] | 21 | } |
22 | |||||
23 | std::string GetCacheDirectory() { | ||||
24 | JNIEnv* env = AttachCurrentThread(); | ||||
[email protected] | 6fa1e7ef | 2012-03-14 11:24:04 | [diff] [blame] | 25 | ScopedJavaLocalRef<jstring> path = |
26 | Java_PathUtils_getCacheDirectory(env, GetApplicationContext()); | ||||
27 | return ConvertJavaStringToUTF8(path); | ||||
28 | } | ||||
29 | |||||
30 | std::string GetDownloadsDirectory() { | ||||
31 | JNIEnv* env = AttachCurrentThread(); | ||||
32 | ScopedJavaLocalRef<jstring> path = | ||||
33 | Java_PathUtils_getDownloadsDirectory(env, GetApplicationContext()); | ||||
34 | return ConvertJavaStringToUTF8(path); | ||||
[email protected] | 61c86c6 | 2011-08-02 16:11:16 | [diff] [blame] | 35 | } |
36 | |||||
[email protected] | 672898b | 2012-07-02 20:04:04 | [diff] [blame] | 37 | std::string GetNativeLibraryDirectory() { |
38 | JNIEnv* env = AttachCurrentThread(); | ||||
39 | ScopedJavaLocalRef<jstring> path = | ||||
40 | Java_PathUtils_getNativeLibraryDirectory(env, GetApplicationContext()); | ||||
41 | return ConvertJavaStringToUTF8(path); | ||||
42 | } | ||||
43 | |||||
[email protected] | 61c86c6 | 2011-08-02 16:11:16 | [diff] [blame] | 44 | bool RegisterPathUtils(JNIEnv* env) { |
45 | return RegisterNativesImpl(env); | ||||
46 | } | ||||
47 | |||||
48 | } // namespace android | ||||
49 | } // namespace base |