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

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

Issue 466983004: [Android] Fail gracefully when accessing exported=false providers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java
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 180b49334ec212d924bd1645c6ec7885242903db..070443d4d3afedb375ca23d2e9c35e34ad4d15e7 100644
--- a/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java
+++ b/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java
@@ -33,7 +33,7 @@ import java.util.List;
* a set of accepted file types. The path of the selected file is passed to the native dialog.
*/
@JNINamespace("ui")
-class SelectFileDialog implements WindowAndroid.IntentCallback{
+class SelectFileDialog implements WindowAndroid.IntentCallback {
private static final String TAG = "SelectFileDialog";
private static final String IMAGE_TYPE = "image/";
private static final String VIDEO_TYPE = "video/";
@@ -296,16 +296,32 @@ class SelectFileDialog implements WindowAndroid.IntentCallback{
protected String[] doInBackground(Uri...uris) {
mFilePaths = new String[uris.length];
String[] displayNames = new String[uris.length];
- for (int i = 0; i < uris.length; i++) {
- mFilePaths[i] = uris[i].toString();
- displayNames[i] = ContentUriUtils.getDisplayName(
- uris[i], mContentResolver, MediaStore.MediaColumns.DISPLAY_NAME);
+ try {
+ for (int i = 0; i < uris.length; i++) {
+ mFilePaths[i] = uris[i].toString();
+ displayNames[i] = ContentUriUtils.getDisplayName(
+ uris[i], mContentResolver, MediaStore.MediaColumns.DISPLAY_NAME);
+ }
+ } catch (SecurityException e) {
+ // Some third party apps will present themselves as being able
+ // to handle the ACTION_GET_CONTENT intent but then declare themselves
+ // as exported=false (or more often omit the exported keyword in
+ // the manifest which defaults to false after JB).
+ // In those cases trying to access the contents raises a security exception
+ // which we should not crash on. See crbug.com/382367 for details.
+ Log.w(TAG, "Unable to extract results from the content provider");
+ return null;
}
+
return displayNames;
}
@Override
protected void onPostExecute(String[] result) {
+ if (result == null) {
+ onFileNotSelected();
+ return;
+ }
if (mIsMultiple) {
nativeOnMultipleFilesSelected(mNativeSelectFileDialog, mFilePaths, result);
} else {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698