Commit c1f4cd57 authored by Viktor Semeniuk's avatar Viktor Semeniuk Committed by Commit Bot

[iOS] Confirmation message before deleting password

This change adds confirmation message to the delete dialog for non
compromised passwords.

Bug: 1141331
Change-Id: I831192aa6adbda67354882d63f25f8f51f955b91
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2504232
Commit-Queue: Viktor Semeniuk <vsemeniuk@google.com>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822080}
parent bd4ea599
...@@ -1762,6 +1762,9 @@ Follow the steps below: ...@@ -1762,6 +1762,9 @@ Follow the steps below:
<message name="IDS_IOS_CHANGE_COMPROMISED_PASSWORD" desc="Button which is shown on Password Details Screen when password is compromised. [iOS only]" meaning="Telling user to change password on a website since it is compromised."> <message name="IDS_IOS_CHANGE_COMPROMISED_PASSWORD" desc="Button which is shown on Password Details Screen when password is compromised. [iOS only]" meaning="Telling user to change password on a website since it is compromised.">
Change Password on Website Change Password on Website
</message> </message>
<message name="IDS_IOS_DELETE_PASSWORD_DESCRIPTION" desc="Message at the top of the confirmation alert when the user tapped delete password button. [iOS only]" meaning="Explaining to the user that deleting password locally won't delete account on a website.">
Deleting this password will not delete your account on <ph name="WEBSITE">$1<ex>twitter.com</ex></ph>.
</message>
<message name="IDS_IOS_DELETE_COMPROMISED_PASSWORD_DESCRIPTION" desc="Message on top of the confirmation alert when the user tapped delete password button. [iOS only]" meaning="Explaining to the user that deleting password locally won't delete account on a website."> <message name="IDS_IOS_DELETE_COMPROMISED_PASSWORD_DESCRIPTION" desc="Message on top of the confirmation alert when the user tapped delete password button. [iOS only]" meaning="Explaining to the user that deleting password locally won't delete account on a website.">
Deleting this password will not delete your account on <ph name="WEBSITE">$1<ex>twitter.com</ex></ph>. Change your password on <ph name="WEBSITE">$1<ex>twitter.com</ex></ph> to keep it safe from others. Deleting this password will not delete your account on <ph name="WEBSITE">$1<ex>twitter.com</ex></ph>. Change your password on <ph name="WEBSITE">$1<ex>twitter.com</ex></ph> to keep it safe from others.
</message> </message>
......
efd4a799fae3a970124d6d79a43a538de3b086ed
\ No newline at end of file
...@@ -148,13 +148,17 @@ ...@@ -148,13 +148,17 @@
[self.alertCoordinator start]; [self.alertCoordinator start];
} }
- (void)showPasswordDeleteDialogWithOrigin:(NSString*)origin { - (void)showPasswordDeleteDialogWithOrigin:(NSString*)origin
compromisedPassword:(BOOL)compromisedPassword {
NSString* message; NSString* message;
if (origin.length > 0) if (origin.length > 0) {
int stringID = compromisedPassword
? IDS_IOS_DELETE_COMPROMISED_PASSWORD_DESCRIPTION
: IDS_IOS_DELETE_PASSWORD_DESCRIPTION;
message = message =
l10n_util::GetNSStringF(IDS_IOS_DELETE_COMPROMISED_PASSWORD_DESCRIPTION, l10n_util::GetNSStringF(stringID, base::SysNSStringToUTF16(origin));
base::SysNSStringToUTF16(origin)); }
self.actionSheetCoordinator = [[ActionSheetCoordinator alloc] self.actionSheetCoordinator = [[ActionSheetCoordinator alloc]
initWithBaseViewController:self.viewController initWithBaseViewController:self.viewController
browser:self.browser browser:self.browser
...@@ -168,9 +172,8 @@ ...@@ -168,9 +172,8 @@
[self.actionSheetCoordinator [self.actionSheetCoordinator
addItemWithTitle:l10n_util::GetNSString(IDS_IOS_CONFIRM_PASSWORD_DELETION) addItemWithTitle:l10n_util::GetNSString(IDS_IOS_CONFIRM_PASSWORD_DELETION)
action:^{ action:^{
[weakSelf [weakSelf passwordDeletionConfirmedForCompromised:
passwordDeletionConfirmedForCompromised:origin.length > compromisedPassword];
0];
} }
style:UIAlertActionStyleDestructive]; style:UIAlertActionStyleDestructive];
......
...@@ -17,8 +17,10 @@ ...@@ -17,8 +17,10 @@
// Called when the user wants to delete password. |origin| is a short website // Called when the user wants to delete password. |origin| is a short website
// version. It is displayed inside dialog. If |origin| is nil dialog is // version. It is displayed inside dialog. If |origin| is nil dialog is
// displayed without message. // displayed without message. |compromisedPassword| indicates whether password
- (void)showPasswordDeleteDialogWithOrigin:(NSString*)origin; // is compromised.
- (void)showPasswordDeleteDialogWithOrigin:(NSString*)origin
compromisedPassword:(BOOL)compromisedPassword;
// Called when the user wants to save edited password. // Called when the user wants to save edited password.
- (void)showPasswordEditDialogWithOrigin:(NSString*)origin; - (void)showPasswordEditDialogWithOrigin:(NSString*)origin;
......
...@@ -462,12 +462,15 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) { ...@@ -462,12 +462,15 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
// Called when user tapped Delete button during editing. It means presented // Called when user tapped Delete button during editing. It means presented
// password should be deleted. // password should be deleted.
- (void)deleteItems:(NSArray<NSIndexPath*>*)indexPaths { - (void)deleteItems:(NSArray<NSIndexPath*>*)indexPaths {
// Pass origin only if password is compromised as confirmation message makes // Pass origin only if password is present as confirmation message makes
// sense only in this case. // sense only in this case.
if (self.password.isCompromised) { if ([self.password.password length]) {
[self.handler showPasswordDeleteDialogWithOrigin:self.password.origin]; [self.handler
showPasswordDeleteDialogWithOrigin:self.password.origin
compromisedPassword:self.password.isCompromised];
} else { } else {
[self.handler showPasswordDeleteDialogWithOrigin:nil]; [self.handler showPasswordDeleteDialogWithOrigin:nil
compromisedPassword:NO];
} }
} }
......
...@@ -50,6 +50,8 @@ constexpr char kPassword[] = "test"; ...@@ -50,6 +50,8 @@ constexpr char kPassword[] = "test";
@property(nonatomic, assign) BOOL deletionCalled; @property(nonatomic, assign) BOOL deletionCalled;
@property(nonatomic, assign) BOOL deletionCalledOnCompromisedPassword;
@property(nonatomic, assign) BOOL editingCalled; @property(nonatomic, assign) BOOL editingCalled;
@end @end
...@@ -62,8 +64,10 @@ constexpr char kPassword[] = "test"; ...@@ -62,8 +64,10 @@ constexpr char kPassword[] = "test";
- (void)showPasscodeDialog { - (void)showPasscodeDialog {
} }
- (void)showPasswordDeleteDialogWithOrigin:(NSString*)origin { - (void)showPasswordDeleteDialogWithOrigin:(NSString*)origin
compromisedPassword:(BOOL)compromisedPassword {
self.deletionCalled = YES; self.deletionCalled = YES;
self.deletionCalledOnCompromisedPassword = compromisedPassword;
} }
- (void)showPasswordEditDialogWithOrigin:(NSString*)origin { - (void)showPasswordEditDialogWithOrigin:(NSString*)origin {
...@@ -336,6 +340,25 @@ TEST_F(PasswordDetailsTableViewControllerTest, TestPasswordDelete) { ...@@ -336,6 +340,25 @@ TEST_F(PasswordDetailsTableViewControllerTest, TestPasswordDelete) {
from:nil from:nil
forEvent:nil]; forEvent:nil];
EXPECT_TRUE(handler().deletionCalled); EXPECT_TRUE(handler().deletionCalled);
EXPECT_FALSE(handler().deletionCalledOnCompromisedPassword);
}
// Tests compromised password deletion trigger showing password delete dialog.
TEST_F(PasswordDetailsTableViewControllerTest, TestCompromisedPasswordDelete) {
SetPassword(kExampleCom, kUsername, kPassword, true);
EXPECT_FALSE(handler().deletionCalled);
PasswordDetailsTableViewController* passwordDetails =
base::mac::ObjCCastStrict<PasswordDetailsTableViewController>(
controller());
[passwordDetails editButtonPressed];
[[UIApplication sharedApplication]
sendAction:passwordDetails.deleteButton.action
to:passwordDetails.deleteButton.target
from:nil
forEvent:nil];
EXPECT_TRUE(handler().deletionCalled);
EXPECT_TRUE(handler().deletionCalledOnCompromisedPassword);
} }
// Tests password editing. User confirmed this action. // Tests password editing. User confirmed this action.
......
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