Commit 0c52f287 authored by Andrey Zaytsev's avatar Andrey Zaytsev Committed by Commit Bot

Safety check on Android: only show the Settings element when the Password check flag is on

This prevents users from only enabling the #safety-check-android flag and getting a crash on the Safety check screen because the required #password-check flag is disabled.
Note: this is only possible if the user changes the flags manually; the Finch config never has the Safety check flag without the Password check one.

Bug: 1070620, 1120824, 1122473
Change-Id: I9720a5fcee845648fb7d617926395c1f855356d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2379898Reviewed-by: default avatarNatalie Chouinard <chouinard@chromium.org>
Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Commit-Queue: Andrey Zaytsev <andzaytsev@google.com>
Auto-Submit: Andrey Zaytsev <andzaytsev@google.com>
Cr-Commit-Position: refs/heads/master@{#803034}
parent b50294c8
...@@ -222,8 +222,9 @@ public class MainSettings extends PreferenceFragmentCompat ...@@ -222,8 +222,9 @@ public class MainSettings extends PreferenceFragmentCompat
getPreferenceScreen().removePreference(findPreference(PREF_DOWNLOADS)); getPreferenceScreen().removePreference(findPreference(PREF_DOWNLOADS));
} }
// Only display the Safety check section if a corresponding flag is enabled. // Only show the Safety check section if both Safety check and Password check flags are on.
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.SAFETY_CHECK_ANDROID)) { if (!ChromeFeatureList.isEnabled(ChromeFeatureList.SAFETY_CHECK_ANDROID)
|| !ChromeFeatureList.isEnabled(ChromeFeatureList.PASSWORD_CHECK)) {
getPreferenceScreen().removePreference(findPreference(PREF_SAFETY_CHECK)); getPreferenceScreen().removePreference(findPreference(PREF_SAFETY_CHECK));
} else { } else {
findPreference(PREF_SAFETY_CHECK) findPreference(PREF_SAFETY_CHECK)
......
...@@ -57,6 +57,7 @@ import org.chromium.chrome.browser.tracing.settings.DeveloperSettings; ...@@ -57,6 +57,7 @@ import org.chromium.chrome.browser.tracing.settings.DeveloperSettings;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.ChromeRenderTestRule; import org.chromium.chrome.test.util.ChromeRenderTestRule;
import org.chromium.chrome.test.util.browser.Features; import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.Features.DisableFeatures;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
import org.chromium.chrome.test.util.browser.sync.SyncTestUtil; import org.chromium.chrome.test.util.browser.sync.SyncTestUtil;
import org.chromium.components.browser_ui.site_settings.SiteSettings; import org.chromium.components.browser_ui.site_settings.SiteSettings;
...@@ -258,12 +259,22 @@ public class MainSettingsFragmentTest { ...@@ -258,12 +259,22 @@ public class MainSettingsFragmentTest {
@Test @Test
@SmallTest @SmallTest
@EnableFeatures(ChromeFeatureList.SAFETY_CHECK_ANDROID) @EnableFeatures({ChromeFeatureList.SAFETY_CHECK_ANDROID, ChromeFeatureList.PASSWORD_CHECK})
public void testSafetyCheckFlagOn() { public void testSafetyCheckFlagOn() {
launchSettingsActivity(); launchSettingsActivity();
assertSettingsExists(MainSettings.PREF_SAFETY_CHECK, SafetyCheckSettingsFragment.class); assertSettingsExists(MainSettings.PREF_SAFETY_CHECK, SafetyCheckSettingsFragment.class);
} }
@Test
@SmallTest
@EnableFeatures(ChromeFeatureList.SAFETY_CHECK_ANDROID)
@DisableFeatures(ChromeFeatureList.PASSWORD_CHECK)
public void testSafetyCheckWithoutPasswordCheck() {
launchSettingsActivity();
Assert.assertNull("Safety check section should be hidden",
mMainSettings.findPreference(MainSettings.PREF_SAFETY_CHECK));
}
@Test @Test
@SmallTest @SmallTest
@EnableFeatures(ChromeFeatureList.SAFE_BROWSING_SECURITY_SECTION_UI) @EnableFeatures(ChromeFeatureList.SAFE_BROWSING_SECURITY_SECTION_UI)
......
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