Merge "Frameworks changes to enable File Reader and blob.slice APIs."
This commit is contained in:
@@ -51,7 +51,7 @@ final class JWebCoreJavaBridge extends Handler {
|
||||
/* package */
|
||||
static final int REFRESH_PLUGINS = 100;
|
||||
|
||||
private HashMap<String, String> mContentUriToFileNameMap;
|
||||
private HashMap<String, String> mContentUriToFilePathMap;
|
||||
|
||||
/**
|
||||
* Construct a new JWebCoreJavaBridge to interface with
|
||||
@@ -273,9 +273,9 @@ final class JWebCoreJavaBridge extends Handler {
|
||||
}
|
||||
|
||||
// Called on the WebCore thread through JNI.
|
||||
private String resolveFileNameForContentUri(String uri) {
|
||||
if (mContentUriToFileNameMap != null) {
|
||||
String fileName = mContentUriToFileNameMap.get(uri);
|
||||
private String resolveFilePathForContentUri(String uri) {
|
||||
if (mContentUriToFilePathMap != null) {
|
||||
String fileName = mContentUriToFilePathMap.get(uri);
|
||||
if (fileName != null) {
|
||||
return fileName;
|
||||
}
|
||||
@@ -287,11 +287,11 @@ final class JWebCoreJavaBridge extends Handler {
|
||||
return jUri.getLastPathSegment();
|
||||
}
|
||||
|
||||
public void storeFileNameForContentUri(String fileName, String contentUri) {
|
||||
if (mContentUriToFileNameMap == null) {
|
||||
mContentUriToFileNameMap = new HashMap<String, String>();
|
||||
public void storeFilePathForContentUri(String path, String contentUri) {
|
||||
if (mContentUriToFilePathMap == null) {
|
||||
mContentUriToFilePathMap = new HashMap<String, String>();
|
||||
}
|
||||
mContentUriToFileNameMap.put(contentUri, fileName);
|
||||
mContentUriToFilePathMap.put(contentUri, path);
|
||||
}
|
||||
|
||||
private native void nativeConstructor();
|
||||
|
||||
@@ -32,7 +32,8 @@ import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Process;
|
||||
import android.provider.OpenableColumns;
|
||||
import android.provider.MediaStore;
|
||||
import android.provider.MediaStore.Images.Media;
|
||||
import android.util.Log;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.KeyEvent;
|
||||
@@ -283,24 +284,26 @@ final class WebViewCore {
|
||||
private String openFileChooser(String acceptType) {
|
||||
Uri uri = mCallbackProxy.openFileChooser(acceptType);
|
||||
if (uri != null) {
|
||||
String fileName = "";
|
||||
String filePath = "";
|
||||
// Note - querying for MediaStore.Images.Media.DATA
|
||||
// seems to work for all content URIs, not just images
|
||||
Cursor cursor = mContext.getContentResolver().query(
|
||||
uri,
|
||||
new String[] { OpenableColumns.DISPLAY_NAME },
|
||||
new String[] { MediaStore.Images.Media.DATA },
|
||||
null, null, null);
|
||||
if (cursor != null) {
|
||||
try {
|
||||
if (cursor.moveToNext()) {
|
||||
fileName = cursor.getString(0);
|
||||
filePath = cursor.getString(0);
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
} else {
|
||||
fileName = uri.getLastPathSegment();
|
||||
filePath = uri.getLastPathSegment();
|
||||
}
|
||||
String uriString = uri.toString();
|
||||
BrowserFrame.sJavaBridge.storeFileNameForContentUri(fileName, uriString);
|
||||
BrowserFrame.sJavaBridge.storeFilePathForContentUri(filePath, uriString);
|
||||
return uriString;
|
||||
}
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user