| 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.app.DownloadManager; | 7 import android.app.DownloadManager; |
| 8 import android.content.BroadcastReceiver; | 8 import android.content.BroadcastReceiver; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| 11 import android.net.Uri; | 11 import android.net.Uri; |
| 12 | 12 |
| 13 import org.chromium.chrome.browser.util.IntentUtils; | 13 import org.chromium.chrome.browser.util.IntentUtils; |
| 14 import org.chromium.components.offline_items_collection.ContentId; |
| 14 | 15 |
| 15 /** | 16 /** |
| 16 * This {@link BroadcastReceiver} handles clicks to download notifications and t
heir action buttons. | 17 * This {@link BroadcastReceiver} handles clicks to download notifications and t
heir action buttons. |
| 17 * Clicking on an in-progress or failed download will open the download manager.
Clicking on | 18 * Clicking on an in-progress or failed download will open the download manager.
Clicking on |
| 18 * a complete, successful download will open the file. Clicking on the resume bu
tton of a paused | 19 * a complete, successful download will open the file. Clicking on the resume bu
tton of a paused |
| 19 * download will relaunch the browser process and try to resume the download fro
m where it is | 20 * download will relaunch the browser process and try to resume the download fro
m where it is |
| 20 * stopped. | 21 * stopped. |
| 21 */ | 22 */ |
| 22 public class DownloadBroadcastReceiver extends BroadcastReceiver { | 23 public class DownloadBroadcastReceiver extends BroadcastReceiver { |
| 23 @Override | 24 @Override |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 DownloadManagerService.openDownloadsPage(context); | 59 DownloadManagerService.openDownloadsPage(context); |
| 59 return; | 60 return; |
| 60 } | 61 } |
| 61 | 62 |
| 62 String downloadFilename = IntentUtils.safeGetStringExtra( | 63 String downloadFilename = IntentUtils.safeGetStringExtra( |
| 63 intent, DownloadNotificationService.EXTRA_DOWNLOAD_FILE_PATH); | 64 intent, DownloadNotificationService.EXTRA_DOWNLOAD_FILE_PATH); |
| 64 boolean isSupportedMimeType = IntentUtils.safeGetBooleanExtra( | 65 boolean isSupportedMimeType = IntentUtils.safeGetBooleanExtra( |
| 65 intent, DownloadNotificationService.EXTRA_IS_SUPPORTED_MIME_TYPE
, false); | 66 intent, DownloadNotificationService.EXTRA_IS_SUPPORTED_MIME_TYPE
, false); |
| 66 boolean isOffTheRecord = IntentUtils.safeGetBooleanExtra( | 67 boolean isOffTheRecord = IntentUtils.safeGetBooleanExtra( |
| 67 intent, DownloadNotificationService.EXTRA_IS_OFF_THE_RECORD, fal
se); | 68 intent, DownloadNotificationService.EXTRA_IS_OFF_THE_RECORD, fal
se); |
| 68 String downloadGuid = IntentUtils.safeGetStringExtra( | 69 ContentId contentId = DownloadNotificationService.getContentIdFromIntent
(intent); |
| 69 intent, DownloadNotificationService.EXTRA_DOWNLOAD_GUID); | |
| 70 DownloadManagerService.openDownloadedContent( | 70 DownloadManagerService.openDownloadedContent( |
| 71 context, downloadFilename, isSupportedMimeType, isOffTheRecord,
downloadGuid, id); | 71 context, downloadFilename, isSupportedMimeType, isOffTheRecord,
contentId.id, id); |
| 72 } | 72 } |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * Called to perform a download operation. This will call the DownloadNotifi
cationService | 75 * Called to perform a download operation. This will call the DownloadNotifi
cationService |
| 76 * to start the browser process asynchronously, and resume or cancel the dow
nload afterwards. | 76 * to start the browser process asynchronously, and resume or cancel the dow
nload afterwards. |
| 77 * @param context Context of the receiver. | 77 * @param context Context of the receiver. |
| 78 * @param intent Intent retrieved from the notification. | 78 * @param intent Intent retrieved from the notification. |
| 79 */ | 79 */ |
| 80 private void performDownloadOperation(final Context context, Intent intent)
{ | 80 private void performDownloadOperation(final Context context, Intent intent)
{ |
| 81 if (DownloadNotificationService.isDownloadOperationIntent(intent)) { | 81 if (DownloadNotificationService.isDownloadOperationIntent(intent)) { |
| 82 DownloadNotificationService.startDownloadNotificationService(context
, intent); | 82 DownloadNotificationService.startDownloadNotificationService(context
, intent); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 } | 85 } |
| OLD | NEW |