| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.download; | 5 package org.chromium.chrome.browser.download; |
| 6 | 6 |
| 7 import android.Manifest.permission; | 7 import android.Manifest.permission; |
| 8 import android.app.Activity; | 8 import android.app.Activity; |
| 9 import android.app.DownloadManager; | 9 import android.app.DownloadManager; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 * @param mimeType MIME type provided by the server. | 422 * @param mimeType MIME type provided by the server. |
| 423 * @param url URL of the data being loaded. | 423 * @param url URL of the data being loaded. |
| 424 * @param filename file name obtained from content disposition header | 424 * @param filename file name obtained from content disposition header |
| 425 * @return The MIME type that should be used for this data. | 425 * @return The MIME type that should be used for this data. |
| 426 */ | 426 */ |
| 427 static String remapGenericMimeType(String mimeType, String url, String filen
ame) { | 427 static String remapGenericMimeType(String mimeType, String url, String filen
ame) { |
| 428 // If we have one of "generic" MIME types, try to deduce | 428 // If we have one of "generic" MIME types, try to deduce |
| 429 // the right MIME type from the file extension (if any): | 429 // the right MIME type from the file extension (if any): |
| 430 if (mimeType == null || mimeType.isEmpty() || "text/plain".equals(mimeTy
pe) | 430 if (mimeType == null || mimeType.isEmpty() || "text/plain".equals(mimeTy
pe) |
| 431 || "application/octet-stream".equals(mimeType) | 431 || "application/octet-stream".equals(mimeType) |
| 432 || "binary/octet-stream".equals(mimeType) |
| 432 || "octet/stream".equals(mimeType) | 433 || "octet/stream".equals(mimeType) |
| 433 || "application/force-download".equals(mimeType) | 434 || "application/force-download".equals(mimeType) |
| 434 || "application/unknown".equals(mimeType)) { | 435 || "application/unknown".equals(mimeType)) { |
| 435 | 436 |
| 436 String extension = getFileExtension(url, filename); | 437 String extension = getFileExtension(url, filename); |
| 437 String newMimeType = MimeTypeMap.getSingleton().getMimeTypeFromExten
sion(extension); | 438 String newMimeType = MimeTypeMap.getSingleton().getMimeTypeFromExten
sion(extension); |
| 438 if (newMimeType != null) { | 439 if (newMimeType != null) { |
| 439 mimeType = newMimeType; | 440 mimeType = newMimeType; |
| 440 } else if (extension.equals("dm")) { | 441 } else if (extension.equals("dm")) { |
| 441 mimeType = OMADownloadHandler.OMA_DRM_MESSAGE_MIME; | 442 mimeType = OMADownloadHandler.OMA_DRM_MESSAGE_MIME; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 private static native String nativeGetDownloadWarningText(String filename); | 563 private static native String nativeGetDownloadWarningText(String filename); |
| 563 private static native boolean nativeIsDownloadDangerous(String filename); | 564 private static native boolean nativeIsDownloadDangerous(String filename); |
| 564 private static native void nativeDangerousDownloadValidated( | 565 private static native void nativeDangerousDownloadValidated( |
| 565 Object tab, String downloadGuid, boolean accept); | 566 Object tab, String downloadGuid, boolean accept); |
| 566 private static native void nativeLaunchDownloadOverwriteInfoBar(ChromeDownlo
adDelegate delegate, | 567 private static native void nativeLaunchDownloadOverwriteInfoBar(ChromeDownlo
adDelegate delegate, |
| 567 Tab tab, DownloadInfo downloadInfo, String fileName, String dirName, | 568 Tab tab, DownloadInfo downloadInfo, String fileName, String dirName, |
| 568 String dirFullPath); | 569 String dirFullPath); |
| 569 private static native void nativeLaunchPermissionUpdateInfoBar( | 570 private static native void nativeLaunchPermissionUpdateInfoBar( |
| 570 Tab tab, String permission, long callbackId); | 571 Tab tab, String permission, long callbackId); |
| 571 } | 572 } |
| OLD | NEW |