| 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.ComponentName; | 9 import android.content.ComponentName; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 long id = ids[0]; | 54 long id = ids[0]; |
| 55 DownloadManager manager = | 55 DownloadManager manager = |
| 56 (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERV
ICE); | 56 (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERV
ICE); |
| 57 Uri uri = manager.getUriForDownloadedFile(id); | 57 Uri uri = manager.getUriForDownloadedFile(id); |
| 58 if (uri == null) { | 58 if (uri == null) { |
| 59 // Open the downloads page | 59 // Open the downloads page |
| 60 DownloadManagerService.openDownloadsPage(context); | 60 DownloadManagerService.openDownloadsPage(context); |
| 61 } else { | 61 } else { |
| 62 String downloadFilename = IntentUtils.safeGetStringExtra( | 62 String downloadFilename = IntentUtils.safeGetStringExtra( |
| 63 intent, DownloadNotificationService.EXTRA_DOWNLOAD_FILE_PATH
); | 63 intent, DownloadNotificationService.EXTRA_DOWNLOAD_FILE_PATH
); |
| 64 boolean isSupportedMimeType = IntentUtils.safeGetBooleanExtra( |
| 65 intent, DownloadNotificationService.EXTRA_IS_SUPPORTED_MIME_
TYPE, false); |
| 64 Intent launchIntent = DownloadManagerService.getLaunchIntentFromDown
loadId( | 66 Intent launchIntent = DownloadManagerService.getLaunchIntentFromDown
loadId( |
| 65 context, downloadFilename, id); | 67 context, downloadFilename, id, isSupportedMimeType); |
| 66 if (!DownloadUtils.fireOpenIntentForDownload(context, launchIntent))
{ | 68 if (!DownloadUtils.fireOpenIntentForDownload(context, launchIntent))
{ |
| 67 DownloadManagerService.openDownloadsPage(context); | 69 DownloadManagerService.openDownloadsPage(context); |
| 68 } | 70 } |
| 69 } | 71 } |
| 70 } | 72 } |
| 71 | 73 |
| 72 /** | 74 /** |
| 73 * 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 |
| 74 * 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. |
| 75 * @param context Context of the receiver. | 77 * @param context Context of the receiver. |
| 76 * @param intent Intent retrieved from the notification. | 78 * @param intent Intent retrieved from the notification. |
| 77 */ | 79 */ |
| 78 private void performDownloadOperation(final Context context, Intent intent)
{ | 80 private void performDownloadOperation(final Context context, Intent intent)
{ |
| 79 if (DownloadNotificationService.isDownloadOperationIntent(intent)) { | 81 if (DownloadNotificationService.isDownloadOperationIntent(intent)) { |
| 80 Intent launchIntent = new Intent(intent); | 82 Intent launchIntent = new Intent(intent); |
| 81 launchIntent.setComponent(new ComponentName( | 83 launchIntent.setComponent(new ComponentName( |
| 82 context.getPackageName(), DownloadNotificationService.class.
getName())); | 84 context.getPackageName(), DownloadNotificationService.class.
getName())); |
| 83 context.startService(launchIntent); | 85 context.startService(launchIntent); |
| 84 } | 86 } |
| 85 } | 87 } |
| 86 } | 88 } |
| OLD | NEW |