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 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1060 assert !ThreadUtils.runningOnUiThread(); | 1060 assert !ThreadUtils.runningOnUiThread(); |
1061 Intent intent = getLaunchIntentFromDownloadId( | 1061 Intent intent = getLaunchIntentFromDownloadId( |
1062 context, download.getDownloadInfo().getFilePath(), | 1062 context, download.getDownloadInfo().getFilePath(), |
1063 download.getSystemDownloadId(), isSupportedMimeType); | 1063 download.getSystemDownloadId(), isSupportedMimeType); |
1064 return (intent == null) | 1064 return (intent == null) |
1065 ? false : ExternalNavigationDelegateImpl.resolveIntent(intent, t rue); | 1065 ? false : ExternalNavigationDelegateImpl.resolveIntent(intent, t rue); |
1066 } | 1066 } |
1067 | 1067 |
1068 /** See {@link #openDownloadedContent(Context, String, boolean, long)}. */ | 1068 /** See {@link #openDownloadedContent(Context, String, boolean, long)}. */ |
1069 protected void openDownloadedContent(final DownloadInfo downloadInfo, final long downloadId) { | 1069 protected void openDownloadedContent(final DownloadInfo downloadInfo, final long downloadId) { |
1070 // TODO(shaktisahu): Move this to the broader openDownloadedContent() or a better place if | |
1071 // possible. | |
1072 updateLastAccessTime(downloadInfo.getDownloadGuid()); | |
David Trainor- moved to gerrit
2017/02/22 05:56:03
Should this be in the postExecute of the broader c
shaktisahu
2017/02/23 06:55:47
Yes. I didn't find the download guid for all the c
| |
1070 openDownloadedContent(mContext, downloadInfo.getFilePath(), | 1073 openDownloadedContent(mContext, downloadInfo.getFilePath(), |
1071 isSupportedMimeType(downloadInfo.getMimeType()), downloadId); | 1074 isSupportedMimeType(downloadInfo.getMimeType()), downloadId); |
1072 } | 1075 } |
1073 | 1076 |
1074 /** | 1077 /** |
1075 * Launch the intent for a given download item, or Download Home if that's n ot possible. | 1078 * Launch the intent for a given download item, or Download Home if that's n ot possible. |
1076 * TODO(qinmin): Move this to DownloadManagerDelegate. | 1079 * TODO(qinmin): Move this to DownloadManagerDelegate. |
1077 * | 1080 * |
1078 * @param context Context to use. | 1081 * @param context Context to use. |
1079 * @param filePath Path to the downloaded item. | 1082 * @param filePath Path to the downloaded item. |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1770 editor.apply(); | 1773 editor.apply(); |
1771 } | 1774 } |
1772 | 1775 |
1773 int getAutoResumptionLimit() { | 1776 int getAutoResumptionLimit() { |
1774 if (mAutoResumptionLimit < 0) { | 1777 if (mAutoResumptionLimit < 0) { |
1775 mAutoResumptionLimit = nativeGetAutoResumptionLimit(); | 1778 mAutoResumptionLimit = nativeGetAutoResumptionLimit(); |
1776 } | 1779 } |
1777 return mAutoResumptionLimit; | 1780 return mAutoResumptionLimit; |
1778 } | 1781 } |
1779 | 1782 |
1783 /** | |
1784 * Updates the last access time of a download. | |
1785 * @param downloadGuid Download GUID. | |
1786 */ | |
1787 @Override | |
1788 public void updateLastAccessTime(String downloadGuid) { | |
1789 nativeUpdateLastAccessTime(getNativeDownloadManagerService(), downloadGu id); | |
1790 } | |
1791 | |
1780 @Override | 1792 @Override |
1781 public void onMaxBandwidthChanged(double maxBandwidthMbps) {} | 1793 public void onMaxBandwidthChanged(double maxBandwidthMbps) {} |
1782 | 1794 |
1783 @Override | 1795 @Override |
1784 public void onNetworkConnect(long netId, int connectionType) {} | 1796 public void onNetworkConnect(long netId, int connectionType) {} |
1785 | 1797 |
1786 @Override | 1798 @Override |
1787 public void onNetworkSoonToDisconnect(long netId) {} | 1799 public void onNetworkSoonToDisconnect(long netId) {} |
1788 | 1800 |
1789 @Override | 1801 @Override |
(...skipping 12 matching lines...) Expand all Loading... | |
1802 long nativeDownloadManagerService, String downloadGuid, boolean isOf fTheRecord, | 1814 long nativeDownloadManagerService, String downloadGuid, boolean isOf fTheRecord, |
1803 boolean isNotificationDismissed); | 1815 boolean isNotificationDismissed); |
1804 private native void nativePauseDownload(long nativeDownloadManagerService, S tring downloadGuid, | 1816 private native void nativePauseDownload(long nativeDownloadManagerService, S tring downloadGuid, |
1805 boolean isOffTheRecord); | 1817 boolean isOffTheRecord); |
1806 private native void nativeRemoveDownload(long nativeDownloadManagerService, String downloadGuid, | 1818 private native void nativeRemoveDownload(long nativeDownloadManagerService, String downloadGuid, |
1807 boolean isOffTheRecord); | 1819 boolean isOffTheRecord); |
1808 private native void nativeGetAllDownloads( | 1820 private native void nativeGetAllDownloads( |
1809 long nativeDownloadManagerService, boolean isOffTheRecord); | 1821 long nativeDownloadManagerService, boolean isOffTheRecord); |
1810 private native void nativeCheckForExternallyRemovedDownloads( | 1822 private native void nativeCheckForExternallyRemovedDownloads( |
1811 long nativeDownloadManagerService, boolean isOffTheRecord); | 1823 long nativeDownloadManagerService, boolean isOffTheRecord); |
1824 private native void nativeUpdateLastAccessTime( | |
1825 long nativeDownloadManagerService, String downloadGuid); | |
1812 } | 1826 } |
OLD | NEW |