Loading core/java/android/webkit/LoadListener.java +24 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -70,7 +71,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; Loading Loading @@ -311,7 +317,17 @@ class LoadListener extends Handler implements EventHandler { if (mMimeType.equals("text/plain") || mMimeType.equals("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; } Loading Loading @@ -918,7 +934,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; Loading Loading @@ -963,7 +979,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 Loading Loading @@ -1393,7 +1409,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; } Loading @@ -1403,14 +1419,14 @@ 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 (DebugFlags.LOAD_LISTENER) { Log.v(LOGTAG, "guessMimeTypeFromExtension: mURL = " + mUrl); Log.v(LOGTAG, "guessMimeTypeFromExtension: url = " + url); } return MimeTypeMap.getSingleton().getMimeTypeFromExtension( MimeTypeMap.getFileExtensionFromUrl(mUrl)); MimeTypeMap.getFileExtensionFromUrl(url)); } /** Loading core/java/android/webkit/MimeTypeMap.java +1 −0 Original line number Diff line number Diff line Loading @@ -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); Loading core/java/android/webkit/URLUtil.java +1 −1 Original line number Diff line number Diff line Loading @@ -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()) { Loading Loading
core/java/android/webkit/LoadListener.java +24 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -70,7 +71,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; Loading Loading @@ -311,7 +317,17 @@ class LoadListener extends Handler implements EventHandler { if (mMimeType.equals("text/plain") || mMimeType.equals("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; } Loading Loading @@ -918,7 +934,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; Loading Loading @@ -963,7 +979,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 Loading Loading @@ -1393,7 +1409,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; } Loading @@ -1403,14 +1419,14 @@ 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 (DebugFlags.LOAD_LISTENER) { Log.v(LOGTAG, "guessMimeTypeFromExtension: mURL = " + mUrl); Log.v(LOGTAG, "guessMimeTypeFromExtension: url = " + url); } return MimeTypeMap.getSingleton().getMimeTypeFromExtension( MimeTypeMap.getFileExtensionFromUrl(mUrl)); MimeTypeMap.getFileExtensionFromUrl(url)); } /** Loading
core/java/android/webkit/MimeTypeMap.java +1 −0 Original line number Diff line number Diff line Loading @@ -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); Loading
core/java/android/webkit/URLUtil.java +1 −1 Original line number Diff line number Diff line Loading @@ -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()) { Loading