Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Unified Diff: trunk/src/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java

Issue 65043023: Revert 235752 "Fix chrome upload with content uri" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/net/test/run_all_unittests.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java
===================================================================
--- trunk/src/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java (revision 235758)
+++ trunk/src/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java (working copy)
@@ -165,11 +165,27 @@
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);
« no previous file with comments | « trunk/src/net/test/run_all_unittests.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698