diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-15 09:47:05 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-15 09:47:05 -0700 |
commit | 21d769da89ac619ee1b8277a3b97b1b3eab3b218 (patch) | |
tree | 5df344e52247aae946c2f13749d67aeb4ef75303 /core/java/android/webkit | |
parent | 83fa3565896ed19846f6498c00de3cc9a29b1a57 (diff) | |
parent | f8ddc988dc2d9be2f75e0b0d9aa234dad7c8258d (diff) | |
download | frameworks_base-21d769da89ac619ee1b8277a3b97b1b3eab3b218.zip frameworks_base-21d769da89ac619ee1b8277a3b97b1b3eab3b218.tar.gz frameworks_base-21d769da89ac619ee1b8277a3b97b1b3eab3b218.tar.bz2 |
Merge change 6926 into donut
* changes:
Fix #1976384. Add p12 to the MimeTypeMap. When downloading p12 in the WebView, send it to the certTool.
Diffstat (limited to 'core/java/android/webkit')
-rw-r--r-- | core/java/android/webkit/LoadListener.java | 32 | ||||
-rw-r--r-- | core/java/android/webkit/MimeTypeMap.java | 1 | ||||
-rw-r--r-- | core/java/android/webkit/URLUtil.java | 2 |
3 files changed, 26 insertions, 9 deletions
diff --git a/core/java/android/webkit/LoadListener.java b/core/java/android/webkit/LoadListener.java index 39360cd..474fa82 100644 --- a/core/java/android/webkit/LoadListener.java +++ b/core/java/android/webkit/LoadListener.java @@ -38,6 +38,7 @@ import com.android.internal.R; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Vector; import java.util.regex.Pattern; @@ -72,7 +73,12 @@ class LoadListener extends Handler implements EventHandler { private static final int HTTP_NOT_FOUND = 404; private static final int HTTP_PROXY_AUTH = 407; - private static final String CERT_MIMETYPE = "application/x-x509-ca-cert"; + private static HashSet<String> sCertificateMimeTypeMap; + static { + sCertificateMimeTypeMap = new HashSet<String>(); + sCertificateMimeTypeMap.add("application/x-x509-ca-cert"); + sCertificateMimeTypeMap.add("application/x-pkcs12"); + } private static int sNativeLoaderCount; @@ -318,7 +324,17 @@ class LoadListener extends Handler implements EventHandler { if (mMimeType.equalsIgnoreCase("text/plain") || mMimeType.equalsIgnoreCase("application/octet-stream")) { - String newMimeType = guessMimeTypeFromExtension(); + // for attachment, use the filename in the Content-Disposition + // to guess the mimetype + String contentDisposition = headers.getContentDisposition(); + String url = null; + if (contentDisposition != null) { + url = URLUtil.parseContentDisposition(contentDisposition); + } + if (url == null) { + url = mUrl; + } + String newMimeType = guessMimeTypeFromExtension(url); if (newMimeType != null) { mMimeType = newMimeType; } @@ -936,7 +952,7 @@ class LoadListener extends Handler implements EventHandler { // This commits the headers without checking the response status code. private void commitHeaders() { - if (mIsMainPageLoader && CERT_MIMETYPE.equals(mMimeType)) { + if (mIsMainPageLoader && sCertificateMimeTypeMap.contains(mMimeType)) { // In the case of downloading certificate, we will save it to the // Keystore in commitLoad. Do not call webcore. return; @@ -982,7 +998,7 @@ class LoadListener extends Handler implements EventHandler { private void commitLoad() { if (mCancelled) return; - if (mIsMainPageLoader && CERT_MIMETYPE.equals(mMimeType)) { + if (mIsMainPageLoader && sCertificateMimeTypeMap.contains(mMimeType)) { // In the case of downloading certificate, we will save it to the // Keystore and stop the current loading so that it will not // generate a new history page @@ -1409,7 +1425,7 @@ class LoadListener extends Handler implements EventHandler { // of frames. If no content-type was specified, it is fine to // default to text/html. mMimeType = "text/html"; - String newMimeType = guessMimeTypeFromExtension(); + String newMimeType = guessMimeTypeFromExtension(mUrl); if (newMimeType != null) { mMimeType = newMimeType; } @@ -1419,15 +1435,15 @@ class LoadListener extends Handler implements EventHandler { /** * guess MIME type based on the file extension. */ - private String guessMimeTypeFromExtension() { + private String guessMimeTypeFromExtension(String url) { // PENDING: need to normalize url if (WebView.LOGV_ENABLED) { - Log.v(LOGTAG, "guessMimeTypeFromExtension: mURL = " + mUrl); + Log.v(LOGTAG, "guessMimeTypeFromExtension: url = " + url); } String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension( - MimeTypeMap.getFileExtensionFromUrl(mUrl)); + MimeTypeMap.getFileExtensionFromUrl(url)); if (mimeType != null) { // XXX: Until the servers send us either correct xhtml or diff --git a/core/java/android/webkit/MimeTypeMap.java b/core/java/android/webkit/MimeTypeMap.java index 85c2275..fdbc692 100644 --- a/core/java/android/webkit/MimeTypeMap.java +++ b/core/java/android/webkit/MimeTypeMap.java @@ -335,6 +335,7 @@ public /* package */ class MimeTypeMap { sMimeTypeMap.loadEntry("application/x-object", "o", false); sMimeTypeMap.loadEntry("application/x-oz-application", "oza", false); + sMimeTypeMap.loadEntry("application/x-pkcs12", "p12", false); sMimeTypeMap.loadEntry("application/x-pkcs7-certreqresp", "p7r", false); sMimeTypeMap.loadEntry("application/x-pkcs7-crl", "crl", false); diff --git a/core/java/android/webkit/URLUtil.java b/core/java/android/webkit/URLUtil.java index d6ac3e9..9889fe9 100644 --- a/core/java/android/webkit/URLUtil.java +++ b/core/java/android/webkit/URLUtil.java @@ -348,7 +348,7 @@ public final class URLUtil { * This header provides a filename for content that is going to be * downloaded to the file system. We only support the attachment type. */ - private static String parseContentDisposition(String contentDisposition) { + static String parseContentDisposition(String contentDisposition) { try { Matcher m = CONTENT_DISPOSITION_PATTERN.matcher(contentDisposition); if (m.find()) { |