Index: base/android/java/src/org/chromium/base/ContentUriUtils.java |
diff --git a/base/android/java/src/org/chromium/base/ContentUriUtils.java b/base/android/java/src/org/chromium/base/ContentUriUtils.java |
index b806b47d4e877a898c04cb683617f01c75c04662..3eb187cc6f9f93960ce08994183f79cd27b442b0 100644 |
--- a/base/android/java/src/org/chromium/base/ContentUriUtils.java |
+++ b/base/android/java/src/org/chromium/base/ContentUriUtils.java |
@@ -11,15 +11,46 @@ import android.net.Uri; |
import android.os.ParcelFileDescriptor; |
import android.util.Log; |
+import java.io.File; |
+ |
/** |
* This class provides methods to access content URI schemes. |
*/ |
-public abstract class ContentUriUtils { |
+public class ContentUriUtils { |
private static final String TAG = "ContentUriUtils"; |
+ private static final ContentUriUtils sInstance = new ContentUriUtils(); |
+ private FileProviderUtil mFileProviderUtil = null; |
+ |
+ /** |
+ * Class for providing functionalities to translate a file into content URI. |
Yaron
2014/08/25 19:13:05
Provides functionality to translate a file into a
qinmin
2014/08/25 20:27:19
Done.
|
+ */ |
+ public interface FileProviderUtil { |
+ /** |
+ * Generate a content uri from the given file. |
+ * @param context Application context. |
+ * @param file The file to be translated. |
+ */ |
+ public Uri getContentUriFromFile(Context context, File file); |
+ } |
// Prevent instantiation. |
private ContentUriUtils() {} |
+ public static ContentUriUtils getInstance() { |
Yaron
2014/08/25 19:13:05
How is this related to FileProviderUtil? Why do we
qinmin
2014/08/25 20:27:19
Since FileProviderUtil implementation exits in chr
|
+ return sInstance; |
+ } |
+ |
+ public void setFileProviderUtil(FileProviderUtil util) { |
+ mFileProviderUtil = util; |
+ } |
+ |
+ public Uri getContentUriFromFile(Context context, File file) { |
+ if (mFileProviderUtil != null) { |
Yaron
2014/08/25 19:13:05
Which threads do you anticipate being involved? If
qinmin
2014/08/25 20:27:19
This should be on the UI thread.
On 2014/08/25 19
Yaron
2014/08/25 23:37:33
Then please add ThreadUtils.assertOnUiThread
qinmin
2014/08/26 00:24:03
Done.
|
+ return mFileProviderUtil.getContentUriFromFile(context, file); |
+ } |
+ return null; |
+ } |
+ |
/** |
* Opens the content URI for reading, and returns the file descriptor to |
* the caller. The caller is responsible for closing the file desciptor. |