Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: ios/chrome/browser/ui/settings/password_details_collection_view_controller.mm

Issue 2722853003: List site in password settings (Closed)
Patch Set: Just rebased Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/settings/password_details_collection_view_controller.mm
diff --git a/ios/chrome/browser/ui/settings/password_details_collection_view_controller.mm b/ios/chrome/browser/ui/settings/password_details_collection_view_controller.mm
index d03a5fc61a153b7904983aa324ae33848bfe7571..220fce7ffe874ce369e369803e71b4dbef08e4cc 100644
--- a/ios/chrome/browser/ui/settings/password_details_collection_view_controller.mm
+++ b/ios/chrome/browser/ui/settings/password_details_collection_view_controller.mm
@@ -32,12 +32,15 @@
namespace {
typedef NS_ENUM(NSInteger, SectionIdentifier) {
- SectionIdentifierUsername = kSectionIdentifierEnumZero,
+ SectionIdentifierSite = kSectionIdentifierEnumZero,
+ SectionIdentifierUsername,
SectionIdentifierPassword,
};
typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeHeader = kItemTypeEnumZero,
+ ItemTypeSite,
+ ItemTypeCopySite,
ItemTypeUsername,
ItemTypeCopyUsername,
ItemTypePassword,
@@ -53,6 +56,8 @@ typedef NS_ENUM(NSInteger, ItemType) {
NSString* _username;
// The saved password.
NSString* _password;
+ // The origin site of the saved credential.
+ NSString* _site;
// Whether the password is shown in plain text form or in obscured form.
BOOL _plainTextPasswordShown;
// The password form.
@@ -88,6 +93,7 @@ reauthenticationModule:(id<ReauthenticationProtocol>)reauthenticationModule
_passwordForm = passwordForm;
_username = [username copy];
_password = [password copy];
+ _site = base::SysUTF8ToNSString(_passwordForm.origin.spec());
self.title =
[PasswordDetailsCollectionViewController simplifyOrigin:origin];
NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
@@ -119,6 +125,19 @@ reauthenticationModule:(id<ReauthenticationProtocol>)reauthenticationModule
[super loadModel];
CollectionViewModel* model = self.collectionViewModel;
+ [model addSectionWithIdentifier:SectionIdentifierSite];
+ CollectionViewTextItem* siteHeader =
+ [[CollectionViewTextItem alloc] initWithType:ItemTypeHeader];
+ siteHeader.text = l10n_util::GetNSString(IDS_IOS_SHOW_PASSWORD_VIEW_SITE);
+ [model setHeader:siteHeader forSectionWithIdentifier:SectionIdentifierSite];
+ PasswordDetailsItem* siteItem =
+ [[PasswordDetailsItem alloc] initWithType:ItemTypeSite];
+ siteItem.text = _site;
+ siteItem.showingText = YES;
+ [model addItem:siteItem toSectionWithIdentifier:SectionIdentifierSite];
+ [model addItem:[self siteCopyButtonItem]
+ toSectionWithIdentifier:SectionIdentifierSite];
+
[model addSectionWithIdentifier:SectionIdentifierUsername];
CollectionViewTextItem* usernameHeader =
[[CollectionViewTextItem alloc] initWithType:ItemTypeHeader];
@@ -166,6 +185,23 @@ reauthenticationModule:(id<ReauthenticationProtocol>)reauthenticationModule
#pragma mark - Items
+- (CollectionViewItem*)siteCopyButtonItem {
+ CollectionViewTextItem* item =
+ [[CollectionViewTextItem alloc] initWithType:ItemTypeCopySite];
+ item.text = l10n_util::GetNSString(IDS_IOS_SETTINGS_SITE_COPY_BUTTON);
+ item.textColor = [[MDCPalette cr_bluePalette] tint500];
+ // Accessibility label adds the header to the text, so that accessibility
+ // users do not have to rely on the visual grouping to understand which part
+ // of the credential is being copied.
+ item.accessibilityLabel = [NSString
+ stringWithFormat:@"%@: %@",
+ l10n_util::GetNSString(IDS_IOS_SHOW_PASSWORD_VIEW_SITE),
+ l10n_util::GetNSString(
+ IDS_IOS_SETTINGS_SITE_COPY_BUTTON)];
+ item.accessibilityTraits |= UIAccessibilityTraitButton;
+ return item;
+}
+
- (CollectionViewItem*)usernameCopyButtonItem {
CollectionViewTextItem* item =
[[CollectionViewTextItem alloc] initWithType:ItemTypeCopyUsername];
@@ -222,6 +258,13 @@ reauthenticationModule:(id<ReauthenticationProtocol>)reauthenticationModule
#pragma mark - Actions
+- (void)copySite {
+ UIPasteboard* generalPasteboard = [UIPasteboard generalPasteboard];
+ generalPasteboard.string = _site;
+ [self showCopyResultToast:l10n_util::GetNSString(
+ IDS_IOS_SETTINGS_SITE_WAS_COPIED_MESSAGE)];
+}
+
- (void)copyUsername {
UIPasteboard* generalPasteboard = [UIPasteboard generalPasteboard];
generalPasteboard.string = _username;
@@ -349,6 +392,9 @@ reauthenticationModule:(id<ReauthenticationProtocol>)reauthenticationModule
NSInteger itemType =
[self.collectionViewModel itemTypeForIndexPath:indexPath];
switch (itemType) {
+ case ItemTypeCopySite:
+ [self copySite];
+ break;
case ItemTypeCopyUsername:
[self copyUsername];
break;

Powered by Google App Engine
This is Rietveld 408576698