Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerService.java

Issue 2651233002: Enable download home by default (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 private static final String TAG = "DownloadService"; 74 private static final String TAG = "DownloadService";
75 private static final String DOWNLOAD_DIRECTORY = "Download"; 75 private static final String DOWNLOAD_DIRECTORY = "Download";
76 protected static final String PENDING_OMA_DOWNLOADS = "PendingOMADownloads"; 76 protected static final String PENDING_OMA_DOWNLOADS = "PendingOMADownloads";
77 private static final String UNKNOWN_MIME_TYPE = "application/unknown"; 77 private static final String UNKNOWN_MIME_TYPE = "application/unknown";
78 private static final String DOWNLOAD_UMA_ENTRY = "DownloadUmaEntry"; 78 private static final String DOWNLOAD_UMA_ENTRY = "DownloadUmaEntry";
79 private static final long UPDATE_DELAY_MILLIS = 1000; 79 private static final long UPDATE_DELAY_MILLIS = 1000;
80 // Wait 10 seconds to resume all downloads, so that we won't impact tab load ing. 80 // Wait 10 seconds to resume all downloads, so that we won't impact tab load ing.
81 private static final long RESUME_DELAY_MILLIS = 10000; 81 private static final long RESUME_DELAY_MILLIS = 10000;
82 private static final int UNKNOWN_DOWNLOAD_STATUS = -1; 82 private static final int UNKNOWN_DOWNLOAD_STATUS = -1;
83 private static final String PREF_IS_DOWNLOAD_HOME_ENABLED =
84 "org.chromium.chrome.browser.download.IS_DOWNLOAD_HOME_ENABLED";
83 85
84 // Values for the histogram MobileDownloadResumptionCount. 86 // Values for the histogram MobileDownloadResumptionCount.
85 private static final int UMA_DOWNLOAD_RESUMPTION_MANUAL_PAUSE = 0; 87 private static final int UMA_DOWNLOAD_RESUMPTION_MANUAL_PAUSE = 0;
86 private static final int UMA_DOWNLOAD_RESUMPTION_BROWSER_KILLED = 1; 88 private static final int UMA_DOWNLOAD_RESUMPTION_BROWSER_KILLED = 1;
87 private static final int UMA_DOWNLOAD_RESUMPTION_CLICKED = 2; 89 private static final int UMA_DOWNLOAD_RESUMPTION_CLICKED = 2;
88 private static final int UMA_DOWNLOAD_RESUMPTION_FAILED = 3; 90 private static final int UMA_DOWNLOAD_RESUMPTION_FAILED = 3;
89 private static final int UMA_DOWNLOAD_RESUMPTION_AUTO_STARTED = 4; 91 private static final int UMA_DOWNLOAD_RESUMPTION_AUTO_STARTED = 4;
90 private static final int UMA_DOWNLOAD_RESUMPTION_COUNT = 5; 92 private static final int UMA_DOWNLOAD_RESUMPTION_COUNT = 5;
91 93
92 // Set will be more expensive to initialize, so use an ArrayList here. 94 // Set will be more expensive to initialize, so use an ArrayList here.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 return prev; 237 return prev;
236 } 238 }
237 239
238 @VisibleForTesting 240 @VisibleForTesting
239 protected DownloadManagerService(Context context, 241 protected DownloadManagerService(Context context,
240 DownloadNotifier downloadNotifier, 242 DownloadNotifier downloadNotifier,
241 Handler handler, 243 Handler handler,
242 long updateDelayInMillis) { 244 long updateDelayInMillis) {
243 mContext = context; 245 mContext = context;
244 mSharedPrefs = ContextUtils.getAppSharedPreferences(); 246 mSharedPrefs = ContextUtils.getAppSharedPreferences();
247 // Clean up unused shared prefs. TODO(qinmin): remove this after M61.
248 mSharedPrefs.edit().remove(PREF_IS_DOWNLOAD_HOME_ENABLED).apply();
245 mDownloadNotifier = downloadNotifier; 249 mDownloadNotifier = downloadNotifier;
246 mUpdateDelayInMillis = updateDelayInMillis; 250 mUpdateDelayInMillis = updateDelayInMillis;
247 mHandler = handler; 251 mHandler = handler;
248 mOMADownloadHandler = new OMADownloadHandler(context); 252 mOMADownloadHandler = new OMADownloadHandler(context);
249 mDownloadSnackbarController = new DownloadSnackbarController(context); 253 mDownloadSnackbarController = new DownloadSnackbarController(context);
250 mDownloadManagerDelegate = new DownloadManagerDelegate(mContext); 254 mDownloadManagerDelegate = new DownloadManagerDelegate(mContext);
251 // Note that this technically leaks the native object, however, Download ManagerService 255 // Note that this technically leaks the native object, however, Download ManagerService
252 // is a singleton that lives forever and there's no clean shutdown of Ch rome on Android. 256 // is a singleton that lives forever and there's no clean shutdown of Ch rome on Android.
253 init(); 257 init();
254 clearPendingOMADownloads(); 258 clearPendingOMADownloads();
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 boolean isNotificationDismissed); 1701 boolean isNotificationDismissed);
1698 private native void nativePauseDownload(long nativeDownloadManagerService, S tring downloadGuid, 1702 private native void nativePauseDownload(long nativeDownloadManagerService, S tring downloadGuid,
1699 boolean isOffTheRecord); 1703 boolean isOffTheRecord);
1700 private native void nativeRemoveDownload(long nativeDownloadManagerService, String downloadGuid, 1704 private native void nativeRemoveDownload(long nativeDownloadManagerService, String downloadGuid,
1701 boolean isOffTheRecord); 1705 boolean isOffTheRecord);
1702 private native void nativeGetAllDownloads( 1706 private native void nativeGetAllDownloads(
1703 long nativeDownloadManagerService, boolean isOffTheRecord); 1707 long nativeDownloadManagerService, boolean isOffTheRecord);
1704 private native void nativeCheckForExternallyRemovedDownloads( 1708 private native void nativeCheckForExternallyRemovedDownloads(
1705 long nativeDownloadManagerService, boolean isOffTheRecord); 1709 long nativeDownloadManagerService, boolean isOffTheRecord);
1706 } 1710 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698