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

Add confirmation for passwords export

This alerts the user about exporting passwords and allows them to confirm the action or cancel it.

Bug: 789122
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I84af89eae3c5b7004d197826abf1a1f5eccc3bb6
Reviewed-on: https://chromium-review.googlesource.com/817418Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Ioana Pandele <ioanap@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523825}
parent b8f5ecbe
...@@ -1072,6 +1072,12 @@ Handoff must also be enabled in the General section of Settings, and your device ...@@ -1072,6 +1072,12 @@ Handoff must also be enabled in the General section of Settings, and your device
<message name="IDS_IOS_EXPORT_PASSWORDS" desc="Button that the user can press to export passwords. [Length: 22em] [iOS only]"> <message name="IDS_IOS_EXPORT_PASSWORDS" desc="Button that the user can press to export passwords. [Length: 22em] [iOS only]">
Export Passwords... Export Passwords...
</message> </message>
<message name="IDS_IOS_EXPORT_PASSWORDS_ALERT_MESSAGE" desc="The message of the alert displayed as a warning to the user who tapped on the button to export passwords. [iOS only]">
Your passwords will be visible to anyone who can see the exported file. Do not share this file with anyone.
</message>
<message name="IDS_IOS_EXPORT_PASSWORDS_CANCEL_BUTTON" desc="Label of a confirmation dialog button which allows the user to cancel passwords export. [Length: 22em] [iOS only]">
Cancel
</message>
<message name="IDS_IOS_SAVE_PASSWORDS_MANAGE_ACCOUNT" desc="Header text with link for the view in Settings for managing saved passwords. [Length: unlimited] [iOS only]"> <message name="IDS_IOS_SAVE_PASSWORDS_MANAGE_ACCOUNT" desc="Header text with link for the view in Settings for managing saved passwords. [Length: unlimited] [iOS only]">
View and manage saved passwords at <ph name="BEGIN_LINK">BEGIN_LINK</ph>passwords.google.com<ph name="END_LINK">END_LINK</ph> View and manage saved passwords at <ph name="BEGIN_LINK">BEGIN_LINK</ph>passwords.google.com<ph name="END_LINK">END_LINK</ph>
</message> </message>
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import "ios/chrome/browser/ui/settings/save_passwords_collection_view_controller.h" #import "ios/chrome/browser/ui/settings/save_passwords_collection_view_controller.h"
#import <UIKit/UIKit.h>
#include "base/ios/ios_util.h" #include "base/ios/ios_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
...@@ -148,9 +150,14 @@ void SavePasswordsConsumer::OnGetPasswordStoreResults( ...@@ -148,9 +150,14 @@ void SavePasswordsConsumer::OnGetPasswordStoreResults(
// Module containing the reauthentication mechanism for viewing and copying // Module containing the reauthentication mechanism for viewing and copying
// passwords. // passwords.
ReauthenticationModule* reauthenticationModule_; ReauthenticationModule* reauthenticationModule_;
// Boolean containing whether the export button and functionality are enabled
// or not.
BOOL exportEnabled_;
} }
// Kick off async request to get logins from password store. // Kick off async request to get logins from password store.
- (void)getLoginsFromPasswordStore; - (void)getLoginsFromPasswordStore;
@end @end
@implementation SavePasswordsCollectionViewController @implementation SavePasswordsCollectionViewController
...@@ -470,9 +477,36 @@ void SavePasswordsConsumer::OnGetPasswordStoreResults( ...@@ -470,9 +477,36 @@ void SavePasswordsConsumer::OnGetPasswordStoreResults(
exportPasswordsItem_.textColor = [[MDCPalette greyPalette] tint500]; exportPasswordsItem_.textColor = [[MDCPalette greyPalette] tint500];
exportPasswordsItem_.accessibilityTraits = UIAccessibilityTraitNotEnabled; exportPasswordsItem_.accessibilityTraits = UIAccessibilityTraitNotEnabled;
[self reconfigureCellsForItems:@[ exportPasswordsItem_ ]]; [self reconfigureCellsForItems:@[ exportPasswordsItem_ ]];
exportEnabled_ = NO;
} else {
exportEnabled_ = YES;
} }
} }
- (void)startPasswordsExportFlow {
UIAlertController* exportConfirmation = [UIAlertController
alertControllerWithTitle:nil
message:l10n_util::GetNSString(
IDS_IOS_EXPORT_PASSWORDS_ALERT_MESSAGE)
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* cancelAction =
[UIAlertAction actionWithTitle:l10n_util::GetNSString(
IDS_IOS_EXPORT_PASSWORDS_CANCEL_BUTTON)
style:UIAlertActionStyleCancel
handler:nil];
[exportConfirmation addAction:cancelAction];
// TODO(crbug.com/789122): Ask for password serialization
// and wire re-authentication.
UIAlertAction* exportAction = [UIAlertAction
actionWithTitle:l10n_util::GetNSString(IDS_IOS_EXPORT_PASSWORDS)
style:UIAlertActionStyleDefault
handler:nil];
[exportConfirmation addAction:exportAction];
[self presentViewController:exportConfirmation animated:YES completion:nil];
}
#pragma mark UICollectionViewDelegate #pragma mark UICollectionViewDelegate
- (void)openDetailedViewForForm:(const autofill::PasswordForm&)form { - (void)openDetailedViewForForm:(const autofill::PasswordForm&)form {
...@@ -518,10 +552,13 @@ void SavePasswordsConsumer::OnGetPasswordStoreResults( ...@@ -518,10 +552,13 @@ void SavePasswordsConsumer::OnGetPasswordStoreResults(
[self openDetailedViewForForm:*blacklistedForms_[indexPath.item]]; [self openDetailedViewForForm:*blacklistedForms_[indexPath.item]];
break; break;
case ItemTypeExportPasswordsButton: case ItemTypeExportPasswordsButton:
DCHECK_EQ(SectionIdentifierExportPasswordsButton,
[model sectionIdentifierForSection:indexPath.section]);
DCHECK(base::FeatureList::IsEnabled( DCHECK(base::FeatureList::IsEnabled(
password_manager::features::kPasswordExport)); password_manager::features::kPasswordExport));
// TODO(crbug.com/789122): Trigger alert dialogue to confirm passwords if (exportEnabled_) {
// export. [self startPasswordsExportFlow];
}
break; break;
default: default:
NOTREACHED(); NOTREACHED();
......
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