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.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.app.DownloadManager; | 8 import android.app.DownloadManager; |
9 import android.app.Notification; | 9 import android.app.Notification; |
10 import android.app.NotificationManager; | 10 import android.app.NotificationManager; |
(...skipping 22 matching lines...) Expand all Loading... |
33 import org.chromium.base.ApplicationStatus; | 33 import org.chromium.base.ApplicationStatus; |
34 import org.chromium.base.ContextUtils; | 34 import org.chromium.base.ContextUtils; |
35 import org.chromium.base.Log; | 35 import org.chromium.base.Log; |
36 import org.chromium.base.ObserverList; | 36 import org.chromium.base.ObserverList; |
37 import org.chromium.base.VisibleForTesting; | 37 import org.chromium.base.VisibleForTesting; |
38 import org.chromium.base.library_loader.LibraryLoader; | 38 import org.chromium.base.library_loader.LibraryLoader; |
39 import org.chromium.base.library_loader.ProcessInitException; | 39 import org.chromium.base.library_loader.ProcessInitException; |
40 import org.chromium.chrome.R; | 40 import org.chromium.chrome.R; |
41 import org.chromium.chrome.browser.AppHooks; | 41 import org.chromium.chrome.browser.AppHooks; |
42 import org.chromium.chrome.browser.ChromeApplication; | 42 import org.chromium.chrome.browser.ChromeApplication; |
| 43 import org.chromium.chrome.browser.download.items.OfflineContentAggregatorNotifi
erFactory; |
43 import org.chromium.chrome.browser.init.BrowserParts; | 44 import org.chromium.chrome.browser.init.BrowserParts; |
44 import org.chromium.chrome.browser.init.ChromeBrowserInitializer; | 45 import org.chromium.chrome.browser.init.ChromeBrowserInitializer; |
45 import org.chromium.chrome.browser.init.EmptyBrowserParts; | 46 import org.chromium.chrome.browser.init.EmptyBrowserParts; |
46 import org.chromium.chrome.browser.notifications.ChromeNotificationBuilder; | 47 import org.chromium.chrome.browser.notifications.ChromeNotificationBuilder; |
47 import org.chromium.chrome.browser.notifications.NotificationConstants; | 48 import org.chromium.chrome.browser.notifications.NotificationConstants; |
48 import org.chromium.chrome.browser.notifications.NotificationUmaTracker; | 49 import org.chromium.chrome.browser.notifications.NotificationUmaTracker; |
49 import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadBri
dge; | 50 import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadBri
dge; |
50 import org.chromium.chrome.browser.profiles.Profile; | 51 import org.chromium.chrome.browser.profiles.Profile; |
51 import org.chromium.chrome.browser.util.IntentUtils; | 52 import org.chromium.chrome.browser.util.IntentUtils; |
52 | 53 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 for (DownloadSharedPreferenceEntry entry : entries) { | 311 for (DownloadSharedPreferenceEntry entry : entries) { |
311 if (canResumeDownload(context, entry)) return true; | 312 if (canResumeDownload(context, entry)) return true; |
312 } | 313 } |
313 return false; | 314 return false; |
314 } | 315 } |
315 | 316 |
316 /** | 317 /** |
317 * Class for clients to access. | 318 * Class for clients to access. |
318 */ | 319 */ |
319 public class LocalBinder extends Binder { | 320 public class LocalBinder extends Binder { |
320 DownloadNotificationService getService() { | 321 public DownloadNotificationService getService() { |
321 return DownloadNotificationService.this; | 322 return DownloadNotificationService.this; |
322 } | 323 } |
323 } | 324 } |
324 | 325 |
325 @Override | 326 @Override |
326 public void onTaskRemoved(Intent rootIntent) { | 327 public void onTaskRemoved(Intent rootIntent) { |
327 super.onTaskRemoved(rootIntent); | 328 super.onTaskRemoved(rootIntent); |
328 // If we've lost all Activities, cancel the off the record downloads and
validate that we | 329 // If we've lost all Activities, cancel the off the record downloads and
validate that we |
329 // should still be showing any download notifications at all. | 330 // should still be showing any download notifications at all. |
330 if (ApplicationStatus.isEveryActivityDestroyed()) { | 331 if (ApplicationStatus.isEveryActivityDestroyed()) { |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 } | 1082 } |
1082 | 1083 |
1083 BrowserParts parts = new EmptyBrowserParts() { | 1084 BrowserParts parts = new EmptyBrowserParts() { |
1084 @Override | 1085 @Override |
1085 public boolean shouldStartGpuProcess() { | 1086 public boolean shouldStartGpuProcess() { |
1086 return false; | 1087 return false; |
1087 } | 1088 } |
1088 | 1089 |
1089 @Override | 1090 @Override |
1090 public void finishNativeInitialization() { | 1091 public void finishNativeInitialization() { |
| 1092 OfflineContentAggregatorNotifierFactory.create(mContext); |
| 1093 |
1091 int itemType = entry != null ? entry.itemType | 1094 int itemType = entry != null ? entry.itemType |
1092 : (ACTION_DOWNLOAD_OPEN.equals(intent.getAction()) | 1095 : (ACTION_DOWNLOAD_OPEN.equals(intent.getAction()) |
1093 ? DownloadSharedPreferenceEntry.ITEM_TYPE_OFFLIN
E_PAGE | 1096 ? DownloadSharedPreferenceEntry.ITEM_TYPE_OFFLIN
E_PAGE |
1094 : DownloadSharedPreferenceEntry.ITEM_TYPE_DOWNLO
AD); | 1097 : DownloadSharedPreferenceEntry.ITEM_TYPE_DOWNLO
AD); |
1095 DownloadServiceDelegate downloadServiceDelegate = | 1098 DownloadServiceDelegate downloadServiceDelegate = |
1096 ACTION_DOWNLOAD_OPEN.equals(intent.getAction()) ? null | 1099 ACTION_DOWNLOAD_OPEN.equals(intent.getAction()) ? null |
1097 : getServiceDelegate(itemType); | 1100 : getServiceDelegate(itemType); |
1098 if (ACTION_DOWNLOAD_CANCEL.equals(intent.getAction())) { | 1101 if (ACTION_DOWNLOAD_CANCEL.equals(intent.getAction())) { |
1099 // TODO(qinmin): Alternatively, we can delete the downlo
aded content on | 1102 // TODO(qinmin): Alternatively, we can delete the downlo
aded content on |
1100 // SD card, and remove the download ID from the SharedPr
eferences so we | 1103 // SD card, and remove the download ID from the SharedPr
eferences so we |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1328 return context.getString(R.string.remaining_duration_minutes, minute
s); | 1331 return context.getString(R.string.remaining_duration_minutes, minute
s); |
1329 } else if (minutes > 0) { | 1332 } else if (minutes > 0) { |
1330 return context.getString(R.string.remaining_duration_one_minute); | 1333 return context.getString(R.string.remaining_duration_one_minute); |
1331 } else if (seconds == 1) { | 1334 } else if (seconds == 1) { |
1332 return context.getString(R.string.remaining_duration_one_second); | 1335 return context.getString(R.string.remaining_duration_one_second); |
1333 } else { | 1336 } else { |
1334 return context.getString(R.string.remaining_duration_seconds, second
s); | 1337 return context.getString(R.string.remaining_duration_seconds, second
s); |
1335 } | 1338 } |
1336 } | 1339 } |
1337 } | 1340 } |
OLD | NEW |