Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1847)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadBroadcastReceiver.java

Issue 2444383002: Fixing a crash when clicking download notification while Chrome is killed (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerDelegate.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerDelegate.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698