Chromium Code Reviews| 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.Activity; | 7 import android.app.Activity; |
| 8 import android.app.DownloadManager; | 8 import android.app.DownloadManager; |
| 9 import android.content.ActivityNotFoundException; | 9 import android.content.ActivityNotFoundException; |
| 10 import android.content.BroadcastReceiver; | 10 import android.content.BroadcastReceiver; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 import org.chromium.base.ContextUtils; | 27 import org.chromium.base.ContextUtils; |
| 28 import org.chromium.base.Log; | 28 import org.chromium.base.Log; |
| 29 import org.chromium.base.ObserverList; | 29 import org.chromium.base.ObserverList; |
| 30 import org.chromium.base.ThreadUtils; | 30 import org.chromium.base.ThreadUtils; |
| 31 import org.chromium.base.VisibleForTesting; | 31 import org.chromium.base.VisibleForTesting; |
| 32 import org.chromium.base.annotations.CalledByNative; | 32 import org.chromium.base.annotations.CalledByNative; |
| 33 import org.chromium.base.annotations.SuppressFBWarnings; | 33 import org.chromium.base.annotations.SuppressFBWarnings; |
| 34 import org.chromium.base.metrics.RecordHistogram; | 34 import org.chromium.base.metrics.RecordHistogram; |
| 35 import org.chromium.chrome.R; | 35 import org.chromium.chrome.R; |
| 36 import org.chromium.chrome.browser.ChromeActivity; | 36 import org.chromium.chrome.browser.ChromeActivity; |
| 37 import org.chromium.chrome.browser.ChromeFeatureList; | |
| 38 import org.chromium.chrome.browser.download.ui.BackendProvider; | 37 import org.chromium.chrome.browser.download.ui.BackendProvider; |
| 39 import org.chromium.chrome.browser.download.ui.DownloadHistoryAdapter; | 38 import org.chromium.chrome.browser.download.ui.DownloadHistoryAdapter; |
| 40 import org.chromium.chrome.browser.externalnav.ExternalNavigationDelegateImpl; | 39 import org.chromium.chrome.browser.externalnav.ExternalNavigationDelegateImpl; |
| 41 import org.chromium.net.ConnectionType; | 40 import org.chromium.net.ConnectionType; |
| 42 import org.chromium.net.NetworkChangeNotifierAutoDetect; | 41 import org.chromium.net.NetworkChangeNotifierAutoDetect; |
| 43 import org.chromium.net.RegistrationPolicyAlwaysRegister; | 42 import org.chromium.net.RegistrationPolicyAlwaysRegister; |
| 44 import org.chromium.ui.widget.Toast; | 43 import org.chromium.ui.widget.Toast; |
| 45 | 44 |
| 46 import java.io.File; | 45 import java.io.File; |
| 47 import java.util.ArrayList; | 46 import java.util.ArrayList; |
| (...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1056 protected void setDownloadSnackbarController( | 1055 protected void setDownloadSnackbarController( |
| 1057 DownloadSnackbarController downloadSnackbarController) { | 1056 DownloadSnackbarController downloadSnackbarController) { |
| 1058 mDownloadSnackbarController = downloadSnackbarController; | 1057 mDownloadSnackbarController = downloadSnackbarController; |
| 1059 } | 1058 } |
| 1060 | 1059 |
| 1061 /** | 1060 /** |
| 1062 * Open the Activity which shows a list of all downloads. | 1061 * Open the Activity which shows a list of all downloads. |
| 1063 * @param context Application context | 1062 * @param context Application context |
| 1064 */ | 1063 */ |
| 1065 protected static void openDownloadsPage(Context context) { | 1064 protected static void openDownloadsPage(Context context) { |
| 1066 if (!ChromeFeatureList.isEnabled(ChromeFeatureList.SYSTEM_DOWNLOAD_MANAG ER)) { | 1065 // Try to open Download Home. |
| 1067 // Try to open Download Home. | 1066 Activity lastActivity = ApplicationStatus.getLastTrackedFocusedActivity( ); |
| 1068 Activity lastActivity = ApplicationStatus.getLastTrackedFocusedActiv ity(); | 1067 if (lastActivity instanceof ChromeActivity) { |
| 1069 if (lastActivity instanceof ChromeActivity) { | 1068 int state = ApplicationStatus.getStateForActivity(lastActivity); |
| 1070 int state = ApplicationStatus.getStateForActivity(lastActivity); | 1069 if (state >= ActivityState.CREATED && state <= ActivityState.RESUMED ) { |
| 1071 if (state >= ActivityState.CREATED && state <= ActivityState.RES UMED) { | 1070 ChromeActivity chromeActivity = (ChromeActivity) lastActivity; |
| 1072 ChromeActivity chromeActivity = (ChromeActivity) lastActivit y; | 1071 DownloadUtils.showDownloadManager( |
| 1073 DownloadUtils.showDownloadManager( | 1072 lastActivity, chromeActivity.getActivityTab()); |
| 1074 lastActivity, chromeActivity.getActivityTab()); | 1073 return; |
| 1075 return; | |
| 1076 } | |
| 1077 } | 1074 } |
| 1078 } | 1075 } |
| 1079 | 1076 |
| 1080 // Open the Android Download Manager. | 1077 // Open the Android Download Manager. |
|
asanka
2016/09/19 19:29:12
Why try to open this at all once Chrome is handlin
gone
2016/09/19 19:33:56
Download Home is tied to a tab: on tablets it's di
asanka
2016/09/19 20:05:06
Right. Though on phones downloads home is a separa
gone
2016/09/19 20:10:42
Separate activity, but it's still tied to whether
qinmin
2016/09/19 21:16:13
For OMA downloads, which didn't go through Chrome,
| |
| 1081 Intent pageView = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS); | 1078 Intent pageView = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS); |
| 1082 pageView.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | 1079 pageView.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 1083 try { | 1080 try { |
| 1084 context.startActivity(pageView); | 1081 context.startActivity(pageView); |
| 1085 } catch (ActivityNotFoundException e) { | 1082 } catch (ActivityNotFoundException e) { |
| 1086 Log.e(TAG, "Cannot find Downloads app", e); | 1083 Log.e(TAG, "Cannot find Downloads app", e); |
| 1087 } | 1084 } |
| 1088 } | 1085 } |
| 1089 | 1086 |
| 1090 /** | 1087 /** |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1657 boolean isNotificationDismissed); | 1654 boolean isNotificationDismissed); |
| 1658 private native void nativePauseDownload(long nativeDownloadManagerService, S tring downloadGuid, | 1655 private native void nativePauseDownload(long nativeDownloadManagerService, S tring downloadGuid, |
| 1659 boolean isOffTheRecord); | 1656 boolean isOffTheRecord); |
| 1660 private native void nativeRemoveDownload(long nativeDownloadManagerService, String downloadGuid, | 1657 private native void nativeRemoveDownload(long nativeDownloadManagerService, String downloadGuid, |
| 1661 boolean isOffTheRecord); | 1658 boolean isOffTheRecord); |
| 1662 private native void nativeGetAllDownloads( | 1659 private native void nativeGetAllDownloads( |
| 1663 long nativeDownloadManagerService, boolean isOffTheRecord); | 1660 long nativeDownloadManagerService, boolean isOffTheRecord); |
| 1664 private native void nativeCheckForExternallyRemovedDownloads( | 1661 private native void nativeCheckForExternallyRemovedDownloads( |
| 1665 long nativeDownloadManagerService, boolean isOffTheRecord); | 1662 long nativeDownloadManagerService, boolean isOffTheRecord); |
| 1666 } | 1663 } |
| OLD | NEW |