OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013 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/content_uri_utils.h" | |
6 | |
7 #include "base/android/jni_android.h" | |
8 #include "base/android/jni_string.h" | |
9 #include "base/platform_file.h" | |
10 #include "jni/ContentUriUtils_jni.h" | |
11 | |
12 using base::android::ConvertUTF8ToJavaString; | |
13 | |
14 namespace base { | |
15 | |
16 bool RegisterContentUriUtils(JNIEnv* env) { | |
17 return RegisterNativesImpl(env); | |
18 } | |
19 | |
20 bool ContentUriExists(const FilePath& content_uri) { | |
21 JNIEnv* env = base::android::AttachCurrentThread(); | |
22 ScopedJavaLocalRef<jstring> j_uri = | |
23 ConvertUTF8ToJavaString(env, content_uri.value()); | |
24 return Java_ContentUriUtils_contentUriExists( | |
25 env, base::android::GetApplicationContext(), j_uri.obj()); | |
26 } | |
27 | |
28 int OpenContentUriForRead(const FilePath& content_uri) { | |
29 JNIEnv* env = base::android::AttachCurrentThread(); | |
30 ScopedJavaLocalRef<jstring> j_uri = | |
31 ConvertUTF8ToJavaString(env, content_uri.value()); | |
32 jint fd = Java_ContentUriUtils_openContentUriForRead( | |
33 env, base::android::GetApplicationContext(), j_uri.obj()); | |
34 if (fd < 0) | |
35 return base::kInvalidPlatformFileValue; | |
36 return fd; | |
37 } | |
38 | |
39 } // namespace base | |
OLD | NEW |