Remove DownloadLaterPromptStatus prefs
DownloadLater dialog is not launched, so remove the prefs.
Bug: 1337109
Change-Id: I316cd1527ff1314aa851b0dbdb21ff61ca7a820f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3733069
Reviewed-by: Lei Zhang <[email protected]>
Commit-Queue: Min Qin <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1019366}
diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn
index 372c4a4..c4e6223 100644
--- a/chrome/android/BUILD.gn
+++ b/chrome/android/BUILD.gn
@@ -1347,7 +1347,6 @@
"javatests/src/org/chromium/chrome/browser/download/DownloadForegroundServiceTest.java",
"javatests/src/org/chromium/chrome/browser/download/DownloadNotificationServiceTest.java",
"javatests/src/org/chromium/chrome/browser/download/SystemDownloadNotifierTest.java",
- "javatests/src/org/chromium/chrome/browser/download/dialogs/DownloadLaterDialogTest.java",
"javatests/src/org/chromium/chrome/browser/download/dialogs/DownloadLocationDialogTest.java",
"javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImplTest.java",
"javatests/src/org/chromium/chrome/browser/externalnav/IntentWithRequestMetadataHandlerTest.java",
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadSettingsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadSettingsTest.java
index 0ad79c9f..c93819e 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadSettingsTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadSettingsTest.java
@@ -102,7 +102,6 @@
mSettingsActivityTestRule.startSettingsActivity();
assertPreference(DownloadSettings.PREF_LOCATION_CHANGE);
assertPreference(DownloadSettings.PREF_LOCATION_PROMPT_ENABLED);
- assertPreference(DownloadSettings.PREF_DOWNLOAD_LATER_PROMPT_ENABLED);
mSettingsActivityTestRule.getActivity().finish();
}
@@ -114,7 +113,6 @@
mSettingsActivityTestRule.startSettingsActivity();
assertPreference(DownloadSettings.PREF_LOCATION_CHANGE);
assertPreference(DownloadSettings.PREF_LOCATION_PROMPT_ENABLED);
- assertPreference(DownloadSettings.PREF_DOWNLOAD_LATER_PROMPT_ENABLED, Matchers.nullValue());
mSettingsActivityTestRule.getActivity().finish();
}
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/download/dialogs/DownloadLaterDialogTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/download/dialogs/DownloadLaterDialogTest.java
deleted file mode 100644
index 7c73204..0000000
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/download/dialogs/DownloadLaterDialogTest.java
+++ /dev/null
@@ -1,325 +0,0 @@
-// Copyright 2020 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.chrome.browser.download.dialogs;
-
-import static androidx.test.espresso.Espresso.onView;
-import static androidx.test.espresso.action.ViewActions.click;
-import static androidx.test.espresso.assertion.ViewAssertions.matches;
-import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
-import static androidx.test.espresso.matcher.ViewMatchers.withId;
-import static androidx.test.espresso.matcher.ViewMatchers.withText;
-
-import static org.hamcrest.Matchers.not;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyLong;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.view.View;
-import android.widget.CheckBox;
-
-import androidx.test.espresso.NoMatchingViewException;
-import androidx.test.filters.MediumTest;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-import org.chromium.base.test.util.CommandLineFlags;
-import org.chromium.chrome.browser.download.DownloadLaterPromptStatus;
-import org.chromium.chrome.browser.download.R;
-import org.chromium.chrome.browser.flags.ChromeSwitches;
-import org.chromium.chrome.browser.preferences.Pref;
-import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
-import org.chromium.components.browser_ui.modaldialog.AppModalPresenter;
-import org.chromium.components.browser_ui.widget.RadioButtonWithDescription;
-import org.chromium.components.prefs.PrefService;
-import org.chromium.content_public.browser.test.util.TestThreadUtils;
-import org.chromium.ui.modaldialog.ModalDialogManager;
-import org.chromium.ui.modaldialog.ModalDialogProperties;
-import org.chromium.ui.modelutil.PropertyModel;
-import org.chromium.ui.test.util.BlankUiTestActivityTestCase;
-
-/**
- * Test to verify download later dialog.
- */
-@RunWith(ChromeJUnit4ClassRunner.class)
[email protected]({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
-public class DownloadLaterDialogTest extends BlankUiTestActivityTestCase {
- private static final long INVALID_START_TIME = -1;
- private static final String POSITIVE_BUTTON_TEXT = "Done";
- private static final String DEFAULT_SUBTITLE =
- "You'll see a notification when this file is ready";
-
- private DownloadLaterDialogCoordinator mDialogCoordinator;
- private PropertyModel mModel;
-
- @Mock
- private DownloadLaterDialogController mController;
-
- @Mock
- DownloadDateTimePickerDialog mDateTimePicker;
-
- @Mock
- PrefService mPrefService;
-
- private AppModalPresenter mAppModalPresenter;
- private ModalDialogManager mModalDialogManager;
-
- private ModalDialogManager getModalDialogManager() {
- return mModalDialogManager;
- }
-
- private DownloadLaterDialogView getDownloadLaterDialogView() {
- return (DownloadLaterDialogView) getModalDialogManager().getCurrentDialogForTest().get(
- ModalDialogProperties.CUSTOM_VIEW);
- }
-
- @Override
- public void setUpTest() throws Exception {
- super.setUpTest();
- MockitoAnnotations.initMocks(this);
- when(mPrefService.getInteger(Pref.DOWNLOAD_LATER_PROMPT_STATUS))
- .thenReturn(DownloadLaterPromptStatus.SHOW_INITIAL);
- doNothing().when(mPrefService).setInteger(anyString(), anyInt());
-
- mAppModalPresenter = new AppModalPresenter(getActivity());
- mModalDialogManager = TestThreadUtils.runOnUiThreadBlockingNoException(() -> {
- return new ModalDialogManager(
- mAppModalPresenter, ModalDialogManager.ModalDialogType.APP);
- });
-
- mDialogCoordinator = new DownloadLaterDialogCoordinator(mDateTimePicker);
- mModel = createModel(
- DownloadLaterDialogChoice.ON_WIFI, DownloadLaterPromptStatus.SHOW_INITIAL);
-
- Assert.assertNotNull(mController);
- mDialogCoordinator.initialize(mController);
- }
-
- private PropertyModel createModel(Integer choice, Integer promptStatus) {
- return createModel(choice, promptStatus, null, null);
- }
-
- private PropertyModel createModel(Integer choice, Integer promptStatus, CharSequence subtitle,
- Boolean showDateTimePicker) {
- PropertyModel.Builder builder =
- new PropertyModel.Builder(DownloadLaterDialogProperties.ALL_KEYS)
- .with(DownloadLaterDialogProperties.CONTROLLER, mDialogCoordinator);
- if (choice != null) {
- builder.with(DownloadLaterDialogProperties.INITIAL_CHOICE, choice);
- }
-
- if (promptStatus != null) {
- builder.with(DownloadLaterDialogProperties.DONT_SHOW_AGAIN_SELECTION, promptStatus);
- }
-
- if (subtitle != null) {
- builder.with(DownloadLaterDialogProperties.SUBTITLE_TEXT, subtitle);
- }
-
- if (showDateTimePicker != null) {
- builder.with(
- DownloadLaterDialogProperties.SHOW_DATE_TIME_PICKER_OPTION, showDateTimePicker);
- }
-
- return TestThreadUtils.runOnUiThreadBlockingNoException(() -> builder.build());
- }
-
- private void showDialog() {
- TestThreadUtils.runOnUiThreadBlocking(() -> {
- mDialogCoordinator.showDialog(
- getActivity(), getModalDialogManager(), mPrefService, mModel);
- });
- }
-
- private void clickPositiveButton() {
- onView(withId(org.chromium.chrome.R.id.positive_button)).perform(click());
- }
-
- private void clickNegativeButton() {
- onView(withId(org.chromium.chrome.R.id.negative_button)).perform(click());
- }
-
- private void assertPositiveButtonText(String expectedText) {
- onView(withId(org.chromium.chrome.R.id.positive_button))
- .check(matches(withText(expectedText)));
- }
-
- private void assertSubtitle(String subtitle) {
- onView(withId(org.chromium.chrome.R.id.subtitle)).check(matches(withText(subtitle)));
- }
-
- private void assertShowAgainCheckBox(boolean enabled, int visibility, boolean checked) {
- onView(withId(R.id.show_again_checkbox)).check((View view, NoMatchingViewException e) -> {
- Assert.assertEquals(enabled, view.isEnabled());
- Assert.assertEquals(visibility, view.getVisibility());
- if (visibility == View.VISIBLE) {
- Assert.assertEquals(checked, ((CheckBox) (view)).isChecked());
- }
- });
- }
-
- private void assertEditText(boolean hasEditText) {
- if (hasEditText) {
- onView(withId(R.id.edit_location)).check(matches(isDisplayed()));
- } else {
- onView(withId(R.id.edit_location)).check(matches(not(isDisplayed())));
- }
- }
-
- @Test
- @MediumTest
- public void testInitialSelectionDownloadNowWithOutCheckbox() {
- mModel = createModel(DownloadLaterDialogChoice.DOWNLOAD_NOW, null);
- showDialog();
- assertPositiveButtonText(POSITIVE_BUTTON_TEXT);
- assertShowAgainCheckBox(true, View.GONE, true);
- assertEditText(false);
- assertSubtitle(DEFAULT_SUBTITLE);
- }
-
- @Test
- @MediumTest
- public void testInitialSelectionOnWifiWithCheckbox() {
- mModel = createModel(
- DownloadLaterDialogChoice.ON_WIFI, DownloadLaterPromptStatus.SHOW_INITIAL);
- showDialog();
- assertPositiveButtonText(POSITIVE_BUTTON_TEXT);
- assertShowAgainCheckBox(true, View.VISIBLE, false);
- assertEditText(false);
- assertSubtitle(DEFAULT_SUBTITLE);
- }
-
- @Test
- @MediumTest
- public void testInitialSelectionOnWifiWithEditLocation() {
- mModel = createModel(
- DownloadLaterDialogChoice.ON_WIFI, DownloadLaterPromptStatus.SHOW_PREFERENCE);
- TestThreadUtils.runOnUiThreadBlocking(
- () -> mModel.set(DownloadLaterDialogProperties.LOCATION_TEXT, "location"));
- showDialog();
- assertPositiveButtonText(POSITIVE_BUTTON_TEXT);
- assertShowAgainCheckBox(true, View.VISIBLE, false);
- assertEditText(true);
- assertSubtitle(DEFAULT_SUBTITLE);
- }
-
- @Test
- @MediumTest
- public void testInitialSelectionDownloadLater() {
- mModel = createModel(
- DownloadLaterDialogChoice.DOWNLOAD_LATER, DownloadLaterPromptStatus.SHOW_INITIAL);
- showDialog();
- assertPositiveButtonText("Next");
- assertShowAgainCheckBox(false, View.VISIBLE, false);
- assertEditText(false);
- assertSubtitle(DEFAULT_SUBTITLE);
- }
-
- @Test
- @MediumTest
- public void testSubtitle() {
- final String subtitle = "awesome subtitle";
- mModel = createModel(DownloadLaterDialogChoice.DOWNLOAD_LATER,
- DownloadLaterPromptStatus.SHOW_INITIAL, subtitle, null);
- showDialog();
- assertSubtitle(subtitle);
- }
-
- @Test
- @MediumTest
- public void testHideDateTimePicker() {
- mModel = createModel(DownloadLaterDialogChoice.DOWNLOAD_NOW,
- DownloadLaterPromptStatus.SHOW_INITIAL, null, false);
- showDialog();
- onView(withId(R.id.choose_date_time)).check(matches(not(isDisplayed())));
- }
-
- @Test
- @MediumTest
- public void testClickNegativeButtonShouldCancel() {
- showDialog();
- clickNegativeButton();
- verify(mController).onDownloadLaterDialogCanceled();
- }
-
- @Test
- @MediumTest
- public void testSelectFromOnWifiToDownloadNow() {
- showDialog();
-
- TestThreadUtils.runOnUiThreadBlocking(() -> {
- // Verify the initial selection of the dialog. The controller should not get an event
- // for the initial setup.
- RadioButtonWithDescription onWifiButton =
- (RadioButtonWithDescription) getDownloadLaterDialogView().findViewById(
- org.chromium.chrome.browser.download.R.id.on_wifi);
- Assert.assertTrue(onWifiButton.isChecked());
-
- // Simulate a click on another radio button, the event should be propagated to
- // controller.
- RadioButtonWithDescription downloadNowButton =
- getDownloadLaterDialogView().findViewById(R.id.download_now);
- Assert.assertNotNull(downloadNowButton);
- downloadNowButton.setChecked(true);
- getDownloadLaterDialogView().onCheckedChanged(null, -1);
- });
-
- clickPositiveButton();
- verify(mController)
- .onDownloadLaterDialogComplete(
- eq(DownloadLaterDialogChoice.DOWNLOAD_NOW), eq(INVALID_START_TIME));
- }
-
- @Test
- @MediumTest
- public void testSelectFromOnWifiToDownloadLater() {
- showDialog();
-
- TestThreadUtils.runOnUiThreadBlocking(() -> {
- RadioButtonWithDescription downloadLaterButton =
- getDownloadLaterDialogView().findViewById(R.id.choose_date_time);
- Assert.assertNotNull(downloadLaterButton);
- downloadLaterButton.setChecked(true);
- getDownloadLaterDialogView().onCheckedChanged(null, -1);
- });
-
- assertPositiveButtonText("Next");
- assertShowAgainCheckBox(false, View.VISIBLE, false);
-
- clickPositiveButton();
- verify(mController, times(0)).onDownloadLaterDialogComplete(anyInt(), anyLong());
- verify(mDateTimePicker).showDialog(any(), any(), any());
- }
-
- @Test
- @MediumTest
- public void testSelectFromDownloadLaterToDownloadNow() {
- showDialog();
- TestThreadUtils.runOnUiThreadBlocking(() -> {
- RadioButtonWithDescription downloadLaterButton =
- getDownloadLaterDialogView().findViewById(R.id.choose_date_time);
- Assert.assertNotNull(downloadLaterButton);
- downloadLaterButton.setChecked(true);
- getDownloadLaterDialogView().onCheckedChanged(null, -1);
-
- RadioButtonWithDescription onWifiButton =
- (RadioButtonWithDescription) getDownloadLaterDialogView().findViewById(
- org.chromium.chrome.browser.download.R.id.on_wifi);
- onWifiButton.setChecked(true);
- getDownloadLaterDialogView().onCheckedChanged(null, -1);
- });
-
- assertPositiveButtonText("Done");
- }
-}
diff --git a/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/DownloadDialogBridge.java b/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/DownloadDialogBridge.java
index e8d18b5..57f262ae 100644
--- a/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/DownloadDialogBridge.java
+++ b/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/DownloadDialogBridge.java
@@ -227,13 +227,10 @@
private void showDownloadLaterDialog() {
assert mPrefService != null;
- @DownloadLaterPromptStatus
- int promptStatus = mPrefService.getInteger(Pref.DOWNLOAD_LATER_PROMPT_STATUS);
PropertyModel.Builder builder =
new PropertyModel.Builder(DownloadLaterDialogProperties.ALL_KEYS)
.with(DownloadLaterDialogProperties.CONTROLLER, mDownloadLaterDialog)
.with(DownloadLaterDialogProperties.INITIAL_CHOICE, mDownloadLaterChoice)
- .with(DownloadLaterDialogProperties.DONT_SHOW_AGAIN_SELECTION, promptStatus)
.with(DownloadLaterDialogProperties.SUBTITLE_TEXT,
getDownloadLaterDialogSubtitle())
.with(DownloadLaterDialogProperties.SHOW_DATE_TIME_PICKER_OPTION,
diff --git a/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/DownloadDialogBridgeUnitTest.java b/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/DownloadDialogBridgeUnitTest.java
index 21f13fd4..86d6f7aa 100644
--- a/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/DownloadDialogBridgeUnitTest.java
+++ b/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/DownloadDialogBridgeUnitTest.java
@@ -40,7 +40,6 @@
import org.chromium.chrome.browser.download.dialogs.DownloadLaterDialogProperties;
import org.chromium.chrome.browser.download.dialogs.DownloadLocationDialogCoordinator;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
-import org.chromium.chrome.browser.preferences.Pref;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.components.prefs.PrefService;
import org.chromium.net.ConnectionType;
@@ -107,8 +106,6 @@
mBridge =
new DownloadDialogBridge(FAKE_NATIVE_HOLDER, mDownloadLaterDialog, mLocationDialog);
mBridge.setPrefServiceForTesting(mPrefService);
- when(mPrefService.getInteger(Pref.DOWNLOAD_LATER_PROMPT_STATUS))
- .thenReturn(DownloadLaterPromptStatus.SHOW_INITIAL);
}
@After
diff --git a/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/dialogs/DownloadLaterDialogCoordinator.java b/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/dialogs/DownloadLaterDialogCoordinator.java
index d05b2f9..82c2e6eb 100644
--- a/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/dialogs/DownloadLaterDialogCoordinator.java
+++ b/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/dialogs/DownloadLaterDialogCoordinator.java
@@ -13,7 +13,6 @@
import org.chromium.chrome.browser.download.DownloadLaterMetrics.DownloadLaterUiEvent;
import org.chromium.chrome.browser.download.R;
import org.chromium.chrome.browser.download.dialogs.DownloadDateTimePickerDialogProperties.State;
-import org.chromium.chrome.browser.preferences.Pref;
import org.chromium.components.prefs.PrefService;
import org.chromium.ui.modaldialog.DialogDismissalCause;
import org.chromium.ui.modaldialog.ModalDialogManager;
@@ -173,26 +172,14 @@
private void notifyComplete(long time) {
assert mController != null;
- maybeUpdatePromptStatus();
mController.onDownloadLaterDialogComplete(mDownloadLaterChoice, time);
}
private void notifyCancel() {
assert mController != null;
- maybeUpdatePromptStatus();
mController.onDownloadLaterDialogCanceled();
}
- private void maybeUpdatePromptStatus() {
- assert mCustomView != null;
- assert mPrefService != null;
- Integer promptStatus = mCustomView.getPromptStatus();
- if (promptStatus != null) {
- mPrefService.setInteger(
- Pref.DOWNLOAD_LATER_PROMPT_STATUS, mCustomView.getPromptStatus());
- }
- }
-
// ModalDialogProperties.Controller implementation.
@Override
public void onClick(PropertyModel model, int buttonType) {
diff --git a/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/dialogs/DownloadLaterDialogView.java b/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/dialogs/DownloadLaterDialogView.java
index c8356204..32ea5f0 100644
--- a/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/dialogs/DownloadLaterDialogView.java
+++ b/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/dialogs/DownloadLaterDialogView.java
@@ -22,7 +22,6 @@
import androidx.annotation.Nullable;
-import org.chromium.chrome.browser.download.DownloadLaterPromptStatus;
import org.chromium.chrome.browser.download.R;
import org.chromium.components.browser_ui.widget.RadioButtonWithDescription;
import org.chromium.ui.modelutil.PropertyKey;
@@ -55,9 +54,6 @@
view.setController(model.get(DownloadLaterDialogProperties.CONTROLLER));
} else if (propertyKey == DownloadLaterDialogProperties.INITIAL_CHOICE) {
view.setChoice(model.get(DownloadLaterDialogProperties.INITIAL_CHOICE));
- } else if (propertyKey == DownloadLaterDialogProperties.DONT_SHOW_AGAIN_SELECTION) {
- view.setCheckbox(
- model.get(DownloadLaterDialogProperties.DONT_SHOW_AGAIN_SELECTION));
} else if (propertyKey == DownloadLaterDialogProperties.DONT_SHOW_AGAIN_DISABLED) {
view.setCheckboxEnabled(
!model.get(DownloadLaterDialogProperties.DONT_SHOW_AGAIN_DISABLED));
@@ -131,22 +127,10 @@
mDownloadLater.setVisibility(showDateTimePicker ? View.VISIBLE : View.GONE);
}
- void setCheckbox(@DownloadLaterPromptStatus int promptStatus) {
- mCheckBox.setVisibility(VISIBLE);
- mCheckBox.setChecked(promptStatus == DownloadLaterPromptStatus.DONT_SHOW);
- }
-
void setCheckboxEnabled(boolean enabled) {
mCheckBox.setEnabled(enabled);
}
- Integer getPromptStatus() {
- if (mCheckBox.getVisibility() == View.GONE || !mCheckBox.isEnabled()) return null;
-
- return mCheckBox.isChecked() ? DownloadLaterPromptStatus.DONT_SHOW
- : DownloadLaterPromptStatus.SHOW_PREFERENCE;
- }
-
void setSubtitle(@Nullable CharSequence subtitle) {
mSubtitle.setText(TextUtils.isEmpty(subtitle) ? "" : subtitle);
}
diff --git a/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/settings/DownloadSettings.java b/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/settings/DownloadSettings.java
index 70297fa..f0dcbd0 100644
--- a/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/settings/DownloadSettings.java
+++ b/chrome/browser/download/android/java/src/org/chromium/chrome/browser/download/settings/DownloadSettings.java
@@ -12,11 +12,8 @@
import androidx.preference.PreferenceFragmentCompat;
import org.chromium.chrome.browser.download.DownloadDialogBridge;
-import org.chromium.chrome.browser.download.DownloadLaterPromptStatus;
import org.chromium.chrome.browser.download.DownloadPromptStatus;
import org.chromium.chrome.browser.download.R;
-import org.chromium.chrome.browser.flags.ChromeFeatureList;
-import org.chromium.chrome.browser.preferences.Pref;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.settings.ChromeManagedPreferenceDelegate;
import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
@@ -31,12 +28,10 @@
public class DownloadSettings
extends PreferenceFragmentCompat implements Preference.OnPreferenceChangeListener {
public static final String PREF_LOCATION_CHANGE = "location_change";
- public static final String PREF_DOWNLOAD_LATER_PROMPT_ENABLED = "download_later_prompt_enabled";
public static final String PREF_LOCATION_PROMPT_ENABLED = "location_prompt_enabled";
private PrefService mPrefService;
private DownloadLocationPreference mLocationChangePref;
- private ChromeSwitchPreference mDownloadLaterPromptEnabledPref;
private ChromeSwitchPreference mLocationPromptEnabledPref;
private ManagedPreferenceDelegate mLocationPromptEnabledPrefDelegate;
@@ -46,15 +41,7 @@
SettingsUtils.addPreferencesFromResource(this, R.xml.download_preferences);
mPrefService = UserPrefs.get(Profile.getLastUsedRegularProfile());
- mDownloadLaterPromptEnabledPref =
- (ChromeSwitchPreference) findPreference(PREF_DOWNLOAD_LATER_PROMPT_ENABLED);
- mDownloadLaterPromptEnabledPref.setOnPreferenceChangeListener(this);
-
boolean locationManaged = DownloadDialogBridge.isLocationDialogManaged();
- if (locationManaged || !ChromeFeatureList.isEnabled(ChromeFeatureList.DOWNLOAD_LATER)) {
- getPreferenceScreen().removePreference(
- findPreference(PREF_DOWNLOAD_LATER_PROMPT_ENABLED));
- }
mLocationPromptEnabledPref =
(ChromeSwitchPreference) findPreference(PREF_LOCATION_PROMPT_ENABLED);
@@ -91,14 +78,6 @@
private void updateDownloadSettings() {
mLocationChangePref.updateSummary();
- if (ChromeFeatureList.isEnabled(ChromeFeatureList.DOWNLOAD_LATER)) {
- @DownloadLaterPromptStatus
- int downloadLaterPromptStatus =
- mPrefService.getInteger(Pref.DOWNLOAD_LATER_PROMPT_STATUS);
- mDownloadLaterPromptEnabledPref.setChecked(
- !(downloadLaterPromptStatus == DownloadLaterPromptStatus.DONT_SHOW));
- }
-
if (DownloadDialogBridge.isLocationDialogManaged()) {
// Location prompt can be controlled by the enterprise policy.
mLocationPromptEnabledPref.setChecked(
@@ -115,23 +94,7 @@
// Preference.OnPreferenceChangeListener implementation.
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
- if (PREF_DOWNLOAD_LATER_PROMPT_ENABLED.equals(preference.getKey())) {
- if (!ChromeFeatureList.isEnabled(ChromeFeatureList.DOWNLOAD_LATER)) return false;
- @DownloadLaterPromptStatus
- int downloadLaterPromptStatus =
- mPrefService.getInteger(Pref.DOWNLOAD_LATER_PROMPT_STATUS);
- if (!(boolean) newValue) {
- mPrefService.setInteger(
- Pref.DOWNLOAD_LATER_PROMPT_STATUS, DownloadLaterPromptStatus.DONT_SHOW);
- return true;
- }
-
- // Only update if the download later dialog has been shown before.
- if (downloadLaterPromptStatus != DownloadLaterPromptStatus.SHOW_INITIAL) {
- mPrefService.setInteger(Pref.DOWNLOAD_LATER_PROMPT_STATUS,
- DownloadLaterPromptStatus.SHOW_PREFERENCE);
- }
- } else if (PREF_LOCATION_PROMPT_ENABLED.equals(preference.getKey())) {
+ if (PREF_LOCATION_PROMPT_ENABLED.equals(preference.getKey())) {
if ((boolean) newValue) {
// Only update if the download location dialog has been shown before.
if (DownloadDialogBridge.getPromptForDownloadAndroid()
diff --git a/chrome/browser/download/chrome_download_manager_delegate_unittest.cc b/chrome/browser/download/chrome_download_manager_delegate_unittest.cc
index 3fe5e62..e1b010a 100644
--- a/chrome/browser/download/chrome_download_manager_delegate_unittest.cc
+++ b/chrome/browser/download/chrome_download_manager_delegate_unittest.cc
@@ -331,12 +331,6 @@
#if BUILDFLAG(IS_ANDROID)
pref_service_->SetInteger(prefs::kPromptForDownloadAndroid,
static_cast<int>(DownloadPromptStatus::DONT_SHOW));
-
- if (base::FeatureList::IsEnabled(download::features::kDownloadLater)) {
- pref_service_->SetInteger(
- prefs::kDownloadLaterPromptStatus,
- static_cast<int>(DownloadLaterPromptStatus::kDontShow));
- }
#endif
}
diff --git a/chrome/browser/download/download_prefs.cc b/chrome/browser/download/download_prefs.cc
index 06698e1..5bf18835 100644
--- a/chrome/browser/download/download_prefs.cc
+++ b/chrome/browser/download/download_prefs.cc
@@ -202,12 +202,6 @@
prompt_for_download_android_.Init(prefs::kPromptForDownloadAndroid, prefs);
RecordDownloadPromptStatus(
static_cast<DownloadPromptStatus>(*prompt_for_download_android_));
- if (base::FeatureList::IsEnabled(download::features::kDownloadLater)) {
- prompt_for_download_later_.Init(prefs::kDownloadLaterPromptStatus, prefs);
- RecordDownloadLaterPromptStatus(
- static_cast<DownloadLaterPromptStatus>(*prompt_for_download_later_));
- }
-
#endif
download_path_.Init(prefs::kDownloadDefaultDirectory, prefs);
save_file_path_.Init(prefs::kSaveFileDefaultDirectory, prefs);
@@ -309,13 +303,6 @@
static_cast<int>(download_prompt_status),
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
- if (base::FeatureList::IsEnabled(download::features::kDownloadLater)) {
- registry->RegisterIntegerPref(
- prefs::kDownloadLaterPromptStatus,
- static_cast<int>(DownloadLaterPromptStatus::kShowInitial),
- user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
- }
-
registry->RegisterBooleanPref(prefs::kShowMissingSdCardErrorAndroid, true);
#endif
}
@@ -410,27 +397,10 @@
}
bool DownloadPrefs::PromptDownloadLater() const {
-#if BUILDFLAG(IS_ANDROID)
- if (prompt_for_download_.IsManaged())
- return false;
-
- if (base::FeatureList::IsEnabled(download::features::kDownloadLater)) {
- return *prompt_for_download_later_ !=
- static_cast<int>(DownloadLaterPromptStatus::kDontShow);
- }
-#endif
-
return false;
}
bool DownloadPrefs::HasDownloadLaterPromptShown() const {
-#if BUILDFLAG(IS_ANDROID)
- if (base::FeatureList::IsEnabled(download::features::kDownloadLater)) {
- return *prompt_for_download_later_ !=
- static_cast<int>(DownloadLaterPromptStatus::kShowInitial);
- }
-#endif
-
return false;
}
diff --git a/chrome/browser/download/download_prefs.h b/chrome/browser/download/download_prefs.h
index 3be27e2..d8c3ce0 100644
--- a/chrome/browser/download/download_prefs.h
+++ b/chrome/browser/download/download_prefs.h
@@ -158,7 +158,6 @@
BooleanPrefMember prompt_for_download_;
#if BUILDFLAG(IS_ANDROID)
IntegerPrefMember prompt_for_download_android_;
- IntegerPrefMember prompt_for_download_later_;
#endif
FilePathPrefMember download_path_;
diff --git a/chrome/browser/download/download_prefs_unittest.cc b/chrome/browser/download/download_prefs_unittest.cc
index 39b00ee..14726e00 100644
--- a/chrome/browser/download/download_prefs_unittest.cc
+++ b/chrome/browser/download/download_prefs_unittest.cc
@@ -60,11 +60,6 @@
content::BrowserTaskEnvironment task_environment_;
base::HistogramTester histogram_tester;
-#if BUILDFLAG(IS_ANDROID)
- base::test::ScopedFeatureList feature_list;
- feature_list.InitAndEnableFeature(download::features::kDownloadLater);
-#endif // BUILDFLAG(IS_ANDROID)
-
// Download prefs are registered when creating the profile.
TestingProfile profile;
DownloadPrefs prefs(&profile);
@@ -73,18 +68,10 @@
// Download prompt prefs should be registered correctly.
histogram_tester.ExpectBucketCount("MobileDownload.DownloadPromptStatus",
DownloadPromptStatus::SHOW_INITIAL, 1);
- histogram_tester.ExpectBucketCount("MobileDownload.DownloadLaterPromptStatus",
- DownloadPromptStatus::SHOW_INITIAL, 1);
int prompt_status = profile.GetTestingPrefService()->GetInteger(
prefs::kPromptForDownloadAndroid);
EXPECT_EQ(prompt_status,
static_cast<int>(DownloadPromptStatus::SHOW_INITIAL));
-
- int download_later_prompt_status =
- profile.GetTestingPrefService()->GetInteger(
- prefs::kDownloadLaterPromptStatus);
- EXPECT_EQ(download_later_prompt_status,
- static_cast<int>(DownloadLaterPromptStatus::kShowInitial));
#endif // BUILDFLAG(IS_ANDROID)
}
@@ -686,36 +673,9 @@
#endif // BUILDFLAG(IS_CHROMEOS)
#if BUILDFLAG(IS_ANDROID)
-TEST(DownloadPrefsTest, DownloadLaterPrefs) {
- base::test::ScopedFeatureList feature_list;
- feature_list.InitAndEnableFeature(download::features::kDownloadLater);
-
- content::BrowserTaskEnvironment task_environment_;
- TestingProfile profile;
- DownloadPrefs prefs(&profile);
-
- EXPECT_TRUE(prefs.PromptDownloadLater());
- EXPECT_FALSE(prefs.HasDownloadLaterPromptShown());
-
- profile.GetPrefs()->SetInteger(
- prefs::kDownloadLaterPromptStatus,
- static_cast<int>(DownloadLaterPromptStatus::kShowPreference));
- EXPECT_TRUE(prefs.PromptDownloadLater());
- EXPECT_TRUE(prefs.HasDownloadLaterPromptShown());
-
- profile.GetPrefs()->SetInteger(
- prefs::kDownloadLaterPromptStatus,
- static_cast<int>(DownloadLaterPromptStatus::kDontShow));
- EXPECT_FALSE(prefs.PromptDownloadLater());
- EXPECT_TRUE(prefs.HasDownloadLaterPromptShown());
-}
-
-// Verfies the returned value of PromptForDownload() and PromptDownloadLater()
+// Verfies the returned value of PromptForDownload()
// when prefs::kPromptForDownload is managed by enterprise policy,
TEST(DownloadPrefsTest, ManagedPromptForDownload) {
- base::test::ScopedFeatureList feature_list;
- feature_list.InitAndEnableFeature(download::features::kDownloadLater);
-
content::BrowserTaskEnvironment task_environment_;
TestingProfile profile;
profile.GetTestingPrefService()->SetManagedPref(
@@ -723,17 +683,12 @@
DownloadPrefs prefs(&profile);
profile.GetPrefs()->SetInteger(
- prefs::kDownloadLaterPromptStatus,
- static_cast<int>(DownloadLaterPromptStatus::kShowPreference));
- profile.GetPrefs()->SetInteger(
prefs::kPromptForDownloadAndroid,
static_cast<int>(DownloadPromptStatus::DONT_SHOW));
- EXPECT_FALSE(prefs.PromptDownloadLater());
EXPECT_TRUE(prefs.PromptForDownload());
profile.GetTestingPrefService()->SetManagedPref(
prefs::kPromptForDownload, std::make_unique<base::Value>(false));
- EXPECT_FALSE(prefs.PromptDownloadLater());
EXPECT_FALSE(prefs.PromptForDownload());
}
diff --git a/chrome/browser/download/download_prompt_status.h b/chrome/browser/download/download_prompt_status.h
index c77f6fa..dde912a 100644
--- a/chrome/browser/download/download_prompt_status.h
+++ b/chrome/browser/download/download_prompt_status.h
@@ -15,14 +15,4 @@
MAX_VALUE
};
-// The status of the download later prompt.
-// A Java counterpart will be generated for this enum.
-// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.download
-enum class DownloadLaterPromptStatus {
- kShowInitial, // Show the prompt because it hasn't been shown before.
- kShowPreference, // Show the prompt because user indicated preference.
- kDontShow, // Don't show the prompt because user indicated preference.
- kMaxValue = kDontShow
-};
-
#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PROMPT_STATUS_H_
diff --git a/chrome/browser/download/download_stats.cc b/chrome/browser/download/download_stats.cc
index 1fbfb6a4..2b13d1a1 100644
--- a/chrome/browser/download/download_stats.cc
+++ b/chrome/browser/download/download_stats.cc
@@ -99,12 +99,6 @@
base::UmaHistogramEnumeration("MobileDownload.DownloadPromptStatus", status,
DownloadPromptStatus::MAX_VALUE);
}
-
-void RecordDownloadLaterPromptStatus(DownloadLaterPromptStatus status) {
- base::UmaHistogramEnumeration("MobileDownload.DownloadLaterPromptStatus",
- status);
-}
-
#endif // BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(IS_CHROMEOS)
diff --git a/chrome/browser/download/download_stats.h b/chrome/browser/download/download_stats.h
index f2ef18d..9e3615d 100644
--- a/chrome/browser/download/download_stats.h
+++ b/chrome/browser/download/download_stats.h
@@ -175,9 +175,6 @@
#if BUILDFLAG(IS_ANDROID)
// Records whether the download dialog is shown to the user.
void RecordDownloadPromptStatus(DownloadPromptStatus status);
-
-// Records whether the download later dialog is shown to the user.
-void RecordDownloadLaterPromptStatus(DownloadLaterPromptStatus status);
#endif // BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(IS_CHROMEOS)
diff --git a/chrome/browser/download/download_stats_unittest.cc b/chrome/browser/download/download_stats_unittest.cc
index f49ed7d..429a828 100644
--- a/chrome/browser/download/download_stats_unittest.cc
+++ b/chrome/browser/download/download_stats_unittest.cc
@@ -17,9 +17,6 @@
constexpr char kDownloadPromptStatusHistogram[] =
"MobileDownload.DownloadPromptStatus";
-constexpr char kDownloadLaterPromptStatusHistogram[] =
- "MobileDownload.DownloadLaterPromptStatus";
-
TEST(DownloadStatsTest, RecordDownloadPromptStatus) {
base::HistogramTester histogram_tester;
RecordDownloadPromptStatus(DownloadPromptStatus::SHOW_INITIAL);
@@ -33,15 +30,6 @@
DownloadPromptStatus::DONT_SHOW, 1);
histogram_tester.ExpectTotalCount(kDownloadPromptStatusHistogram, 3);
}
-
-TEST(DownloadStatsTest, RecordDownloadLaterPromptStatus) {
- base::HistogramTester histogram_tester;
- RecordDownloadLaterPromptStatus(DownloadLaterPromptStatus::kDontShow);
- histogram_tester.ExpectBucketCount(kDownloadLaterPromptStatusHistogram,
- DownloadLaterPromptStatus::kDontShow, 1);
- histogram_tester.ExpectTotalCount(kDownloadLaterPromptStatusHistogram, 1);
-}
-
#endif // BUILDFLAG(IS_ANDROID)
TEST(DownloadStatsTest, RecordDownloadCancelReason) {
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 0905a4a..d25d2e9 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -766,6 +766,12 @@
const char kPrivacySandboxPreferencesReconciled[] =
"privacy_sandbox.preferences_reconciled";
+#if BUILDFLAG(IS_ANDROID)
+// Deprecated 06/2022.
+const char kDownloadLaterPromptStatus[] =
+ "download.download_later_prompt_status";
+#endif // BUILDFLAG(IS_ANDROID)
+
// Register local state used only for migration (clearing or moving to a new
// key).
void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) {
@@ -1002,6 +1008,10 @@
#endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
registry->RegisterBooleanPref(kPrivacySandboxPreferencesReconciled, false);
+
+#if BUILDFLAG(IS_ANDROID)
+ registry->RegisterIntegerPref(kDownloadLaterPromptStatus, 0);
+#endif // BUILDFLAG(IS_ANDROID)
}
} // namespace
@@ -1954,6 +1964,7 @@
#if BUILDFLAG(IS_ANDROID)
// Added 06/2022.
syncer::MigrateSyncRequestedPrefPostMice(profile_prefs);
+ profile_prefs->ClearPref(kDownloadLaterPromptStatus);
#endif // BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 1a45f9a4..bb0d5d04 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -1822,10 +1822,6 @@
// ask the user where they want to download the file (only for Android).
const char kPromptForDownloadAndroid[] = "download.prompt_for_download_android";
-// The prompt status for the download later dialog.
-const char kDownloadLaterPromptStatus[] =
- "download.download_later_prompt_status";
-
// Boolean which specifies whether we should display the missing SD card error.
// This is only applicable for Android.
const char kShowMissingSdCardErrorAndroid[] =
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index f97c682..37acb43 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -601,7 +601,6 @@
#endif
#if BUILDFLAG(IS_ANDROID)
extern const char kPromptForDownloadAndroid[];
-extern const char kDownloadLaterPromptStatus[];
extern const char kShowMissingSdCardErrorAndroid[];
extern const char kIncognitoReauthenticationForAndroid[];
#endif