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.Context; | 10 import android.content.Context; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 import java.util.concurrent.ConcurrentHashMap; | 43 import java.util.concurrent.ConcurrentHashMap; |
44 import java.util.concurrent.atomic.AtomicBoolean; | 44 import java.util.concurrent.atomic.AtomicBoolean; |
45 | 45 |
46 /** | 46 /** |
47 * Chrome implementation of the DownloadNotificationService interface. This clas
s is responsible for | 47 * Chrome implementation of the DownloadNotificationService interface. This clas
s is responsible for |
48 * keeping track of which downloads are in progress. It generates updates for pr
ogress of downloads | 48 * keeping track of which downloads are in progress. It generates updates for pr
ogress of downloads |
49 * and handles cleaning up of interrupted progress notifications. | 49 * and handles cleaning up of interrupted progress notifications. |
50 */ | 50 */ |
51 public class DownloadManagerService extends BroadcastReceiver implements | 51 public class DownloadManagerService extends BroadcastReceiver implements |
52 DownloadController.DownloadNotificationService { | 52 DownloadController.DownloadNotificationService { |
53 private static final String TAG = "cr.DownloadService"; | 53 private static final String TAG = "DownloadService"; |
54 private static final String DOWNLOAD_NOTIFICATION_IDS = "DownloadNotificatio
nIds"; | 54 private static final String DOWNLOAD_NOTIFICATION_IDS = "DownloadNotificatio
nIds"; |
55 private static final String DOWNLOAD_DIRECTORY = "Download"; | 55 private static final String DOWNLOAD_DIRECTORY = "Download"; |
56 protected static final String PENDING_OMA_DOWNLOADS = "PendingOMADownloads"; | 56 protected static final String PENDING_OMA_DOWNLOADS = "PendingOMADownloads"; |
57 private static final String UNKNOWN_MIME_TYPE = "application/unknown"; | 57 private static final String UNKNOWN_MIME_TYPE = "application/unknown"; |
58 private static final long UPDATE_DELAY_MILLIS = 1000; | 58 private static final long UPDATE_DELAY_MILLIS = 1000; |
59 private static final long INVALID_DOWNLOAD_ID = -1L; | 59 private static final long INVALID_DOWNLOAD_ID = -1L; |
60 private static final int UNKNOWN_DOWNLOAD_STATUS = -1; | 60 private static final int UNKNOWN_DOWNLOAD_STATUS = -1; |
61 // Set will be more expensive to initialize, so use an ArrayList here. | 61 // Set will be more expensive to initialize, so use an ArrayList here. |
62 private static final List<String> MIME_TYPES_TO_OPEN = new ArrayList<String>
(Arrays.asList( | 62 private static final List<String> MIME_TYPES_TO_OPEN = new ArrayList<String>
(Arrays.asList( |
63 OMADownloadHandler.OMA_DOWNLOAD_DESCRIPTOR_MIME, | 63 OMADownloadHandler.OMA_DOWNLOAD_DESCRIPTOR_MIME, |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 protected static void openDownloadsPage(Context context) { | 1015 protected static void openDownloadsPage(Context context) { |
1016 Intent pageView = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS); | 1016 Intent pageView = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS); |
1017 pageView.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | 1017 pageView.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
1018 try { | 1018 try { |
1019 context.startActivity(pageView); | 1019 context.startActivity(pageView); |
1020 } catch (ActivityNotFoundException e) { | 1020 } catch (ActivityNotFoundException e) { |
1021 Log.e(TAG, "Cannot find Downloads app", e); | 1021 Log.e(TAG, "Cannot find Downloads app", e); |
1022 } | 1022 } |
1023 } | 1023 } |
1024 } | 1024 } |
OLD | NEW |