diff options
author | Kristian Monsen <kristianm@google.com> | 2010-11-01 15:49:45 +0000 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-11-04 12:05:58 +0000 |
commit | badf945656d9c584b7ac7cf88b9c55fe6c393ce6 (patch) | |
tree | d20387aa28e569b7ff221d2bdcedc9ec031f6752 /core/java/android/webkit/BrowserFrame.java | |
parent | dfe7fd1776f8472b303f57d4715dcc160e735dd6 (diff) | |
download | frameworks_base-badf945656d9c584b7ac7cf88b9c55fe6c393ce6.zip frameworks_base-badf945656d9c584b7ac7cf88b9c55fe6c393ce6.tar.gz frameworks_base-badf945656d9c584b7ac7cf88b9c55fe6c393ce6.tar.bz2 |
Move more of android file handling in Java
Moving some of the code (finding which kind of file it is and
deleting parts of the url) to Java from C++.
Is needed by the following change in external/webkit:
https://android-git.corp.google.com/g/#change,77383
Change-Id: Ifc6008501eb580a0aaa5e307732b6f49ebd19ac4
Diffstat (limited to 'core/java/android/webkit/BrowserFrame.java')
-rw-r--r-- | core/java/android/webkit/BrowserFrame.java | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java index 2087664..cce7914 100644 --- a/core/java/android/webkit/BrowserFrame.java +++ b/core/java/android/webkit/BrowserFrame.java @@ -674,13 +674,16 @@ class BrowserFrame extends Handler { * @param url The url to load. * @return An InputStream to the android resource */ - private InputStream inputStreamForAndroidResource(String url, int type) { - final int RESOURCE = 1; - final int ASSET = 2; - final int CONTENT = 3; - - if (type == RESOURCE) { - // file:///android_res + private InputStream inputStreamForAndroidResource(String url) { + // This list needs to be kept in sync with the list in + // external/webkit/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp + final String ANDROID_ASSET = "file:///android_asset/"; + final String ANDROID_RESOURCE = "file:///android_res/"; + final String ANDROID_CONTENT = "content:"; + + // file:///android_res + if (url.startsWith(ANDROID_RESOURCE)) { + url = url.replaceFirst(ANDROID_RESOURCE, ""); if (url == null || url.length() == 0) { Log.e(LOGTAG, "url has length 0 " + url); return null; @@ -717,15 +720,18 @@ class BrowserFrame extends Handler { return null; } - } else if (type == ASSET) { - // file:///android_asset + // file:///android_asset + } else if (url.startsWith(ANDROID_ASSET)) { + url = url.replaceFirst(ANDROID_ASSET, ""); try { AssetManager assets = mContext.getAssets(); return assets.open(url, AssetManager.ACCESS_STREAMING); } catch (IOException e) { return null; } - } else if (type == CONTENT) { + + // content:// + } else if (url.startsWith(ANDROID_CONTENT)) { try { // Strip off mimetype, for compatibility with ContentLoader.java // If we don't do this, we can fail to load Gmail attachments, |