diff options
author | qinmin@chromium.org <qinmin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-18 18:10:58 +0000 |
---|---|---|
committer | qinmin@chromium.org <qinmin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-18 18:10:58 +0000 |
commit | 912bf8a680aa1c0251e55a926168602f0e8b6b9d (patch) | |
tree | a656bae670c012aad7b46793627b66bdca3025c8 /ui | |
parent | 16dfd619d06e28297712f315409c34c89d2b46fe (diff) | |
download | chromium_src-912bf8a680aa1c0251e55a926168602f0e8b6b9d.zip chromium_src-912bf8a680aa1c0251e55a926168602f0e8b6b9d.tar.gz chromium_src-912bf8a680aa1c0251e55a926168602f0e8b6b9d.tar.bz2 |
Revert 235752 "Fix chrome upload with content uri"
> Fix chrome upload with content uri
>
> For android, the upload file dialog returns files with content uri scheme(content://).
> This CL makes it possible for upload to work with this new file type.
> It fixes both the form and fileapi based uploads.
>
> The CL follows the same code path used by regular file upload and the content url is encompassed by a FilePath object.
>
> R=jar@chromium.org, joth@chromium.org, kinuko@chromium.org, mmenke@chromium.org, tsepez@chromium.org
> TBR=yfriedman
> BUG=278640
>
> Review URL: https://codereview.chromium.org/46303005
TBR=qinmin@chromium.org
Review URL: https://codereview.chromium.org/65043023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235760 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java b/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java index 4e269b0..f495767 100644 --- a/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java +++ b/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java @@ -165,11 +165,27 @@ class SelectFileDialog implements WindowAndroid.IntentCallback{ return; } - if (results.getScheme() != null - && results.getScheme().equals(ContentResolver.SCHEME_CONTENT)) { - nativeOnFileSelected(mNativeSelectFileDialog, results.getData().toString()); - return; - } + Cursor cursor = null; + try { + // We get back a content:// URI from the system if the user picked a file from the + // gallery. The ContentView has functionality that will convert that content:// URI to + // a file path on disk that Chromium understands. + cursor = contentResolver.query(results.getData(), + new String[] { MediaStore.MediaColumns.DATA }, null, null, null); + if (cursor != null) { + if (cursor.getCount() == 1) { + cursor.moveToFirst(); + String path = cursor.getString(0); + if (path != null) { + // Not all providers support the MediaStore.DATA column. For example, + // Gallery3D (com.android.gallery3d.provider) does not support it for + // Picasa Web Album images. + nativeOnFileSelected(mNativeSelectFileDialog, path); + return; + } + } + } + } finally { if (cursor != null) { cursor.close(); } } onFileNotSelected(); window.showError(R.string.opening_file_error); |