Commit 0b9c06d8 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][Password-Breach] Add subtitle to the toggle

Updates the detail text of the switch based on the logged in status
and the preference value.

Bug: 986322
Change-Id: I11f346f003e756c4ab55e75992c7fdf16f1d7492
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1852090Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705076}
parent 7dbbaa34
......@@ -1346,7 +1346,16 @@ Handoff must also be enabled in the General section of Settings, and your device
Save Passwords
</message>
<message name="IDS_IOS_LEAK_CHECK_SWITCH" 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 name="IDS_IOS_LEAK_CHECK_SIGNED_IN_DESC" desc="Text that describes the 'Password Leak Detection' functionality to signed-in users.">
Warns you if a password you use was part of a data breach.
</message>
<message name="IDS_IOS_LEAK_CHECK_SIGNED_OUT_DISABLED_DESC" desc="Text that describes the 'Password Leak Detection' functionality to signed-out users who have disabled the feature.">
Google can check if your passwords were part of a data breach.
</message>
<message name="IDS_IOS_LEAK_CHECK_SIGNED_OUT_ENABLED_DESC" desc="Text that describes the 'Password Leak Detection' functionality to signed-out users who have not disabled the feature.">
Google can check if your passwords were part of a data breach. This will be turned on when you sign in with your Google Account.
</message>
<message name="IDS_IOS_PASSWORDS" desc="Title for the view in Settings for managing saved passwords. [Length: 15em] [iOS only]">
Passwords
......
......@@ -369,6 +369,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
if (base::FeatureList::IsEnabled(
password_manager::features::kLeakDetection)) {
leakCheckItem_ = [self leakCheckItem];
[self updateDetailTextLeakCheckItem];
[model addItem:leakCheckItem_
toSectionWithIdentifier:SectionIdentifierSavePasswordsSwitch];
}
......@@ -532,6 +533,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
if ([self.tableViewModel
hasItemForItemType:ItemTypePasswordLeakCheckSwitch
sectionIdentifier:SectionIdentifierSavePasswordsSwitch]) {
[self updateDetailTextLeakCheckItem];
[self reconfigureCellsForItems:@[ leakCheckItem_ ]];
}
} else {
......@@ -555,6 +557,8 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
// Update the item.
leakCheckItem_.on = [passwordLeakCheckEnabled_ value];
[self updateDetailTextLeakCheckItem];
[self reconfigureCellsForItems:@[ leakCheckItem_ ]];
}
#pragma mark - SavePasswordsConsumerDelegate
......@@ -1258,6 +1262,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
AuthenticationService* authService =
AuthenticationServiceFactory::GetForBrowserState(browserState_);
[leakCheckItem_ setEnabled:enabled && authService->IsAuthenticated()];
[self updateDetailTextLeakCheckItem];
[self reconfigureCellsForItems:@[ leakCheckItem_ ]];
}
......@@ -1273,6 +1278,29 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
}
}
// Updates the detail text of the leak check item based on the state.
- (void)updateDetailTextLeakCheckItem {
if (!leakCheckItem_) {
return;
}
if (self.editing) {
// When editing keep the current detail text.
return;
}
if (leakCheckItem_.enabled) {
leakCheckItem_.detailText =
l10n_util::GetNSString(IDS_IOS_LEAK_CHECK_SIGNED_IN_DESC);
return;
}
if (leakCheckItem_.on) {
leakCheckItem_.detailText =
l10n_util::GetNSString(IDS_IOS_LEAK_CHECK_SIGNED_OUT_ENABLED_DESC);
return;
}
leakCheckItem_.detailText =
l10n_util::GetNSString(IDS_IOS_LEAK_CHECK_SIGNED_OUT_DISABLED_DESC);
}
#pragma mark - Testing
- (void)setReauthenticationModuleForExporter:
......
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