diff options
author | qinmin <qinmin@chromium.org> | 2014-08-27 16:01:21 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-27 23:05:47 +0000 |
commit | 22b41158f1be60572f4eaa1da8676c36f69cb394 (patch) | |
tree | 192388f709b003a1d859429e68180b9643d8ebae /base/android/java | |
parent | 39a6a1b1e570f54aaa957095400b6d40aae0e0f1 (diff) | |
download | chromium_src-22b41158f1be60572f4eaa1da8676c36f69cb394.zip chromium_src-22b41158f1be60572f4eaa1da8676c36f69cb394.tar.gz chromium_src-22b41158f1be60572f4eaa1da8676c36f69cb394.tar.bz2 |
Use content URI to upload photos taken by camera
Currently chrome creates a file path when uploading a photo taken through camera
However, this doesn't always work.
Instead, we should use content URI. See more details in the crbug.
BUG=405593
Review URL: https://codereview.chromium.org/489053003
Cr-Commit-Position: refs/heads/master@{#292257}
Diffstat (limited to 'base/android/java')
-rw-r--r-- | base/android/java/src/org/chromium/base/ContentUriUtils.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/base/android/java/src/org/chromium/base/ContentUriUtils.java b/base/android/java/src/org/chromium/base/ContentUriUtils.java index b806b47..70c27ed 100644 --- a/base/android/java/src/org/chromium/base/ContentUriUtils.java +++ b/base/android/java/src/org/chromium/base/ContentUriUtils.java @@ -11,15 +11,43 @@ 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 { private static final String TAG = "ContentUriUtils"; + private static FileProviderUtil sFileProviderUtil; + + /** + * Provides functionality to translate a file into a content URI for use + * with a content provider. + */ + 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 void setFileProviderUtil(FileProviderUtil util) { + sFileProviderUtil = util; + } + + public static Uri getContentUriFromFile(Context context, File file) { + ThreadUtils.assertOnUiThread(); + if (sFileProviderUtil != null) { + return sFileProviderUtil.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. |