| 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 81a0d2091056657c7e3251d4852ab637ec24076a..bbd07864f91464109ec50d928d2280d672de697b 100644
|
| --- a/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java
|
| +++ b/ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java
|
| @@ -9,7 +9,6 @@ import android.app.Activity;
|
| import android.content.ClipData;
|
| import android.content.ContentResolver;
|
| import android.content.Intent;
|
| -import android.database.Cursor;
|
| import android.net.Uri;
|
| import android.os.Build;
|
| import android.os.Environment;
|
| @@ -17,6 +16,7 @@ import android.provider.MediaStore;
|
| import android.text.TextUtils;
|
|
|
| import org.chromium.base.CalledByNative;
|
| +import org.chromium.base.ContentUriUtils;
|
| import org.chromium.base.JNINamespace;
|
| import org.chromium.ui.R;
|
|
|
| @@ -139,31 +139,6 @@ class SelectFileDialog implements WindowAndroid.IntentCallback{
|
| }
|
|
|
| /**
|
| - * @return the display name of the @code uri if present in the database
|
| - * or an empty string otherwise.
|
| - */
|
| - private String resolveFileName(Uri uri, ContentResolver contentResolver) {
|
| - if (contentResolver == null || uri == null) return "";
|
| - Cursor cursor = null;
|
| - try {
|
| - cursor = contentResolver.query(uri, null, null, null, null);
|
| -
|
| - if (cursor != null && cursor.getCount() >= 1) {
|
| - cursor.moveToFirst();
|
| - int index = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
|
| - if (index > -1) return cursor.getString(index);
|
| - }
|
| - } catch (NullPointerException e) {
|
| - // Some android models don't handle the provider call correctly.
|
| - // see crbug.com/345393
|
| - return "";
|
| - } finally {
|
| - if (cursor != null) cursor.close();
|
| - }
|
| - return "";
|
| - }
|
| -
|
| - /**
|
| * Callback method to handle the intent results and pass on the path to the native
|
| * SelectFileDialog.
|
| * @param window The window that has access to the application activity.
|
| @@ -214,7 +189,7 @@ class SelectFileDialog implements WindowAndroid.IntentCallback{
|
| final Uri uri = clipData.getItemAt(i).getUri();
|
|
|
| filePathArray[i] = uri.toString();
|
| - displayNameArray[i] = resolveFileName(uri, contentResolver);
|
| + displayNameArray[i] = ContentUriUtils.getDisplayName(uri, contentResolver);
|
| }
|
|
|
| nativeOnMultipleFilesSelected(mNativeSelectFileDialog,
|
| @@ -231,8 +206,8 @@ class SelectFileDialog implements WindowAndroid.IntentCallback{
|
| if (ContentResolver.SCHEME_CONTENT.equals(results.getScheme())) {
|
| nativeOnFileSelected(mNativeSelectFileDialog,
|
| results.getData().toString(),
|
| - resolveFileName(results.getData(),
|
| - contentResolver));
|
| + ContentUriUtils.getDisplayName(results.getData(),
|
| + contentResolver));
|
| return;
|
| }
|
|
|
|
|