Index: base/android/content_uri_utils.cc |
diff --git a/base/android/content_uri_utils.cc b/base/android/content_uri_utils.cc |
index 0e0c0ea6bb127840862a9e0689aa5a89be4a5950..0482feef891db38f3f6807fb9f9fba9126fcb936 100644 |
--- a/base/android/content_uri_utils.cc |
+++ b/base/android/content_uri_utils.cc |
@@ -35,4 +35,14 @@ File OpenContentUriForRead(const FilePath& content_uri) { |
return File(fd); |
} |
+std::string GetContentUriMimeType(const FilePath& content_uri) { |
+ JNIEnv* env = base::android::AttachCurrentThread(); |
+ ScopedJavaLocalRef<jstring> j_uri = |
+ ConvertUTF8ToJavaString(env, content_uri.value()); |
+ ScopedJavaLocalRef<jstring> j_mime = |
+ Java_ContentUriUtils_getMimeType( |
+ env, base::android::GetApplicationContext(), j_uri.obj()); |
+ return base::android::ConvertJavaStringToUTF8(env, j_mime.obj()); |
+} |
+ |
} // namespace base |