Commit c35c7f9a authored by Side Yilmaz's avatar Side Yilmaz Committed by Commit Bot

Update download classes to replace |getLastUsedProfile| function.

|Profile#getLastUsedProfile| is depreciated and replaced with
|Profile#getLastUsedRegularProfile|. This CL updates the deprecated
function at download classes.

This CL also updates |DownloadManagerCoordinator#create| function by
adding |isIncognito| param to pass the correct profile type (i.e., regular or
incognito).

Bug: 1041781
Change-Id: I8ecae53f09396067dbeaa1b89bd0a0c0840a9ab4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2148749
Commit-Queue: Side YILMAZ <sideyilmaz@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760011}
parent e3c46bef
......@@ -70,7 +70,7 @@ public class DownloadActivity extends SnackbarActivity implements ModalDialogMan
mModalDialogManager = new ModalDialogManager(
new AppModalPresenter(this), ModalDialogManager.ModalDialogType.APP);
mDownloadCoordinator = DownloadManagerCoordinatorFactory.create(
this, config, getSnackbarManager(), mModalDialogManager);
this, config, getSnackbarManager(), mModalDialogManager, isOffTheRecord);
setContentView(mDownloadCoordinator.getView());
mIsOffTheRecord = isOffTheRecord;
mDownloadCoordinator.addObserver(mUiObserver);
......
......@@ -43,8 +43,9 @@ public class DownloadPage extends BasicNativePage implements DownloadManagerCoor
.setShowPaginationHeaders(DownloadUtils.shouldShowPaginationHeaders())
.build();
mDownloadCoordinator = DownloadManagerCoordinatorFactory.create(
activity, config, activity.getSnackbarManager(), activity.getModalDialogManager());
mDownloadCoordinator = DownloadManagerCoordinatorFactory.create(activity, config,
activity.getSnackbarManager(), activity.getModalDialogManager(),
activity.getCurrentTabModel().isIncognito());
mDownloadCoordinator.addObserver(this);
mTitle = activity.getString(R.string.menu_downloads);
......
......@@ -206,7 +206,10 @@ public class DownloadUtils {
}
if (BrowserStartupController.getInstance().isFullBrowserStarted()) {
Profile profile = (tab == null ? Profile.getLastUsedProfile()
// TODO (https://crbug.com/1048632): Use the current profile (i.e., regular profile or
// incognito profile) instead of always using regular profile. It works correctly now,
// but it is not safe.
Profile profile = (tab == null ? Profile.getLastUsedRegularProfile()
: Profile.fromWebContents(tab.getWebContents()));
Tracker tracker = TrackerFactory.getTrackerForProfile(profile);
tracker.notifyEvent(EventConstants.DOWNLOAD_HOME_OPENED);
......
......@@ -24,12 +24,14 @@ public class DownloadManagerCoordinatorFactory {
* @param config A {@link DownloadManagerUiConfig} to provide configuration params.
* @param snackbarManager The {@link SnackbarManager} that should be used to show snackbars.
* @param modalDialogManager The {@link ModalDialogManager} that should be used to show dialog.
* @param isIncognito The boolean that represents whether the current mode is incognito.
* @return A new {@link DownloadManagerCoordinator} instance.
*/
public static DownloadManagerCoordinator create(Activity activity,
DownloadManagerUiConfig config, SnackbarManager snackbarManager,
ModalDialogManager modalDialogManager) {
Profile profile = Profile.getLastUsedRegularProfile();
ModalDialogManager modalDialogManager, boolean isIncognito) {
Profile profile = isIncognito ? Profile.getLastUsedRegularProfile().getOffTheRecordProfile()
: Profile.getLastUsedRegularProfile();
LegacyDownloadProvider legacyProvider =
config.useNewDownloadPath ? null : new LegacyDownloadProviderImpl();
return new DownloadManagerCoordinatorImpl(activity, config, new PrefetchEnabledSupplier(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment