| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 nativeLaunchDuplicateDownloadInfoBar(ChromeDownloadDelegate.this, mTab,
info, | 257 nativeLaunchDuplicateDownloadInfoBar(ChromeDownloadDelegate.this, mTab,
info, |
| 258 new File(fullDirPath, info.getFileName()).toString(), mTab.isInc
ognito()); | 258 new File(fullDirPath, info.getFileName()).toString(), mTab.isInc
ognito()); |
| 259 } | 259 } |
| 260 | 260 |
| 261 /** | 261 /** |
| 262 * Enqueue a request to download a file using Android DownloadManager. | 262 * Enqueue a request to download a file using Android DownloadManager. |
| 263 * | 263 * |
| 264 * @param info Download information about the download. | 264 * @param info Download information about the download. |
| 265 */ | 265 */ |
| 266 private void enqueueDownloadManagerRequest(final DownloadInfo info) { | 266 private void enqueueDownloadManagerRequest(final DownloadInfo info) { |
| 267 DownloadManagerService.getDownloadManagerService( | 267 DownloadManagerService.getDownloadManagerService().enqueueDownloadManage
rRequest( |
| 268 mContext.getApplicationContext()).enqueueDownloadManagerRequest( | 268 new DownloadItem(true, info), true); |
| 269 new DownloadItem(true, info), true); | |
| 270 closeBlankTab(); | 269 closeBlankTab(); |
| 271 } | 270 } |
| 272 | 271 |
| 273 /** | 272 /** |
| 274 * Check the external storage and notify user on error. | 273 * Check the external storage and notify user on error. |
| 275 * | 274 * |
| 276 * @param fullDirPath The dir path to download a file. Normally this is exte
rnal storage. | 275 * @param fullDirPath The dir path to download a file. Normally this is exte
rnal storage. |
| 277 * @param externalStorageStatus The status of the external storage. | 276 * @param externalStorageStatus The status of the external storage. |
| 278 * @return Whether external storage is ok for downloading. | 277 * @return Whether external storage is ok for downloading. |
| 279 */ | 278 */ |
| (...skipping 20 matching lines...) Expand all Loading... |
| 300 return true; | 299 return true; |
| 301 } | 300 } |
| 302 | 301 |
| 303 /** | 302 /** |
| 304 * Alerts user of download failure. | 303 * Alerts user of download failure. |
| 305 * | 304 * |
| 306 * @param fileName Name of the download file. | 305 * @param fileName Name of the download file. |
| 307 * @param reason Reason of failure defined in {@link DownloadManager} | 306 * @param reason Reason of failure defined in {@link DownloadManager} |
| 308 */ | 307 */ |
| 309 private void alertDownloadFailure(String fileName, int reason) { | 308 private void alertDownloadFailure(String fileName, int reason) { |
| 310 DownloadManagerService.getDownloadManagerService( | 309 DownloadManagerService.getDownloadManagerService().onDownloadFailed(file
Name, reason); |
| 311 mContext.getApplicationContext()).onDownloadFailed(fileName, rea
son); | |
| 312 } | 310 } |
| 313 | 311 |
| 314 /** | 312 /** |
| 315 * Enqueue a request to download a file using Android DownloadManager. | 313 * Enqueue a request to download a file using Android DownloadManager. |
| 316 * @param url Url to download. | 314 * @param url Url to download. |
| 317 * @param userAgent User agent to use. | 315 * @param userAgent User agent to use. |
| 318 * @param contentDisposition Content disposition of the request. | 316 * @param contentDisposition Content disposition of the request. |
| 319 * @param mimeType MIME type. | 317 * @param mimeType MIME type. |
| 320 * @param cookie Cookie to use. | 318 * @param cookie Cookie to use. |
| 321 * @param referrer Referrer to use. | 319 * @param referrer Referrer to use. |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 return mContext; | 486 return mContext; |
| 489 } | 487 } |
| 490 | 488 |
| 491 private native void nativeInit(WebContents webContents); | 489 private native void nativeInit(WebContents webContents); |
| 492 private static native String nativeGetDownloadWarningText(String filename); | 490 private static native String nativeGetDownloadWarningText(String filename); |
| 493 private static native void nativeLaunchDuplicateDownloadInfoBar(ChromeDownlo
adDelegate delegate, | 491 private static native void nativeLaunchDuplicateDownloadInfoBar(ChromeDownlo
adDelegate delegate, |
| 494 Tab tab, DownloadInfo downloadInfo, String filePath, boolean isIncog
nito); | 492 Tab tab, DownloadInfo downloadInfo, String filePath, boolean isIncog
nito); |
| 495 private static native void nativeLaunchPermissionUpdateInfoBar( | 493 private static native void nativeLaunchPermissionUpdateInfoBar( |
| 496 Tab tab, String permission, long callbackId); | 494 Tab tab, String permission, long callbackId); |
| 497 } | 495 } |
| OLD | NEW |