Index: ui/android/java/src/org/chromium/ui/SelectFileDialog.java |
diff --git a/ui/android/java/src/org/chromium/ui/SelectFileDialog.java b/ui/android/java/src/org/chromium/ui/SelectFileDialog.java |
index 91533b52cf0f1a9a8a3b4bac233cd60cbbf86966..cc5ae1848b6683b46e2c791efc34997558165ae3 100644 |
--- a/ui/android/java/src/org/chromium/ui/SelectFileDialog.java |
+++ b/ui/android/java/src/org/chromium/ui/SelectFileDialog.java |
@@ -144,43 +144,54 @@ class SelectFileDialog implements WindowAndroid.IntentCallback{ |
onFileNotSelected(); |
return; |
} |
- boolean success = false; |
+ |
if (results == null) { |
// If we have a successful return but no data, then assume this is the camera returning |
// the photo that we requested. |
nativeOnFileSelected(mNativeSelectFileDialog, mCameraOutputUri.getPath()); |
- success = true; |
// Broadcast to the media scanner that there's a new photo on the device so it will |
// show up right away in the gallery (rather than waiting until the next time the media |
// scanner runs). |
window.sendBroadcast(new Intent( |
Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, mCameraOutputUri)); |
- } else { |
+ return; |
+ } |
+ |
+ if ("file".equals(results.getData().getScheme())) { |
aurimas (slooooooooow)
2013/11/05 20:52:07
Should pull "file" out as a constant.
Miguel Garcia
2013/11/06 18:07:51
Really? In this case it just seems an overkill. I
Ted C
2013/11/08 17:00:13
I hit this same issue anytime I want to check agai
Miguel Garcia
2013/11/09 07:09:08
Ok, will leave it as is then.
On 2013/11/08 17:00
|
+ nativeOnFileSelected(mNativeSelectFileDialog, |
+ results.getData().getSchemeSpecificPart()); |
+ 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 c = contentResolver.query(results.getData(), |
+ cursor = contentResolver.query(results.getData(), |
new String[] { MediaStore.MediaColumns.DATA }, null, null, null); |
- if (c != null) { |
- if (c.getCount() == 1) { |
- c.moveToFirst(); |
- String path = c.getString(0); |
+ 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); |
- success = true; |
+ return; |
} |
} |
- c.close(); |
+ } |
+ } finally { |
+ if (cursor != null) { |
+ cursor.close(); |
Ted C
2013/11/08 17:00:13
this could all fit on one line
Miguel Garcia
2013/11/09 07:09:08
Done.
|
} |
} |
- if (!success) { |
- onFileNotSelected(); |
- window.showError(R.string.opening_file_error); |
- } |
+ |
+ onFileNotSelected(); |
+ window.showError(R.string.opening_file_error); |
} |
private void onFileNotSelected() { |