Commit e945ccef authored by Ioana Pandele's avatar Ioana Pandele Committed by Commit Bot

[Android] Update leak check switch

- Add a description
- Change string
- Change order
- Only display for signed in users

Bug: 986322
Change-Id: I47e7320f66caad5587348c4e63d0e565c54bf68e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1776541
Commit-Queue: Ioana Pandele <ioanap@chromium.org>
Reviewed-by: default avatarFriedrich [CET] <fhorschig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692265}
parent ebd771be
...@@ -34,6 +34,7 @@ import org.chromium.chrome.browser.preferences.PrefServiceBridge; ...@@ -34,6 +34,7 @@ import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.preferences.PreferencesLauncher; import org.chromium.chrome.browser.preferences.PreferencesLauncher;
import org.chromium.chrome.browser.preferences.SearchUtils; import org.chromium.chrome.browser.preferences.SearchUtils;
import org.chromium.chrome.browser.preferences.TextMessagePreference; import org.chromium.chrome.browser.preferences.TextMessagePreference;
import org.chromium.components.signin.ChromeSigninController;
import org.chromium.ui.text.SpanApplier; import org.chromium.ui.text.SpanApplier;
import java.util.Locale; import java.util.Locale;
...@@ -72,8 +73,8 @@ public class SavePasswordsPreferences ...@@ -72,8 +73,8 @@ public class SavePasswordsPreferences
private static final String PREF_KEY_SAVED_PASSWORDS_NO_TEXT = "saved_passwords_no_text"; private static final String PREF_KEY_SAVED_PASSWORDS_NO_TEXT = "saved_passwords_no_text";
private static final int ORDER_SWITCH = 0; private static final int ORDER_SWITCH = 0;
private static final int ORDER_AUTO_SIGNIN_CHECKBOX = 1; private static final int ORDER_AUTO_LEAK_DETECTION_SWITCH = 1;
private static final int ORDER_AUTO_LEAK_DETECTION_SWITCH = 2; private static final int ORDER_AUTO_SIGNIN_CHECKBOX = 2;
private static final int ORDER_MANAGE_ACCOUNT_LINK = 3; private static final int ORDER_MANAGE_ACCOUNT_LINK = 3;
private static final int ORDER_SAVED_PASSWORDS = 4; private static final int ORDER_SAVED_PASSWORDS = 4;
private static final int ORDER_EXCEPTIONS = 5; private static final int ORDER_EXCEPTIONS = 5;
...@@ -209,8 +210,13 @@ public class SavePasswordsPreferences ...@@ -209,8 +210,13 @@ public class SavePasswordsPreferences
getPreferenceScreen().removeAll(); getPreferenceScreen().removeAll();
if (mSearchQuery == null) { if (mSearchQuery == null) {
createSavePasswordsSwitch(); createSavePasswordsSwitch();
ChromeSigninController signInController = ChromeSigninController.get();
if (signInController != null && signInController.isSignedIn()) {
createAutoLeakDetectionSwitch();
}
createAutoSignInCheckbox(); createAutoSignInCheckbox();
createAutoLeakDetectionSwitch();
} }
PasswordManagerHandlerProvider.getInstance() PasswordManagerHandlerProvider.getInstance()
.getPasswordManagerHandler() .getPasswordManagerHandler()
...@@ -440,9 +446,9 @@ public class SavePasswordsPreferences ...@@ -440,9 +446,9 @@ public class SavePasswordsPreferences
mAutoLeakDetectionSwitch = new ChromeSwitchPreference(getStyledContext(), null); mAutoLeakDetectionSwitch = new ChromeSwitchPreference(getStyledContext(), null);
mAutoLeakDetectionSwitch.setKey(PREF_LEAK_DETECTION_SWITCH); mAutoLeakDetectionSwitch.setKey(PREF_LEAK_DETECTION_SWITCH);
// TODO(crbug.com/986317): Add description and update title.
mAutoLeakDetectionSwitch.setTitle(R.string.passwords_leak_detection_switch_title); mAutoLeakDetectionSwitch.setTitle(R.string.passwords_leak_detection_switch_title);
mAutoLeakDetectionSwitch.setOrder(ORDER_AUTO_LEAK_DETECTION_SWITCH); mAutoLeakDetectionSwitch.setOrder(ORDER_AUTO_LEAK_DETECTION_SWITCH);
mAutoLeakDetectionSwitch.setSummary(R.string.passwords_leak_detection_switch_description);
mAutoLeakDetectionSwitch.setOnPreferenceChangeListener((preference, newValue) -> { mAutoLeakDetectionSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
PrefServiceBridge.getInstance().setPasswordLeakDetectionEnabled((boolean) newValue); PrefServiceBridge.getInstance().setPasswordLeakDetectionEnabled((boolean) newValue);
return true; return true;
......
...@@ -556,9 +556,12 @@ CHAR-LIMIT guidelines: ...@@ -556,9 +556,12 @@ CHAR-LIMIT guidelines:
<message name="IDS_PASSWORDS_AUTO_SIGNIN_DESCRIPTION" desc="Text under 'Auto sign-in' checkbox"> <message name="IDS_PASSWORDS_AUTO_SIGNIN_DESCRIPTION" desc="Text under 'Auto sign-in' checkbox">
Automatically sign in to websites using stored credentials. When the feature is off, you’ll be asked for verification every time before signing in to a website. Automatically sign in to websites using stored credentials. When the feature is off, you’ll be asked for verification every time before signing in to a website.
</message> </message>
<message name="IDS_PASSWORDS_LEAK_DETECTION_SWITCH_TITLE" desc="Title for the switch togglingwhether Chrome should check that entered credentials have been part of a leak."> <message name="IDS_PASSWORDS_LEAK_DETECTION_SWITCH_TITLE" desc="Title for the switch toggling whether Chrome should check that entered credentials have been part of a leak.">
Check password safety Check password safety
</message> </message>
<message name="IDS_PASSWORDS_LEAK_DETECTION_SWITCH_DESCRIPTION" desc="Description for the switch toggling whether Chrome should check that entered credentials have been part of a leak.">
Warns you if a password you use was part of a data breach
</message>
<message name="IDS_SECTION_SAVED_PASSWORDS_EXCEPTIONS" desc="Header for the list of websites for which user selected to never save passwords. [CHAR-LIMIT=32]"> <message name="IDS_SECTION_SAVED_PASSWORDS_EXCEPTIONS" desc="Header for the list of websites for which user selected to never save passwords. [CHAR-LIMIT=32]">
Never saved Never saved
</message> </message>
......
feb1d516f50af8ba55ff6753762220dca3ab18ab 4ce3fc0c7ec4f132ea462f09e7f2986266c05000
\ No newline at end of file \ No newline at end of file
...@@ -540,6 +540,9 @@ public class SavePasswordsPreferencesTest { ...@@ -540,6 +540,9 @@ public class SavePasswordsPreferencesTest {
@Feature({"Preferences"}) @Feature({"Preferences"})
@Features.EnableFeatures({SavePasswordsPreferences.PASSWORD_LEAK_DETECTION_FEATURE}) @Features.EnableFeatures({SavePasswordsPreferences.PASSWORD_LEAK_DETECTION_FEATURE})
public void testLeakDetectionSwitchEnabled() throws Exception { public void testLeakDetectionSwitchEnabled() throws Exception {
// The switch is only displayed for signed in users.
ChromeSigninController.get().setSignedInAccountName("Test Account");
TestThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> { PrefServiceBridge.getInstance().setPasswordLeakDetectionEnabled(true); }); () -> { PrefServiceBridge.getInstance().setPasswordLeakDetectionEnabled(true); });
...@@ -566,6 +569,9 @@ public class SavePasswordsPreferencesTest { ...@@ -566,6 +569,9 @@ public class SavePasswordsPreferencesTest {
@Feature({"Preferences"}) @Feature({"Preferences"})
@Features.EnableFeatures({SavePasswordsPreferences.PASSWORD_LEAK_DETECTION_FEATURE}) @Features.EnableFeatures({SavePasswordsPreferences.PASSWORD_LEAK_DETECTION_FEATURE})
public void testLeakDetectionSwitchDisabled() throws Exception { public void testLeakDetectionSwitchDisabled() throws Exception {
// The switch is only displayed for signed in users.
ChromeSigninController.get().setSignedInAccountName("Test Account");
TestThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> { PrefServiceBridge.getInstance().setPasswordLeakDetectionEnabled(false); }); () -> { PrefServiceBridge.getInstance().setPasswordLeakDetectionEnabled(false); });
final Preferences preferences = final Preferences preferences =
...@@ -579,6 +585,21 @@ public class SavePasswordsPreferencesTest { ...@@ -579,6 +585,21 @@ public class SavePasswordsPreferencesTest {
Assert.assertFalse(onOffSwitch.isChecked()); Assert.assertFalse(onOffSwitch.isChecked());
} }
@Test
@SmallTest
@Feature({"Preferences"})
@Features.EnableFeatures({SavePasswordsPreferences.PASSWORD_LEAK_DETECTION_FEATURE})
public void testLeakDetectionNonSignedIn() throws Exception {
final Preferences preferences =
PreferencesTest.startPreferences(InstrumentationRegistry.getInstrumentation(),
SavePasswordsPreferences.class.getName());
SavePasswordsPreferences savedPasswordPrefs =
(SavePasswordsPreferences) preferences.getMainFragment();
// The switch shouldn't be displayed for non signed-in users.
Assert.assertNull(savedPasswordPrefs.findPreference(
SavePasswordsPreferences.PREF_LEAK_DETECTION_SWITCH));
}
/** /**
* Tests that the link pointing to managing passwords in the user's account is not displayed * Tests that the link pointing to managing passwords in the user's account is not displayed
* for non signed in users. * for non signed in users.
......
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