| 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.ActivityNotFoundException; | 8 import android.content.ActivityNotFoundException; |
| 9 import android.content.BroadcastReceiver; | 9 import android.content.BroadcastReceiver; |
| 10 import android.content.ComponentName; | 10 import android.content.ComponentName; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 @Override | 23 @Override |
| 24 public void onReceive(final Context context, Intent intent) { | 24 public void onReceive(final Context context, Intent intent) { |
| 25 String action = intent.getAction(); | 25 String action = intent.getAction(); |
| 26 switch (action) { | 26 switch (action) { |
| 27 case DownloadManager.ACTION_NOTIFICATION_CLICKED: | 27 case DownloadManager.ACTION_NOTIFICATION_CLICKED: |
| 28 openDownload(context, intent); | 28 openDownload(context, intent); |
| 29 break; | 29 break; |
| 30 case DownloadNotificationService.ACTION_DOWNLOAD_RESUME: | 30 case DownloadNotificationService.ACTION_DOWNLOAD_RESUME: |
| 31 case DownloadNotificationService.ACTION_DOWNLOAD_CANCEL: | 31 case DownloadNotificationService.ACTION_DOWNLOAD_CANCEL: |
| 32 case DownloadNotificationService.ACTION_DOWNLOAD_PAUSE: | 32 case DownloadNotificationService.ACTION_DOWNLOAD_PAUSE: |
| 33 case DownloadNotificationService.ACTION_DOWNLOAD_OPEN: |
| 33 performDownloadOperation(context, intent); | 34 performDownloadOperation(context, intent); |
| 34 break; | 35 break; |
| 35 default: | 36 default: |
| 36 break; | 37 break; |
| 37 } | 38 } |
| 38 } | 39 } |
| 39 | 40 |
| 40 /** | 41 /** |
| 41 * Called to open a given download item that is downloaded by the android Do
wnloadManager. | 42 * Called to open a given download item that is downloaded by the android Do
wnloadManager. |
| 42 * @param context Context of the receiver. | 43 * @param context Context of the receiver. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 * @param intent Intent retrieved from the notification. | 76 * @param intent Intent retrieved from the notification. |
| 76 */ | 77 */ |
| 77 private void performDownloadOperation(final Context context, Intent intent)
{ | 78 private void performDownloadOperation(final Context context, Intent intent)
{ |
| 78 if (DownloadNotificationService.isDownloadOperationIntent(intent)) { | 79 if (DownloadNotificationService.isDownloadOperationIntent(intent)) { |
| 79 Intent launchIntent = new Intent(intent); | 80 Intent launchIntent = new Intent(intent); |
| 80 launchIntent.setComponent(new ComponentName( | 81 launchIntent.setComponent(new ComponentName( |
| 81 context.getPackageName(), DownloadNotificationService.class.
getName())); | 82 context.getPackageName(), DownloadNotificationService.class.
getName())); |
| 82 context.startService(launchIntent); | 83 context.startService(launchIntent); |
| 83 } | 84 } |
| 84 } | 85 } |
| 85 } | 86 } |
| OLD | NEW |