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

Update DownloadSnackbarController to use incognito profile

when called incognito.

This CL replaces usage of deprecated |getLastUsedProfile| with
|isOffTheRecord| param. Curently, always regular profile is used to
get InfoBarController, since |getLastUsedProfile| return always regular
profile. However it is not true.

Therefore, this CL uses |isOffTheRecord| param from info of
download item at DownloadManagerService to get correct InfoBarController
for the correct profile object(i.e., regular or off-the-record profile).

Bug: 1041781
Change-Id: I2d5ecf786043c8cf8fa7b62e09240a3d0c6f3c88
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083301Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Reviewed-by: default avatarShakti Sahu <shaktisahu@chromium.org>
Commit-Queue: Side YILMAZ <sideyilmaz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747164}
parent 242ca2e1
...@@ -917,9 +917,9 @@ public class DownloadManagerService implements DownloadController.Observer, ...@@ -917,9 +917,9 @@ public class DownloadManagerService implements DownloadController.Observer,
getDownloadFailureMessage(item.getDownloadInfo().getFileName(), reason); getDownloadFailureMessage(item.getDownloadInfo().getFileName(), reason);
if (mDownloadSnackbarController.getSnackbarManager() != null) { if (mDownloadSnackbarController.getSnackbarManager() != null) {
mDownloadSnackbarController.onDownloadFailed( mDownloadSnackbarController.onDownloadFailed(failureMessage,
failureMessage, reason == DownloadManager.ERROR_FILE_ALREADY_EXISTS,
reason == DownloadManager.ERROR_FILE_ALREADY_EXISTS); item.getDownloadInfo().isOffTheRecord());
} else { } else {
Toast.makeText(ContextUtils.getApplicationContext(), failureMessage, Toast.LENGTH_SHORT) Toast.makeText(ContextUtils.getApplicationContext(), failureMessage, Toast.LENGTH_SHORT)
.show(); .show();
......
...@@ -12,7 +12,6 @@ import org.chromium.base.ApplicationStatus; ...@@ -12,7 +12,6 @@ import org.chromium.base.ApplicationStatus;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.items.OfflineContentAggregatorNotificationBridgeUiFactory; import org.chromium.chrome.browser.download.items.OfflineContentAggregatorNotificationBridgeUiFactory;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar; import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager; import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
import org.chromium.components.offline_items_collection.LaunchLocation; import org.chromium.components.offline_items_collection.LaunchLocation;
...@@ -83,8 +82,9 @@ public class DownloadSnackbarController implements SnackbarManager.SnackbarContr ...@@ -83,8 +82,9 @@ public class DownloadSnackbarController implements SnackbarManager.SnackbarContr
* @param showAllDownloads Whether to show all downloads in case the failure is caused by * @param showAllDownloads Whether to show all downloads in case the failure is caused by
* duplicated files. * duplicated files.
*/ */
public void onDownloadFailed(String errorMessage, boolean showAllDownloads) { public void onDownloadFailed(
if (isShowingDownloadInfoBar()) return; String errorMessage, boolean showAllDownloads, boolean isOffTheRecord) {
if (isShowingDownloadInfoBar(isOffTheRecord)) return;
if (getSnackbarManager() == null) return; if (getSnackbarManager() == null) return;
// TODO(qinmin): Coalesce snackbars if multiple downloads finish at the same time. // TODO(qinmin): Coalesce snackbars if multiple downloads finish at the same time.
Snackbar snackbar = Snackbar.make(errorMessage, this, Snackbar.TYPE_NOTIFICATION, Snackbar snackbar = Snackbar.make(errorMessage, this, Snackbar.TYPE_NOTIFICATION,
...@@ -131,10 +131,10 @@ public class DownloadSnackbarController implements SnackbarManager.SnackbarContr ...@@ -131,10 +131,10 @@ public class DownloadSnackbarController implements SnackbarManager.SnackbarContr
return null; return null;
} }
private boolean isShowingDownloadInfoBar() { private boolean isShowingDownloadInfoBar(boolean isOffTheRecord) {
DownloadInfoBarController infoBarController = DownloadInfoBarController infoBarController =
DownloadManagerService.getDownloadManagerService().getInfoBarController( DownloadManagerService.getDownloadManagerService().getInfoBarController(
Profile.getLastUsedProfile().isOffTheRecord()); isOffTheRecord);
return infoBarController == null ? false : infoBarController.isShowing(); return infoBarController == null ? false : infoBarController.isShowing();
} }
} }
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